diff options
Diffstat (limited to 'tests/AndroidTests/src/com/android/unit_tests/content/ConfigTest.java')
-rw-r--r-- | tests/AndroidTests/src/com/android/unit_tests/content/ConfigTest.java | 594 |
1 files changed, 384 insertions, 210 deletions
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 a63885d..1ea83c3 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/content/ConfigTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/content/ConfigTest.java @@ -32,6 +32,20 @@ import com.android.unit_tests.R; import java.util.Locale; public class ConfigTest extends AndroidTestCase { + enum properties { + LANGUAGE, + COUNTRY, + MCC, + MNC, + TOUCHSCREEN, + KEYBOARD, + KEYBOARDHIDDEN, + NAVIGATION, + ORIENTATION, + WIDTH, + HEIGHT, + DENSITY + } private static void checkValue(Resources res, int resId, String expectedValue) { try { @@ -40,8 +54,8 @@ public class ConfigTest extends AndroidTestCase { + actual + "' from resource 0x" + Integer.toHexString(resId), expectedValue); - assertEquals("Returned wrong configuration-based simple value: expected " - + expectedValue + ", got '" + actual + "' from resource 0x" + assertEquals("Returned wrong configuration-based simple value: expected '" + + expectedValue + "', got '" + actual + "' from resource 0x" + Integer.toHexString(resId), expectedValue, actual); } catch (Resources.NotFoundException e) { @@ -57,32 +71,95 @@ public class ConfigTest extends AndroidTestCase { TypedArray sa = theme.obtainStyledAttributes(resId, styleable); for (int i = 0; i < styleable.length; i++) { String actual = sa.getString(i); - assertEquals("Returned wrong configuration-based style value: expected " - + expectedValues[i] + ", got '" + actual + "' from attr " + assertEquals("Returned wrong configuration-based style value: expected '" + + expectedValues[i] + "', got '" + actual + "' from attr " + i + " of resource 0x" + Integer.toHexString(resId), actual, expectedValues[i]); } sa.recycle(); } - public Resources getResources(Configuration config, - int mcc, int mnc, int touchscreen, int keyboard, int keysHidden, - int navigation, int width, int height) { - AssetManager assmgr = new AssetManager(); - assmgr.addAssetPath(mContext.getPackageResourcePath()); - DisplayMetrics metrics = new DisplayMetrics(); - WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); - Display d = wm.getDefaultDisplay(); - d.getMetrics(metrics); - config.mcc = mcc; - config.mnc = mnc; - config.touchscreen = touchscreen; - config.keyboard = keyboard; - config.keyboardHidden = keysHidden; - config.navigation = navigation; - metrics.widthPixels = width; - metrics.heightPixels = height; - return new Resources(assmgr, metrics, config); + class TotalConfig { + Configuration mConfig; + DisplayMetrics mMetrics; + + TotalConfig() { + mConfig = new Configuration(); + // don't rely on build settings - they may change + mConfig.locale = new Locale("en", "US"); + mConfig.mcc = 310; + mConfig.mnc = 001; // unused + mConfig.touchscreen = Configuration.TOUCHSCREEN_FINGER; + mConfig.keyboard = Configuration.KEYBOARD_QWERTY; + mConfig.keyboardHidden = Configuration.KEYBOARDHIDDEN_YES; + mConfig.navigation = Configuration.NAVIGATION_TRACKBALL; + mConfig.orientation = Configuration.ORIENTATION_PORTRAIT; + + mMetrics = new DisplayMetrics(); + mMetrics.widthPixels = 200; + mMetrics.heightPixels = 320; + mMetrics.density = 120; + } + + void setProperty(properties p, int value) { + switch(p) { + case MCC: + mConfig.mcc = value; + break; + case MNC: + mConfig.mnc = value; + break; + case TOUCHSCREEN: + mConfig.touchscreen = value; + break; + case KEYBOARD: + mConfig.keyboard = value; + break; + case KEYBOARDHIDDEN: + mConfig.keyboardHidden = value; + break; + case NAVIGATION: + mConfig.navigation = value; + break; + case ORIENTATION: + mConfig.orientation = value; + break; + case WIDTH: + mMetrics.widthPixels = value; + break; + case HEIGHT: + mMetrics.heightPixels = value; + break; + case DENSITY: + mMetrics.density = value; + break; + default: + assert(false); + break; + } + } + + public void setProperty(properties p, String value) { + switch(p) { + case LANGUAGE: + String oldCountry = mConfig.locale.getCountry(); + mConfig.locale = new Locale(value, oldCountry); + break; + case COUNTRY: + String oldLanguage = mConfig.locale.getLanguage(); + mConfig.locale = new Locale(oldLanguage, value); + break; + default: + assert(false); + break; + } + } + + public Resources getResources() { + AssetManager assmgr = new AssetManager(); + assmgr.addAssetPath(mContext.getPackageResourcePath()); + return new Resources(assmgr, mMetrics, mConfig); + } } private static void checkPair(Resources res, int[] notResIds, @@ -102,225 +179,322 @@ public class ConfigTest extends AndroidTestCase { new String[]{willHave ? bagString : null}); } - private static void checkAllExcept(Resources res, int[] notResIds) { - checkPair(res, notResIds, - R.configVarying.simple_default, "only simple default", - R.configVarying.bag_default, "only bag default"); - checkPair(res, notResIds, - R.configVarying.simple_mcc111, "only simple mcc111", - R.configVarying.bag_mcc111, "only bag mcc111"); - checkPair(res, notResIds, - R.configVarying.simple_mnc222, "only simple mnc222", - R.configVarying.bag_mnc222, "only bag mnc222"); - checkPair(res, notResIds, - R.configVarying.simple_xx, "only simple xx", - R.configVarying.bag_xx, "only bag xx"); - checkPair(res, notResIds, - R.configVarying.simple_xx_rYY, "only simple xx_rYY", - R.configVarying.bag_xx_rYY, "only bag xx_rYY"); - checkPair(res, notResIds, - R.configVarying.simple_notouch, "only simple notouch", - R.configVarying.bag_notouch, "only bag notouch"); - checkPair(res, notResIds, - R.configVarying.simple_finger, "only simple finger", - R.configVarying.bag_finger, "only bag finger"); - checkPair(res, notResIds, - R.configVarying.simple_stylus, "only simple stylus", - R.configVarying.bag_stylus, "only bag stylus"); - checkPair(res, notResIds, - R.configVarying.simple_12key, "only simple 12key", - R.configVarying.bag_12key, "only bag 12key"); - checkPair(res, notResIds, - R.configVarying.simple_320x200, "only simple 320x200", - R.configVarying.bag_320x200, "only bag 320x200"); - checkPair(res, notResIds, - R.configVarying.simple_480x320, "only simple 480x320", - R.configVarying.bag_480x320, "only bag 480x320"); - } - - @SmallTest - public void testDefaultNavigationMethod() throws Exception { - assertEquals(mContext.getResources().getConfiguration().navigation, - Configuration.NAVIGATION_TRACKBALL); - } - @SmallTest public void testAllConfigs() throws Exception { /** * Test a resource that contains a value for each possible single * configuration value. */ - Configuration config = new Configuration(); - Resources res = getResources(config, 0, 0, 0, 0, 0, 0, 0, 0); - checkValue(res, R.configVarying.simple, "simple default"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag default"}); - - config.locale = new Locale("xx"); - res = getResources(config, 0, 0, 0, 0, 0, 0, 0, 0); - checkValue(res, R.configVarying.simple, "simple xx"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag xx"}); - - config.locale = new Locale("xx", "YY"); - res = getResources(config, 0, 0, 0, 0, 0, 0, 0, 0); + 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"}); + + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.LANGUAGE, "xx"); + config.setProperty(properties.COUNTRY, "YY"); + res = config.getResources(); checkValue(res, R.configVarying.simple, "simple xx-rYY"); checkValue(res, R.configVarying.bag, R.styleable.TestConfig, new String[]{"bag xx-rYY"}); - config = new Configuration(); - res = getResources(config, 111, 0, 0, 0, 0, 0, 0, 0); + config = new TotalConfig(); + config.setProperty(properties.MCC, 111); + res = config.getResources(); checkValue(res, R.configVarying.simple, "simple mcc111"); checkValue(res, R.configVarying.bag, R.styleable.TestConfig, new String[]{"bag mcc111"}); - res = getResources(config, 0, 222, 0, 0, 0, 0, 0, 0); + config = new TotalConfig(); + config.setProperty(properties.MNC, 222); + res = config.getResources(); checkValue(res, R.configVarying.simple, "simple mnc222"); checkValue(res, R.configVarying.bag, R.styleable.TestConfig, new String[]{"bag mnc222"}); - res = getResources(config, 0, 0, Configuration.TOUCHSCREEN_NOTOUCH, 0, 0, 0, 0, 0); - checkValue(res, R.configVarying.simple, "simple notouch"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag notouch"}); - - res = getResources(config, 0, 0, Configuration.TOUCHSCREEN_FINGER, 0, 0, 0, 0, 0); - checkValue(res, R.configVarying.simple, "simple finger"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag finger"}); - - res = getResources(config, 0, 0, Configuration.TOUCHSCREEN_STYLUS, 0, 0, 0, 0, 0); - checkValue(res, R.configVarying.simple, "simple stylus"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag stylus"}); - - res = getResources(config, 0, 0, 0, Configuration.KEYBOARD_NOKEYS, 0, 0, 0, 0); - checkValue(res, R.configVarying.simple, "simple nokeys"); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.TOUCHSCREEN, Configuration.TOUCHSCREEN_FINGER); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.TOUCHSCREEN, Configuration.TOUCHSCREEN_STYLUS); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_NOKEYS); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_QWERTY); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_12KEY); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.KEYBOARDHIDDEN, Configuration.KEYBOARDHIDDEN_YES); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.KEYBOARDHIDDEN, Configuration.KEYBOARDHIDDEN_NO); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.NAVIGATION, Configuration.NAVIGATION_NONAV); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.NAVIGATION, Configuration.NAVIGATION_DPAD); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.NAVIGATION, Configuration.NAVIGATION_TRACKBALL); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.NAVIGATION, Configuration.NAVIGATION_WHEEL); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.HEIGHT, 320); + config.setProperty(properties.WIDTH, 200); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.HEIGHT, 480); + config.setProperty(properties.WIDTH, 320); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.DENSITY, 240); + res = config.getResources(); + checkValue(res, R.configVarying.simple, "simple 240dpi"); checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag nokeys"}); + R.styleable.TestConfig, new String[]{"bag 240dpi"}); + + config = new TotalConfig(); + config.setProperty(properties.DENSITY, 120); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.ORIENTATION, Configuration.ORIENTATION_LANDSCAPE); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.ORIENTATION, Configuration.ORIENTATION_PORTRAIT); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.ORIENTATION, Configuration.ORIENTATION_SQUARE); + 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"}); + } - res = getResources(config, 0, 0, 0, Configuration.KEYBOARD_QWERTY, 0, 0, 0, 0); - checkValue(res, R.configVarying.simple, "simple qwerty"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag qwerty"}); +// TODO - add tests for special cases - ie, other key params seem ignored if +// nokeys is set - res = getResources(config, 0, 0, 0, Configuration.KEYBOARD_12KEY, 0, 0, 0, 0); - checkValue(res, R.configVarying.simple, "simple 12key"); + @MediumTest + public void testCombinations() throws Exception { + /** + * Verify that proper strings are found for multiple-selectivity case + * (ie, a string set for locale and mcc is found only when both are + * true). + */ + TotalConfig config = new TotalConfig(); + config.setProperty(properties.LANGUAGE, "xx"); + config.setProperty(properties.COUNTRY, "YY"); + config.setProperty(properties.MCC, 111); + Resources res = config.getResources(); + checkValue(res, R.configVarying.simple, "simple mcc111 xx-rYY"); checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag 12key"}); + R.styleable.TestConfig, new String[]{"bag mcc111 xx-rYY"}); - res = getResources(config, 0, 0, 0, 0, Configuration.KEYBOARDHIDDEN_YES, 0, 0, 0); - checkValue(res, R.configVarying.simple, "simple keyshidden"); + config = new TotalConfig(); + config.setProperty(properties.LANGUAGE, "xx"); + config.setProperty(properties.COUNTRY, "YY"); + config.setProperty(properties.MCC, 333); + res = config.getResources(); + checkValue(res, R.configVarying.simple, "simple xx-rYY"); checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag keyshidden"}); + R.styleable.TestConfig, new String[]{"bag xx-rYY"}); - res = getResources(config, 0, 0, 0, 0, Configuration.KEYBOARDHIDDEN_NO, 0, 0, 0); - 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.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"}); + } - res = getResources(config, 0, 0, 0, 0, 0, Configuration.NAVIGATION_NONAV, 0, 0); - checkValue(res, R.configVarying.simple, "simple nonav"); - checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag nonav"}); + @MediumTest + public void testPrecidence() throws Exception { + /** + * Verify that in cases of ties, the specific ordering is followed + */ - res = getResources(config, 0, 0, 0, 0, 0, Configuration.NAVIGATION_DPAD, 0, 0); - checkValue(res, R.configVarying.simple, "simple dpad"); + /* full A + B + C doesn't exist. Do we get A + C or B + C? + */ + TotalConfig config = new TotalConfig(); + config.setProperty(properties.MCC, 111); + config.setProperty(properties.MNC, 222); + config.setProperty(properties.LANGUAGE, "xx"); + Resources res = config.getResources(); + checkValue(res, R.configVarying.simple, "simple mcc111 mnc222"); checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag dpad"}); - - res = getResources(config, 0, 0, 0, 0, 0, Configuration.NAVIGATION_TRACKBALL, 0, 0); - checkValue(res, R.configVarying.simple, "simple trackball"); + R.styleable.TestConfig, new String[]{"bag mcc111 mnc222"}); + + config = new TotalConfig(); + config.setProperty(properties.MNC, 222); + config.setProperty(properties.LANGUAGE, "xx"); + config.setProperty(properties.ORIENTATION, Configuration.ORIENTATION_SQUARE); + res = config.getResources(); + checkValue(res, R.configVarying.simple, "simple mnc222 xx"); checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag trackball"}); - - res = getResources(config, 0, 0, 0, 0, 0, Configuration.NAVIGATION_WHEEL, 0, 0); - checkValue(res, R.configVarying.simple, "simple wheel"); + R.styleable.TestConfig, new String[]{"bag mnc222 xx"}); + + config = new TotalConfig(); + config.setProperty(properties.LANGUAGE, "xx"); + 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.bag, - R.styleable.TestConfig, new String[]{"bag wheel"}); - - res = getResources(config, 0, 0, 0, 0, 0, 0, 320, 200); - checkValue(res, R.configVarying.simple, "simple 320x200"); + R.styleable.TestConfig, new String[]{"bag xx 32dpi"}); + + config = new TotalConfig(); + config.setProperty(properties.ORIENTATION, Configuration.ORIENTATION_SQUARE); + config.setProperty(properties.DENSITY, 32); + config.setProperty(properties.TOUCHSCREEN, Configuration.TOUCHSCREEN_STYLUS); + res = config.getResources(); + checkValue(res, R.configVarying.simple, "simple 32dpi stylus"); checkValue(res, R.configVarying.bag, - R.styleable.TestConfig, new String[]{"bag 320x200"}); - - res = getResources(config, 0, 0, 0, 0, 0, 0, 480, 320); - checkValue(res, R.configVarying.simple, "simple 480x320"); + R.styleable.TestConfig, new String[]{"bag 32dpi stylus"}); + + config = new TotalConfig(); + config.setProperty(properties.DENSITY, 32); + 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 480x320"}); - } - - @MediumTest - public void testSingleConfig() throws Exception { - /** - * Test resources that contain a value for only one possible configuration - * value. XXX This is not yet complete. - */ - Configuration config = new Configuration(); - Resources res = getResources(config, 0, 0, 0, 0, 0, 0, 0, 0); - checkAllExcept(res, new int[]{ - R.configVarying.simple_xx, - R.configVarying.simple_xx_rYY}); - - config.locale = new Locale("xx"); - res = getResources(config, 0, 0, 0, 0, 0, 0, 0, 0); - checkAllExcept(res, null); - - config.locale = new Locale("xx", "YY"); - res = getResources(config, 0, 0, 0, 0, 0, 0, 0, 0); - checkAllExcept(res, null); - - config.locale = new Locale("xx", "ZZ"); - res = getResources(config, 0, 0, 0, 0, 0, 0, 0, 0); - checkAllExcept(res, new int[]{R.configVarying.simple_xx_rYY}); - - config = new Configuration(); - res = getResources(config, 111, 0, 0, 0, 0, 0, 0, 0); - checkAllExcept(res, new int[]{ - R.configVarying.simple_xx, - R.configVarying.simple_xx_rYY}); - - res = getResources(config, 0, 222, 0, 0, 0, 0, 0, 0); - checkAllExcept(res, new int[]{ - R.configVarying.simple_xx, - R.configVarying.simple_xx_rYY}); - - res = getResources(config, 0, 0, Configuration.TOUCHSCREEN_NOTOUCH, 0, 0, 0, 0, 0); - checkAllExcept(res, new int[]{ - R.configVarying.simple_xx, - R.configVarying.simple_xx_rYY, - R.configVarying.simple_finger, - R.configVarying.simple_stylus}); - - res = getResources(config, 0, 0, Configuration.TOUCHSCREEN_FINGER, 0, 0, 0, 0, 0); - checkAllExcept(res, new int[]{ - R.configVarying.simple_xx, - R.configVarying.simple_xx_rYY, - R.configVarying.simple_notouch, - R.configVarying.simple_stylus}); - - res = getResources(config, 0, 0, Configuration.TOUCHSCREEN_STYLUS, 0, 0, 0, 0, 0); - checkAllExcept(res, new int[]{ - R.configVarying.simple_xx, - R.configVarying.simple_xx_rYY, - R.configVarying.simple_notouch, - R.configVarying.simple_finger}); - - res = getResources(config, 0, 0, 0, Configuration.KEYBOARD_12KEY, 0, 0, 0, 0); - checkAllExcept(res, new int[]{ - R.configVarying.simple_xx, - R.configVarying.simple_xx_rYY}); - - res = getResources(config, 0, 0, 0, 0, 0, 0, 320, 200); - checkAllExcept(res, new int[]{ - R.configVarying.simple_xx, - R.configVarying.simple_xx_rYY, - R.configVarying.simple_480x320}); - - res = getResources(config, 0, 0, 0, 0, 0, 0, 480, 320); - checkAllExcept(res, new int[]{ - R.configVarying.simple_xx, - R.configVarying.simple_xx_rYY, - R.configVarying.simple_320x200}); + 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.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"}); + + config = new TotalConfig(); + config.setProperty(properties.KEYBOARDHIDDEN, Configuration.KEYBOARDHIDDEN_NO); + config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_12KEY); + 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"}); + + config = new TotalConfig(); + config.setProperty(properties.KEYBOARD, Configuration.KEYBOARD_12KEY); + 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"}); } } |