Add resource tests for configs that are the same.
Verifies that two "sw" resources with the same size will not
incorrectly identify one as better than the other.
Change-Id: Ifd9a4341cc676e54b67e40914070c435071d39b9
diff --git a/tests/Android.mk b/tests/Android.mk
index 4868654..708f051 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -28,7 +28,8 @@
LOCAL_JNI_SHARED_LIBRARIES := libcts_jni
# Resource unit tests use a private locale and some densities
-LOCAL_AAPT_FLAGS = -c xx_YY -c cs -c 320dpi -c 240dpi -c 160dpi -c 32dpi \
+LOCAL_AAPT_FLAGS = -c xx_YY -c cs -c small -c normal -c large -c xlarge \
+ -c 320dpi -c 240dpi -c 160dpi -c 32dpi \
--preferred-configurations 320dpi --preferred-configurations 240dpi \
--preferred-configurations 160dpi --preferred-configurations 32dpi
diff --git a/tests/res/values-sw590dp-hdpi/configVarying.xml b/tests/res/values-sw590dp-hdpi/configVarying.xml
new file mode 100755
index 0000000..9864e50
--- /dev/null
+++ b/tests/res/values-sw590dp-hdpi/configVarying.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <item type="configVarying" name="simple">simple sw590 hdpi</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag sw590 hdpi</item>
+ </bag>
+ <item type="configVarying" name="sw">590 hdpi</item>
+</resources>
diff --git a/tests/res/values-sw590dp-mdpi/configVarying.xml b/tests/res/values-sw590dp-mdpi/configVarying.xml
new file mode 100755
index 0000000..7089ca9
--- /dev/null
+++ b/tests/res/values-sw590dp-mdpi/configVarying.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <item type="configVarying" name="simple">simple sw590 mdpi</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag sw590 mdpi</item>
+ </bag>
+ <item type="configVarying" name="sw">590 mdpi</item>
+</resources>
diff --git a/tests/res/values-sw590dp-xhdpi/configVarying.xml b/tests/res/values-sw590dp-xhdpi/configVarying.xml
new file mode 100755
index 0000000..5c55f2c
--- /dev/null
+++ b/tests/res/values-sw590dp-xhdpi/configVarying.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <item type="configVarying" name="simple">simple sw590 xhdpi</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag sw590 xhdpi</item>
+ </bag>
+ <item type="configVarying" name="sw">590 xhdpi</item>
+</resources>
diff --git a/tests/res/values-sw590dp/configVarying.xml b/tests/res/values-sw590dp/configVarying.xml
new file mode 100755
index 0000000..8563921
--- /dev/null
+++ b/tests/res/values-sw590dp/configVarying.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <item type="configVarying" name="simple">simple sw590</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag sw590</item>
+ </bag>
+ <item type="configVarying" name="sw">590</item>
+</resources>
diff --git a/tests/res/values-sw591dp-hdpi/configVarying.xml b/tests/res/values-sw591dp-hdpi/configVarying.xml
new file mode 100755
index 0000000..880dced
--- /dev/null
+++ b/tests/res/values-sw591dp-hdpi/configVarying.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <item type="configVarying" name="simple">simple sw591 hdpi</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag sw591 hdpi</item>
+ </bag>
+ <item type="configVarying" name="sw">591 hdpi</item>
+</resources>
diff --git a/tests/res/values-sw591dp/configVarying.xml b/tests/res/values-sw591dp/configVarying.xml
new file mode 100755
index 0000000..4a0ee85
--- /dev/null
+++ b/tests/res/values-sw591dp/configVarying.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <item type="configVarying" name="simple">simple sw591</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag sw591</item>
+ </bag>
+ <item type="configVarying" name="sw">591</item>
+</resources>
diff --git a/tests/tests/content/src/android/content/res/cts/ConfigTest.java b/tests/tests/content/src/android/content/res/cts/ConfigTest.java
index 144c2f2..60197b6 100755
--- a/tests/tests/content/src/android/content/res/cts/ConfigTest.java
+++ b/tests/tests/content/src/android/content/res/cts/ConfigTest.java
@@ -733,9 +733,9 @@
// ensure that swNNNdp, wNNNdp, and hNNNdp are working correctly
// for various common screen configurations.
TotalConfig config = makeClassicConfig();
- config.setProperty(Properties.SWIDTH_DP, 599);
- config.setProperty(Properties.WIDTH_DP, 599);
- config.setProperty(Properties.HEIGHT_DP, 549);
+ config.setProperty(Properties.SWIDTH_DP, 589);
+ config.setProperty(Properties.WIDTH_DP, 589);
+ config.setProperty(Properties.HEIGHT_DP, 500);
config.setProperty(Properties.ORIENTATION, Configuration.ORIENTATION_LANDSCAPE);
config.setProperty(Properties.SCREENLAYOUT, Configuration.SCREENLAYOUT_SIZE_LARGE);
Resources res = config.getResources();
@@ -746,6 +746,44 @@
checkValue(res, R.configVarying.wh, "default");
config = makeClassicConfig();
+ config.setProperty(Properties.SWIDTH_DP, 590);
+ config.setProperty(Properties.WIDTH_DP, 590);
+ config.setProperty(Properties.HEIGHT_DP, 500);
+ config.setProperty(Properties.ORIENTATION, Configuration.ORIENTATION_LANDSCAPE);
+ config.setProperty(Properties.SCREENLAYOUT, Configuration.SCREENLAYOUT_SIZE_LARGE);
+ config.setProperty(Properties.DENSITY, DisplayMetrics.DENSITY_MEDIUM);
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple sw590 mdpi");
+ checkValue(res, R.configVarying.sw, "590 mdpi");
+
+ config.setProperty(Properties.DENSITY, DisplayMetrics.DENSITY_HIGH);
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple sw590 hdpi");
+ checkValue(res, R.configVarying.sw, "590 hdpi");
+
+ config.setProperty(Properties.DENSITY, DisplayMetrics.DENSITY_XHIGH);
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple sw590 xhdpi");
+ checkValue(res, R.configVarying.sw, "590 xhdpi");
+
+ config.setProperty(Properties.SWIDTH_DP, 591);
+ config.setProperty(Properties.WIDTH_DP, 591);
+ config.setProperty(Properties.DENSITY, DisplayMetrics.DENSITY_MEDIUM);
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple sw591");
+ checkValue(res, R.configVarying.sw, "591");
+
+ config.setProperty(Properties.DENSITY, DisplayMetrics.DENSITY_HIGH);
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple sw591 hdpi");
+ checkValue(res, R.configVarying.sw, "591 hdpi");
+
+ config.setProperty(Properties.DENSITY, DisplayMetrics.DENSITY_XHIGH);
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple sw591 hdpi");
+ checkValue(res, R.configVarying.sw, "591 hdpi");
+
+ config = makeClassicConfig();
config.setProperty(Properties.SWIDTH_DP, 480);
config.setProperty(Properties.WIDTH_DP, 800);
config.setProperty(Properties.HEIGHT_DP, 480);