diff options
author | Xavier Ducrohet <xav@android.com> | 2011-03-18 12:13:51 -0700 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2011-03-18 12:13:51 -0700 |
commit | 65e36c24654b47f4fc314566d2883582fc2708ba (patch) | |
tree | 61e7009df6755afc17e16531619a4df3398e9331 | |
parent | 026ba97e98e0527d910e15c4e1512893a777a8d2 (diff) | |
download | sdk-65e36c24654b47f4fc314566d2883582fc2708ba.zip sdk-65e36c24654b47f4fc314566d2883582fc2708ba.tar.gz sdk-65e36c24654b47f4fc314566d2883582fc2708ba.tar.bz2 |
Fix unit tests from the previous refactor.
Change-Id: I464fe3f94e701e619b474f82aaf84ee04d158e71
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/ResourceHelper.java | 74 | ||||
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/manager/ConfigMatchTest.java | 54 | ||||
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/manager/QualifierListTest.java | 76 | ||||
-rw-r--r-- | ide_common/tests/.classpath | 9 | ||||
-rw-r--r-- | ide_common/tests/.project | 17 | ||||
-rw-r--r-- | ide_common/tests/Android.mk | 27 | ||||
-rw-r--r-- | ide_common/tests/src/com/android/ide/common/resources/configuration/CountryCodeQualifierTest.java (renamed from eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/CountryCodeQualifierTest.java) | 9 | ||||
-rw-r--r-- | ide_common/tests/src/com/android/ide/common/resources/configuration/DockModeQualifierTest.java (renamed from eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/DockModeQualifierTest.java) | 7 | ||||
-rw-r--r-- | ide_common/tests/src/com/android/ide/common/resources/configuration/FolderConfigurationTest.java | 38 | ||||
-rw-r--r-- | ide_common/tests/src/com/android/ide/common/resources/configuration/KeyboardStateQualifierTest.java (renamed from eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/KeyboardStateQualifierTest.java) | 8 | ||||
-rw-r--r-- | ide_common/tests/src/com/android/ide/common/resources/configuration/LanguageQualifierTest.java (renamed from eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/LanguageQualifierTest.java) | 17 | ||||
-rw-r--r-- | ide_common/tests/src/com/android/ide/common/resources/configuration/NavigationMethodQualifierTest.java (renamed from eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/NavigationMethodQualifierTest.java) | 8 | ||||
-rw-r--r-- | ide_common/tests/src/com/android/ide/common/resources/configuration/NetworkCodeQualifierTest.java (renamed from eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/NetworkCodeQualifierTest.java) | 9 | ||||
-rw-r--r-- | ide_common/tests/src/com/android/ide/common/resources/configuration/PixelDensityQualifierTest.java (renamed from eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/PixelDensityQualifierTest.java) | 8 | ||||
-rw-r--r-- | ide_common/tests/src/com/android/ide/common/resources/configuration/RegionQualifierTest.java (renamed from eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/RegionQualifierTest.java) | 9 | ||||
-rw-r--r-- | ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenDimensionQualifierTest.java (renamed from eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/ScreenDimensionQualifierTest.java) | 13 | ||||
-rw-r--r-- | ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenOrientationQualifierTest.java (renamed from eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/ScreenOrientationQualifierTest.java) | 8 | ||||
-rw-r--r-- | ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenSizeQualifierTest.java (renamed from eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/ScreenSizeQualifierTest.java) | 8 | ||||
-rw-r--r-- | ide_common/tests/src/com/android/ide/common/resources/configuration/TextInputMethodQualifierTest.java (renamed from eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/TextInputMethodQualifierTest.java) | 8 | ||||
-rw-r--r-- | ide_common/tests/src/com/android/ide/common/resources/configuration/TouchScreenQualifierTest.java (renamed from eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/TouchScreenQualifierTest.java) | 8 |
20 files changed, 174 insertions, 241 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/ResourceHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/ResourceHelper.java index 7672a6a..73d3c93 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/ResourceHelper.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/ResourceHelper.java @@ -19,6 +19,7 @@ package com.android.ide.eclipse.adt.internal.resources; import com.android.ide.common.resources.ResourceDeltaKind; import com.android.ide.common.resources.configuration.CountryCodeQualifier; import com.android.ide.common.resources.configuration.DockModeQualifier; +import com.android.ide.common.resources.configuration.FolderConfiguration; import com.android.ide.common.resources.configuration.KeyboardStateQualifier; import com.android.ide.common.resources.configuration.LanguageQualifier; import com.android.ide.common.resources.configuration.NavigationMethodQualifier; @@ -48,60 +49,35 @@ import java.util.Map; */ public class ResourceHelper { - private final static Map<Class<?>, Image> ICON_MAP = new HashMap<Class<?>, Image>(20); + private final static Map<Class<?>, Image> sIconMap = new HashMap<Class<?>, Image>( + FolderConfiguration.getQualifierCount()); + + static { + IconFactory factory = IconFactory.getInstance(); + sIconMap.put(CountryCodeQualifier.class, factory.getIcon("mcc")); //$NON-NLS-1$ + sIconMap.put(NetworkCodeQualifier.class, factory.getIcon("mnc")); //$NON-NLS-1$ + sIconMap.put(LanguageQualifier.class, factory.getIcon("language")); //$NON-NLS-1$ + sIconMap.put(RegionQualifier.class, factory.getIcon("region")); //$NON-NLS-1$ + sIconMap.put(ScreenSizeQualifier.class, factory.getIcon("size")); //$NON-NLS-1$ + sIconMap.put(ScreenRatioQualifier.class, factory.getIcon("ratio")); //$NON-NLS-1$ + sIconMap.put(ScreenOrientationQualifier.class, factory.getIcon("orientation")); //$NON-NLS-1$ + sIconMap.put(DockModeQualifier.class, factory.getIcon("dockmode")); //$NON-NLS-1$ + sIconMap.put(NightModeQualifier.class, factory.getIcon("nightmode")); //$NON-NLS-1$ + sIconMap.put(PixelDensityQualifier.class, factory.getIcon("dpi")); //$NON-NLS-1$ + sIconMap.put(TouchScreenQualifier.class, factory.getIcon("touch")); //$NON-NLS-1$ + sIconMap.put(KeyboardStateQualifier.class, factory.getIcon("keyboard")); //$NON-NLS-1$ + sIconMap.put(TextInputMethodQualifier.class, factory.getIcon("text_input")); //$NON-NLS-1$ + sIconMap.put(NavigationStateQualifier.class, factory.getIcon("navpad")); //$NON-NLS-1$ + sIconMap.put(NavigationMethodQualifier.class, factory.getIcon("navpad")); //$NON-NLS-1$ + sIconMap.put(ScreenDimensionQualifier.class, factory.getIcon("dimension")); //$NON-NLS-1$ + sIconMap.put(VersionQualifier.class, factory.getIcon("version")); //$NON-NLS-1$ + } /** * Returns the icon for the qualifier. */ public static Image getIcon(Class<? extends ResourceQualifier> theClass) { - Image image = ICON_MAP.get(theClass); - if (image == null) { - image = computeImage(theClass); - ICON_MAP.put(theClass, image); - } - - return image; - } - - private static Image computeImage(Class<? extends ResourceQualifier> theClass) { - if (theClass == CountryCodeQualifier.class) { - return IconFactory.getInstance().getIcon("mcc"); //$NON-NLS-1$ - } else if (theClass == NetworkCodeQualifier.class) { - return IconFactory.getInstance().getIcon("mnc"); //$NON-NLS-1$ - } else if (theClass == LanguageQualifier.class) { - return IconFactory.getInstance().getIcon("language"); //$NON-NLS-1$ - } else if (theClass == RegionQualifier.class) { - return IconFactory.getInstance().getIcon("region"); //$NON-NLS-1$ - } else if (theClass == ScreenSizeQualifier.class) { - return IconFactory.getInstance().getIcon("size"); //$NON-NLS-1$ - } else if (theClass == ScreenRatioQualifier.class) { - return IconFactory.getInstance().getIcon("ratio"); //$NON-NLS-1$ - } else if (theClass == ScreenOrientationQualifier.class) { - return IconFactory.getInstance().getIcon("orientation"); //$NON-NLS-1$ - } else if (theClass == DockModeQualifier.class) { - return IconFactory.getInstance().getIcon("dockmode"); //$NON-NLS-1$ - } else if (theClass == NightModeQualifier.class) { - return IconFactory.getInstance().getIcon("nightmode"); //$NON-NLS-1$ - } else if (theClass == PixelDensityQualifier.class) { - return IconFactory.getInstance().getIcon("dpi"); //$NON-NLS-1$ - } else if (theClass == TouchScreenQualifier.class) { - return IconFactory.getInstance().getIcon("touch"); //$NON-NLS-1$ - } else if (theClass == KeyboardStateQualifier.class) { - return IconFactory.getInstance().getIcon("keyboard"); //$NON-NLS-1$ - } else if (theClass == TextInputMethodQualifier.class) { - return IconFactory.getInstance().getIcon("text_input"); //$NON-NLS-1$ - } else if (theClass == NavigationStateQualifier.class) { - return IconFactory.getInstance().getIcon("navpad"); //$NON-NLS-1$ - } else if (theClass == NavigationMethodQualifier.class) { - return IconFactory.getInstance().getIcon("navpad"); //$NON-NLS-1$ - } else if (theClass == ScreenDimensionQualifier.class) { - return IconFactory.getInstance().getIcon("dimension"); //$NON-NLS-1$ - } else if (theClass == VersionQualifier.class) { - return IconFactory.getInstance().getIcon("version"); //$NON-NLS-1$ - } - - // this can only happen if we forget to add a class above. - return null; + return sIconMap.get(theClass); } /** diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/manager/ConfigMatchTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/manager/ConfigMatchTest.java index 3551d6f..f2a6b54 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/manager/ConfigMatchTest.java +++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/manager/ConfigMatchTest.java @@ -21,13 +21,10 @@ import com.android.ide.common.resources.ResourceFolder; import com.android.ide.common.resources.ResourceRepository; import com.android.ide.common.resources.SingleResourceFile; import com.android.ide.common.resources.configuration.FolderConfiguration; -import com.android.ide.common.resources.configuration.ResourceQualifier; import com.android.ide.eclipse.adt.internal.resources.manager.ProjectResources; -import com.android.ide.eclipse.adt.internal.resources.manager.ResourceManager; import com.android.ide.eclipse.adt.io.IFileWrapper; import com.android.ide.eclipse.adt.io.IFolderWrapper; import com.android.ide.eclipse.mock.Mocks; -import com.android.io.IAbstractFolder; import com.android.resources.DockMode; import com.android.resources.Keyboard; import com.android.resources.KeyboardState; @@ -41,9 +38,6 @@ import com.android.resources.TouchScreen; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; -import java.lang.reflect.Field; -import java.lang.reflect.Method; - import junit.framework.TestCase; public class ConfigMatchTest extends TestCase { @@ -51,8 +45,8 @@ public class ConfigMatchTest extends TestCase { private static final String MISC1_FILENAME = "foo.xml"; //$NON-NLS-1$ private static final String MISC2_FILENAME = "bar.xml"; //$NON-NLS-1$ + private FolderConfiguration mDefaultConfig; private ProjectResources mResources; - private ResourceQualifier[] mQualifierList; private FolderConfiguration config4; private FolderConfiguration config3; private FolderConfiguration config2; @@ -62,15 +56,9 @@ public class ConfigMatchTest extends TestCase { protected void setUp() throws Exception { super.setUp(); - // create a Resource Manager to get a list of qualifier as instantiated by the real code. - // Thanks for QualifierListTest we know this contains all the qualifiers. - ResourceManager manager = ResourceManager.getInstance(); - Field qualifierListField = ResourceManager.class.getDeclaredField("mQualifiers"); - assertNotNull(qualifierListField); - qualifierListField.setAccessible(true); - - // get the actual list. - mQualifierList = (ResourceQualifier[])qualifierListField.get(manager); + // create a default config with all qualifiers. + mDefaultConfig = new FolderConfiguration(); + mDefaultConfig.createDefault(); // create the project resources. mResources = new ProjectResources(null /*project*/); @@ -234,17 +222,18 @@ public class ConfigMatchTest extends TestCase { * this particular qualifier. */ private FolderConfiguration getConfiguration(String... qualifierValues) { - FolderConfiguration config = new FolderConfiguration(); + // FolderConfiguration.getQualifierCount is always valid and up to date. + final int count = FolderConfiguration.getQualifierCount(); - // those must be of the same length - assertEquals(qualifierValues.length, mQualifierList.length); + // Check we have the right number of qualifier. + assertEquals(qualifierValues.length, count); - int index = 0; + FolderConfiguration config = new FolderConfiguration(); - for (ResourceQualifier qualifier : mQualifierList) { - String value = qualifierValues[index++]; + for (int i = 0 ; i < count ; i++) { + String value = qualifierValues[i]; if (value != null) { - assertTrue(qualifier.checkAndSet(value, config)); + assertTrue(mDefaultConfig.getQualifier(i).checkAndSet(value, config)); } } @@ -268,28 +257,11 @@ public class ConfigMatchTest extends TestCase { IFolder folder = Mocks.createFolder(folderName, memberList); // add it to the resource, and get back a ResourceFolder object. - ResourceFolder resFolder = _addProjectResourceFolder(resources, config, folder); + ResourceFolder resFolder = resources.processFolder(new IFolderWrapper(folder)); // and fill it with files from the list. for (IFile file : memberList) { resFolder.addFile(new SingleResourceFile(new IFileWrapper(file), resFolder)); } } - - /** Calls ResourceRepository.add() method via reflection to circumvent access - * restrictions that are enforced when running in the plug-in environment - * ie cannot access package or protected members in a different plug-in, even - * if they are in the same declared package as the accessor - */ - private ResourceFolder _addProjectResourceFolder(ResourceRepository resources, - FolderConfiguration config, IFolder folder) throws Exception { - - Method addMethod = ResourceRepository.class.getDeclaredMethod("add", - ResourceFolderType.class, FolderConfiguration.class, - IAbstractFolder.class); - addMethod.setAccessible(true); - ResourceFolder resFolder = (ResourceFolder)addMethod.invoke(resources, - ResourceFolderType.LAYOUT, config, new IFolderWrapper(folder)); - return resFolder; - } } diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/manager/QualifierListTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/manager/QualifierListTest.java deleted file mode 100644 index 37ee37a..0000000 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/manager/QualifierListTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php - * - * 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.eclipse.adt.internal.editors.resources.manager; - -import com.android.ide.common.resources.configuration.FolderConfiguration; -import com.android.ide.common.resources.configuration.ResourceQualifier; -import com.android.ide.eclipse.adt.internal.resources.manager.ResourceManager; - -import java.lang.reflect.Field; - -import junit.framework.TestCase; - -public class QualifierListTest extends TestCase { - - private ResourceManager mManager; - - @Override - public void setUp() throws Exception { - super.setUp(); - - mManager = ResourceManager.getInstance(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - mManager = null; - } - - public void testQualifierList() { - try { - // get the list of qualifier in the resource manager - Field qualifierListField = ResourceManager.class.getDeclaredField("mQualifiers"); - assertNotNull(qualifierListField); - qualifierListField.setAccessible(true); - - // get the actual list. - ResourceQualifier[] qualifierList = - (ResourceQualifier[])qualifierListField.get(mManager); - - // now get the number of qualifier in the FolderConfiguration - Field qualCountField = FolderConfiguration.class.getDeclaredField("INDEX_COUNT"); - assertNotNull(qualCountField); - qualCountField.setAccessible(true); - - // get the constant value - Integer count = (Integer)qualCountField.get(null); - - // now compare - assertEquals(count.intValue(), qualifierList.length); - } catch (SecurityException e) { - assertTrue(false); - } catch (NoSuchFieldException e) { - assertTrue(false); - } catch (IllegalArgumentException e) { - assertTrue(false); - } catch (IllegalAccessException e) { - assertTrue(false); - } - } -} - 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/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/CountryCodeQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/CountryCodeQualifierTest.java index 85a95f8..eba8b8d 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/CountryCodeQualifierTest.java +++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/CountryCodeQualifierTest.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2008 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * 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.eclipse.org/org/documents/epl-v10.php + * 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, @@ -14,10 +14,7 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.editors.resources.configurations; - -import com.android.ide.common.resources.configuration.CountryCodeQualifier; -import com.android.ide.common.resources.configuration.FolderConfiguration; +package com.android.ide.common.resources.configuration; import junit.framework.TestCase; diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/DockModeQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/DockModeQualifierTest.java index 3765e6c..195d474 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/DockModeQualifierTest.java +++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/DockModeQualifierTest.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2010 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * 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.eclipse.org/org/documents/epl-v10.php + * 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, @@ -14,9 +14,8 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.editors.resources.configurations; +package com.android.ide.common.resources.configuration; -import com.android.ide.common.resources.configuration.DockModeQualifier; import com.android.resources.DockMode; import junit.framework.TestCase; 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/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/KeyboardStateQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/KeyboardStateQualifierTest.java index d3ad232..cf52a38 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/KeyboardStateQualifierTest.java +++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/KeyboardStateQualifierTest.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2008 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * 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.eclipse.org/org/documents/epl-v10.php + * 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, @@ -14,10 +14,8 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.editors.resources.configurations; +package com.android.ide.common.resources.configuration; -import com.android.ide.common.resources.configuration.FolderConfiguration; -import com.android.ide.common.resources.configuration.KeyboardStateQualifier; import com.android.resources.KeyboardState; import junit.framework.TestCase; diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/LanguageQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/LanguageQualifierTest.java index 2c0f203..2dfd65f 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/LanguageQualifierTest.java +++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/LanguageQualifierTest.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2007 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * 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.eclipse.org/org/documents/epl-v10.php + * 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, @@ -14,15 +14,12 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.editors.resources.configurations; - -import com.android.ide.common.resources.configuration.FolderConfiguration; -import com.android.ide.common.resources.configuration.LanguageQualifier; +package com.android.ide.common.resources.configuration; import junit.framework.TestCase; public class LanguageQualifierTest extends TestCase { - + private FolderConfiguration config; private LanguageQualifier lq; @@ -39,14 +36,14 @@ public class LanguageQualifierTest extends TestCase { 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$ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/NavigationMethodQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/NavigationMethodQualifierTest.java index d8c116b..4237dde 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/NavigationMethodQualifierTest.java +++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/NavigationMethodQualifierTest.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2007 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * 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.eclipse.org/org/documents/epl-v10.php + * 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, @@ -14,10 +14,8 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.editors.resources.configurations; +package com.android.ide.common.resources.configuration; -import com.android.ide.common.resources.configuration.FolderConfiguration; -import com.android.ide.common.resources.configuration.NavigationMethodQualifier; import com.android.resources.Navigation; import junit.framework.TestCase; diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/NetworkCodeQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/NetworkCodeQualifierTest.java index 75b509c..6896316 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/NetworkCodeQualifierTest.java +++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/NetworkCodeQualifierTest.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2008 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * 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.eclipse.org/org/documents/epl-v10.php + * 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, @@ -14,10 +14,7 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.editors.resources.configurations; - -import com.android.ide.common.resources.configuration.FolderConfiguration; -import com.android.ide.common.resources.configuration.NetworkCodeQualifier; +package com.android.ide.common.resources.configuration; import junit.framework.TestCase; diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/PixelDensityQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/PixelDensityQualifierTest.java index 76fe24a..b99f2af 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/PixelDensityQualifierTest.java +++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/PixelDensityQualifierTest.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2007 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * 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.eclipse.org/org/documents/epl-v10.php + * 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, @@ -14,10 +14,8 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.editors.resources.configurations; +package com.android.ide.common.resources.configuration; -import com.android.ide.common.resources.configuration.FolderConfiguration; -import com.android.ide.common.resources.configuration.PixelDensityQualifier; import com.android.resources.Density; import junit.framework.TestCase; diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/RegionQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/RegionQualifierTest.java index e050e2b..fc0402c 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/RegionQualifierTest.java +++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/RegionQualifierTest.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2007 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * 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.eclipse.org/org/documents/epl-v10.php + * 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, @@ -14,10 +14,7 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.editors.resources.configurations; - -import com.android.ide.common.resources.configuration.FolderConfiguration; -import com.android.ide.common.resources.configuration.RegionQualifier; +package com.android.ide.common.resources.configuration; import junit.framework.TestCase; diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/ScreenDimensionQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenDimensionQualifierTest.java index 6059141..e57424f 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/ScreenDimensionQualifierTest.java +++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenDimensionQualifierTest.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2007 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * 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.eclipse.org/org/documents/epl-v10.php + * 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, @@ -14,10 +14,7 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.editors.resources.configurations; - -import com.android.ide.common.resources.configuration.FolderConfiguration; -import com.android.ide.common.resources.configuration.ScreenDimensionQualifier; +package com.android.ide.common.resources.configuration; import junit.framework.TestCase; @@ -39,7 +36,7 @@ public class ScreenDimensionQualifierTest extends TestCase { sdq = null; config = null; } - + public void testCheckAndSet() { assertEquals(true, sdq.checkAndSet("400x200", config));//$NON-NLS-1$ assertTrue(config.getScreenDimensionQualifier() != null); @@ -47,7 +44,7 @@ public class ScreenDimensionQualifierTest extends TestCase { 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$ diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/ScreenOrientationQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenOrientationQualifierTest.java index 2b2dd51..3aac5f3 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/ScreenOrientationQualifierTest.java +++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenOrientationQualifierTest.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2007 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * 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.eclipse.org/org/documents/epl-v10.php + * 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, @@ -14,10 +14,8 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.editors.resources.configurations; +package com.android.ide.common.resources.configuration; -import com.android.ide.common.resources.configuration.FolderConfiguration; -import com.android.ide.common.resources.configuration.ScreenOrientationQualifier; import com.android.resources.ScreenOrientation; import junit.framework.TestCase; diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/ScreenSizeQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenSizeQualifierTest.java index f14a917..b19f125 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/ScreenSizeQualifierTest.java +++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenSizeQualifierTest.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2010 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * 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.eclipse.org/org/documents/epl-v10.php + * 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, @@ -14,10 +14,8 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.editors.resources.configurations; +package com.android.ide.common.resources.configuration; -import com.android.ide.common.resources.configuration.FolderConfiguration; -import com.android.ide.common.resources.configuration.ScreenSizeQualifier; import com.android.resources.ScreenSize; import junit.framework.TestCase; diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/TextInputMethodQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/TextInputMethodQualifierTest.java index f33eb55..bc2c890 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/TextInputMethodQualifierTest.java +++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/TextInputMethodQualifierTest.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2007 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * 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.eclipse.org/org/documents/epl-v10.php + * 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, @@ -14,10 +14,8 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.editors.resources.configurations; +package com.android.ide.common.resources.configuration; -import com.android.ide.common.resources.configuration.FolderConfiguration; -import com.android.ide.common.resources.configuration.TextInputMethodQualifier; import com.android.resources.Keyboard; import junit.framework.TestCase; diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/TouchScreenQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/TouchScreenQualifierTest.java index 0a55c8f..04f8a30 100644 --- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/resources/configurations/TouchScreenQualifierTest.java +++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/TouchScreenQualifierTest.java @@ -1,11 +1,11 @@ /* * Copyright (C) 2007 The Android Open Source Project * - * Licensed under the Eclipse Public License, Version 1.0 (the "License"); + * 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.eclipse.org/org/documents/epl-v10.php + * 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, @@ -14,10 +14,8 @@ * limitations under the License. */ -package com.android.ide.eclipse.adt.internal.editors.resources.configurations; +package com.android.ide.common.resources.configuration; -import com.android.ide.common.resources.configuration.FolderConfiguration; -import com.android.ide.common.resources.configuration.TouchScreenQualifier; import com.android.resources.TouchScreen; import junit.framework.TestCase; |