From 96e20409afc720f61d0cd49bf1441f62069bd6bb Mon Sep 17 00:00:00 2001 From: Robert Greenwalt Date: Wed, 22 Apr 2009 14:35:11 -0700 Subject: Squashed commit of the following: commit 012b56fc607cf243cf4b29cb2a5f172bcbe0aecd Author: Robert Greenwalt Date: Wed Apr 22 14:31:26 2009 -0700 Additional fixes and tests for density. commit 91fdc8e187551ae69e0029a4325fb3ad38fe411b Author: Robert Greenwalt 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. --- .../res/values-320x200/configVarying.xml | 22 -- .../res/values-32dpi/configVarying.xml | 22 ++ .../res/values-640x400/configVarying.xml | 22 ++ .../res/values-finger/configVarying.xml | 22 -- .../res/values-fr-rFR/configVarying.xml | 22 ++ tests/AndroidTests/res/values-fr/configVarying.xml | 22 ++ .../res/values-keyshidden/configVarying.xml | 22 -- .../res/values-mcc110-xx/configVarying.xml | 22 ++ .../res/values-mcc112/configVarying.xml | 22 ++ .../res/values-mnc220-xx/configVarying.xml | 22 ++ .../res/values-mnc222-32dpi/configVarying.xml | 22 ++ .../res/values-mnc223/configVarying.xml | 22 ++ .../AndroidTests/res/values-port/configVarying.xml | 22 -- .../res/values-qwerty/configVarying.xml | 22 -- .../res/values-trackball/configVarying.xml | 22 -- .../com/android/unit_tests/content/ConfigTest.java | 314 ++++++++++++--------- 16 files changed, 375 insertions(+), 269 deletions(-) delete mode 100644 tests/AndroidTests/res/values-320x200/configVarying.xml create mode 100644 tests/AndroidTests/res/values-32dpi/configVarying.xml create mode 100644 tests/AndroidTests/res/values-640x400/configVarying.xml delete mode 100644 tests/AndroidTests/res/values-finger/configVarying.xml create mode 100644 tests/AndroidTests/res/values-fr-rFR/configVarying.xml create mode 100644 tests/AndroidTests/res/values-fr/configVarying.xml delete mode 100644 tests/AndroidTests/res/values-keyshidden/configVarying.xml create mode 100644 tests/AndroidTests/res/values-mcc110-xx/configVarying.xml create mode 100644 tests/AndroidTests/res/values-mcc112/configVarying.xml create mode 100644 tests/AndroidTests/res/values-mnc220-xx/configVarying.xml create mode 100644 tests/AndroidTests/res/values-mnc222-32dpi/configVarying.xml create mode 100644 tests/AndroidTests/res/values-mnc223/configVarying.xml delete mode 100644 tests/AndroidTests/res/values-port/configVarying.xml delete mode 100644 tests/AndroidTests/res/values-qwerty/configVarying.xml delete mode 100644 tests/AndroidTests/res/values-trackball/configVarying.xml (limited to 'tests') diff --git a/tests/AndroidTests/res/values-320x200/configVarying.xml b/tests/AndroidTests/res/values-320x200/configVarying.xml deleted file mode 100644 index ca2a286..0000000 --- a/tests/AndroidTests/res/values-320x200/configVarying.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - simple 320x200 - - bag 320x200 - - diff --git a/tests/AndroidTests/res/values-32dpi/configVarying.xml b/tests/AndroidTests/res/values-32dpi/configVarying.xml new file mode 100644 index 0000000..f903f0f --- /dev/null +++ b/tests/AndroidTests/res/values-32dpi/configVarying.xml @@ -0,0 +1,22 @@ + + + + + simple 32dpi + + bag 32dpi + + diff --git a/tests/AndroidTests/res/values-640x400/configVarying.xml b/tests/AndroidTests/res/values-640x400/configVarying.xml new file mode 100644 index 0000000..30332c0 --- /dev/null +++ b/tests/AndroidTests/res/values-640x400/configVarying.xml @@ -0,0 +1,22 @@ + + + + + simple 640x400 + + bag 640x400 + + diff --git a/tests/AndroidTests/res/values-finger/configVarying.xml b/tests/AndroidTests/res/values-finger/configVarying.xml deleted file mode 100644 index 674787e..0000000 --- a/tests/AndroidTests/res/values-finger/configVarying.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - simple finger - - bag finger - - 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 @@ + + + + + simple fr FR + + bag fr FR + + 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 @@ + + + + + simple fr + + bag fr + + diff --git a/tests/AndroidTests/res/values-keyshidden/configVarying.xml b/tests/AndroidTests/res/values-keyshidden/configVarying.xml deleted file mode 100644 index fdffc4d..0000000 --- a/tests/AndroidTests/res/values-keyshidden/configVarying.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - simple keyshidden - - bag keyshidden - - diff --git a/tests/AndroidTests/res/values-mcc110-xx/configVarying.xml b/tests/AndroidTests/res/values-mcc110-xx/configVarying.xml new file mode 100644 index 0000000..82e2435 --- /dev/null +++ b/tests/AndroidTests/res/values-mcc110-xx/configVarying.xml @@ -0,0 +1,22 @@ + + + + + simple mcc110 xx + + bag mcc110 xx + + diff --git a/tests/AndroidTests/res/values-mcc112/configVarying.xml b/tests/AndroidTests/res/values-mcc112/configVarying.xml new file mode 100644 index 0000000..9c05d77 --- /dev/null +++ b/tests/AndroidTests/res/values-mcc112/configVarying.xml @@ -0,0 +1,22 @@ + + + + + simple mcc112 + + bag mcc112 + + 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 @@ + + + + + simple mnc220 xx + + bag mnc220 xx + + diff --git a/tests/AndroidTests/res/values-mnc222-32dpi/configVarying.xml b/tests/AndroidTests/res/values-mnc222-32dpi/configVarying.xml new file mode 100644 index 0000000..03bea33 --- /dev/null +++ b/tests/AndroidTests/res/values-mnc222-32dpi/configVarying.xml @@ -0,0 +1,22 @@ + + + + + simple mnc222 32dpi + + bag mnc222 32dpi + + diff --git a/tests/AndroidTests/res/values-mnc223/configVarying.xml b/tests/AndroidTests/res/values-mnc223/configVarying.xml new file mode 100644 index 0000000..8936cbc --- /dev/null +++ b/tests/AndroidTests/res/values-mnc223/configVarying.xml @@ -0,0 +1,22 @@ + + + + + simple mnc223 + + bag mnc223 + + diff --git a/tests/AndroidTests/res/values-port/configVarying.xml b/tests/AndroidTests/res/values-port/configVarying.xml deleted file mode 100644 index 0e1f247..0000000 --- a/tests/AndroidTests/res/values-port/configVarying.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - simple portrait - - bag portrait - - diff --git a/tests/AndroidTests/res/values-qwerty/configVarying.xml b/tests/AndroidTests/res/values-qwerty/configVarying.xml deleted file mode 100644 index 939f682..0000000 --- a/tests/AndroidTests/res/values-qwerty/configVarying.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - simple qwerty - - bag qwerty - - diff --git a/tests/AndroidTests/res/values-trackball/configVarying.xml b/tests/AndroidTests/res/values-trackball/configVarying.xml deleted file mode 100644 index 0dec300..0000000 --- a/tests/AndroidTests/res/values-trackball/configVarying.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - simple trackball - - bag trackball - - 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"}); } } -- cgit v1.1