aboutsummaryrefslogtreecommitdiffstats
path: root/ide_common
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2011-03-18 12:13:51 -0700
committerXavier Ducrohet <xav@android.com>2011-03-18 12:13:51 -0700
commit65e36c24654b47f4fc314566d2883582fc2708ba (patch)
tree61e7009df6755afc17e16531619a4df3398e9331 /ide_common
parent026ba97e98e0527d910e15c4e1512893a777a8d2 (diff)
downloadsdk-65e36c24654b47f4fc314566d2883582fc2708ba.zip
sdk-65e36c24654b47f4fc314566d2883582fc2708ba.tar.gz
sdk-65e36c24654b47f4fc314566d2883582fc2708ba.tar.bz2
Fix unit tests from the previous refactor.
Change-Id: I464fe3f94e701e619b474f82aaf84ee04d158e71
Diffstat (limited to 'ide_common')
-rw-r--r--ide_common/tests/.classpath9
-rw-r--r--ide_common/tests/.project17
-rw-r--r--ide_common/tests/Android.mk27
-rw-r--r--ide_common/tests/src/com/android/ide/common/resources/configuration/CountryCodeQualifierTest.java55
-rw-r--r--ide_common/tests/src/com/android/ide/common/resources/configuration/DockModeQualifierTest.java69
-rw-r--r--ide_common/tests/src/com/android/ide/common/resources/configuration/FolderConfigurationTest.java38
-rw-r--r--ide_common/tests/src/com/android/ide/common/resources/configuration/KeyboardStateQualifierTest.java61
-rw-r--r--ide_common/tests/src/com/android/ide/common/resources/configuration/LanguageQualifierTest.java53
-rw-r--r--ide_common/tests/src/com/android/ide/common/resources/configuration/NavigationMethodQualifierTest.java68
-rw-r--r--ide_common/tests/src/com/android/ide/common/resources/configuration/NetworkCodeQualifierTest.java55
-rw-r--r--ide_common/tests/src/com/android/ide/common/resources/configuration/PixelDensityQualifierTest.java118
-rw-r--r--ide_common/tests/src/com/android/ide/common/resources/configuration/RegionQualifierTest.java54
-rw-r--r--ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenDimensionQualifierTest.java57
-rw-r--r--ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenOrientationQualifierTest.java72
-rw-r--r--ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenSizeQualifierTest.java69
-rw-r--r--ide_common/tests/src/com/android/ide/common/resources/configuration/TextInputMethodQualifierTest.java70
-rw-r--r--ide_common/tests/src/com/android/ide/common/resources/configuration/TouchScreenQualifierTest.java68
17 files changed, 960 insertions, 0 deletions
diff --git a/ide_common/tests/.classpath b/ide_common/tests/.classpath
new file mode 100644
index 0000000..3cc56e3
--- /dev/null
+++ b/ide_common/tests/.classpath
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/ide_common"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/common"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/ide_common/tests/.project b/ide_common/tests/.project
new file mode 100644
index 0000000..1cfa60e
--- /dev/null
+++ b/ide_common/tests/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>ide_common-tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/ide_common/tests/Android.mk b/ide_common/tests/Android.mk
new file mode 100644
index 0000000..9443dba
--- /dev/null
+++ b/ide_common/tests/Android.mk
@@ -0,0 +1,27 @@
+# Copyright (C) 2011 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.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+# Only compile source java files in this lib.
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_MODULE := ide_common-tests
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_JAVA_LIBRARIES := common ide_common junit
+
+include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/ide_common/tests/src/com/android/ide/common/resources/configuration/CountryCodeQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/CountryCodeQualifierTest.java
new file mode 100644
index 0000000..eba8b8d
--- /dev/null
+++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/CountryCodeQualifierTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+package com.android.ide.common.resources.configuration;
+
+import junit.framework.TestCase;
+
+public class CountryCodeQualifierTest extends TestCase {
+
+ private CountryCodeQualifier mccq;
+ private FolderConfiguration config;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mccq = new CountryCodeQualifier();
+ config = new FolderConfiguration();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ mccq = null;
+ config = null;
+ }
+
+ public void testCheckAndSet() {
+ assertEquals(true, mccq.checkAndSet("mcc123", config));//$NON-NLS-1$
+ assertTrue(config.getCountryCodeQualifier() != null);
+ assertEquals(123, config.getCountryCodeQualifier().getCode());
+ assertEquals("mcc123", config.getCountryCodeQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testFailures() {
+ assertEquals(false, mccq.checkAndSet("", config));//$NON-NLS-1$
+ assertEquals(false, mccq.checkAndSet("mcc", config));//$NON-NLS-1$
+ assertEquals(false, mccq.checkAndSet("MCC123", config));//$NON-NLS-1$
+ assertEquals(false, mccq.checkAndSet("123", config));//$NON-NLS-1$
+ assertEquals(false, mccq.checkAndSet("mccsdf", config));//$NON-NLS-1$
+ }
+
+}
diff --git a/ide_common/tests/src/com/android/ide/common/resources/configuration/DockModeQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/DockModeQualifierTest.java
new file mode 100644
index 0000000..195d474
--- /dev/null
+++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/DockModeQualifierTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+package com.android.ide.common.resources.configuration;
+
+import com.android.resources.DockMode;
+
+import junit.framework.TestCase;
+
+public class DockModeQualifierTest extends TestCase {
+
+ private DockModeQualifier mCarQualifier;
+ private DockModeQualifier mDeskQualifier;
+ private DockModeQualifier mNoneQualifier;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mCarQualifier = new DockModeQualifier(DockMode.CAR);
+ mDeskQualifier = new DockModeQualifier(DockMode.DESK);
+ mNoneQualifier = new DockModeQualifier(DockMode.NONE);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ mCarQualifier = null;
+ mDeskQualifier = null;
+ mNoneQualifier = null;
+ }
+
+ public void testIsBetterMatchThan() {
+ assertTrue(mNoneQualifier.isBetterMatchThan(mCarQualifier, mDeskQualifier));
+ assertFalse(mNoneQualifier.isBetterMatchThan(mDeskQualifier, mDeskQualifier));
+ assertTrue(mNoneQualifier.isBetterMatchThan(mDeskQualifier, mCarQualifier));
+ assertFalse(mNoneQualifier.isBetterMatchThan(mCarQualifier, mCarQualifier));
+
+ assertTrue(mDeskQualifier.isBetterMatchThan(mCarQualifier, mDeskQualifier));
+ assertFalse(mDeskQualifier.isBetterMatchThan(mCarQualifier, mCarQualifier));
+
+ assertTrue(mCarQualifier.isBetterMatchThan(mDeskQualifier, mCarQualifier));
+ assertFalse(mCarQualifier.isBetterMatchThan(mDeskQualifier, mDeskQualifier));
+ }
+
+ public void testIsMatchFor() {
+ assertTrue(mNoneQualifier.isMatchFor(mCarQualifier));
+ assertTrue(mNoneQualifier.isMatchFor(mDeskQualifier));
+ assertTrue(mCarQualifier.isMatchFor(mCarQualifier));
+ assertTrue(mDeskQualifier.isMatchFor(mDeskQualifier));
+
+ assertFalse(mCarQualifier.isMatchFor(mNoneQualifier));
+ assertFalse(mCarQualifier.isMatchFor(mDeskQualifier));
+ assertFalse(mDeskQualifier.isMatchFor(mCarQualifier));
+ assertFalse(mDeskQualifier.isMatchFor(mNoneQualifier));
+ }
+}
diff --git a/ide_common/tests/src/com/android/ide/common/resources/configuration/FolderConfigurationTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/FolderConfigurationTest.java
new file mode 100644
index 0000000..6d0d487
--- /dev/null
+++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/FolderConfigurationTest.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+package com.android.ide.common.resources.configuration;
+
+import junit.framework.TestCase;
+
+public class FolderConfigurationTest extends TestCase {
+
+ /*
+ * Test createDefault creates all the qualifiers.
+ */
+ public void testCreateDefault() {
+ FolderConfiguration defaultConfig = new FolderConfiguration();
+ defaultConfig.createDefault();
+
+ // this is always valid and up to date.
+ final int count = FolderConfiguration.getQualifierCount();
+
+ // make sure all the qualifiers were created.
+ for (int i = 0 ; i < count ; i++) {
+ assertNotNull(defaultConfig.getQualifier(i));
+ }
+ }
+}
diff --git a/ide_common/tests/src/com/android/ide/common/resources/configuration/KeyboardStateQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/KeyboardStateQualifierTest.java
new file mode 100644
index 0000000..cf52a38
--- /dev/null
+++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/KeyboardStateQualifierTest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+package com.android.ide.common.resources.configuration;
+
+import com.android.resources.KeyboardState;
+
+import junit.framework.TestCase;
+
+public class KeyboardStateQualifierTest extends TestCase {
+
+ private KeyboardStateQualifier ksq;
+ private FolderConfiguration config;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ ksq = new KeyboardStateQualifier();
+ config = new FolderConfiguration();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ ksq = null;
+ config = null;
+ }
+
+ public void testExposed() {
+ assertEquals(true, ksq.checkAndSet("keysexposed", config)); //$NON-NLS-1$
+ assertTrue(config.getKeyboardStateQualifier() != null);
+ assertEquals(KeyboardState.EXPOSED, config.getKeyboardStateQualifier().getValue());
+ assertEquals("keysexposed", config.getKeyboardStateQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testHidden() {
+ assertEquals(true, ksq.checkAndSet("keyshidden", config)); //$NON-NLS-1$
+ assertTrue(config.getKeyboardStateQualifier() != null);
+ assertEquals(KeyboardState.HIDDEN, config.getKeyboardStateQualifier().getValue());
+ assertEquals("keyshidden", config.getKeyboardStateQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testFailures() {
+ assertEquals(false, ksq.checkAndSet("", config));//$NON-NLS-1$
+ assertEquals(false, ksq.checkAndSet("KEYSEXPOSED", config));//$NON-NLS-1$
+ assertEquals(false, ksq.checkAndSet("other", config));//$NON-NLS-1$
+ }
+}
diff --git a/ide_common/tests/src/com/android/ide/common/resources/configuration/LanguageQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/LanguageQualifierTest.java
new file mode 100644
index 0000000..2dfd65f
--- /dev/null
+++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/LanguageQualifierTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+package com.android.ide.common.resources.configuration;
+
+import junit.framework.TestCase;
+
+public class LanguageQualifierTest extends TestCase {
+
+ private FolderConfiguration config;
+ private LanguageQualifier lq;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ config = new FolderConfiguration();
+ lq = new LanguageQualifier();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ config = null;
+ lq = null;
+ }
+
+ public void testCheckAndSet() {
+ assertEquals(true, lq.checkAndSet("en", config)); //$NON-NLS-1$
+ assertTrue(config.getLanguageQualifier() != null);
+ assertEquals("en", config.getLanguageQualifier().toString()); //$NON-NLS-1$
+
+ }
+
+ public void testFailures() {
+ assertEquals(false, lq.checkAndSet("", config)); //$NON-NLS-1$
+ assertEquals(false, lq.checkAndSet("EN", config)); //$NON-NLS-1$
+ assertEquals(false, lq.checkAndSet("abc", config)); //$NON-NLS-1$
+ }
+}
+
diff --git a/ide_common/tests/src/com/android/ide/common/resources/configuration/NavigationMethodQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/NavigationMethodQualifierTest.java
new file mode 100644
index 0000000..4237dde
--- /dev/null
+++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/NavigationMethodQualifierTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+package com.android.ide.common.resources.configuration;
+
+import com.android.resources.Navigation;
+
+import junit.framework.TestCase;
+
+public class NavigationMethodQualifierTest extends TestCase {
+
+ private FolderConfiguration config;
+ private NavigationMethodQualifier nmq;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ config = new FolderConfiguration();
+ nmq = new NavigationMethodQualifier();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ config = null;
+ nmq = null;
+ }
+
+ public void testDPad() {
+ assertEquals(true, nmq.checkAndSet("dpad", config)); //$NON-NLS-1$
+ assertTrue(config.getNavigationMethodQualifier() != null);
+ assertEquals(Navigation.DPAD, config.getNavigationMethodQualifier().getValue());
+ assertEquals("dpad", config.getNavigationMethodQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testTrackball() {
+ assertEquals(true, nmq.checkAndSet("trackball", config)); //$NON-NLS-1$
+ assertTrue(config.getNavigationMethodQualifier() != null);
+ assertEquals(Navigation.TRACKBALL, config.getNavigationMethodQualifier().getValue());
+ assertEquals("trackball", config.getNavigationMethodQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testWheel() {
+ assertEquals(true, nmq.checkAndSet("wheel", config)); //$NON-NLS-1$
+ assertTrue(config.getNavigationMethodQualifier() != null);
+ assertEquals(Navigation.WHEEL, config.getNavigationMethodQualifier().getValue());
+ assertEquals("wheel", config.getNavigationMethodQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testFailures() {
+ assertEquals(false, nmq.checkAndSet("", config));//$NON-NLS-1$
+ assertEquals(false, nmq.checkAndSet("WHEEL", config));//$NON-NLS-1$
+ assertEquals(false, nmq.checkAndSet("other", config));//$NON-NLS-1$
+ }
+}
diff --git a/ide_common/tests/src/com/android/ide/common/resources/configuration/NetworkCodeQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/NetworkCodeQualifierTest.java
new file mode 100644
index 0000000..6896316
--- /dev/null
+++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/NetworkCodeQualifierTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+package com.android.ide.common.resources.configuration;
+
+import junit.framework.TestCase;
+
+public class NetworkCodeQualifierTest extends TestCase {
+
+ private NetworkCodeQualifier mncq;
+ private FolderConfiguration config;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mncq = new NetworkCodeQualifier();
+ config = new FolderConfiguration();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ mncq = null;
+ config = null;
+ }
+
+ public void testCheckAndSet() {
+ assertEquals(true, mncq.checkAndSet("mnc123", config));//$NON-NLS-1$
+ assertTrue(config.getNetworkCodeQualifier() != null);
+ assertEquals(123, config.getNetworkCodeQualifier().getCode());
+ assertEquals("mnc123", config.getNetworkCodeQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testFailures() {
+ assertEquals(false, mncq.checkAndSet("", config));//$NON-NLS-1$
+ assertEquals(false, mncq.checkAndSet("mnc", config));//$NON-NLS-1$
+ assertEquals(false, mncq.checkAndSet("MNC123", config));//$NON-NLS-1$
+ assertEquals(false, mncq.checkAndSet("123", config));//$NON-NLS-1$
+ assertEquals(false, mncq.checkAndSet("mncsdf", config));//$NON-NLS-1$
+ }
+
+}
diff --git a/ide_common/tests/src/com/android/ide/common/resources/configuration/PixelDensityQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/PixelDensityQualifierTest.java
new file mode 100644
index 0000000..b99f2af
--- /dev/null
+++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/PixelDensityQualifierTest.java
@@ -0,0 +1,118 @@
+/*
+ * 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.
+ */
+
+package com.android.ide.common.resources.configuration;
+
+import com.android.resources.Density;
+
+import junit.framework.TestCase;
+
+public class PixelDensityQualifierTest extends TestCase {
+
+ private PixelDensityQualifier pdq;
+ private FolderConfiguration config;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ pdq = new PixelDensityQualifier();
+ config = new FolderConfiguration();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ pdq = null;
+ config = null;
+ }
+
+ public void testCheckAndSet() {
+ assertEquals(true, pdq.checkAndSet("ldpi", config));//$NON-NLS-1$
+ assertTrue(config.getPixelDensityQualifier() != null);
+ assertEquals(Density.LOW, config.getPixelDensityQualifier().getValue());
+ assertEquals("ldpi", config.getPixelDensityQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testFailures() {
+ assertEquals(false, pdq.checkAndSet("", config));//$NON-NLS-1$
+ assertEquals(false, pdq.checkAndSet("dpi", config));//$NON-NLS-1$
+ assertEquals(false, pdq.checkAndSet("123dpi", config));//$NON-NLS-1$
+ assertEquals(false, pdq.checkAndSet("123", config));//$NON-NLS-1$
+ assertEquals(false, pdq.checkAndSet("sdfdpi", config));//$NON-NLS-1$
+ }
+
+ public void testIsBetterMatchThan() {
+ PixelDensityQualifier ldpi = new PixelDensityQualifier(Density.LOW);
+ PixelDensityQualifier mdpi = new PixelDensityQualifier(Density.MEDIUM);
+ PixelDensityQualifier hdpi = new PixelDensityQualifier(Density.HIGH);
+ PixelDensityQualifier xhdpi = new PixelDensityQualifier(Density.XHIGH);
+
+ // first test that each Q is a better match than all other Qs when the ref is the same Q.
+ assertTrue(ldpi.isBetterMatchThan(mdpi, ldpi));
+ assertTrue(ldpi.isBetterMatchThan(hdpi, ldpi));
+ assertTrue(ldpi.isBetterMatchThan(xhdpi, ldpi));
+
+ assertTrue(mdpi.isBetterMatchThan(ldpi, mdpi));
+ assertTrue(mdpi.isBetterMatchThan(hdpi, mdpi));
+ assertTrue(mdpi.isBetterMatchThan(xhdpi, mdpi));
+
+ assertTrue(hdpi.isBetterMatchThan(ldpi, hdpi));
+ assertTrue(hdpi.isBetterMatchThan(mdpi, hdpi));
+ assertTrue(hdpi.isBetterMatchThan(xhdpi, hdpi));
+
+ assertTrue(xhdpi.isBetterMatchThan(ldpi, xhdpi));
+ assertTrue(xhdpi.isBetterMatchThan(mdpi, xhdpi));
+ assertTrue(xhdpi.isBetterMatchThan(hdpi, xhdpi));
+
+ // now test that the highest dpi is always preferable if there's no exact match
+
+ // looking for ldpi:
+ assertTrue(hdpi.isBetterMatchThan(mdpi, ldpi));
+ assertTrue(xhdpi.isBetterMatchThan(mdpi, ldpi));
+ assertTrue(xhdpi.isBetterMatchThan(hdpi, ldpi));
+ // the other way around
+ assertFalse(mdpi.isBetterMatchThan(hdpi, ldpi));
+ assertFalse(mdpi.isBetterMatchThan(xhdpi, ldpi));
+ assertFalse(hdpi.isBetterMatchThan(xhdpi, ldpi));
+
+ // looking for mdpi
+ assertTrue(hdpi.isBetterMatchThan(ldpi, mdpi));
+ assertTrue(xhdpi.isBetterMatchThan(ldpi, mdpi));
+ assertTrue(xhdpi.isBetterMatchThan(hdpi, mdpi));
+ // the other way around
+ assertFalse(ldpi.isBetterMatchThan(hdpi, mdpi));
+ assertFalse(ldpi.isBetterMatchThan(xhdpi, mdpi));
+ assertFalse(hdpi.isBetterMatchThan(xhdpi, mdpi));
+
+ // looking for hdpi
+ assertTrue(mdpi.isBetterMatchThan(ldpi, hdpi));
+ assertTrue(xhdpi.isBetterMatchThan(ldpi, hdpi));
+ assertTrue(xhdpi.isBetterMatchThan(mdpi, hdpi));
+ // the other way around
+ assertFalse(ldpi.isBetterMatchThan(mdpi, hdpi));
+ assertFalse(ldpi.isBetterMatchThan(xhdpi, hdpi));
+ assertFalse(mdpi.isBetterMatchThan(xhdpi, hdpi));
+
+ // looking for xhdpi
+ assertTrue(mdpi.isBetterMatchThan(ldpi, xhdpi));
+ assertTrue(hdpi.isBetterMatchThan(ldpi, xhdpi));
+ assertTrue(hdpi.isBetterMatchThan(mdpi, xhdpi));
+ // the other way around
+ assertFalse(ldpi.isBetterMatchThan(mdpi, xhdpi));
+ assertFalse(ldpi.isBetterMatchThan(hdpi, xhdpi));
+ assertFalse(mdpi.isBetterMatchThan(hdpi, xhdpi));
+ }
+}
diff --git a/ide_common/tests/src/com/android/ide/common/resources/configuration/RegionQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/RegionQualifierTest.java
new file mode 100644
index 0000000..fc0402c
--- /dev/null
+++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/RegionQualifierTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+package com.android.ide.common.resources.configuration;
+
+import junit.framework.TestCase;
+
+public class RegionQualifierTest extends TestCase {
+
+ private RegionQualifier rq;
+ private FolderConfiguration config;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ rq = new RegionQualifier();
+ config = new FolderConfiguration();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ rq = null;
+ config = null;
+ }
+
+ public void testCheckAndSet() {
+ assertEquals(true, rq.checkAndSet("rUS", config));//$NON-NLS-1$
+ assertTrue(config.getRegionQualifier() != null);
+ assertEquals("US", config.getRegionQualifier().getValue()); //$NON-NLS-1$
+ assertEquals("rUS", config.getRegionQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testFailures() {
+ assertEquals(false, rq.checkAndSet("", config));//$NON-NLS-1$
+ assertEquals(false, rq.checkAndSet("rus", config));//$NON-NLS-1$
+ assertEquals(false, rq.checkAndSet("rUSA", config));//$NON-NLS-1$
+ assertEquals(false, rq.checkAndSet("abc", config));//$NON-NLS-1$
+ }
+}
diff --git a/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenDimensionQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenDimensionQualifierTest.java
new file mode 100644
index 0000000..e57424f
--- /dev/null
+++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenDimensionQualifierTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+package com.android.ide.common.resources.configuration;
+
+import junit.framework.TestCase;
+
+public class ScreenDimensionQualifierTest extends TestCase {
+
+ private ScreenDimensionQualifier sdq;
+ private FolderConfiguration config;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ sdq = new ScreenDimensionQualifier();
+ config = new FolderConfiguration();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ sdq = null;
+ config = null;
+ }
+
+ public void testCheckAndSet() {
+ assertEquals(true, sdq.checkAndSet("400x200", config));//$NON-NLS-1$
+ assertTrue(config.getScreenDimensionQualifier() != null);
+ assertEquals(400, config.getScreenDimensionQualifier().getValue1());
+ assertEquals(200, config.getScreenDimensionQualifier().getValue2());
+ assertEquals("400x200", config.getScreenDimensionQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testFailures() {
+ assertEquals(false, sdq.checkAndSet("", config));//$NON-NLS-1$
+ assertEquals(false, sdq.checkAndSet("400X200", config));//$NON-NLS-1$
+ assertEquals(false, sdq.checkAndSet("x200", config));//$NON-NLS-1$
+ assertEquals(false, sdq.checkAndSet("ax200", config));//$NON-NLS-1$
+ assertEquals(false, sdq.checkAndSet("400x", config));//$NON-NLS-1$
+ assertEquals(false, sdq.checkAndSet("400xa", config));//$NON-NLS-1$
+ assertEquals(false, sdq.checkAndSet("other", config));//$NON-NLS-1$
+ }
+}
diff --git a/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenOrientationQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenOrientationQualifierTest.java
new file mode 100644
index 0000000..3aac5f3
--- /dev/null
+++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenOrientationQualifierTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+package com.android.ide.common.resources.configuration;
+
+import com.android.resources.ScreenOrientation;
+
+import junit.framework.TestCase;
+
+public class ScreenOrientationQualifierTest extends TestCase {
+
+ private ScreenOrientationQualifier soq;
+ private FolderConfiguration config;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ soq = new ScreenOrientationQualifier();
+ config = new FolderConfiguration();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ soq = null;
+ config = null;
+ }
+
+ public void testPortrait() {
+ assertEquals(true, soq.checkAndSet("port", config)); //$NON-NLS-1$
+ assertTrue(config.getScreenOrientationQualifier() != null);
+ assertEquals(ScreenOrientation.PORTRAIT, config.getScreenOrientationQualifier().getValue());
+ assertEquals("port", config.getScreenOrientationQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testLanscape() {
+ assertEquals(true, soq.checkAndSet("land", config)); //$NON-NLS-1$
+ assertTrue(config.getScreenOrientationQualifier() != null);
+ assertEquals(ScreenOrientation.LANDSCAPE,
+ config.getScreenOrientationQualifier().getValue());
+ assertEquals("land", config.getScreenOrientationQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testSquare() {
+ assertEquals(true, soq.checkAndSet("square", config)); //$NON-NLS-1$
+ assertTrue(config.getScreenOrientationQualifier() != null);
+ assertEquals(ScreenOrientation.SQUARE,
+ config.getScreenOrientationQualifier().getValue());
+ assertEquals("square", config.getScreenOrientationQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testFailures() {
+ assertEquals(false, soq.checkAndSet("", config));//$NON-NLS-1$
+ assertEquals(false, soq.checkAndSet("PORT", config));//$NON-NLS-1$
+ assertEquals(false, soq.checkAndSet("landscape", config));//$NON-NLS-1$
+ assertEquals(false, soq.checkAndSet("portrait", config));//$NON-NLS-1$
+ assertEquals(false, soq.checkAndSet("other", config));//$NON-NLS-1$
+ }
+}
diff --git a/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenSizeQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenSizeQualifierTest.java
new file mode 100644
index 0000000..b19f125
--- /dev/null
+++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenSizeQualifierTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+package com.android.ide.common.resources.configuration;
+
+import com.android.resources.ScreenSize;
+
+import junit.framework.TestCase;
+
+public class ScreenSizeQualifierTest extends TestCase {
+
+ private ScreenSizeQualifier ssq;
+ private FolderConfiguration config;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ ssq = new ScreenSizeQualifier();
+ config = new FolderConfiguration();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ ssq = null;
+ config = null;
+ }
+
+ public void testSmall() {
+ assertEquals(true, ssq.checkAndSet("small", config)); //$NON-NLS-1$
+ assertTrue(config.getScreenSizeQualifier() != null);
+ assertEquals(ScreenSize.SMALL, config.getScreenSizeQualifier().getValue());
+ assertEquals("small", config.getScreenSizeQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testNormal() {
+ assertEquals(true, ssq.checkAndSet("normal", config)); //$NON-NLS-1$
+ assertTrue(config.getScreenSizeQualifier() != null);
+ assertEquals(ScreenSize.NORMAL, config.getScreenSizeQualifier().getValue());
+ assertEquals("normal", config.getScreenSizeQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testLarge() {
+ assertEquals(true, ssq.checkAndSet("large", config)); //$NON-NLS-1$
+ assertTrue(config.getScreenSizeQualifier() != null);
+ assertEquals(ScreenSize.LARGE, config.getScreenSizeQualifier().getValue());
+ assertEquals("large", config.getScreenSizeQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testXLarge() {
+ assertEquals(true, ssq.checkAndSet("xlarge", config)); //$NON-NLS-1$
+ assertTrue(config.getScreenSizeQualifier() != null);
+ assertEquals(ScreenSize.XLARGE, config.getScreenSizeQualifier().getValue());
+ assertEquals("xlarge", config.getScreenSizeQualifier().toString()); //$NON-NLS-1$
+ }
+}
diff --git a/ide_common/tests/src/com/android/ide/common/resources/configuration/TextInputMethodQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/TextInputMethodQualifierTest.java
new file mode 100644
index 0000000..bc2c890
--- /dev/null
+++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/TextInputMethodQualifierTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+package com.android.ide.common.resources.configuration;
+
+import com.android.resources.Keyboard;
+
+import junit.framework.TestCase;
+
+public class TextInputMethodQualifierTest extends TestCase {
+
+ private TextInputMethodQualifier timq;
+ private FolderConfiguration config;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ timq = new TextInputMethodQualifier();
+ config = new FolderConfiguration();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ timq = null;
+ config = null;
+ }
+
+ public void testQuerty() {
+ assertEquals(true, timq.checkAndSet("qwerty", config)); //$NON-NLS-1$
+ assertTrue(config.getTextInputMethodQualifier() != null);
+ assertEquals(Keyboard.QWERTY, config.getTextInputMethodQualifier().getValue());
+ assertEquals("qwerty", config.getTextInputMethodQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void test12Key() {
+ assertEquals(true, timq.checkAndSet("12key", config)); //$NON-NLS-1$
+ assertTrue(config.getTextInputMethodQualifier() != null);
+ assertEquals(Keyboard.TWELVEKEY, config.getTextInputMethodQualifier().getValue());
+ assertEquals("12key", config.getTextInputMethodQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testNoKey() {
+ assertEquals(true, timq.checkAndSet("nokeys", config)); //$NON-NLS-1$
+ assertTrue(config.getTextInputMethodQualifier() != null);
+ assertEquals(Keyboard.NOKEY, config.getTextInputMethodQualifier().getValue());
+ assertEquals("nokeys", config.getTextInputMethodQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testFailures() {
+ assertEquals(false, timq.checkAndSet("", config));//$NON-NLS-1$
+ assertEquals(false, timq.checkAndSet("QWERTY", config));//$NON-NLS-1$
+ assertEquals(false, timq.checkAndSet("12keys", config));//$NON-NLS-1$
+ assertEquals(false, timq.checkAndSet("*12key", config));//$NON-NLS-1$
+ assertEquals(false, timq.checkAndSet("other", config));//$NON-NLS-1$
+ }
+}
diff --git a/ide_common/tests/src/com/android/ide/common/resources/configuration/TouchScreenQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/TouchScreenQualifierTest.java
new file mode 100644
index 0000000..04f8a30
--- /dev/null
+++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/TouchScreenQualifierTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+package com.android.ide.common.resources.configuration;
+
+import com.android.resources.TouchScreen;
+
+import junit.framework.TestCase;
+
+public class TouchScreenQualifierTest extends TestCase {
+
+ private TouchScreenQualifier tsq;
+ private FolderConfiguration config;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ tsq = new TouchScreenQualifier();
+ config = new FolderConfiguration();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ tsq = null;
+ config = null;
+ }
+
+ public void testNoTouch() {
+ assertEquals(true, tsq.checkAndSet("notouch", config)); //$NON-NLS-1$
+ assertTrue(config.getTouchTypeQualifier() != null);
+ assertEquals(TouchScreen.NOTOUCH, config.getTouchTypeQualifier().getValue());
+ assertEquals("notouch", config.getTouchTypeQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testFinger() {
+ assertEquals(true, tsq.checkAndSet("finger", config)); //$NON-NLS-1$
+ assertTrue(config.getTouchTypeQualifier() != null);
+ assertEquals(TouchScreen.FINGER, config.getTouchTypeQualifier().getValue());
+ assertEquals("finger", config.getTouchTypeQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testStylus() {
+ assertEquals(true, tsq.checkAndSet("stylus", config)); //$NON-NLS-1$
+ assertTrue(config.getTouchTypeQualifier() != null);
+ assertEquals(TouchScreen.STYLUS, config.getTouchTypeQualifier().getValue());
+ assertEquals("stylus", config.getTouchTypeQualifier().toString()); //$NON-NLS-1$
+ }
+
+ public void testFailures() {
+ assertEquals(false, tsq.checkAndSet("", config));//$NON-NLS-1$
+ assertEquals(false, tsq.checkAndSet("STYLUS", config));//$NON-NLS-1$
+ assertEquals(false, tsq.checkAndSet("other", config));//$NON-NLS-1$
+ }
+}