aboutsummaryrefslogtreecommitdiffstats
path: root/sdk_common/tests/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'sdk_common/tests/src/com/android')
-rw-r--r--sdk_common/tests/src/com/android/ide/common/resources/ResourceRepositoryTest.java45
-rw-r--r--sdk_common/tests/src/com/android/ide/common/resources/ValueResourceParserTest.java148
-rw-r--r--sdk_common/tests/src/com/android/ide/common/resources/configuration/CountryCodeQualifierTest.java55
-rw-r--r--sdk_common/tests/src/com/android/ide/common/resources/configuration/DockModeQualifierTest.java83
-rw-r--r--sdk_common/tests/src/com/android/ide/common/resources/configuration/FolderConfigurationTest.java127
-rw-r--r--sdk_common/tests/src/com/android/ide/common/resources/configuration/KeyboardStateQualifierTest.java61
-rw-r--r--sdk_common/tests/src/com/android/ide/common/resources/configuration/LanguageQualifierTest.java53
-rw-r--r--sdk_common/tests/src/com/android/ide/common/resources/configuration/NavigationMethodQualifierTest.java68
-rw-r--r--sdk_common/tests/src/com/android/ide/common/resources/configuration/NetworkCodeQualifierTest.java55
-rw-r--r--sdk_common/tests/src/com/android/ide/common/resources/configuration/PixelDensityQualifierTest.java118
-rw-r--r--sdk_common/tests/src/com/android/ide/common/resources/configuration/RegionQualifierTest.java54
-rw-r--r--sdk_common/tests/src/com/android/ide/common/resources/configuration/ScreenDimensionQualifierTest.java57
-rw-r--r--sdk_common/tests/src/com/android/ide/common/resources/configuration/ScreenOrientationQualifierTest.java72
-rw-r--r--sdk_common/tests/src/com/android/ide/common/resources/configuration/ScreenSizeQualifierTest.java69
-rw-r--r--sdk_common/tests/src/com/android/ide/common/resources/configuration/TextInputMethodQualifierTest.java70
-rw-r--r--sdk_common/tests/src/com/android/ide/common/resources/configuration/TouchScreenQualifierTest.java68
-rw-r--r--sdk_common/tests/src/com/android/ide/common/xml/AndroidManifestParserTest.java175
-rw-r--r--sdk_common/tests/src/com/android/ide/common/xml/SupportsScreensTest.java148
18 files changed, 0 insertions, 1526 deletions
diff --git a/sdk_common/tests/src/com/android/ide/common/resources/ResourceRepositoryTest.java b/sdk_common/tests/src/com/android/ide/common/resources/ResourceRepositoryTest.java
deleted file mode 100644
index a8b8b1e..0000000
--- a/sdk_common/tests/src/com/android/ide/common/resources/ResourceRepositoryTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2012 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;
-
-import static com.android.resources.ResourceType.ATTR;
-import static com.android.resources.ResourceType.DIMEN;
-import static com.android.resources.ResourceType.LAYOUT;
-import junit.framework.TestCase;
-
-@SuppressWarnings("javadoc")
-public class ResourceRepositoryTest extends TestCase {
- public void testParseResource() {
- assertNull(ResourceRepository.parseResource(""));
- assertNull(ResourceRepository.parseResource("not_a_resource"));
-
- assertEquals(LAYOUT, ResourceRepository.parseResource("@layout/foo").getFirst());
- assertEquals(DIMEN, ResourceRepository.parseResource("@dimen/foo").getFirst());
- assertEquals(DIMEN, ResourceRepository.parseResource("@android:dimen/foo").getFirst());
- assertEquals("foo", ResourceRepository.parseResource("@layout/foo").getSecond());
- assertEquals("foo", ResourceRepository.parseResource("@dimen/foo").getSecond());
- assertEquals("foo", ResourceRepository.parseResource("@android:dimen/foo").getSecond());
-
- assertEquals(ATTR, ResourceRepository.parseResource("?attr/foo").getFirst());
- assertEquals("foo", ResourceRepository.parseResource("?attr/foo").getSecond());
-
- assertEquals(ATTR, ResourceRepository.parseResource("?foo").getFirst());
- assertEquals("foo", ResourceRepository.parseResource("?foo").getSecond());
-
- assertEquals(ATTR, ResourceRepository.parseResource("?android:foo").getFirst());
- assertEquals("foo", ResourceRepository.parseResource("?android:foo").getSecond());
- }
-}
diff --git a/sdk_common/tests/src/com/android/ide/common/resources/ValueResourceParserTest.java b/sdk_common/tests/src/com/android/ide/common/resources/ValueResourceParserTest.java
deleted file mode 100644
index aed6060..0000000
--- a/sdk_common/tests/src/com/android/ide/common/resources/ValueResourceParserTest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2013 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;
-
-import static com.android.ide.common.resources.ValueResourceParser.escapeResourceString;
-import static com.android.ide.common.resources.ValueResourceParser.isEscaped;
-import static com.android.ide.common.resources.ValueResourceParser.unescapeResourceString;
-
-import junit.framework.TestCase;
-
-public class ValueResourceParserTest extends TestCase {
-
- public void testEscapeStringShouldEscapeXmlSpecialCharacters() throws Exception {
- assertEquals("&lt;", escapeResourceString("<"));
- assertEquals("&amp;", escapeResourceString("&"));
- }
-
- public void testEscapeStringShouldEscapeQuotes() throws Exception {
- assertEquals("\\'", escapeResourceString("'"));
- assertEquals("\\\"", escapeResourceString("\""));
- assertEquals("\" ' \"", escapeResourceString(" ' "));
- }
-
- public void testEscapeStringShouldPreserveWhitespace() throws Exception {
- assertEquals("\"at end \"", escapeResourceString("at end "));
- assertEquals("\" at begin\"", escapeResourceString(" at begin"));
- }
-
- public void testEscapeStringShouldEscapeAtSignAndQuestionMarkOnlyAtBeginning()
- throws Exception {
- assertEquals("\\@text", escapeResourceString("@text"));
- assertEquals("a@text", escapeResourceString("a@text"));
- assertEquals("\\?text", escapeResourceString("?text"));
- assertEquals("a?text", escapeResourceString("a?text"));
- assertEquals("\" ?text\"", escapeResourceString(" ?text"));
- }
-
- public void testEscapeStringShouldEscapeJavaEscapeSequences() throws Exception {
- assertEquals("\\n", escapeResourceString("\n"));
- assertEquals("\\t", escapeResourceString("\t"));
- assertEquals("\\\\", escapeResourceString("\\"));
- }
-
- public void testTrim() throws Exception {
- assertEquals("", unescapeResourceString("", false, true));
- assertEquals("", unescapeResourceString(" \n ", false, true));
- assertEquals("test", unescapeResourceString(" test ", false, true));
- assertEquals(" test ", unescapeResourceString("\" test \"", false, true));
- assertEquals("test", unescapeResourceString("\n\t test \t\n ", false, true));
-
- assertEquals("test\n", unescapeResourceString(" test\\n ", false, true));
- assertEquals(" test\n ", unescapeResourceString("\" test\\n \"", false, true));
- assertEquals("te\\st", unescapeResourceString("\n\t te\\\\st \t\n ", false, true));
- assertEquals("te\\st", unescapeResourceString(" te\\\\st ", false, true));
- assertEquals("test", unescapeResourceString("\"\"\"test\"\" ", false, true));
- assertEquals("\"test\"", unescapeResourceString("\"\"\\\"test\\\"\" ", false, true));
- assertEquals("test ", unescapeResourceString("test\\ ", false, true));
- assertEquals("\\\\\\", unescapeResourceString("\\\\\\\\\\\\ ", false, true));
- assertEquals("\\\\\\ ", unescapeResourceString("\\\\\\\\\\\\\\ ", false, true));
- }
-
- public void testNoTrim() throws Exception {
- assertEquals("", unescapeResourceString("", false, false));
- assertEquals(" \n ", unescapeResourceString(" \n ", false, false));
- assertEquals(" test ", unescapeResourceString(" test ", false, false));
- assertEquals("\" test \"", unescapeResourceString("\" test \"", false, false));
- assertEquals("\n\t test \t\n ", unescapeResourceString("\n\t test \t\n ", false, false));
-
- assertEquals(" test\n ", unescapeResourceString(" test\\n ", false, false));
- assertEquals("\" test\n \"", unescapeResourceString("\" test\\n \"", false, false));
- assertEquals("\n\t te\\st \t\n ", unescapeResourceString("\n\t te\\\\st \t\n ", false, false));
- assertEquals(" te\\st ", unescapeResourceString(" te\\\\st ", false, false));
- assertEquals("\"\"\"test\"\" ", unescapeResourceString("\"\"\"test\"\" ", false, false));
- assertEquals("\"\"\"test\"\" ", unescapeResourceString("\"\"\\\"test\\\"\" ", false, false));
- assertEquals("test ", unescapeResourceString("test\\ ", false, false));
- assertEquals("\\\\\\ ", unescapeResourceString("\\\\\\\\\\\\ ", false, false));
- assertEquals("\\\\\\ ", unescapeResourceString("\\\\\\\\\\\\\\ ", false, false));
- }
-
- public void testUnescapeStringShouldUnescapeXmlSpecialCharacters() throws Exception {
- assertEquals("&lt;", unescapeResourceString("&lt;", false, true));
- assertEquals("<", unescapeResourceString("&lt;", true, true));
- assertEquals("<", unescapeResourceString(" &lt; ", true, true));
- assertEquals("&amp;", unescapeResourceString("&amp;", false, true));
- assertEquals("&", unescapeResourceString("&amp;", true, true));
- assertEquals("&", unescapeResourceString(" &amp; ", true, true));
- assertEquals("!<", unescapeResourceString("!&lt;", true, true));
- }
-
- public void testUnescapeStringShouldUnescapeQuotes() throws Exception {
- assertEquals("'", unescapeResourceString("\\'", false, true));
- assertEquals("\"", unescapeResourceString("\\\"", false, true));
- assertEquals(" ' ", unescapeResourceString("\" ' \"", false, true));
- }
-
- public void testUnescapeStringShouldPreserveWhitespace() throws Exception {
- assertEquals("at end ", unescapeResourceString("\"at end \"", false, true));
- assertEquals(" at begin", unescapeResourceString("\" at begin\"", false, true));
- }
-
- public void testUnescapeStringShouldUnescapeAtSignAndQuestionMarkOnlyAtBeginning()
- throws Exception {
- assertEquals("@text", unescapeResourceString("\\@text", false, true));
- assertEquals("a@text", unescapeResourceString("a@text", false, true));
- assertEquals("?text", unescapeResourceString("\\?text", false, true));
- assertEquals("a?text", unescapeResourceString("a?text", false, true));
- assertEquals(" ?text", unescapeResourceString("\" ?text\"", false, true));
- }
-
- public void testUnescapeStringShouldUnescapeJavaUnescapeSequences() throws Exception {
- assertEquals("\n", unescapeResourceString("\\n", false, true));
- assertEquals("\t", unescapeResourceString("\\t", false, true));
- assertEquals("\\", unescapeResourceString("\\\\", false, true));
- }
-
- public void testIsEscaped() throws Exception {
- assertFalse(isEscaped("", 0));
- assertFalse(isEscaped(" ", 0));
- assertFalse(isEscaped(" ", 1));
- assertFalse(isEscaped("x\\y ", 0));
- assertFalse(isEscaped("x\\y ", 1));
- assertTrue(isEscaped("x\\y ", 2));
- assertFalse(isEscaped("x\\y ", 3));
- assertFalse(isEscaped("x\\\\y ", 0));
- assertFalse(isEscaped("x\\\\y ", 1));
- assertTrue(isEscaped("x\\\\y ", 2));
- assertFalse(isEscaped("x\\\\y ", 3));
- assertFalse(isEscaped("\\\\\\\\y ", 0));
- assertTrue(isEscaped( "\\\\\\\\y ", 1));
- assertFalse(isEscaped("\\\\\\\\y ", 2));
- assertTrue(isEscaped( "\\\\\\\\y ", 3));
- assertFalse(isEscaped("\\\\\\\\y ", 4));
- }
-}
diff --git a/sdk_common/tests/src/com/android/ide/common/resources/configuration/CountryCodeQualifierTest.java b/sdk_common/tests/src/com/android/ide/common/resources/configuration/CountryCodeQualifierTest.java
deleted file mode 100644
index eba8b8d..0000000
--- a/sdk_common/tests/src/com/android/ide/common/resources/configuration/CountryCodeQualifierTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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/sdk_common/tests/src/com/android/ide/common/resources/configuration/DockModeQualifierTest.java b/sdk_common/tests/src/com/android/ide/common/resources/configuration/DockModeQualifierTest.java
deleted file mode 100644
index 1653805..0000000
--- a/sdk_common/tests/src/com/android/ide/common/resources/configuration/DockModeQualifierTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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.UiMode;
-
-import junit.framework.TestCase;
-
-public class DockModeQualifierTest extends TestCase {
-
- private UiModeQualifier mCarQualifier;
- private UiModeQualifier mDeskQualifier;
- private UiModeQualifier mTVQualifier;
- private UiModeQualifier mNoneQualifier;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mCarQualifier = new UiModeQualifier(UiMode.CAR);
- mDeskQualifier = new UiModeQualifier(UiMode.DESK);
- mTVQualifier = new UiModeQualifier(UiMode.TELEVISION);
- mNoneQualifier = new UiModeQualifier(UiMode.NORMAL);
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- mCarQualifier = null;
- mDeskQualifier = null;
- mTVQualifier = null;
- mNoneQualifier = null;
- }
-
- public void testIsBetterMatchThan() {
- assertTrue(mNoneQualifier.isBetterMatchThan(mCarQualifier, mDeskQualifier));
- 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));
-
- assertTrue(mTVQualifier.isBetterMatchThan(mCarQualifier, mTVQualifier));
- assertFalse(mTVQualifier.isBetterMatchThan(mDeskQualifier, mDeskQualifier));
-
- }
-
- public void testIsMatchFor() {
- assertTrue(mNoneQualifier.isMatchFor(mCarQualifier));
- assertTrue(mNoneQualifier.isMatchFor(mDeskQualifier));
- assertTrue(mNoneQualifier.isMatchFor(mTVQualifier));
- assertTrue(mCarQualifier.isMatchFor(mCarQualifier));
- assertTrue(mDeskQualifier.isMatchFor(mDeskQualifier));
- assertTrue(mTVQualifier.isMatchFor(mTVQualifier));
-
- assertFalse(mCarQualifier.isMatchFor(mNoneQualifier));
- assertFalse(mCarQualifier.isMatchFor(mDeskQualifier));
-
- assertFalse(mDeskQualifier.isMatchFor(mCarQualifier));
- assertFalse(mDeskQualifier.isMatchFor(mNoneQualifier));
-
- assertFalse(mTVQualifier.isMatchFor(mCarQualifier));
- assertFalse(mTVQualifier.isMatchFor(mNoneQualifier));
- }
-}
diff --git a/sdk_common/tests/src/com/android/ide/common/resources/configuration/FolderConfigurationTest.java b/sdk_common/tests/src/com/android/ide/common/resources/configuration/FolderConfigurationTest.java
deleted file mode 100644
index 5f29791..0000000
--- a/sdk_common/tests/src/com/android/ide/common/resources/configuration/FolderConfigurationTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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 java.util.ArrayList;
-import java.util.List;
-
-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));
- }
- }
-
- public void testSimpleResMatch() {
- runConfigMatchTest(
- "en-rGB-port-hdpi-notouch-12key",
- 3,
- "",
- "en",
- "fr-rCA",
- "en-port",
- "en-notouch-12key",
- "port-ldpi",
- "port-notouch-12key");
- }
-
- public void testVersionResMatch() {
- runConfigMatchTest(
- "en-rUS-w600dp-h1024dp-large-port-mdpi-finger-nokeys-v12",
- 2,
- "",
- "large",
- "w540dp");
- }
-
- public void testAddQualifier() {
- FolderConfiguration defaultConfig = new FolderConfiguration();
- defaultConfig.createDefault();
-
- final int count = FolderConfiguration.getQualifierCount();
- for (int i = 0 ; i < count ; i++) {
- FolderConfiguration empty = new FolderConfiguration();
-
- ResourceQualifier q = defaultConfig.getQualifier(i);
-
- empty.addQualifier(q);
-
- // check it was added
- assertNotNull(
- "addQualifier failed for " + q.getClass().getName(), empty.getQualifier(i));
- }
- }
-
-
- // --- helper methods
-
- private final static class MockConfigurable implements Configurable {
-
- private final FolderConfiguration mConfig;
-
- MockConfigurable(String config) {
- mConfig = FolderConfiguration.getConfig(getFolderSegments(config));
- }
-
- @Override
- public FolderConfiguration getConfiguration() {
- return mConfig;
- }
-
- @Override
- public String toString() {
- return mConfig.toString();
- }
- }
-
- private void runConfigMatchTest(String refConfig, int resultIndex, String... configs) {
- FolderConfiguration reference = FolderConfiguration.getConfig(getFolderSegments(refConfig));
- assertNotNull(reference);
-
- List<? extends Configurable> list = getConfigurable(configs);
-
- Configurable match = reference.findMatchingConfigurable(list);
- assertEquals(resultIndex, list.indexOf(match));
- }
-
- private List<? extends Configurable> getConfigurable(String... configs) {
- ArrayList<MockConfigurable> list = new ArrayList<MockConfigurable>();
-
- for (String config : configs) {
- list.add(new MockConfigurable(config));
- }
-
- return list;
- }
-
- private static String[] getFolderSegments(String config) {
- return (config.length() > 0 ? "foo-" + config : "foo").split("-");
- }
-}
diff --git a/sdk_common/tests/src/com/android/ide/common/resources/configuration/KeyboardStateQualifierTest.java b/sdk_common/tests/src/com/android/ide/common/resources/configuration/KeyboardStateQualifierTest.java
deleted file mode 100644
index cf52a38..0000000
--- a/sdk_common/tests/src/com/android/ide/common/resources/configuration/KeyboardStateQualifierTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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/sdk_common/tests/src/com/android/ide/common/resources/configuration/LanguageQualifierTest.java b/sdk_common/tests/src/com/android/ide/common/resources/configuration/LanguageQualifierTest.java
deleted file mode 100644
index 2dfd65f..0000000
--- a/sdk_common/tests/src/com/android/ide/common/resources/configuration/LanguageQualifierTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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/sdk_common/tests/src/com/android/ide/common/resources/configuration/NavigationMethodQualifierTest.java b/sdk_common/tests/src/com/android/ide/common/resources/configuration/NavigationMethodQualifierTest.java
deleted file mode 100644
index 4237dde..0000000
--- a/sdk_common/tests/src/com/android/ide/common/resources/configuration/NavigationMethodQualifierTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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/sdk_common/tests/src/com/android/ide/common/resources/configuration/NetworkCodeQualifierTest.java b/sdk_common/tests/src/com/android/ide/common/resources/configuration/NetworkCodeQualifierTest.java
deleted file mode 100644
index 6896316..0000000
--- a/sdk_common/tests/src/com/android/ide/common/resources/configuration/NetworkCodeQualifierTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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/sdk_common/tests/src/com/android/ide/common/resources/configuration/PixelDensityQualifierTest.java b/sdk_common/tests/src/com/android/ide/common/resources/configuration/PixelDensityQualifierTest.java
deleted file mode 100644
index 4ab493a..0000000
--- a/sdk_common/tests/src/com/android/ide/common/resources/configuration/PixelDensityQualifierTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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 DensityQualifier pdq;
- private FolderConfiguration config;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- pdq = new DensityQualifier();
- 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.getDensityQualifier() != null);
- assertEquals(Density.LOW, config.getDensityQualifier().getValue());
- assertEquals("ldpi", config.getDensityQualifier().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() {
- DensityQualifier ldpi = new DensityQualifier(Density.LOW);
- DensityQualifier mdpi = new DensityQualifier(Density.MEDIUM);
- DensityQualifier hdpi = new DensityQualifier(Density.HIGH);
- DensityQualifier xhdpi = new DensityQualifier(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/sdk_common/tests/src/com/android/ide/common/resources/configuration/RegionQualifierTest.java b/sdk_common/tests/src/com/android/ide/common/resources/configuration/RegionQualifierTest.java
deleted file mode 100644
index fc0402c..0000000
--- a/sdk_common/tests/src/com/android/ide/common/resources/configuration/RegionQualifierTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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/sdk_common/tests/src/com/android/ide/common/resources/configuration/ScreenDimensionQualifierTest.java b/sdk_common/tests/src/com/android/ide/common/resources/configuration/ScreenDimensionQualifierTest.java
deleted file mode 100644
index e57424f..0000000
--- a/sdk_common/tests/src/com/android/ide/common/resources/configuration/ScreenDimensionQualifierTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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/sdk_common/tests/src/com/android/ide/common/resources/configuration/ScreenOrientationQualifierTest.java b/sdk_common/tests/src/com/android/ide/common/resources/configuration/ScreenOrientationQualifierTest.java
deleted file mode 100644
index 3aac5f3..0000000
--- a/sdk_common/tests/src/com/android/ide/common/resources/configuration/ScreenOrientationQualifierTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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/sdk_common/tests/src/com/android/ide/common/resources/configuration/ScreenSizeQualifierTest.java b/sdk_common/tests/src/com/android/ide/common/resources/configuration/ScreenSizeQualifierTest.java
deleted file mode 100644
index b19f125..0000000
--- a/sdk_common/tests/src/com/android/ide/common/resources/configuration/ScreenSizeQualifierTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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/sdk_common/tests/src/com/android/ide/common/resources/configuration/TextInputMethodQualifierTest.java b/sdk_common/tests/src/com/android/ide/common/resources/configuration/TextInputMethodQualifierTest.java
deleted file mode 100644
index bc2c890..0000000
--- a/sdk_common/tests/src/com/android/ide/common/resources/configuration/TextInputMethodQualifierTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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/sdk_common/tests/src/com/android/ide/common/resources/configuration/TouchScreenQualifierTest.java b/sdk_common/tests/src/com/android/ide/common/resources/configuration/TouchScreenQualifierTest.java
deleted file mode 100644
index 04f8a30..0000000
--- a/sdk_common/tests/src/com/android/ide/common/resources/configuration/TouchScreenQualifierTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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$
- }
-}
diff --git a/sdk_common/tests/src/com/android/ide/common/xml/AndroidManifestParserTest.java b/sdk_common/tests/src/com/android/ide/common/xml/AndroidManifestParserTest.java
deleted file mode 100644
index fee6014..0000000
--- a/sdk_common/tests/src/com/android/ide/common/xml/AndroidManifestParserTest.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * 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.xml;
-
-import com.android.ide.common.xml.ManifestData.UsesFeature;
-import com.android.ide.common.xml.ManifestData.UsesLibrary;
-import com.android.resources.Keyboard;
-import com.android.resources.Navigation;
-import com.android.resources.TouchScreen;
-
-import junit.framework.TestCase;
-
-import java.io.InputStream;
-
-/**
- * Tests for {@link AndroidManifestParser}
- */
-public class AndroidManifestParserTest extends TestCase {
- private ManifestData mManifestTestApp;
- private ManifestData mManifestInstrumentation;
-
- private static final String TESTDATA_PATH =
- "/com/android/sdklib/testdata/"; //$NON-NLS-1$
- private static final String INSTRUMENTATION_XML = TESTDATA_PATH +
- "AndroidManifest-instrumentation.xml"; //$NON-NLS-1$
- private static final String TESTAPP_XML = TESTDATA_PATH +
- "AndroidManifest-testapp.xml"; //$NON-NLS-1$
- private static final String ACTIVITY_ALIAS_XML = TESTDATA_PATH +
- "AndroidManifest-activityalias.xml"; //$NON-NLS-1$
- private static final String PACKAGE_NAME = "com.android.testapp"; //$NON-NLS-1$
- private static final Integer VERSION_CODE = 42;
- private static final String ACTIVITY_NAME = "com.android.testapp.MainActivity"; //$NON-NLS-1$
- private static final String LIBRARY_NAME = "android.test.runner"; //$NON-NLS-1$
- private static final String LIBRARY_NAME2 = "android.test.runner2"; //$NON-NLS-1$
- private static final String FEATURE_NAME = "com.foo.feature"; //$NON-NLS-1$
- private static final String INSTRUMENTATION_NAME = "android.test.InstrumentationTestRunner"; //$NON-NLS-1$
- private static final String INSTRUMENTATION_TARGET = "com.android.AndroidProject"; //$NON-NLS-1$
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- InputStream manifestStream = this.getClass().getResourceAsStream(TESTAPP_XML);
-
- mManifestTestApp = AndroidManifestParser.parse(manifestStream);
- assertNotNull(mManifestTestApp);
-
- manifestStream = this.getClass().getResourceAsStream(INSTRUMENTATION_XML);
- mManifestInstrumentation = AndroidManifestParser.parse(manifestStream);
- assertNotNull(mManifestInstrumentation);
- }
-
- public void testGetInstrumentationInformation() {
- assertEquals(1, mManifestInstrumentation.getInstrumentations().length);
- assertEquals(INSTRUMENTATION_NAME,
- mManifestInstrumentation.getInstrumentations()[0].getName());
- assertEquals(INSTRUMENTATION_TARGET,
- mManifestInstrumentation.getInstrumentations()[0].getTargetPackage());
- }
-
- public void testGetPackage() {
- assertEquals(PACKAGE_NAME, mManifestTestApp.getPackage());
- }
-
- public void testGetVersionCode() {
- assertEquals(VERSION_CODE, mManifestTestApp.getVersionCode());
- assertEquals(null, mManifestInstrumentation.getVersionCode());
- }
-
- public void testMinSdkVersion() {
- assertEquals(7, mManifestTestApp.getMinSdkVersion());
- assertEquals(8, mManifestTestApp.getTargetSdkVersion());
-
- assertEquals("foo", mManifestInstrumentation.getMinSdkVersionString());
- assertEquals(ManifestData.MIN_SDK_CODENAME, mManifestInstrumentation.getMinSdkVersion());
- }
-
- public void testGetActivities() {
- assertEquals(1, mManifestTestApp.getActivities().length);
- ManifestData.Activity activity = mManifestTestApp.getActivities()[0];
- assertEquals(ACTIVITY_NAME, activity.getName());
- assertTrue(activity.hasAction());
- assertTrue(activity.isHomeActivity());
- assertTrue(activity.hasAction());
- assertEquals(activity, mManifestTestApp.getActivities()[0]);
- }
-
- public void testGetLauncherActivity() {
- ManifestData.Activity activity = mManifestTestApp.getLauncherActivity();
- assertEquals(ACTIVITY_NAME, activity.getName());
- assertTrue(activity.hasAction());
- assertTrue(activity.isHomeActivity());
- }
-
- public void testSupportsScreen() {
- ManifestData.SupportsScreens supportsScreens =
- mManifestTestApp.getSupportsScreensFromManifest();
-
- assertNotNull(supportsScreens);
- assertEquals(Boolean.TRUE, supportsScreens.getAnyDensity());
- assertEquals(Boolean.TRUE, supportsScreens.getResizeable());
- assertEquals(Boolean.TRUE, supportsScreens.getSmallScreens());
- assertEquals(Boolean.TRUE, supportsScreens.getNormalScreens());
- assertEquals(Boolean.TRUE, supportsScreens.getLargeScreens());
- }
-
- public void testUsesConfiguration() {
- ManifestData.UsesConfiguration usesConfig = mManifestTestApp.getUsesConfiguration();
-
- assertNotNull(usesConfig);
- assertEquals(Boolean.TRUE, usesConfig.getReqFiveWayNav());
- assertEquals(Navigation.NONAV, usesConfig.getReqNavigation());
- assertEquals(Boolean.TRUE, usesConfig.getReqHardKeyboard());
- assertEquals(Keyboard.TWELVEKEY, usesConfig.getReqKeyboardType());
- assertEquals(TouchScreen.FINGER, usesConfig.getReqTouchScreen());
- }
-
- private void assertEquals(ManifestData.Activity lhs, ManifestData.Activity rhs) {
- assertTrue(lhs == rhs || (lhs != null && rhs != null));
- if (lhs != null && rhs != null) {
- assertEquals(lhs.getName(), rhs.getName());
- assertEquals(lhs.isExported(), rhs.isExported());
- assertEquals(lhs.hasAction(), rhs.hasAction());
- assertEquals(lhs.isHomeActivity(), rhs.isHomeActivity());
- }
- }
-
- public void testGetUsesLibraries() {
- UsesLibrary[] libraries = mManifestTestApp.getUsesLibraries();
-
- assertEquals(2, libraries.length);
- assertEquals(LIBRARY_NAME, libraries[0].getName());
- assertEquals(Boolean.FALSE, libraries[0].getRequired());
- assertEquals(LIBRARY_NAME2, libraries[1].getName());
- assertEquals(Boolean.TRUE, libraries[1].getRequired());
- }
-
- public void testGetUsesFeatures() {
- UsesFeature[] features = mManifestTestApp.getUsesFeatures();
-
- assertEquals(2, features.length);
- assertEquals(0x00020001, features[0].mGlEsVersion);
- assertEquals(Boolean.TRUE, features[0].getRequired());
- assertEquals(FEATURE_NAME, features[1].getName());
- assertEquals(Boolean.TRUE, features[1].getRequired());
- }
-
- public void testGetPackageName() {
- assertEquals(PACKAGE_NAME, mManifestTestApp.getPackage());
- }
-
- public void testActivityAlias() throws Exception {
- InputStream manifestStream = this.getClass().getResourceAsStream(ACTIVITY_ALIAS_XML);
-
- ManifestData manifest = AndroidManifestParser.parse(manifestStream);
- assertNotNull(manifest);
-
- assertEquals(manifest.getLauncherActivity().getName(),
- "com.android.testapp.AliasActivity"); //$NON-NLS-1$
- }
-}
diff --git a/sdk_common/tests/src/com/android/ide/common/xml/SupportsScreensTest.java b/sdk_common/tests/src/com/android/ide/common/xml/SupportsScreensTest.java
deleted file mode 100644
index aa88fc7..0000000
--- a/sdk_common/tests/src/com/android/ide/common/xml/SupportsScreensTest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * 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.xml;
-
-import com.android.ide.common.xml.AndroidManifestParser;
-import com.android.ide.common.xml.ManifestData;
-import com.android.ide.common.xml.ManifestData.SupportsScreens;
-
-import java.io.InputStream;
-
-import junit.framework.TestCase;
-
-public class SupportsScreensTest extends TestCase {
-
- private static final String TESTDATA_PATH =
- "/com/android/sdklib/testdata/"; //$NON-NLS-1$
- private static final String TESTAPP2_XML = TESTDATA_PATH +
- "AndroidManifest-testapp2.xml"; //$NON-NLS-1$
-
- public void testDefaultValuesApi3() {
- SupportsScreens supportsScreens = SupportsScreens.getDefaultValues(3);
-
- assertNotNull(supportsScreens);
- assertEquals(Boolean.FALSE, supportsScreens.getAnyDensity());
- assertEquals(Boolean.FALSE, supportsScreens.getResizeable());
- assertEquals(Boolean.FALSE, supportsScreens.getSmallScreens());
- assertEquals(Boolean.TRUE, supportsScreens.getNormalScreens());
- assertEquals(Boolean.FALSE, supportsScreens.getLargeScreens());
- }
-
- public void testDefaultValuesApi4() {
- SupportsScreens supportsScreens = SupportsScreens.getDefaultValues(4);
-
- assertNotNull(supportsScreens);
- assertEquals(Boolean.TRUE, supportsScreens.getAnyDensity());
- assertEquals(Boolean.TRUE, supportsScreens.getResizeable());
- assertEquals(Boolean.TRUE, supportsScreens.getSmallScreens());
- assertEquals(Boolean.TRUE, supportsScreens.getNormalScreens());
- assertEquals(Boolean.TRUE, supportsScreens.getLargeScreens());
- }
-
- public void testManifestParsing() throws Exception {
- InputStream manifestStream = this.getClass().getResourceAsStream(TESTAPP2_XML);
-
- ManifestData data = AndroidManifestParser.parse(manifestStream);
- assertNotNull(data);
-
- SupportsScreens supportsScreens = data.getSupportsScreensFromManifest();
- assertNotNull(supportsScreens);
- assertEquals(null, supportsScreens.getAnyDensity());
- assertEquals(null, supportsScreens.getResizeable());
- assertEquals(null, supportsScreens.getSmallScreens());
- assertEquals(null, supportsScreens.getNormalScreens());
- assertEquals(Boolean.FALSE, supportsScreens.getLargeScreens());
-
- supportsScreens = data.getSupportsScreensValues();
- assertNotNull(supportsScreens);
- assertEquals(Boolean.TRUE, supportsScreens.getAnyDensity());
- assertEquals(Boolean.TRUE, supportsScreens.getResizeable());
- assertEquals(Boolean.TRUE, supportsScreens.getSmallScreens());
- assertEquals(Boolean.TRUE, supportsScreens.getNormalScreens());
- assertEquals(Boolean.FALSE, supportsScreens.getLargeScreens());
- }
-
- public void testOverlapWith() {
- SupportsScreens supportsN = new SupportsScreens("false|false|false|true|false");
- SupportsScreens supportsSL = new SupportsScreens("false|false|true|false|true");
-
- assertTrue(supportsN.overlapWith(supportsSL));
- assertTrue(supportsSL.overlapWith(supportsN));
- }
-
- public void testCompareScreenSizesWith() {
- // set instance that support all combo of the three sizes.
- SupportsScreens supportsS = new SupportsScreens("false|false|true|false|false");
- SupportsScreens supportsN = new SupportsScreens("false|false|false|true|false");
- SupportsScreens supportsL = new SupportsScreens("false|false|false|false|true");
- SupportsScreens supportsSL = new SupportsScreens("false|false|true|false|true");
-
- assertEquals(-1, supportsS.compareScreenSizesWith(supportsN));
- assertEquals( 1, supportsN.compareScreenSizesWith(supportsS));
- assertEquals(-1, supportsN.compareScreenSizesWith(supportsL));
- assertEquals(-1, supportsS.compareScreenSizesWith(supportsL));
-
- // test thrown exception for overlapWith == true
- try {
- supportsSL.compareScreenSizesWith(supportsN);
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // success!
- }
-
- // test thrown exception for hasStrictlyDifferentScreenSupportAs == false
- try {
- supportsSL.compareScreenSizesWith(supportsS);
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- // success!
- }
-
- }
-
- public void testHasStrictlyDifferentScreenSupportAs() {
- SupportsScreens supportsS = new SupportsScreens("false|false|true|false|false");
- SupportsScreens supportsN = new SupportsScreens("false|false|false|true|false");
- SupportsScreens supportsL = new SupportsScreens("false|false|false|false|true");
-
- SupportsScreens supportsSN = new SupportsScreens("false|false|true|true|false");
- SupportsScreens supportsNL = new SupportsScreens("false|false|false|true|true");
- SupportsScreens supportsSL = new SupportsScreens("false|false|true|false|true");
- SupportsScreens supportsSNL = new SupportsScreens("false|false|true|true|true");
-
- assertTrue(supportsS.hasStrictlyDifferentScreenSupportAs(supportsN));
- assertTrue(supportsS.hasStrictlyDifferentScreenSupportAs(supportsL));
- assertTrue(supportsN.hasStrictlyDifferentScreenSupportAs(supportsS));
- assertTrue(supportsN.hasStrictlyDifferentScreenSupportAs(supportsL));
- assertTrue(supportsL.hasStrictlyDifferentScreenSupportAs(supportsS));
- assertTrue(supportsL.hasStrictlyDifferentScreenSupportAs(supportsN));
-
-
- assertFalse(supportsSN.hasStrictlyDifferentScreenSupportAs(supportsS));
- assertFalse(supportsSN.hasStrictlyDifferentScreenSupportAs(supportsN));
- assertTrue(supportsSN.hasStrictlyDifferentScreenSupportAs(supportsL));
- assertFalse(supportsSL.hasStrictlyDifferentScreenSupportAs(supportsS));
- assertTrue(supportsSL.hasStrictlyDifferentScreenSupportAs(supportsN));
- assertFalse(supportsSL.hasStrictlyDifferentScreenSupportAs(supportsL));
- assertTrue(supportsNL.hasStrictlyDifferentScreenSupportAs(supportsS));
- assertFalse(supportsNL.hasStrictlyDifferentScreenSupportAs(supportsN));
- assertFalse(supportsNL.hasStrictlyDifferentScreenSupportAs(supportsL));
- assertFalse(supportsSNL.hasStrictlyDifferentScreenSupportAs(supportsS));
- assertFalse(supportsSNL.hasStrictlyDifferentScreenSupportAs(supportsN));
- assertFalse(supportsSNL.hasStrictlyDifferentScreenSupportAs(supportsL));
- }
-}