diff options
author | Robert Greenwalt <robdroid@android.com> | 2009-04-22 14:35:11 -0700 |
---|---|---|
committer | Robert Greenwalt <robdroid@android.com> | 2009-04-22 14:35:11 -0700 |
commit | 96e20409afc720f61d0cd49bf1441f62069bd6bb (patch) | |
tree | 8088015f1763a454848ad35d4f5dc8f64ebcf6f4 /tests | |
parent | 644cf62660c87a9b8d5bcb22412cc2ad2aeea291 (diff) | |
download | frameworks_base-96e20409afc720f61d0cd49bf1441f62069bd6bb.zip frameworks_base-96e20409afc720f61d0cd49bf1441f62069bd6bb.tar.gz frameworks_base-96e20409afc720f61d0cd49bf1441f62069bd6bb.tar.bz2 |
Squashed commit of the following:
commit 012b56fc607cf243cf4b29cb2a5f172bcbe0aecd
Author: Robert Greenwalt <robdroid@android.com>
Date: Wed Apr 22 14:31:26 2009 -0700
Additional fixes and tests for density.
commit 91fdc8e187551ae69e0029a4325fb3ad38fe411b
Author: Robert Greenwalt <robdroid@android.com>
Date: Tue Apr 14 14:39:00 2009 -0700
Fix runtime resource selection logic.
Fix isBetterThan so that o or this may be supperior at any stage.
Used to only handle this-better or tie at each stage, biasing against o.
Also allows reset of unit test to succeed. Fixes bug 1709202.
Diffstat (limited to 'tests')
10 files changed, 255 insertions, 149 deletions
diff --git a/tests/AndroidTests/res/values-port/configVarying.xml b/tests/AndroidTests/res/values-32dpi/configVarying.xml index 0e1f247..f903f0f 100644 --- a/tests/AndroidTests/res/values-port/configVarying.xml +++ b/tests/AndroidTests/res/values-32dpi/configVarying.xml @@ -15,8 +15,8 @@ --> <resources> - <item type="configVarying" name="simple">simple portrait</item> + <item type="configVarying" name="simple">simple 32dpi</item> <bag type="configVarying" name="bag"> - <item name="testString">bag portrait</item> + <item name="testString">bag 32dpi</item> </bag> </resources> diff --git a/tests/AndroidTests/res/values-320x200/configVarying.xml b/tests/AndroidTests/res/values-640x400/configVarying.xml index ca2a286..30332c0 100644 --- a/tests/AndroidTests/res/values-320x200/configVarying.xml +++ b/tests/AndroidTests/res/values-640x400/configVarying.xml @@ -15,8 +15,8 @@ --> <resources> - <item type="configVarying" name="simple">simple 320x200</item> + <item type="configVarying" name="simple">simple 640x400</item> <bag type="configVarying" name="bag"> - <item name="testString">bag 320x200</item> + <item name="testString">bag 640x400</item> </bag> </resources> diff --git a/tests/AndroidTests/res/values-fr-rFR/configVarying.xml b/tests/AndroidTests/res/values-fr-rFR/configVarying.xml new file mode 100644 index 0000000..5ecac7c --- /dev/null +++ b/tests/AndroidTests/res/values-fr-rFR/configVarying.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2007 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 fr FR</item> + <bag type="configVarying" name="bag"> + <item name="testString">bag fr FR</item> + </bag> +</resources> diff --git a/tests/AndroidTests/res/values-fr/configVarying.xml b/tests/AndroidTests/res/values-fr/configVarying.xml new file mode 100644 index 0000000..8413b5a --- /dev/null +++ b/tests/AndroidTests/res/values-fr/configVarying.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2007 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 fr</item> + <bag type="configVarying" name="bag"> + <item name="testString">bag fr</item> + </bag> +</resources> diff --git a/tests/AndroidTests/res/values-trackball/configVarying.xml b/tests/AndroidTests/res/values-mcc110-xx/configVarying.xml index 0dec300..82e2435 100644 --- a/tests/AndroidTests/res/values-trackball/configVarying.xml +++ b/tests/AndroidTests/res/values-mcc110-xx/configVarying.xml @@ -15,8 +15,8 @@ --> <resources> - <item type="configVarying" name="simple">simple trackball</item> + <item type="configVarying" name="simple">simple mcc110 xx</item> <bag type="configVarying" name="bag"> - <item name="testString">bag trackball</item> + <item name="testString">bag mcc110 xx</item> </bag> </resources> diff --git a/tests/AndroidTests/res/values-finger/configVarying.xml b/tests/AndroidTests/res/values-mcc112/configVarying.xml index 674787e..9c05d77 100644 --- a/tests/AndroidTests/res/values-finger/configVarying.xml +++ b/tests/AndroidTests/res/values-mcc112/configVarying.xml @@ -15,8 +15,8 @@ --> <resources> - <item type="configVarying" name="simple">simple finger</item> + <item type="configVarying" name="simple">simple mcc112</item> <bag type="configVarying" name="bag"> - <item name="testString">bag finger</item> + <item name="testString">bag mcc112</item> </bag> </resources> diff --git a/tests/AndroidTests/res/values-mnc220-xx/configVarying.xml b/tests/AndroidTests/res/values-mnc220-xx/configVarying.xml new file mode 100644 index 0000000..fbc7888 --- /dev/null +++ b/tests/AndroidTests/res/values-mnc220-xx/configVarying.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2007 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 mnc220 xx</item> + <bag type="configVarying" name="bag"> + <item name="testString">bag mnc220 xx</item> + </bag> +</resources> diff --git a/tests/AndroidTests/res/values-keyshidden/configVarying.xml b/tests/AndroidTests/res/values-mnc222-32dpi/configVarying.xml index fdffc4d..03bea33 100644 --- a/tests/AndroidTests/res/values-keyshidden/configVarying.xml +++ b/tests/AndroidTests/res/values-mnc222-32dpi/configVarying.xml @@ -15,8 +15,8 @@ --> <resources> - <item type="configVarying" name="simple">simple keyshidden</item> + <item type="configVarying" name="simple">simple mnc222 32dpi</item> <bag type="configVarying" name="bag"> - <item name="testString">bag keyshidden</item> + <item name="testString">bag mnc222 32dpi</item> </bag> </resources> diff --git a/tests/AndroidTests/res/values-qwerty/configVarying.xml b/tests/AndroidTests/res/values-mnc223/configVarying.xml index 939f682..8936cbc 100644 --- a/tests/AndroidTests/res/values-qwerty/configVarying.xml +++ b/tests/AndroidTests/res/values-mnc223/configVarying.xml @@ -15,8 +15,8 @@ --> <resources> - <item type="configVarying" name="simple">simple qwerty</item> + <item type="configVarying" name="simple">simple mnc223</item> <bag type="configVarying" name="bag"> - <item name="testString">bag qwerty</item> + <item name="testString">bag mnc223</item> </bag> </resources> diff --git a/tests/AndroidTests/src/com/android/unit_tests/content/ConfigTest.java b/tests/AndroidTests/src/com/android/unit_tests/content/ConfigTest.java index 1ea83c3..e6639d3 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/content/ConfigTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/content/ConfigTest.java @@ -98,7 +98,7 @@ public class ConfigTest extends AndroidTestCase { mMetrics = new DisplayMetrics(); mMetrics.widthPixels = 200; mMetrics.heightPixels = 320; - mMetrics.density = 120; + mMetrics.density = 1; } void setProperty(properties p, int value) { @@ -131,7 +131,9 @@ public class ConfigTest extends AndroidTestCase { mMetrics.heightPixels = value; break; case DENSITY: - mMetrics.density = value; + // this is the ratio from the standard + + mMetrics.density = (((float)value)/((float)DisplayMetrics.DEFAULT_DENSITY)); break; default: assert(false); @@ -187,18 +189,16 @@ public class ConfigTest extends AndroidTestCase { */ TotalConfig config = new TotalConfig(); Resources res = config.getResources(); -// got simple 240dpi -// checkValue(res, R.configVarying.simple, "simple default"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag default"}); + checkValue(res, R.configVarying.simple, "simple default"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag default"}); config = new TotalConfig(); config.setProperty(properties.LANGUAGE, "xx"); res = config.getResources(); -// got simple xx 32dpi -// checkValue(res, R.configVarying.simple, "simple xx"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag xx"}); + checkValue(res, R.configVarying.simple, "simple xx"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag xx"}); config = new TotalConfig(); config.setProperty(properties.LANGUAGE, "xx"); @@ -225,155 +225,160 @@ public class ConfigTest extends AndroidTestCase { config = new TotalConfig(); config.setProperty(properties.TOUCHSCREEN, Configuration.TOUCHSCREEN_NOTOUCH); res = config.getResources(); -// got simple 240dpi -// checkValue(res, R.configVarying.simple, "simple notouch"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag notouch"}); + checkValue(res, R.configVarying.simple, "simple notouch"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag notouch"}); config = new TotalConfig(); - config.setProperty(properties.TOUCHSCREEN, Configuration.TOUCHSCREEN_FINGER); + config.setProperty(properties.TOUCHSCREEN, Configuration.TOUCHSCREEN_STYLUS); res = config.getResources(); -// got simple 240dpi -// checkValue(res, R.configVarying.simple, "simple finger"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag finger"}); + checkValue(res, R.configVarying.simple, "simple stylus"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag stylus"}); config = new TotalConfig(); - config.setProperty(properties.TOUCHSCREEN, Configuration.TOUCHSCREEN_STYLUS); + config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_NOKEYS); res = config.getResources(); -// got simple 32dpi stylus -// checkValue(res, R.configVarying.simple, "simple stylus"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag stylus"}); + checkValue(res, R.configVarying.simple, "simple nokeys"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag nokeys"}); config = new TotalConfig(); - config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_NOKEYS); + config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_12KEY); res = config.getResources(); -// got simple 240dpi -// checkValue(res, R.configVarying.simple, "simple nokeys"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag nokeys"}); + checkValue(res, R.configVarying.simple, "simple 12key"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag 12key"}); config = new TotalConfig(); - config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_QWERTY); + config.setProperty(properties.KEYBOARDHIDDEN, Configuration.KEYBOARDHIDDEN_NO); res = config.getResources(); -// got simple 240dpi -// checkValue(res, R.configVarying.simple, "simple qwerty"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag qwerty"}); + checkValue(res, R.configVarying.simple, "simple keysexposed"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag keysexposed"}); config = new TotalConfig(); - config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_12KEY); + config.setProperty(properties.NAVIGATION, Configuration.NAVIGATION_NONAV); res = config.getResources(); -// got simple 240dpi -// checkValue(res, R.configVarying.simple, "simple 12key"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag 12key"}); + checkValue(res, R.configVarying.simple, "simple nonav"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag nonav"}); config = new TotalConfig(); - config.setProperty(properties.KEYBOARDHIDDEN, Configuration.KEYBOARDHIDDEN_YES); + config.setProperty(properties.NAVIGATION, Configuration.NAVIGATION_DPAD); res = config.getResources(); -// got simple 240dpi -// checkValue(res, R.configVarying.simple, "simple keyshidden"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag keyshidden"}); + checkValue(res, R.configVarying.simple, "simple dpad"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag dpad"}); config = new TotalConfig(); - config.setProperty(properties.KEYBOARDHIDDEN, Configuration.KEYBOARDHIDDEN_NO); + config.setProperty(properties.NAVIGATION, Configuration.NAVIGATION_WHEEL); res = config.getResources(); -// got simple 32dpi keysexposed -// checkValue(res, R.configVarying.simple, "simple keysexposed"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag keysexposed"}); + checkValue(res, R.configVarying.simple, "simple wheel"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag wheel"}); config = new TotalConfig(); - config.setProperty(properties.NAVIGATION, Configuration.NAVIGATION_NONAV); + config.setProperty(properties.HEIGHT, 480); + config.setProperty(properties.WIDTH, 320); res = config.getResources(); -// got simple 240dpi -// checkValue(res, R.configVarying.simple, "simple nonav"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag nonav"}); + checkValue(res, R.configVarying.simple, "simple 480x320"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag 480x320"}); config = new TotalConfig(); - config.setProperty(properties.NAVIGATION, Configuration.NAVIGATION_DPAD); + config.setProperty(properties.DENSITY, 240); res = config.getResources(); -// got simple 240dpi -// checkValue(res, R.configVarying.simple, "simple dpad"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag dpad"}); + checkValue(res, R.configVarying.simple, "simple 240dpi"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag 240dpi"}); config = new TotalConfig(); - config.setProperty(properties.NAVIGATION, Configuration.NAVIGATION_TRACKBALL); + config.setProperty(properties.ORIENTATION, Configuration.ORIENTATION_LANDSCAPE); res = config.getResources(); -// got simple 240dpi -// checkValue(res, R.configVarying.simple, "simple trackball"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag trackball"}); + checkValue(res, R.configVarying.simple, "simple landscape"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag landscape"}); config = new TotalConfig(); - config.setProperty(properties.NAVIGATION, Configuration.NAVIGATION_WHEEL); + config.setProperty(properties.ORIENTATION, Configuration.ORIENTATION_SQUARE); res = config.getResources(); -// got simple 240dpi -// checkValue(res, R.configVarying.simple, "simple wheel"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag wheel"}); + checkValue(res, R.configVarying.simple, "simple square"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag square"}); + } + + @MediumTest + public void testDensity() throws Exception { + // have 32, 240 and the default 160 content. + // rule is that closest wins, with down scaling (larger content) + // being twice as nice as upscaling. + // transition at H/2 * (-1 +/- sqrt(1+8L/H)) + // SO, X < 49 goes to 32 + // 49 >= X < 182 goes to 160 + // X >= 182 goes to 240 + TotalConfig config = new TotalConfig(); + config.setProperty(properties.DENSITY, 2); + Resources res = config.getResources(); + checkValue(res, R.configVarying.simple, "simple 32dpi"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag 32dpi"}); config = new TotalConfig(); - config.setProperty(properties.HEIGHT, 320); - config.setProperty(properties.WIDTH, 200); + config.setProperty(properties.DENSITY, 32); res = config.getResources(); -// got simple 240dpi -// checkValue(res, R.configVarying.simple, "simple 320x200"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag 320x200"}); + checkValue(res, R.configVarying.simple, "simple 32dpi"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag 32dpi"}); config = new TotalConfig(); - config.setProperty(properties.HEIGHT, 480); - config.setProperty(properties.WIDTH, 320); + config.setProperty(properties.DENSITY, 48); res = config.getResources(); -// got simple 240dpi -// checkValue(res, R.configVarying.simple, "simple 480x320"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag 480x320"}); + checkValue(res, R.configVarying.simple, "simple 32dpi"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag 32dpi"}); config = new TotalConfig(); - config.setProperty(properties.DENSITY, 240); + config.setProperty(properties.DENSITY, 49); res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple 240dpi"); + checkValue(res, R.configVarying.simple, "simple default"); checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag 240dpi"}); + R.styleable.TestConfig, new String[]{"bag default"}); config = new TotalConfig(); - config.setProperty(properties.DENSITY, 120); + config.setProperty(properties.DENSITY, 150); res = config.getResources(); -// got simple 240dpi -// checkValue(res, R.configVarying.simple, "simple 120dpi"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag 120dpi"}); + checkValue(res, R.configVarying.simple, "simple default"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag default"}); config = new TotalConfig(); - config.setProperty(properties.ORIENTATION, Configuration.ORIENTATION_LANDSCAPE); + config.setProperty(properties.DENSITY, 181); res = config.getResources(); -// got simple 240dpi -// checkValue(res, R.configVarying.simple, "simple landscape"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag landscape"}); + checkValue(res, R.configVarying.simple, "simple default"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag default"}); config = new TotalConfig(); - config.setProperty(properties.ORIENTATION, Configuration.ORIENTATION_PORTRAIT); + config.setProperty(properties.DENSITY, 182); res = config.getResources(); -// got simple 240dpi -// checkValue(res, R.configVarying.simple, "simple portrait"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag portrait"}); + checkValue(res, R.configVarying.simple, "simple 240dpi"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag 240dpi"}); config = new TotalConfig(); - config.setProperty(properties.ORIENTATION, Configuration.ORIENTATION_SQUARE); + config.setProperty(properties.DENSITY, 239); res = config.getResources(); -// got simple square 32dpi -// checkValue(res, R.configVarying.simple, "simple square"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag square"}); + checkValue(res, R.configVarying.simple, "simple 240dpi"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag 240dpi"}); + + config = new TotalConfig(); + config.setProperty(properties.DENSITY, 490); + res = config.getResources(); + checkValue(res, R.configVarying.simple, "simple 240dpi"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag 240dpi"}); } // TODO - add tests for special cases - ie, other key params seem ignored if @@ -407,10 +412,9 @@ public class ConfigTest extends AndroidTestCase { config = new TotalConfig(); config.setProperty(properties.MNC, 333); res = config.getResources(); -// got simple 24dpi -// checkValue(res, R.configVarying.simple, "simple default"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag default"}); + checkValue(res, R.configVarying.simple, "simple default"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag default"}); } @MediumTest @@ -419,13 +423,31 @@ public class ConfigTest extends AndroidTestCase { * Verify that in cases of ties, the specific ordering is followed */ - /* full A + B + C doesn't exist. Do we get A + C or B + C? + /** + * Precidence order: mcc, mnc, locale, orientation, density, + * touchscreen, hidden, keyboard, navigation, width-height + */ + + /** + * verify mcc trumps mnc. Have 110-xx, 220-xx but no 110-220 + * so with is selected? Should be mcc110-xx. */ TotalConfig config = new TotalConfig(); + config.setProperty(properties.MCC, 110); + config.setProperty(properties.MNC, 220); + config.setProperty(properties.LANGUAGE, "xx"); + Resources res = config.getResources(); + checkValue(res, R.configVarying.simple, "simple mcc110 xx"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag mcc110 xx"}); + + /* full A + B + C doesn't exist. Do we get A + C or B + C? + */ + config = new TotalConfig(); config.setProperty(properties.MCC, 111); config.setProperty(properties.MNC, 222); config.setProperty(properties.LANGUAGE, "xx"); - Resources res = config.getResources(); + res = config.getResources(); checkValue(res, R.configVarying.simple, "simple mcc111 mnc222"); checkValue(res, R.configVarying.bag, R.styleable.TestConfig, new String[]{"bag mcc111 mnc222"}); @@ -433,7 +455,8 @@ public class ConfigTest extends AndroidTestCase { config = new TotalConfig(); config.setProperty(properties.MNC, 222); config.setProperty(properties.LANGUAGE, "xx"); - config.setProperty(properties.ORIENTATION, Configuration.ORIENTATION_SQUARE); + config.setProperty(properties.ORIENTATION, + Configuration.ORIENTATION_SQUARE); res = config.getResources(); checkValue(res, R.configVarying.simple, "simple mnc222 xx"); checkValue(res, R.configVarying.bag, @@ -441,60 +464,77 @@ public class ConfigTest extends AndroidTestCase { config = new TotalConfig(); config.setProperty(properties.LANGUAGE, "xx"); - config.setProperty(properties.ORIENTATION, Configuration.ORIENTATION_SQUARE); + config.setProperty(properties.ORIENTATION, + Configuration.ORIENTATION_SQUARE); config.setProperty(properties.DENSITY, 32); res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple xx 32dpi"); + checkValue(res, R.configVarying.simple, "simple xx square"); checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag xx 32dpi"}); + R.styleable.TestConfig, new String[]{"bag xx square"}); config = new TotalConfig(); - config.setProperty(properties.ORIENTATION, Configuration.ORIENTATION_SQUARE); + config.setProperty(properties.ORIENTATION, + Configuration.ORIENTATION_SQUARE); config.setProperty(properties.DENSITY, 32); - config.setProperty(properties.TOUCHSCREEN, Configuration.TOUCHSCREEN_STYLUS); + config.setProperty(properties.TOUCHSCREEN, + Configuration.TOUCHSCREEN_STYLUS); res = config.getResources(); - checkValue(res, R.configVarying.simple, "simple 32dpi stylus"); + checkValue(res, R.configVarying.simple, "simple square 32dpi"); checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag 32dpi stylus"}); + R.styleable.TestConfig, new String[]{"bag square 32dpi"}); config = new TotalConfig(); config.setProperty(properties.DENSITY, 32); - config.setProperty(properties.TOUCHSCREEN, Configuration.TOUCHSCREEN_STYLUS); - config.setProperty(properties.KEYBOARDHIDDEN, Configuration.KEYBOARDHIDDEN_NO); + config.setProperty(properties.TOUCHSCREEN, + Configuration.TOUCHSCREEN_STYLUS); + config.setProperty(properties.KEYBOARDHIDDEN, + Configuration.KEYBOARDHIDDEN_NO); res = config.getResources(); checkValue(res, R.configVarying.simple, "simple 32dpi stylus"); checkValue(res, R.configVarying.bag, R.styleable.TestConfig, new String[]{"bag 32dpi stylus"}); config = new TotalConfig(); - config.setProperty(properties.TOUCHSCREEN, Configuration.TOUCHSCREEN_STYLUS); - config.setProperty(properties.KEYBOARDHIDDEN, Configuration.KEYBOARDHIDDEN_NO); + config.setProperty(properties.TOUCHSCREEN, + Configuration.TOUCHSCREEN_STYLUS); + config.setProperty(properties.KEYBOARDHIDDEN, + Configuration.KEYBOARDHIDDEN_NO); config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_12KEY); res = config.getResources(); -// got simple 32dpi stylus -// checkValue(res, R.configVarying.simple, "simple stylus 12key"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag stylus 12key"}); + checkValue(res, R.configVarying.simple, "simple stylus keysexposed"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag stylus keysexposed"}); config = new TotalConfig(); - config.setProperty(properties.KEYBOARDHIDDEN, Configuration.KEYBOARDHIDDEN_NO); + config.setProperty(properties.KEYBOARDHIDDEN, + Configuration.KEYBOARDHIDDEN_NO); config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_12KEY); - config.setProperty(properties.NAVIGATION, Configuration.NAVIGATION_DPAD); + config.setProperty(properties.NAVIGATION, + Configuration.NAVIGATION_DPAD); res = config.getResources(); -// got simple 32dpi exposed -// checkValue(res, R.configVarying.simple, "simple stylus keysexposed"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag stylus keysexposed"}); + checkValue(res, R.configVarying.simple, "simple keysexposed 12key"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag keysexposed 12key"}); config = new TotalConfig(); config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_12KEY); - config.setProperty(properties.NAVIGATION, Configuration.NAVIGATION_DPAD); + config.setProperty(properties.NAVIGATION, + Configuration.NAVIGATION_DPAD); config.setProperty(properties.HEIGHT, 63); config.setProperty(properties.WIDTH, 57); res = config.getResources(); -// got simple 240dpi -// checkValue(res, R.configVarying.simple, "simple 12key dpad"); -// checkValue(res, R.configVarying.bag, -// R.styleable.TestConfig, new String[]{"bag 12key dpad"}); + checkValue(res, R.configVarying.simple, "simple 12key dpad"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag 12key dpad"}); + + config = new TotalConfig(); + config.setProperty(properties.NAVIGATION, + Configuration.NAVIGATION_DPAD); + config.setProperty(properties.HEIGHT, 640); + config.setProperty(properties.WIDTH, 400); + res = config.getResources(); + checkValue(res, R.configVarying.simple, "simple dpad"); + checkValue(res, R.configVarying.bag, + R.styleable.TestConfig, new String[]{"bag dpad"}); } } |