summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2014-02-03 11:36:14 +0000
committerNarayan Kamath <narayan@google.com>2014-06-30 12:20:12 +0100
commit82ee2e50f63c00c3a57ce4f76f1843a58b176e09 (patch)
tree92a5e32934e1029a1dfebbaf1bed5671f2536541
parent29d107aadae219e85253eaacf2234638c159dfb3 (diff)
downloadcts-82ee2e50f63c00c3a57ce4f76f1843a58b176e09.tar.gz
Add CTS tests for extended locales.
(cherry picked from commit e80d5b0e7b79abf222ed831a16d316911a964465) Change-Id: I5d4f38d62b430f3d5d5aa00d735ca8fa32d3cfec
-rw-r--r--tests/Android.mk1
-rw-r--r--tests/res/values-b+kok+419+VARIANT/configVarying.xml22
-rw-r--r--tests/res/values-b+kok+419/configVarying.xml22
-rw-r--r--tests/res/values-b+kok+IN/configVarying.xml22
-rw-r--r--tests/res/values-b+kok+Knda+419+VARIANT/configVarying.xml22
-rw-r--r--tests/res/values-b+kok+Knda+419/configVarying.xml22
-rw-r--r--tests/res/values-b+kok+Knda/configVarying.xml22
-rw-r--r--tests/res/values-b+kok+VARIANT/configVarying.xml22
-rw-r--r--tests/res/values-b+kok/configVarying.xml22
-rw-r--r--tests/tests/content/src/android/content/res/cts/ConfigTest.java93
10 files changed, 265 insertions, 5 deletions
diff --git a/tests/Android.mk b/tests/Android.mk
index a4cc38f2482..0c8f71fbb39 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -30,6 +30,7 @@ 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 small -c normal -c large -c xlarge \
-c 320dpi -c 240dpi -c 160dpi -c 32dpi \
+ -c kok,kok_IN,kok_419,kok_419_VARIANT,kok_Knda_419,kok_Knda_419_VARIANT,kok_VARIANT,kok_Knda \
--preferred-configurations 320dpi --preferred-configurations 240dpi \
--preferred-configurations 160dpi --preferred-configurations 32dpi
diff --git a/tests/res/values-b+kok+419+VARIANT/configVarying.xml b/tests/res/values-b+kok+419+VARIANT/configVarying.xml
new file mode 100644
index 00000000000..3560279ef16
--- /dev/null
+++ b/tests/res/values-b+kok+419+VARIANT/configVarying.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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 kok 419 VARIANT</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag kok 419 VARIANT</item>
+ </bag>
+</resources>
diff --git a/tests/res/values-b+kok+419/configVarying.xml b/tests/res/values-b+kok+419/configVarying.xml
new file mode 100644
index 00000000000..b6f37f9db40
--- /dev/null
+++ b/tests/res/values-b+kok+419/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 kok 419</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag kok 419</item>
+ </bag>
+</resources>
diff --git a/tests/res/values-b+kok+IN/configVarying.xml b/tests/res/values-b+kok+IN/configVarying.xml
new file mode 100644
index 00000000000..967ea470d11
--- /dev/null
+++ b/tests/res/values-b+kok+IN/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 kok IN</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag kok IN</item>
+ </bag>
+</resources>
diff --git a/tests/res/values-b+kok+Knda+419+VARIANT/configVarying.xml b/tests/res/values-b+kok+Knda+419+VARIANT/configVarying.xml
new file mode 100644
index 00000000000..2b2bcea991b
--- /dev/null
+++ b/tests/res/values-b+kok+Knda+419+VARIANT/configVarying.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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 kok Knda 419 VARIANT</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag kok Knda 419 VARIANT</item>
+ </bag>
+</resources>
diff --git a/tests/res/values-b+kok+Knda+419/configVarying.xml b/tests/res/values-b+kok+Knda+419/configVarying.xml
new file mode 100644
index 00000000000..cbc53b95ba7
--- /dev/null
+++ b/tests/res/values-b+kok+Knda+419/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 kok Knda 419</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag kok Knda 419</item>
+ </bag>
+</resources>
diff --git a/tests/res/values-b+kok+Knda/configVarying.xml b/tests/res/values-b+kok+Knda/configVarying.xml
new file mode 100644
index 00000000000..f73574961cf
--- /dev/null
+++ b/tests/res/values-b+kok+Knda/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 kok Knda</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag kok Knda</item>
+ </bag>
+</resources>
diff --git a/tests/res/values-b+kok+VARIANT/configVarying.xml b/tests/res/values-b+kok+VARIANT/configVarying.xml
new file mode 100644
index 00000000000..6743b7f45ce
--- /dev/null
+++ b/tests/res/values-b+kok+VARIANT/configVarying.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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 kok VARIANT</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag kok VARIANT</item>
+ </bag>
+</resources>
diff --git a/tests/res/values-b+kok/configVarying.xml b/tests/res/values-b+kok/configVarying.xml
new file mode 100644
index 00000000000..e1bafa142bf
--- /dev/null
+++ b/tests/res/values-b+kok/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 kok</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag kok</item>
+ </bag>
+</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 bcfabe19829..2f892b06e51 100644
--- a/tests/tests/content/src/android/content/res/cts/ConfigTest.java
+++ b/tests/tests/content/src/android/content/res/cts/ConfigTest.java
@@ -35,6 +35,8 @@ public class ConfigTest extends AndroidTestCase {
enum Properties {
LANGUAGE,
COUNTRY,
+ SCRIPT,
+ VARIANT,
MCC,
MNC,
TOUCHSCREEN,
@@ -88,7 +90,7 @@ public class ConfigTest extends AndroidTestCase {
public TotalConfig() {
mConfig = new Configuration();
mMetrics = new DisplayMetrics();
- mConfig.locale = new Locale("++", "++");
+ mConfig.locale = Locale.ROOT;
}
public void setProperty(final Properties p, final int value) {
@@ -149,12 +151,28 @@ public class ConfigTest extends AndroidTestCase {
public void setProperty(final Properties p, final String value) {
switch(p) {
case LANGUAGE:
- final String oldCountry = mConfig.locale.getCountry();
- mConfig.locale = new Locale(value, oldCountry);
+ mConfig.locale = new Locale.Builder()
+ .setLocale(mConfig.locale)
+ .setLanguage(value)
+ .build();
break;
case COUNTRY:
- final String oldLanguage = mConfig.locale.getLanguage();
- mConfig.locale = new Locale(oldLanguage, value);
+ mConfig.locale = new Locale.Builder()
+ .setLocale(mConfig.locale)
+ .setRegion(value)
+ .build();
+ break;
+ case SCRIPT:
+ mConfig.locale = new Locale.Builder()
+ .setLocale(mConfig.locale)
+ .setScript(value)
+ .build();
+ break;
+ case VARIANT:
+ mConfig.locale = new Locale.Builder()
+ .setLocale(mConfig.locale)
+ .setVariant(value)
+ .build();
break;
default:
assert(false);
@@ -1131,4 +1149,69 @@ public class ConfigTest extends AndroidTestCase {
assertEquals("base", mContext.getResources().getString(R.string.version_old));
assertEquals("v3", mContext.getResources().getString(R.string.version_v3));
}
+
+ @MediumTest
+ public void testExtendedLocales() {
+ TotalConfig config = makeClassicConfig();
+ // BCP 47 Locale kok
+ config.setProperty(Properties.LANGUAGE, "kok");
+ Resources res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple kok");
+ checkValue(res, R.configVarying.bag,
+ R.styleable.TestConfig, new String[]{"bag kok"});
+
+ // BCP 47 Locale kok-IN
+ config.setProperty(Properties.COUNTRY, "IN");
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple kok IN");
+ checkValue(res, R.configVarying.bag,
+ R.styleable.TestConfig, new String[]{"bag kok IN"});
+
+ // BCP 47 Locale kok-419
+ config.setProperty(Properties.COUNTRY, "419");
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple kok 419");
+ checkValue(res, R.configVarying.bag,
+ R.styleable.TestConfig, new String[]{"bag kok 419"});
+
+
+ // BCP 47 Locale kok-419-VARIANT
+ config.setProperty(Properties.VARIANT, "VARIANT");
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple kok 419 VARIANT");
+ checkValue(res, R.configVarying.bag,
+ R.styleable.TestConfig, new String[]{"bag kok 419 VARIANT"});
+
+ // BCP 47 Locale kok-Knda
+ config = makeClassicConfig();
+ config.setProperty(Properties.LANGUAGE, "kok");
+ config.setProperty(Properties.SCRIPT, "Knda");
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple kok Knda");
+ checkValue(res, R.configVarying.bag,
+ R.styleable.TestConfig, new String[]{"bag kok Knda"});
+
+ // BCP 47 Locale kok-Knda-419
+ config.setProperty(Properties.COUNTRY, "419");
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple kok Knda 419");
+ checkValue(res, R.configVarying.bag,
+ R.styleable.TestConfig, new String[]{"bag kok Knda 419"});
+
+ // BCP 47 Locale kok-Knda-419-VARIANT
+ config.setProperty(Properties.VARIANT, "VARIANT");
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple kok Knda 419 VARIANT");
+ checkValue(res, R.configVarying.bag,
+ R.styleable.TestConfig, new String[]{"bag kok Knda 419 VARIANT"});
+
+ // BCP 47 Locale kok-VARIANT
+ config = makeClassicConfig();
+ config.setProperty(Properties.LANGUAGE, "kok");
+ config.setProperty(Properties.VARIANT, "VARIANT");
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple kok VARIANT");
+ checkValue(res, R.configVarying.bag,
+ R.styleable.TestConfig, new String[]{"bag kok VARIANT"});
+ }
}