Initial Contribution
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.build;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class BaseBuilderTest extends TestCase {
|
||||
|
||||
public void testParseAaptOutput() {
|
||||
Pattern p = Pattern.compile( "^(.+):(\\d+):\\s(.+)$"); //$NON-NLS-1$
|
||||
String s = "C:\\java\\workspace-android\\AndroidApp\\res\\values\\strings.xml:11: WARNING: empty 'some warning text";
|
||||
|
||||
Matcher m = p.matcher(s);
|
||||
assertEquals(true, m.matches());
|
||||
assertEquals("C:\\java\\workspace-android\\AndroidApp\\res\\values\\strings.xml", m.group(1));
|
||||
assertEquals("11", m.group(2));
|
||||
assertEquals("WARNING: empty 'some warning text", m.group(3));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.project;
|
||||
|
||||
import com.android.ide.eclipse.mock.ClasspathEntryMock;
|
||||
import com.android.ide.eclipse.mock.JavaProjectMock;
|
||||
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jdt.core.IClasspathEntry;
|
||||
import org.eclipse.jdt.core.JavaModelException;
|
||||
import org.eclipse.jdt.launching.JavaRuntime;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class ProjectHelperTest extends TestCase {
|
||||
|
||||
/** The old container id */
|
||||
private final static String OLD_CONTAINER_ID =
|
||||
"com.android.ide.eclipse.adt.project.AndroidClasspathContainerInitializer"; //$NON-NLS-1$
|
||||
|
||||
/** The container id for the android framework jar file */
|
||||
private final static String CONTAINER_ID =
|
||||
"com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"; //$NON-NLS-1$
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
// pass for now
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
// pass for now
|
||||
}
|
||||
|
||||
public final void testFixProjectClasspathEntriesFromOldContainer() throws JavaModelException {
|
||||
// create a project with a path to an android .zip
|
||||
JavaProjectMock javaProject = new JavaProjectMock(
|
||||
new IClasspathEntry[] {
|
||||
new ClasspathEntryMock(new Path("Project/src"), //$NON-NLS-1$
|
||||
IClasspathEntry.CPE_SOURCE),
|
||||
new ClasspathEntryMock(new Path(OLD_CONTAINER_ID),
|
||||
IClasspathEntry.CPE_CONTAINER),
|
||||
},
|
||||
new Path("Project/bin"));
|
||||
|
||||
ProjectHelper.fixProjectClasspathEntries(javaProject);
|
||||
|
||||
IClasspathEntry[] fixedEntries = javaProject.getRawClasspath();
|
||||
assertEquals(2, fixedEntries.length);
|
||||
assertEquals("Project/src", fixedEntries[0].getPath().toString());
|
||||
assertEquals(CONTAINER_ID, fixedEntries[1].getPath().toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.resources;
|
||||
|
||||
import com.android.ide.eclipse.adt.resources.LayoutParamsParser.IClass;
|
||||
import com.android.ide.eclipse.tests.AdtTestData;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Unit Test for {@link FrameworkClassLoader}.
|
||||
*
|
||||
* Uses the classes jar.example.Class1/Class2 stored in tests/data/jar_example.jar.
|
||||
*/
|
||||
public class AndroidJarLoaderTest extends TestCase {
|
||||
|
||||
private AndroidJarLoader mFrameworkClassLoader;
|
||||
|
||||
/** Creates an instance of {@link FrameworkClassLoader} on our test data JAR */
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
String jarfilePath = AdtTestData.getInstance().getTestFilePath("jar_example.jar"); //$NON-NLS-1$
|
||||
mFrameworkClassLoader = new AndroidJarLoader(jarfilePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
/** Preloads classes. They should load just fine. */
|
||||
public final void testPreLoadClasses() throws Exception {
|
||||
mFrameworkClassLoader.preLoadClasses("jar.example.", null); //$NON-NLS-1$
|
||||
HashMap<String, Class<?>> map = getPrivateClassCache();
|
||||
assertEquals(0, map.size());
|
||||
HashMap<String,byte[]> data = getPrivateEntryCache();
|
||||
assertTrue(data.containsKey("jar.example.Class1")); //$NON-NLS-1$
|
||||
assertTrue(data.containsKey("jar.example.Class2")); //$NON-NLS-1$
|
||||
assertTrue(data.containsKey("jar.example.Class1$InnerStaticClass1")); //$NON-NLS-1$
|
||||
assertTrue(data.containsKey("jar.example.Class1$InnerClass2")); //$NON-NLS-1$
|
||||
assertEquals(4, data.size());
|
||||
}
|
||||
|
||||
/** Preloads a class not in the JAR. Preloading does nothing in this case. */
|
||||
public final void testPreLoadClasses_classNotFound() throws Exception {
|
||||
mFrameworkClassLoader.preLoadClasses("not.a.package.", null); //$NON-NLS-1$
|
||||
HashMap<String, Class<?>> map = getPrivateClassCache();
|
||||
assertEquals(0, map.size());
|
||||
HashMap<String,byte[]> data = getPrivateEntryCache();
|
||||
assertEquals(0, data.size());
|
||||
}
|
||||
|
||||
/** Finds a class we just preloaded. It should work. */
|
||||
public final void testFindClass_classFound() throws Exception {
|
||||
Class<?> c = _findClass(mFrameworkClassLoader, "jar.example.Class2"); //$NON-NLS-1$
|
||||
assertEquals("jar.example.Class2", c.getName()); //$NON-NLS-1$
|
||||
HashMap<String, Class<?>> map = getPrivateClassCache();
|
||||
assertTrue(map.containsKey("jar.example.Class2")); //$NON-NLS-1$
|
||||
assertEquals(1, map.size());
|
||||
}
|
||||
|
||||
/** call the protected method findClass */
|
||||
private Class<?> _findClass(AndroidJarLoader jarLoader, String name) throws Exception {
|
||||
Method findClassMethod = AndroidJarLoader.class.getDeclaredMethod(
|
||||
"findClass", String.class); //$NON-NLS-1$
|
||||
findClassMethod.setAccessible(true);
|
||||
try {
|
||||
return (Class<?>)findClassMethod.invoke(jarLoader, name);
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
throw (Exception)e.getCause();
|
||||
}
|
||||
}
|
||||
|
||||
/** Trying to find a class that we fail to preload should throw a CNFE. */
|
||||
public final void testFindClass_classNotFound() throws Exception {
|
||||
try {
|
||||
// Will throw ClassNotFoundException
|
||||
_findClass(mFrameworkClassLoader, "not.a.valid.ClassName"); //$NON-NLS-1$
|
||||
} catch (ClassNotFoundException e) {
|
||||
// check the message in the CNFE
|
||||
assertEquals("not.a.valid.ClassName", e.getMessage()); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
// Exception not thrown - this is a failure
|
||||
fail("Expected ClassNotFoundException not thrown");
|
||||
}
|
||||
|
||||
public final void testFindClassesDerivingFrom() throws Exception {
|
||||
HashMap<String, ArrayList<IClass>> found =
|
||||
mFrameworkClassLoader.findClassesDerivingFrom("jar.example.", new String[] { //$NON-NLS-1$
|
||||
"jar.example.Class1", //$NON-NLS-1$
|
||||
"jar.example.Class2" }); //$NON-NLS-1$
|
||||
|
||||
assertTrue(found.containsKey("jar.example.Class1")); //$NON-NLS-1$
|
||||
assertTrue(found.containsKey("jar.example.Class2")); //$NON-NLS-1$
|
||||
assertEquals(2, found.size());
|
||||
// Only Class2 derives from Class1..
|
||||
// Class1 and Class1$InnerStaticClass1 derive from Object and are thus ignored.
|
||||
// Class1$InnerClass2 should never be seen either.
|
||||
assertEquals("jar.example.Class2", //$NON-NLS-1$
|
||||
found.get("jar.example.Class1").get(0).getCanonicalName()); //$NON-NLS-1$
|
||||
assertEquals(1, found.get("jar.example.Class1").size()); //$NON-NLS-1$
|
||||
assertEquals(0, found.get("jar.example.Class2").size()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
// --- Utilities ---
|
||||
|
||||
/**
|
||||
* Retrieves the private mFrameworkClassLoader.mClassCache field using reflection.
|
||||
*
|
||||
* @throws NoSuchFieldException
|
||||
* @throws SecurityException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private HashMap<String, Class<?> > getPrivateClassCache()
|
||||
throws SecurityException, NoSuchFieldException,
|
||||
IllegalArgumentException, IllegalAccessException {
|
||||
Field field = AndroidJarLoader.class.getDeclaredField("mClassCache"); //$NON-NLS-1$
|
||||
field.setAccessible(true);
|
||||
return (HashMap<String, Class<?>>) field.get(mFrameworkClassLoader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the private mFrameworkClassLoader.mEntryCache field using reflection.
|
||||
*
|
||||
* @throws NoSuchFieldException
|
||||
* @throws SecurityException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private HashMap<String,byte[]> getPrivateEntryCache()
|
||||
throws SecurityException, NoSuchFieldException,
|
||||
IllegalArgumentException, IllegalAccessException {
|
||||
Field field = AndroidJarLoader.class.getDeclaredField("mEntryCache"); //$NON-NLS-1$
|
||||
field.setAccessible(true);
|
||||
return (HashMap<String, byte[]>) field.get(mFrameworkClassLoader);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.resources;
|
||||
|
||||
import com.android.ide.eclipse.adt.resources.AndroidJarLoader.ClassWrapper;
|
||||
import com.android.ide.eclipse.adt.resources.LayoutParamsParser.IClass;
|
||||
import com.android.ide.eclipse.common.resources.AttrsXmlParser;
|
||||
import com.android.ide.eclipse.common.resources.ViewClassInfo;
|
||||
import com.android.ide.eclipse.common.resources.ViewClassInfo.LayoutParamsInfo;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Test the inner private methods of FrameworkResourceParser.
|
||||
*
|
||||
* Convention: method names that start with an underscore are actually local wrappers
|
||||
* that call private methods from {@link FrameworkResourceParser} using reflection.
|
||||
* This is inspired by the Python coding rule which mandates underscores prefixes for
|
||||
* "private" methods.
|
||||
*/
|
||||
public class LayoutParamsParserTest extends TestCase {
|
||||
|
||||
private static class MockFrameworkClassLoader extends AndroidJarLoader {
|
||||
MockFrameworkClassLoader() {
|
||||
super(null /* osFrameworkLocation */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, ArrayList<IClass>> findClassesDerivingFrom(
|
||||
String rootPackage, String[] superClasses) throws ClassFormatError {
|
||||
return new HashMap<String, ArrayList<IClass>>();
|
||||
}
|
||||
}
|
||||
|
||||
private static class MockAttrsXmlPath {
|
||||
public String getPath() {
|
||||
ClassLoader cl = this.getClass().getClassLoader();
|
||||
URL res = cl.getResource("data/mock_attrs.xml"); //$NON-NLS-1$
|
||||
return res.getFile();
|
||||
}
|
||||
}
|
||||
|
||||
private static class MockLayoutParamsParser extends LayoutParamsParser {
|
||||
public MockLayoutParamsParser() {
|
||||
super(new MockFrameworkClassLoader(),
|
||||
new AttrsXmlParser(new MockAttrsXmlPath().getPath()).preload());
|
||||
|
||||
mTopViewClass = new ClassWrapper(mock_android.view.View.class);
|
||||
mTopGroupClass = new ClassWrapper(mock_android.view.ViewGroup.class);
|
||||
mTopLayoutParamsClass = new ClassWrapper(mock_android.view.ViewGroup.LayoutParams.class);
|
||||
|
||||
mViewList = new ArrayList<IClass>();
|
||||
mGroupList = new ArrayList<IClass>();
|
||||
mViewMap = new TreeMap<String, ExtViewClassInfo>();
|
||||
mGroupMap = new TreeMap<String, ExtViewClassInfo>();
|
||||
mLayoutParamsMap = new HashMap<String, LayoutParamsInfo>();
|
||||
}
|
||||
}
|
||||
|
||||
private MockLayoutParamsParser mParser;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
mParser = new MockLayoutParamsParser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
public final void testFindLayoutParams() throws Exception {
|
||||
assertEquals(mock_android.view.ViewGroup.LayoutParams.class,
|
||||
((ClassWrapper)_findLayoutParams(mock_android.view.ViewGroup.class)).wrappedClass());
|
||||
|
||||
assertEquals(mock_android.widget.LinearLayout.LayoutParams.class,
|
||||
((ClassWrapper)_findLayoutParams(mock_android.widget.LinearLayout.class)).wrappedClass());
|
||||
|
||||
assertEquals(mock_android.widget.TableLayout.LayoutParams.class,
|
||||
((ClassWrapper)_findLayoutParams(mock_android.widget.TableLayout.class)).wrappedClass());
|
||||
}
|
||||
|
||||
public final void testGetLayoutParamsInfo() throws Exception {
|
||||
LayoutParamsInfo info1 = _getLayoutParamsInfo(
|
||||
mock_android.view.ViewGroup.LayoutParams.class);
|
||||
assertNotNull(info1);
|
||||
// ViewGroup.LayoutData has Object for superClass, which we don't map
|
||||
assertNull(info1.getSuperClass());
|
||||
|
||||
LayoutParamsInfo info2 = _getLayoutParamsInfo(
|
||||
mock_android.widget.LinearLayout.LayoutParams.class);
|
||||
assertNotNull(info2);
|
||||
// LinearLayout.LayoutData links to ViewGroup.LayoutParams
|
||||
assertSame(info1, info2.getSuperClass());
|
||||
|
||||
LayoutParamsInfo info3 = _getLayoutParamsInfo(
|
||||
mock_android.widget.TableLayout.LayoutParams.class);
|
||||
assertNotNull(info3);
|
||||
// TableLayout.LayoutData does not link to ViewGroup.LayoutParams nor
|
||||
// LinearLayout.LayoutParams
|
||||
assertNotSame(info1, info3.getSuperClass());
|
||||
assertNotSame(info2, info3.getSuperClass());
|
||||
// TableLayout.LayoutParams => ViewGroup.MarginLayoutParams => ViewGroup.LayoutParams
|
||||
assertSame(info1, info3.getSuperClass().getSuperClass());
|
||||
}
|
||||
|
||||
public final void testGetLayoutClasses() throws Exception {
|
||||
// _getLayoutClasses();
|
||||
}
|
||||
|
||||
//---- access to private methods
|
||||
|
||||
/** Calls the private constructor of the parser */
|
||||
private FrameworkResourceParser _Constructor(String osJarPath) throws Exception {
|
||||
Constructor<FrameworkResourceParser> constructor =
|
||||
FrameworkResourceParser.class.getDeclaredConstructor(String.class);
|
||||
constructor.setAccessible(true);
|
||||
return constructor.newInstance(osJarPath);
|
||||
}
|
||||
|
||||
/** calls the private getLayoutClasses() of the parser */
|
||||
private void _getLayoutClasses() throws Exception {
|
||||
Method method = FrameworkResourceParser.class.getDeclaredMethod("getLayoutClasses"); //$NON-NLS-1$
|
||||
method.setAccessible(true);
|
||||
method.invoke(mParser);
|
||||
}
|
||||
|
||||
/** calls the private addGroup() of the parser */
|
||||
private ViewClassInfo _addGroup(Class<?> groupClass) throws Exception {
|
||||
Method method = LayoutParamsParser.class.getDeclaredMethod("addGroup", //$NON-NLS-1$
|
||||
IClass.class);
|
||||
method.setAccessible(true);
|
||||
return (ViewClassInfo) method.invoke(mParser, new ClassWrapper(groupClass));
|
||||
}
|
||||
|
||||
/** calls the private addLayoutParams() of the parser */
|
||||
private LayoutParamsInfo _addLayoutParams(Class<?> groupClass) throws Exception {
|
||||
Method method = LayoutParamsParser.class.getDeclaredMethod("addLayoutParams", //$NON-NLS-1$
|
||||
IClass.class);
|
||||
method.setAccessible(true);
|
||||
return (LayoutParamsInfo) method.invoke(mParser, new ClassWrapper(groupClass));
|
||||
}
|
||||
|
||||
/** calls the private getLayoutParamsInfo() of the parser */
|
||||
private LayoutParamsInfo _getLayoutParamsInfo(Class<?> layoutParamsClass) throws Exception {
|
||||
Method method = LayoutParamsParser.class.getDeclaredMethod("getLayoutParamsInfo", //$NON-NLS-1$
|
||||
IClass.class);
|
||||
method.setAccessible(true);
|
||||
return (LayoutParamsInfo) method.invoke(mParser, new ClassWrapper(layoutParamsClass));
|
||||
}
|
||||
|
||||
/** calls the private findLayoutParams() of the parser */
|
||||
private IClass _findLayoutParams(Class<?> groupClass) throws Exception {
|
||||
Method method = LayoutParamsParser.class.getDeclaredMethod("findLayoutParams", //$NON-NLS-1$
|
||||
IClass.class);
|
||||
method.setAccessible(true);
|
||||
return (IClass) method.invoke(mParser, new ClassWrapper(groupClass));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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.common.project;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class AndroidManifestHelperTest extends TestCase {
|
||||
private File mFile;
|
||||
private AndroidManifestHelper mManifest;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
mFile = File.createTempFile("androidManifest", "xml"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
assertNotNull(mFile);
|
||||
|
||||
FileWriter fw = new FileWriter(mFile);
|
||||
fw.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); //$NON-NLS-1$
|
||||
fw.write("<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n"); //$NON-NLS-1$
|
||||
fw.write(" package=\"com.android.testapp\">\n"); //$NON-NLS-1$
|
||||
fw.write(" <application android:icon=\"@drawable/icon\">\n"); //$NON-NLS-1$
|
||||
fw.write(" <activity android:name=\".MainActivity\" android:label=\"@string/app_name\">\n"); //$NON-NLS-1$
|
||||
fw.write(" <intent-filter>\n"); //$NON-NLS-1$
|
||||
fw.write(" <action android:name=\"android.intent.action.MAIN\" />\n"); //$NON-NLS-1$
|
||||
fw.write(" <category android:name=\"android.intent.category.LAUNCHER\" />\"\n"); //$NON-NLS-1$
|
||||
fw.write(" <category android:name=\"android.intent.category.DEFAULT\" />\n"); //$NON-NLS-1$
|
||||
fw.write(" </intent-filter>\n"); //$NON-NLS-1$
|
||||
fw.write(" </activity>\n"); //$NON-NLS-1$
|
||||
fw.write(" <activity android:name=\".OptionsActivity\" android:label=\"@string/options\"\n"); //$NON-NLS-1$
|
||||
fw.write(" android:theme=\"@style/Theme.Floating\">\n"); //$NON-NLS-1$
|
||||
fw.write(" <intent-filter>\n"); //$NON-NLS-1$
|
||||
fw.write(" <action android:name=\"com.android.mandelbrot.action.EDIT_OPTIONS\" />\n"); //$NON-NLS-1$
|
||||
fw.write(" <category android:name=\"android.intent.category.PREFERENCE_CATEGORY\" />\n"); //$NON-NLS-1$
|
||||
fw.write(" </intent-filter>\n"); //$NON-NLS-1$
|
||||
fw.write(" </activity>\n"); //$NON-NLS-1$
|
||||
fw.write(" <activity android:name=\".InfoActivity\" android:label=\"@string/options\"\n"); //$NON-NLS-1$
|
||||
fw.write(" android:theme=\"@style/Theme.Floating\">\n"); //$NON-NLS-1$
|
||||
fw.write(" <intent-filter>\n"); //$NON-NLS-1$
|
||||
fw.write(" <action android:name=\"com.android.mandelbrot.action.DISPLAY_INFO\" />\n"); //$NON-NLS-1$
|
||||
fw.write(" </intent-filter>\n"); //$NON-NLS-1$
|
||||
fw.write(" </activity>\n"); //$NON-NLS-1$
|
||||
fw.write(" </application>\n"); //$NON-NLS-1$
|
||||
fw.write("</manifest>\n"); //$NON-NLS-1$
|
||||
fw.flush();
|
||||
fw.close();
|
||||
|
||||
mManifest = new AndroidManifestHelper(mFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
assertTrue(mFile.delete());
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testExists() {
|
||||
assertTrue(mManifest.exists());
|
||||
}
|
||||
|
||||
public void testNotExists() throws IOException {
|
||||
File f = File.createTempFile("androidManifest2", "xml"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
assertTrue(f.delete());
|
||||
AndroidManifestHelper manifest = new AndroidManifestHelper(f.getAbsolutePath());
|
||||
assertFalse(manifest.exists());
|
||||
}
|
||||
|
||||
public void testGetPackageName() {
|
||||
assertEquals("com.android.testapp", mManifest.getPackageName());
|
||||
}
|
||||
|
||||
public void testGetActivityName() {
|
||||
assertEquals("", mManifest.getActivityName(0)); //$NON-NLS-1$
|
||||
assertEquals(".MainActivity", mManifest.getActivityName(1)); //$NON-NLS-1$
|
||||
assertEquals(".OptionsActivity", mManifest.getActivityName(2)); //$NON-NLS-1$
|
||||
assertEquals(".InfoActivity", mManifest.getActivityName(3)); //$NON-NLS-1$
|
||||
assertEquals("", mManifest.getActivityName(4)); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.common.resources;
|
||||
|
||||
|
||||
import com.android.ide.eclipse.common.resources.DeclareStyleableInfo.AttributeInfo;
|
||||
import com.android.ide.eclipse.common.resources.DeclareStyleableInfo.AttributeInfo.Format;
|
||||
import com.android.ide.eclipse.tests.AdtTestData;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class AttrsXmlParserTest extends TestCase {
|
||||
|
||||
private AttrsXmlParser mParser;
|
||||
private String mFilePath;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
mFilePath = AdtTestData.getInstance().getTestFilePath("mock_attrs.xml"); //$NON-NLS-1$
|
||||
mParser = new AttrsXmlParser(mFilePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
public final void testGetDocument() throws Exception {
|
||||
assertNotNull(_getDocument());
|
||||
}
|
||||
|
||||
public void testGetOsAttrsXmlPath() throws Exception {
|
||||
assertEquals(mFilePath, mParser.getOsAttrsXmlPath());
|
||||
}
|
||||
|
||||
public final void testPreload() throws Exception {
|
||||
assertSame(mParser, mParser.preload());
|
||||
}
|
||||
|
||||
|
||||
public final void testLoadViewAttributes() throws Exception {
|
||||
mParser.preload();
|
||||
ViewClassInfo info = new ViewClassInfo(
|
||||
false /* isLayout */,
|
||||
"mock_android.something.Theme", //$NON-NLS-1$
|
||||
"Theme"); //$NON-NLS-1$
|
||||
mParser.loadViewAttributes(info);
|
||||
|
||||
assertEquals("These are the standard attributes that make up a complete theme.", //$NON-NLS-1$
|
||||
info.getJavaDoc());
|
||||
AttributeInfo[] attrs = info.getAttributes();
|
||||
assertEquals(1, attrs.length);
|
||||
assertEquals("scrollbarSize", info.getAttributes()[0].getName());
|
||||
assertEquals(1, info.getAttributes()[0].getFormats().length);
|
||||
assertEquals(Format.DIMENSION, info.getAttributes()[0].getFormats()[0]);
|
||||
}
|
||||
|
||||
public final void testEnumFlagValues() throws Exception {
|
||||
/* The XML being read contains:
|
||||
<!-- Standard orientation constant. -->
|
||||
<attr name="orientation">
|
||||
<!-- Defines an horizontal widget. -->
|
||||
<enum name="horizontal" value="0" />
|
||||
<!-- Defines a vertical widget. -->
|
||||
<enum name="vertical" value="1" />
|
||||
</attr>
|
||||
*/
|
||||
|
||||
mParser.preload();
|
||||
Map<String, Map<String, Integer>> attrMap = mParser.getEnumFlagValues();
|
||||
assertTrue(attrMap.containsKey("orientation"));
|
||||
|
||||
Map<String, Integer> valueMap = attrMap.get("orientation");
|
||||
assertTrue(valueMap.containsKey("horizontal"));
|
||||
assertTrue(valueMap.containsKey("vertical"));
|
||||
assertEquals(Integer.valueOf(0), valueMap.get("horizontal"));
|
||||
assertEquals(Integer.valueOf(1), valueMap.get("vertical"));
|
||||
}
|
||||
|
||||
//---- access to private methods
|
||||
|
||||
private Document _getDocument() throws Exception {
|
||||
Method method = AttrsXmlParser.class.getDeclaredMethod("getDocument"); //$NON-NLS-1$
|
||||
method.setAccessible(true);
|
||||
return (Document) method.invoke(mParser);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.editors.descriptors;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Unit tests for DescriptorsUtils in the editors plugin
|
||||
*/
|
||||
public class DescriptorsUtilsTest extends TestCase {
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testPrettyAttributeUiName() {
|
||||
assertEquals("", DescriptorsUtils.prettyAttributeUiName(""));
|
||||
|
||||
assertEquals("Max width for view",
|
||||
DescriptorsUtils.prettyAttributeUiName("maxWidthForView"));
|
||||
|
||||
assertEquals("Layout width",
|
||||
DescriptorsUtils.prettyAttributeUiName("layout_width"));
|
||||
|
||||
// X Y and Z are capitalized when used as single words (so "T" becomes "t")
|
||||
assertEquals("Axis X", DescriptorsUtils.prettyAttributeUiName("axisX"));
|
||||
assertEquals("Axis Y", DescriptorsUtils.prettyAttributeUiName("axisY"));
|
||||
assertEquals("Axis Z", DescriptorsUtils.prettyAttributeUiName("axisZ"));
|
||||
assertEquals("Axis t", DescriptorsUtils.prettyAttributeUiName("axisT"));
|
||||
|
||||
assertEquals("The X axis", DescriptorsUtils.prettyAttributeUiName("theXAxis"));
|
||||
assertEquals("The Y axis", DescriptorsUtils.prettyAttributeUiName("theYAxis"));
|
||||
assertEquals("The Z axis", DescriptorsUtils.prettyAttributeUiName("theZAxis"));
|
||||
assertEquals("The t axis", DescriptorsUtils.prettyAttributeUiName("theTAxis"));
|
||||
}
|
||||
|
||||
public void testCapitalize() {
|
||||
assertEquals("UPPER", DescriptorsUtils.capitalize("UPPER"));
|
||||
assertEquals("Lower", DescriptorsUtils.capitalize("lower"));
|
||||
assertEquals("Capital", DescriptorsUtils.capitalize("Capital"));
|
||||
assertEquals("CamelCase", DescriptorsUtils.capitalize("camelCase"));
|
||||
assertEquals("", DescriptorsUtils.capitalize(""));
|
||||
}
|
||||
|
||||
public void testFormatTooltip() {
|
||||
assertEquals("", DescriptorsUtils.formatTooltip(""));
|
||||
|
||||
assertEquals("\"application\"",
|
||||
DescriptorsUtils.formatTooltip(
|
||||
"<code>application</code>"));
|
||||
|
||||
assertEquals("android.content.Intent",
|
||||
DescriptorsUtils.formatTooltip(
|
||||
"{@link android.content.Intent}"));
|
||||
|
||||
assertEquals("FLAG_ACTIVITY_SINGLE_TOP",
|
||||
DescriptorsUtils.formatTooltip(
|
||||
"{@link android.content.Intent#FLAG_ACTIVITY_SINGLE_TOP}"));
|
||||
|
||||
assertEquals("activity-alias",
|
||||
DescriptorsUtils.formatTooltip(
|
||||
"{@link \t #AndroidManifestActivityAlias \tactivity-alias }"));
|
||||
|
||||
assertEquals("\"permission\"",
|
||||
DescriptorsUtils.formatTooltip(
|
||||
"{@link #AndroidManifestPermission <permission>}"));
|
||||
|
||||
assertEquals("and etc.",
|
||||
DescriptorsUtils.formatTooltip(
|
||||
"{@link #IntentCategory <category> and etc. }"));
|
||||
|
||||
assertEquals("Activity.onNewIntent()",
|
||||
DescriptorsUtils.formatTooltip(
|
||||
"{@link android.app.Activity#onNewIntent Activity.onNewIntent()}"));
|
||||
}
|
||||
|
||||
public void testFormatFormText() {
|
||||
ElementDescriptor desc = new ElementDescriptor("application");
|
||||
desc.setSdkUrl(DescriptorsUtils.MANIFEST_SDK_URL + "TagApplication");
|
||||
String docBaseUrl = "http://base";
|
||||
assertEquals("<form><p></p></form>", DescriptorsUtils.formatFormText("", desc, docBaseUrl));
|
||||
|
||||
assertEquals("<form><p><a href=\"http://base/reference/android/R.styleable.html#TagApplication\">application</a></p></form>",
|
||||
DescriptorsUtils.formatFormText(
|
||||
"<code>application</code>",
|
||||
desc, docBaseUrl));
|
||||
|
||||
assertEquals("<form><p><b>android.content.Intent</b></p></form>",
|
||||
DescriptorsUtils.formatFormText(
|
||||
"{@link android.content.Intent}",
|
||||
desc, docBaseUrl));
|
||||
|
||||
assertEquals("<form><p><a href=\"http://base/reference/android/R.styleable.html#AndroidManifestPermission\">AndroidManifestPermission</a></p></form>",
|
||||
DescriptorsUtils.formatFormText(
|
||||
"{@link #AndroidManifestPermission}",
|
||||
desc, docBaseUrl));
|
||||
|
||||
assertEquals("<form><p><a href=\"http://base/reference/android/R.styleable.html#AndroidManifestPermission\">\"permission\"</a></p></form>",
|
||||
DescriptorsUtils.formatFormText(
|
||||
"{@link #AndroidManifestPermission <permission>}",
|
||||
desc, docBaseUrl));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.editors.layout;
|
||||
|
||||
import com.android.ide.eclipse.common.AndroidConstants;
|
||||
import com.android.ide.eclipse.editors.descriptors.AttributeDescriptor;
|
||||
import com.android.ide.eclipse.editors.descriptors.ElementDescriptor;
|
||||
import com.android.ide.eclipse.editors.descriptors.TextAttributeDescriptor;
|
||||
import com.android.ide.eclipse.editors.mock.MockXmlNode;
|
||||
import com.android.ide.eclipse.editors.uimodel.UiElementNode;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class UiElementPullParserTest extends TestCase {
|
||||
|
||||
private UiElementNode ui;
|
||||
private HashMap<String, String> button1Map;
|
||||
private HashMap<String, String> button2Map;
|
||||
private HashMap<String, String> textMap;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
// set up some basic descriptors.
|
||||
// We have button, textview, linear layout, relative layout.
|
||||
// only the layouts have children (all 4 descriptors possible)
|
||||
// Also add some dummy attributes.
|
||||
ElementDescriptor buttonDescriptor = new ElementDescriptor("Button", "Button", "", "",
|
||||
new AttributeDescriptor[] {
|
||||
new TextAttributeDescriptor("name", "name", AndroidConstants.NS_RESOURCES, ""),
|
||||
new TextAttributeDescriptor("text", "text", AndroidConstants.NS_RESOURCES, ""),
|
||||
},
|
||||
new ElementDescriptor[] {}, false);
|
||||
|
||||
ElementDescriptor textDescriptor = new ElementDescriptor("TextView", "TextView", "", "",
|
||||
new AttributeDescriptor[] {
|
||||
new TextAttributeDescriptor("name", "name", AndroidConstants.NS_RESOURCES, ""),
|
||||
new TextAttributeDescriptor("text", "text", AndroidConstants.NS_RESOURCES, ""), },
|
||||
new ElementDescriptor[] {}, false);
|
||||
|
||||
ElementDescriptor linearDescriptor = new ElementDescriptor("LinearLayout", "Linear Layout",
|
||||
"", "",
|
||||
new AttributeDescriptor[] {
|
||||
new TextAttributeDescriptor("orientation", "orientation",
|
||||
AndroidConstants.NS_RESOURCES, ""),
|
||||
},
|
||||
new ElementDescriptor[] { }, false);
|
||||
|
||||
ElementDescriptor relativeDescriptor = new ElementDescriptor("RelativeLayout",
|
||||
"Relative Layout", "", "",
|
||||
new AttributeDescriptor[] {
|
||||
new TextAttributeDescriptor("orientation", "orientation",
|
||||
AndroidConstants.NS_RESOURCES, ""),
|
||||
},
|
||||
new ElementDescriptor[] { }, false);
|
||||
|
||||
ElementDescriptor[] a = new ElementDescriptor[] {
|
||||
buttonDescriptor, textDescriptor, linearDescriptor, relativeDescriptor
|
||||
};
|
||||
|
||||
linearDescriptor.setChildren(a);
|
||||
relativeDescriptor.setChildren(a);
|
||||
|
||||
// document descriptor
|
||||
ElementDescriptor rootDescriptor = new ElementDescriptor("root", "", "", "",
|
||||
new AttributeDescriptor[] { }, a, false);
|
||||
|
||||
|
||||
ui = new UiElementNode(rootDescriptor);
|
||||
|
||||
/* create a dummy XML file.
|
||||
* <LinearLayout android:orientation="vertical">
|
||||
* <Button android:name="button1" android:text="button1text"/>
|
||||
* <RelativeLayout android:orientation="toto">
|
||||
* <Button android:name="button2" android:text="button2text"/>
|
||||
* <TextView android:name="text1" android:text="text1text"/>
|
||||
* </RelativeLayout>
|
||||
* </LinearLayout>
|
||||
*/
|
||||
MockXmlNode button1 = new MockXmlNode(null /* namespace */, "Button", Node.ELEMENT_NODE,
|
||||
null);
|
||||
button1.addAttributes(AndroidConstants.NS_RESOURCES, "name", "button1");
|
||||
button1.addAttributes(AndroidConstants.NS_RESOURCES, "text", "button1text");
|
||||
|
||||
// create a map of the attributes we add to the multi-attribute nodes so that
|
||||
// we can more easily test the values when we parse the XML.
|
||||
// This is due to some attributes showing in a certain order for a node and in a different
|
||||
// order in another node. Since the order doesn't matter, we just simplify the test.
|
||||
button1Map = new HashMap<String, String>();
|
||||
button1Map.put("name", "button1");
|
||||
button1Map.put("text", "button1text");
|
||||
|
||||
MockXmlNode button2 = new MockXmlNode(null /* namespace */, "Button", Node.ELEMENT_NODE,
|
||||
null);
|
||||
button2.addAttributes(AndroidConstants.NS_RESOURCES, "name", "button2");
|
||||
button2.addAttributes(AndroidConstants.NS_RESOURCES, "text", "button2text");
|
||||
|
||||
button2Map = new HashMap<String, String>();
|
||||
button2Map.put("name", "button2");
|
||||
button2Map.put("text", "button2text");
|
||||
|
||||
MockXmlNode text = new MockXmlNode(null /* namespace */, "TextView", Node.ELEMENT_NODE,
|
||||
null);
|
||||
text.addAttributes(AndroidConstants.NS_RESOURCES, "name", "text1");
|
||||
text.addAttributes(AndroidConstants.NS_RESOURCES, "text", "text1text");
|
||||
|
||||
textMap = new HashMap<String, String>();
|
||||
textMap.put("name", "text1");
|
||||
textMap.put("text", "text1text");
|
||||
|
||||
MockXmlNode relative = new MockXmlNode(null /* namespace */, "RelativeLayout",
|
||||
Node.ELEMENT_NODE, new MockXmlNode[] { button2, text });
|
||||
relative.addAttributes(AndroidConstants.NS_RESOURCES, "orientation", "toto");
|
||||
|
||||
MockXmlNode linear = new MockXmlNode(null /* namespace */, "LinearLayout",
|
||||
Node.ELEMENT_NODE, new MockXmlNode[] { button1, relative });
|
||||
linear.addAttributes(AndroidConstants.NS_RESOURCES, "orientation", "vertical");
|
||||
|
||||
MockXmlNode root = new MockXmlNode(null /* namespace */, "root", Node.ELEMENT_NODE,
|
||||
new MockXmlNode[] { linear });
|
||||
|
||||
// put the namespace/prefix in place
|
||||
root.setPrefix(AndroidConstants.NS_RESOURCES, "android");
|
||||
|
||||
// load the xml into the UiElementNode
|
||||
ui.loadFromXmlNode(root);
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testParser() {
|
||||
try {
|
||||
// wrap the parser around the ui element node, and start parsing
|
||||
UiElementPullParser parser = new UiElementPullParser(ui);
|
||||
|
||||
assertEquals(XmlPullParser.START_DOCUMENT, parser.getEventType());
|
||||
|
||||
// top level Linear layout
|
||||
assertEquals(XmlPullParser.START_TAG, parser.next());
|
||||
assertEquals("LinearLayout", parser.getName());
|
||||
assertEquals(1, parser.getAttributeCount());
|
||||
assertEquals("orientation", parser.getAttributeName(0));
|
||||
assertEquals(AndroidConstants.NS_RESOURCES, parser.getAttributeNamespace(0));
|
||||
assertEquals("android", parser.getAttributePrefix(0));
|
||||
assertEquals("vertical", parser.getAttributeValue(0));
|
||||
|
||||
// Button
|
||||
assertEquals(XmlPullParser.START_TAG, parser.next());
|
||||
assertEquals("Button", parser.getName());
|
||||
assertEquals(2, parser.getAttributeCount());
|
||||
check(parser, 0, button1Map);
|
||||
check(parser, 1, button1Map);
|
||||
// end of button
|
||||
assertEquals(XmlPullParser.END_TAG, parser.next());
|
||||
|
||||
// Relative Layout
|
||||
assertEquals(XmlPullParser.START_TAG, parser.next());
|
||||
assertEquals("RelativeLayout", parser.getName());
|
||||
assertEquals(1, parser.getAttributeCount());
|
||||
assertEquals("orientation", parser.getAttributeName(0));
|
||||
assertEquals(AndroidConstants.NS_RESOURCES, parser.getAttributeNamespace(0));
|
||||
assertEquals("android", parser.getAttributePrefix(0));
|
||||
assertEquals("toto", parser.getAttributeValue(0));
|
||||
|
||||
// Button
|
||||
assertEquals(XmlPullParser.START_TAG, parser.next());
|
||||
assertEquals("Button", parser.getName());
|
||||
assertEquals(2, parser.getAttributeCount());
|
||||
check(parser, 0, button2Map);
|
||||
check(parser, 1, button2Map);
|
||||
// end of button
|
||||
assertEquals(XmlPullParser.END_TAG, parser.next());
|
||||
|
||||
// TextView
|
||||
assertEquals(XmlPullParser.START_TAG, parser.next());
|
||||
assertEquals("TextView", parser.getName());
|
||||
assertEquals(2, parser.getAttributeCount());
|
||||
check(parser, 0, textMap);
|
||||
check(parser, 1, textMap);
|
||||
// end of TextView
|
||||
assertEquals(XmlPullParser.END_TAG, parser.next());
|
||||
|
||||
// end of RelativeLayout
|
||||
assertEquals(XmlPullParser.END_TAG, parser.next());
|
||||
|
||||
|
||||
// end of top level linear layout
|
||||
assertEquals(XmlPullParser.END_TAG, parser.next());
|
||||
|
||||
assertEquals(XmlPullParser.END_DOCUMENT, parser.next());
|
||||
} catch (XmlPullParserException e) {
|
||||
e.printStackTrace();
|
||||
assertTrue(false);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives a {@link XmlPullParser} at the START_TAG level, and checks the i-th attribute
|
||||
* to be present in the {@link HashMap} with the proper (name, value)
|
||||
* @param parser
|
||||
* @param i
|
||||
* @param map
|
||||
*/
|
||||
private void check(UiElementPullParser parser, int i, HashMap<String, String> map) {
|
||||
String name = parser.getAttributeName(i);
|
||||
String value = parser.getAttributeValue(i);
|
||||
|
||||
String referenceValue = map.get(name);
|
||||
assertNotNull(referenceValue);
|
||||
assertEquals(referenceValue, value);
|
||||
|
||||
assertEquals(AndroidConstants.NS_RESOURCES, parser.getAttributeNamespace(i));
|
||||
assertEquals("android", parser.getAttributePrefix(i));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* 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.editors.manifest.model;
|
||||
|
||||
import com.android.ide.eclipse.editors.descriptors.ElementDescriptor;
|
||||
import com.android.ide.eclipse.editors.mock.MockXmlNode;
|
||||
import com.android.ide.eclipse.editors.uimodel.UiElementNode;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class UiElementNodeTest extends TestCase {
|
||||
|
||||
private ElementDescriptor e;
|
||||
private UiElementNode ui;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
e = new ElementDescriptor("manifest", new ElementDescriptor[] {
|
||||
new ElementDescriptor("application", new ElementDescriptor[] {
|
||||
new ElementDescriptor("provider"),
|
||||
new ElementDescriptor("activity", new ElementDescriptor[] {
|
||||
new ElementDescriptor("intent-filter")
|
||||
}),
|
||||
}),
|
||||
new ElementDescriptor("permission")
|
||||
});
|
||||
|
||||
ui = new UiElementNode(e);
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
// pass
|
||||
}
|
||||
|
||||
/**
|
||||
* Check initialization values for ui node
|
||||
*/
|
||||
public void testInit() {
|
||||
assertSame(e, ui.getDescriptor());
|
||||
assertNull(ui.getUiParent());
|
||||
assertEquals(0, ui.getUiChildren().size());
|
||||
assertEquals(0, ui.getUiAttributes().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* loadFrom() does nothing if the root node doesn't match what's expected
|
||||
*/
|
||||
public void testLoadFrom_InvalidRoot() {
|
||||
assertEquals(0, ui.getUiChildren().size());
|
||||
MockXmlNode root = new MockXmlNode(null /* namespace */, "blah", Node.ELEMENT_NODE, null);
|
||||
ui.loadFromXmlNode(root);
|
||||
assertEquals(0, ui.getUiChildren().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* UiElementNode.loadFrom should be used to populate an empty ui node from an
|
||||
* existing XML node tree.
|
||||
*/
|
||||
public void testLoadFrom_NewTree_1_Node() {
|
||||
MockXmlNode root = new MockXmlNode(null /* namespace */, "manifest", Node.ELEMENT_NODE,
|
||||
new MockXmlNode[] {
|
||||
new MockXmlNode(null /* namespace */, "application", Node.ELEMENT_NODE, null)
|
||||
});
|
||||
|
||||
// get /manifest
|
||||
ui.loadFromXmlNode(root);
|
||||
assertEquals("manifest", ui.getDescriptor().getXmlName());
|
||||
assertEquals(1, ui.getUiChildren().size());
|
||||
assertEquals(0, ui.getUiAttributes().size());
|
||||
|
||||
// get /manifest/application
|
||||
Iterator<UiElementNode> ui_child_it = ui.getUiChildren().iterator();
|
||||
UiElementNode application = ui_child_it.next();
|
||||
assertEquals("application", application.getDescriptor().getXmlName());
|
||||
assertEquals(0, application.getUiChildren().size());
|
||||
assertEquals(0, application.getUiAttributes().size());
|
||||
}
|
||||
|
||||
|
||||
public void testLoadFrom_NewTree_2_Nodes() {
|
||||
MockXmlNode root = new MockXmlNode(null /* namespace */, "manifest", Node.ELEMENT_NODE,
|
||||
new MockXmlNode[] {
|
||||
new MockXmlNode(null /* namespace */, "application", Node.ELEMENT_NODE, null),
|
||||
new MockXmlNode(null /* namespace */, "permission", Node.ELEMENT_NODE, null),
|
||||
});
|
||||
|
||||
// get /manifest
|
||||
ui.loadFromXmlNode(root);
|
||||
assertEquals("manifest", ui.getDescriptor().getXmlName());
|
||||
assertEquals(2, ui.getUiChildren().size());
|
||||
assertEquals(0, ui.getUiAttributes().size());
|
||||
|
||||
// get /manifest/application
|
||||
Iterator<UiElementNode> ui_child_it = ui.getUiChildren().iterator();
|
||||
UiElementNode application = ui_child_it.next();
|
||||
assertEquals("application", application.getDescriptor().getXmlName());
|
||||
assertEquals(0, application.getUiChildren().size());
|
||||
assertEquals(0, application.getUiAttributes().size());
|
||||
|
||||
// get /manifest/permission
|
||||
UiElementNode first_permission = ui_child_it.next();
|
||||
assertEquals("permission", first_permission.getDescriptor().getXmlName());
|
||||
assertEquals(0, first_permission.getUiChildren().size());
|
||||
assertEquals(0, first_permission.getUiAttributes().size());
|
||||
}
|
||||
|
||||
public void testLoadFrom_NewTree_N_Nodes() {
|
||||
MockXmlNode root = new MockXmlNode(null /* namespace */, "manifest", Node.ELEMENT_NODE,
|
||||
new MockXmlNode[] {
|
||||
new MockXmlNode(null /* namespace */, "application", Node.ELEMENT_NODE,
|
||||
new MockXmlNode[] {
|
||||
new MockXmlNode(null /* namespace */, "activity", Node.ELEMENT_NODE,
|
||||
null),
|
||||
new MockXmlNode(null /* namespace */, "activity", Node.ELEMENT_NODE,
|
||||
new MockXmlNode[] {
|
||||
new MockXmlNode(null /* namespace */, "intent-filter",
|
||||
Node.ELEMENT_NODE, null),
|
||||
}),
|
||||
new MockXmlNode(null /* namespace */, "provider", Node.ELEMENT_NODE,
|
||||
null),
|
||||
new MockXmlNode(null /* namespace */, "provider", Node.ELEMENT_NODE,
|
||||
null),
|
||||
}),
|
||||
new MockXmlNode(null /* namespace */, "permission", Node.ELEMENT_NODE,
|
||||
null),
|
||||
new MockXmlNode(null /* namespace */, "permission", Node.ELEMENT_NODE,
|
||||
null),
|
||||
});
|
||||
|
||||
// get /manifest
|
||||
ui.loadFromXmlNode(root);
|
||||
assertEquals("manifest", ui.getDescriptor().getXmlName());
|
||||
assertEquals(3, ui.getUiChildren().size());
|
||||
assertEquals(0, ui.getUiAttributes().size());
|
||||
|
||||
// get /manifest/application
|
||||
Iterator<UiElementNode> ui_child_it = ui.getUiChildren().iterator();
|
||||
UiElementNode application = ui_child_it.next();
|
||||
assertEquals("application", application.getDescriptor().getXmlName());
|
||||
assertEquals(4, application.getUiChildren().size());
|
||||
assertEquals(0, application.getUiAttributes().size());
|
||||
|
||||
// get /manifest/application/activity #1
|
||||
Iterator<UiElementNode> app_child_it = application.getUiChildren().iterator();
|
||||
UiElementNode first_activity = app_child_it.next();
|
||||
assertEquals("activity", first_activity.getDescriptor().getXmlName());
|
||||
assertEquals(0, first_activity.getUiChildren().size());
|
||||
assertEquals(0, first_activity.getUiAttributes().size());
|
||||
|
||||
// get /manifest/application/activity #2
|
||||
UiElementNode second_activity = app_child_it.next();
|
||||
assertEquals("activity", second_activity.getDescriptor().getXmlName());
|
||||
assertEquals(1, second_activity.getUiChildren().size());
|
||||
assertEquals(0, second_activity.getUiAttributes().size());
|
||||
|
||||
// get /manifest/application/activity #2/intent-filter #1
|
||||
Iterator<UiElementNode> activity_child_it = second_activity.getUiChildren().iterator();
|
||||
UiElementNode intent_filter = activity_child_it.next();
|
||||
assertEquals("intent-filter", intent_filter.getDescriptor().getXmlName());
|
||||
assertEquals(0, intent_filter.getUiChildren().size());
|
||||
assertEquals(0, intent_filter.getUiAttributes().size());
|
||||
|
||||
// get /manifest/application/provider #1
|
||||
UiElementNode first_provider = app_child_it.next();
|
||||
assertEquals("provider", first_provider.getDescriptor().getXmlName());
|
||||
assertEquals(0, first_provider.getUiChildren().size());
|
||||
assertEquals(0, first_provider.getUiAttributes().size());
|
||||
|
||||
// get /manifest/application/provider #2
|
||||
UiElementNode second_provider = app_child_it.next();
|
||||
assertEquals("provider", second_provider.getDescriptor().getXmlName());
|
||||
assertEquals(0, second_provider.getUiChildren().size());
|
||||
assertEquals(0, second_provider.getUiAttributes().size());
|
||||
|
||||
// get /manifest/permission #1
|
||||
UiElementNode first_permission = ui_child_it.next();
|
||||
assertEquals("permission", first_permission.getDescriptor().getXmlName());
|
||||
assertEquals(0, first_permission.getUiChildren().size());
|
||||
assertEquals(0, first_permission.getUiAttributes().size());
|
||||
|
||||
// get /manifest/permission #1
|
||||
UiElementNode second_permission = ui_child_it.next();
|
||||
assertEquals("permission", second_permission.getDescriptor().getXmlName());
|
||||
assertEquals(0, second_permission.getUiChildren().size());
|
||||
assertEquals(0, second_permission.getUiAttributes().size());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.editors.mock;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
class MockNamedNodeMap implements NamedNodeMap {
|
||||
|
||||
/** map for access by namespace/name */
|
||||
private final HashMap<String, HashMap<String, Node>> mNodeMap =
|
||||
new HashMap<String, HashMap<String, Node>>();
|
||||
|
||||
/** list for access by index */
|
||||
private final ArrayList<Node> mNodeList = new ArrayList<Node>();
|
||||
|
||||
public MockXmlNode addAttribute(String namespace, String localName, String value) {
|
||||
MockXmlNode node = new MockXmlNode(namespace, localName, value);
|
||||
|
||||
if (namespace == null) {
|
||||
namespace = ""; // no namespace
|
||||
}
|
||||
|
||||
// get the map for the namespace
|
||||
HashMap<String, Node> map = mNodeMap.get(namespace);
|
||||
if (map == null) {
|
||||
map = new HashMap<String, Node>();
|
||||
mNodeMap.put(namespace, map);
|
||||
}
|
||||
|
||||
|
||||
map.put(localName, node);
|
||||
mNodeList.add(node);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
// --------- NamedNodeMap -------
|
||||
|
||||
public int getLength() {
|
||||
return mNodeList.size();
|
||||
}
|
||||
|
||||
public Node getNamedItem(String name) {
|
||||
HashMap<String, Node> map = mNodeMap.get(""); // no namespace
|
||||
if (map != null) {
|
||||
return map.get(name);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Node getNamedItemNS(String namespaceURI, String localName) throws DOMException {
|
||||
if (namespaceURI == null) {
|
||||
namespaceURI = ""; //no namespace
|
||||
}
|
||||
|
||||
HashMap<String, Node> map = mNodeMap.get(namespaceURI);
|
||||
if (map != null) {
|
||||
return map.get(localName);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Node item(int index) {
|
||||
return mNodeList.get(index);
|
||||
}
|
||||
|
||||
public Node removeNamedItem(String name) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Node setNamedItem(Node arg) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Node setNamedItemNS(Node arg) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* 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.editors.mock;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
/**
|
||||
* A quick mock implementation of NodeList on top of ArrayList.
|
||||
*/
|
||||
public class MockNodeList implements NodeList {
|
||||
|
||||
ArrayList<MockXmlNode> mChildren;
|
||||
|
||||
/**
|
||||
* Constructs a node list from a given children list.
|
||||
*
|
||||
* @param children The children list. Can be null.
|
||||
*/
|
||||
public MockNodeList(MockXmlNode[] children) {
|
||||
mChildren = new ArrayList<MockXmlNode>();
|
||||
if (children != null) {
|
||||
for (MockXmlNode n : children) {
|
||||
mChildren.add(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return mChildren.size();
|
||||
}
|
||||
|
||||
public Node item(int index) {
|
||||
if (index >= 0 && index < mChildren.size()) {
|
||||
return mChildren.get(index);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<MockXmlNode> getArrayList() {
|
||||
return mChildren;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
/*
|
||||
* 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.editors.mock;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.UserDataHandler;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
|
||||
/**
|
||||
* A mock XML node with only a minimal set of information.
|
||||
*/
|
||||
public class MockXmlNode implements Node {
|
||||
|
||||
MockNodeList mNodeList;
|
||||
private String mLocalName;
|
||||
private String mNamespace;
|
||||
private short mNodeType;
|
||||
private MockXmlNode mParent;
|
||||
private MockXmlNode mPreviousSibling;
|
||||
private MockXmlNode mNextSibling;
|
||||
private String mAttrValue;
|
||||
private MockNamedNodeMap mAttributes;
|
||||
|
||||
// namespace stuff only set in the root node
|
||||
/** map from namespace to prefix. */
|
||||
private HashMap<String, String> mNsMap = null;
|
||||
|
||||
/**
|
||||
* Constructs a node from a given children list.
|
||||
*
|
||||
* @param namespace The namespace of the node or null if none
|
||||
* @param localName The XML local node name.
|
||||
* @param node_type One of Node.xxx_NODE constants, e.g. Node.ELEMENT_NODE
|
||||
* @param children The children list. Can be null.
|
||||
*/
|
||||
public MockXmlNode(String namespace, String localName, short node_type,
|
||||
MockXmlNode[] children) {
|
||||
mLocalName = localName;
|
||||
mNamespace = namespace;
|
||||
mNodeType = node_type;
|
||||
mNodeList = new MockNodeList(children);
|
||||
fixNavigation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an attribute node
|
||||
*
|
||||
* @param namespace The namespace of the node or null if none
|
||||
* @param localName The XML local node name.
|
||||
* @param value the value of the attribute
|
||||
*/
|
||||
public MockXmlNode(String namespace, String localName, String value) {
|
||||
mLocalName = localName;
|
||||
mNamespace = namespace;
|
||||
mAttrValue = value;
|
||||
mNodeType = Node.ATTRIBUTE_NODE;
|
||||
mNodeList = new MockNodeList(new MockXmlNode[0]);
|
||||
fixNavigation();
|
||||
}
|
||||
|
||||
private void fixNavigation() {
|
||||
MockXmlNode prev = null;
|
||||
for (MockXmlNode n : mNodeList.getArrayList()) {
|
||||
n.mParent = this;
|
||||
n.mPreviousSibling = prev;
|
||||
if (prev != null) {
|
||||
prev.mNextSibling = n;
|
||||
}
|
||||
n.fixNavigation();
|
||||
prev = n;
|
||||
}
|
||||
}
|
||||
|
||||
public void addAttributes(String namespaceURI, String localName, String value) {
|
||||
if (mAttributes == null) {
|
||||
mAttributes = new MockNamedNodeMap();
|
||||
}
|
||||
|
||||
MockXmlNode node = mAttributes.addAttribute(namespaceURI, localName, value);
|
||||
node.mParent = this;
|
||||
}
|
||||
|
||||
public void setPrefix(String namespace, String prefix) {
|
||||
if (mNsMap == null) {
|
||||
mNsMap = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
mNsMap.put(namespace, prefix);
|
||||
}
|
||||
|
||||
public String getPrefix(String namespace) {
|
||||
if (mNsMap != null) {
|
||||
return mNsMap.get(namespace);
|
||||
}
|
||||
|
||||
return mParent.getPrefix(namespace);
|
||||
}
|
||||
|
||||
|
||||
// ----------- Node methods
|
||||
|
||||
public Node appendChild(Node newChild) throws DOMException {
|
||||
mNodeList.getArrayList().add((MockXmlNode) newChild);
|
||||
return newChild;
|
||||
}
|
||||
|
||||
public NamedNodeMap getAttributes() {
|
||||
return mAttributes;
|
||||
}
|
||||
|
||||
public NodeList getChildNodes() {
|
||||
return mNodeList;
|
||||
}
|
||||
|
||||
public Node getFirstChild() {
|
||||
if (mNodeList.getLength() > 0) {
|
||||
return mNodeList.item(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Node getLastChild() {
|
||||
if (mNodeList.getLength() > 0) {
|
||||
return mNodeList.item(mNodeList.getLength() - 1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Node getNextSibling() {
|
||||
return mNextSibling;
|
||||
}
|
||||
|
||||
public String getNodeName() {
|
||||
return mLocalName;
|
||||
}
|
||||
|
||||
public String getLocalName() {
|
||||
return mLocalName;
|
||||
}
|
||||
|
||||
public short getNodeType() {
|
||||
return mNodeType;
|
||||
}
|
||||
|
||||
public Node getParentNode() {
|
||||
return mParent;
|
||||
}
|
||||
|
||||
public Node getPreviousSibling() {
|
||||
return mPreviousSibling;
|
||||
}
|
||||
|
||||
public boolean hasChildNodes() {
|
||||
return mNodeList.getLength() > 0;
|
||||
}
|
||||
|
||||
public boolean hasAttributes() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new NotImplementedException();
|
||||
//return false;
|
||||
}
|
||||
|
||||
public boolean isSameNode(Node other) {
|
||||
return this == other;
|
||||
}
|
||||
|
||||
public String getNodeValue() throws DOMException {
|
||||
return mAttrValue;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return getPrefix(getNamespaceURI());
|
||||
}
|
||||
|
||||
public String getNamespaceURI() {
|
||||
return mNamespace;
|
||||
}
|
||||
|
||||
|
||||
// --- methods not implemented ---
|
||||
|
||||
public Node cloneNode(boolean deep) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public short compareDocumentPosition(Node other) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getBaseURI() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Object getFeature(String feature, String version) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Document getOwnerDocument() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getTextContent() throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Object getUserData(String key) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Node insertBefore(Node newChild, Node refChild)
|
||||
throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isDefaultNamespace(String namespaceURI) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isEqualNode(Node arg) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isSupported(String feature, String version) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String lookupNamespaceURI(String prefix) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String lookupPrefix(String namespaceURI) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void normalize() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Node removeChild(Node oldChild) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Node replaceChild(Node newChild, Node oldChild)
|
||||
throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setNodeValue(String nodeValue) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setTextContent(String textContent) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Object setUserData(String key, Object data,
|
||||
UserDataHandler handler) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.editors.resources.configurations;
|
||||
|
||||
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$
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.editors.resources.configurations;
|
||||
|
||||
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(KeyboardStateQualifier.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(KeyboardStateQualifier.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$
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.editors.resources.configurations;
|
||||
|
||||
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$
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.editors.resources.configurations;
|
||||
|
||||
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(NavigationMethodQualifier.NavigationMethod.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(NavigationMethodQualifier.NavigationMethod.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(NavigationMethodQualifier.NavigationMethod.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$
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.editors.resources.configurations;
|
||||
|
||||
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$
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.editors.resources.configurations;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class PixelDensityQualifierTest extends TestCase {
|
||||
|
||||
private PixelDensityQualifier pdq;
|
||||
private FolderConfiguration config;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
pdq = new PixelDensityQualifier();
|
||||
config = new FolderConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
pdq = null;
|
||||
config = null;
|
||||
}
|
||||
|
||||
public void testCheckAndSet() {
|
||||
assertEquals(true, pdq.checkAndSet("123dpi", config));//$NON-NLS-1$
|
||||
assertTrue(config.getPixelDensityQualifier() != null);
|
||||
assertEquals(123, config.getPixelDensityQualifier().getValue());
|
||||
assertEquals("123dpi", config.getPixelDensityQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testFailures() {
|
||||
assertEquals(false, pdq.checkAndSet("", config));//$NON-NLS-1$
|
||||
assertEquals(false, pdq.checkAndSet("dpi", config));//$NON-NLS-1$
|
||||
assertEquals(false, pdq.checkAndSet("123DPI", config));//$NON-NLS-1$
|
||||
assertEquals(false, pdq.checkAndSet("123", config));//$NON-NLS-1$
|
||||
assertEquals(false, pdq.checkAndSet("sdfdpi", config));//$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.editors.resources.configurations;
|
||||
|
||||
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$
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.editors.resources.configurations;
|
||||
|
||||
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$
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.editors.resources.configurations;
|
||||
|
||||
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(ScreenOrientationQualifier.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(ScreenOrientationQualifier.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(ScreenOrientationQualifier.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$
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.editors.resources.configurations;
|
||||
|
||||
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(TextInputMethodQualifier.TextInputMethod.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(TextInputMethodQualifier.TextInputMethod.TWELVEKEYS,
|
||||
config.getTextInputMethodQualifier().getValue());
|
||||
assertEquals("12key", config.getTextInputMethodQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testNoKey() {
|
||||
assertEquals(true, timq.checkAndSet("nokey", config)); //$NON-NLS-1$
|
||||
assertTrue(config.getTextInputMethodQualifier() != null);
|
||||
assertEquals(TextInputMethodQualifier.TextInputMethod.NOKEY,
|
||||
config.getTextInputMethodQualifier().getValue());
|
||||
assertEquals("nokey", 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$
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.editors.resources.configurations;
|
||||
|
||||
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(TouchScreenQualifier.TouchScreenType.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(TouchScreenQualifier.TouchScreenType.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(TouchScreenQualifier.TouchScreenType.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$
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.editors.resources.manager;
|
||||
|
||||
import com.android.ide.eclipse.editors.resources.configurations.FolderConfiguration;
|
||||
import com.android.ide.eclipse.editors.resources.configurations.ResourceQualifier;
|
||||
import com.android.ide.eclipse.editors.resources.configurations.KeyboardStateQualifier.KeyboardState;
|
||||
import com.android.ide.eclipse.editors.resources.configurations.NavigationMethodQualifier.NavigationMethod;
|
||||
import com.android.ide.eclipse.editors.resources.configurations.ScreenOrientationQualifier.ScreenOrientation;
|
||||
import com.android.ide.eclipse.editors.resources.configurations.TextInputMethodQualifier.TextInputMethod;
|
||||
import com.android.ide.eclipse.editors.resources.configurations.TouchScreenQualifier.TouchScreenType;
|
||||
import com.android.ide.eclipse.editors.resources.manager.files.IAbstractFolder;
|
||||
import com.android.ide.eclipse.editors.resources.manager.files.IFileWrapper;
|
||||
import com.android.ide.eclipse.editors.resources.manager.files.IFolderWrapper;
|
||||
import com.android.ide.eclipse.mock.FileMock;
|
||||
import com.android.ide.eclipse.mock.FolderMock;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class ConfigMatchTest extends TestCase {
|
||||
private static final String SEARCHED_FILENAME = "main.xml"; //$NON-NLS-1$
|
||||
private static final String MISC1_FILENAME = "foo.xml"; //$NON-NLS-1$
|
||||
private static final String MISC2_FILENAME = "bar.xml"; //$NON-NLS-1$
|
||||
|
||||
private ProjectResources mResources;
|
||||
private ArrayList<ResourceQualifier> mQualifierList;
|
||||
private FolderConfiguration config4;
|
||||
private FolderConfiguration config3;
|
||||
private FolderConfiguration config2;
|
||||
private FolderConfiguration config1;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
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 = (ArrayList<ResourceQualifier>)qualifierListField.get(manager);
|
||||
|
||||
// create the project resources.
|
||||
mResources = new ProjectResources(false /* isFrameworkRepository */);
|
||||
|
||||
// create 2 arrays of IResource. one with the filename being looked up, and one without.
|
||||
// Since the required API uses IResource, we can use MockFolder for them.
|
||||
FileMock[] validMemberList = new FileMock[] {
|
||||
new FileMock(MISC1_FILENAME),
|
||||
new FileMock(SEARCHED_FILENAME),
|
||||
new FileMock(MISC2_FILENAME),
|
||||
};
|
||||
FileMock[] invalidMemberList = new FileMock[] {
|
||||
new FileMock(MISC1_FILENAME),
|
||||
new FileMock(MISC2_FILENAME),
|
||||
};
|
||||
|
||||
// add multiple ResourceFolder to the project resource.
|
||||
FolderConfiguration defaultConfig = getConfiguration(
|
||||
null, // country code
|
||||
null, // network code
|
||||
null, // language
|
||||
null, // region
|
||||
null, // screen orientation
|
||||
null, // dpi
|
||||
null, // touch mode
|
||||
null, // keyboard state
|
||||
null, // text input
|
||||
null, // navigation
|
||||
null); // screen size
|
||||
|
||||
addFolder(mResources, defaultConfig, validMemberList);
|
||||
|
||||
config1 = getConfiguration(
|
||||
null, // country code
|
||||
null, // network code
|
||||
"en", // language
|
||||
null, // region
|
||||
null, // screen orientation
|
||||
null, // dpi
|
||||
null, // touch mode
|
||||
KeyboardState.EXPOSED.getValue(), // keyboard state
|
||||
null, // text input
|
||||
null, // navigation
|
||||
null); // screen size
|
||||
|
||||
addFolder(mResources, config1, validMemberList);
|
||||
|
||||
config2 = getConfiguration(
|
||||
null, // country code
|
||||
null, // network code
|
||||
"en", // language
|
||||
null, // region
|
||||
null, // screen orientation
|
||||
null, // dpi
|
||||
null, // touch mode
|
||||
KeyboardState.HIDDEN.getValue(), // keyboard state
|
||||
null, // text input
|
||||
null, // navigation
|
||||
null); // screen size
|
||||
|
||||
addFolder(mResources, config2, validMemberList);
|
||||
|
||||
config3 = getConfiguration(
|
||||
null, // country code
|
||||
null, // network code
|
||||
"en", // language
|
||||
null, // region
|
||||
ScreenOrientation.LANDSCAPE.getValue(), // screen orientation
|
||||
null, // dpi
|
||||
null, // touch mode
|
||||
null, // keyboard state
|
||||
null, // text input
|
||||
null, // navigation
|
||||
null); // screen size
|
||||
|
||||
addFolder(mResources, config3, validMemberList);
|
||||
|
||||
config4 = getConfiguration(
|
||||
"mcc310", // country code
|
||||
"mnc435", // network code
|
||||
"en", // language
|
||||
"rUS", // region
|
||||
ScreenOrientation.LANDSCAPE.getValue(), // screen orientation
|
||||
"160dpi", // dpi
|
||||
TouchScreenType.FINGER.getValue(), // touch mode
|
||||
KeyboardState.EXPOSED.getValue(), // keyboard state
|
||||
TextInputMethod.QWERTY.getValue(), // text input
|
||||
NavigationMethod.DPAD.getValue(), // navigation
|
||||
"480x320"); // screen size
|
||||
|
||||
addFolder(mResources, config4, invalidMemberList);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
mResources = null;
|
||||
}
|
||||
|
||||
public void test1() {
|
||||
FolderConfiguration testConfig = getConfiguration(
|
||||
"mcc310", // country code
|
||||
"mnc435", // network code
|
||||
"en", // language
|
||||
"rUS", // region
|
||||
ScreenOrientation.LANDSCAPE.getValue(), // screen orientation
|
||||
"160dpi", // dpi
|
||||
TouchScreenType.FINGER.getValue(), // touch mode
|
||||
KeyboardState.EXPOSED.getValue(), // keyboard state
|
||||
TextInputMethod.QWERTY.getValue(), // text input
|
||||
NavigationMethod.DPAD.getValue(), // navigation
|
||||
"480x320"); // screen size
|
||||
|
||||
ResourceFile result = mResources.getMatchingFile(SEARCHED_FILENAME,
|
||||
ResourceFolderType.LAYOUT, testConfig);
|
||||
|
||||
boolean bresult = result.getFolder().getConfiguration().equals(config3);
|
||||
assertEquals(bresult, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link FolderConfiguration}.
|
||||
* @param qualifierValues The list of qualifier values. The length must equals the total number
|
||||
* of Qualifiers. <code>null</code> is permitted and will make the FolderConfiguration not use
|
||||
* this particular qualifier.
|
||||
*/
|
||||
private FolderConfiguration getConfiguration(String... qualifierValues) {
|
||||
FolderConfiguration config = new FolderConfiguration();
|
||||
|
||||
// those must be of the same length
|
||||
assertEquals(qualifierValues.length, mQualifierList.size());
|
||||
|
||||
int index = 0;
|
||||
|
||||
for (ResourceQualifier qualifier : mQualifierList) {
|
||||
String value = qualifierValues[index++];
|
||||
if (value != null) {
|
||||
assertTrue(qualifier.checkAndSet(value, config));
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a folder to the given {@link ProjectResources} with the given
|
||||
* {@link FolderConfiguration}. The folder is filled with files from the provided list.
|
||||
* @param resources the {@link ProjectResources} in which to add the folder.
|
||||
* @param config the {@link FolderConfiguration} for the created folder.
|
||||
* @param memberList the list of files for the folder.
|
||||
*/
|
||||
private void addFolder(ProjectResources resources, FolderConfiguration config,
|
||||
FileMock[] memberList) throws Exception {
|
||||
|
||||
// figure out the folder name based on the configuration
|
||||
String folderName = "layout";
|
||||
if (config.isDefault() == false) {
|
||||
folderName += "-" + config.toString();
|
||||
}
|
||||
|
||||
// create the folder mock
|
||||
FolderMock folder = new FolderMock(folderName, memberList);
|
||||
|
||||
// add it to the resource, and get back a ResourceFolder object.
|
||||
ResourceFolder resFolder = _addProjectResourceFolder(resources, config, folder);
|
||||
|
||||
// and fill it with files from the list.
|
||||
for (FileMock file : memberList) {
|
||||
resFolder.addFile(new SingleResourceFile(new IFileWrapper(file), resFolder));
|
||||
}
|
||||
}
|
||||
|
||||
/** Calls ProjectResource.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(ProjectResources resources,
|
||||
FolderConfiguration config, FolderMock folder) throws Exception {
|
||||
|
||||
Method addMethod = ProjectResources.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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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.editors.resources.manager;
|
||||
|
||||
import com.android.ide.eclipse.editors.resources.configurations.FolderConfiguration;
|
||||
import com.android.ide.eclipse.editors.resources.configurations.ResourceQualifier;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.mock;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.jdt.core.IAccessRule;
|
||||
import org.eclipse.jdt.core.IClasspathAttribute;
|
||||
import org.eclipse.jdt.core.IClasspathEntry;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
public class ClasspathEntryMock implements IClasspathEntry {
|
||||
|
||||
private int mKind;
|
||||
private IPath mPath;
|
||||
|
||||
public ClasspathEntryMock(IPath path, int kind) {
|
||||
mPath = path;
|
||||
mKind = kind;
|
||||
}
|
||||
|
||||
public int getEntryKind() {
|
||||
return mKind;
|
||||
}
|
||||
|
||||
public IPath getPath() {
|
||||
return mPath;
|
||||
}
|
||||
|
||||
// -------- UNIMPLEMENTED METHODS ----------------
|
||||
|
||||
public boolean combineAccessRules() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IAccessRule[] getAccessRules() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int getContentKind() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath[] getExclusionPatterns() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IClasspathAttribute[] getExtraAttributes() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath[] getInclusionPatterns() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getOutputLocation() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IClasspathEntry getResolvedEntry() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getSourceAttachmentPath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getSourceAttachmentRootPath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isExported() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,447 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.mock;
|
||||
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFileState;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.resources.IResourceProxy;
|
||||
import org.eclipse.core.resources.IResourceProxyVisitor;
|
||||
import org.eclipse.core.resources.IResourceVisitor;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourceAttributes;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.core.runtime.content.IContentDescription;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Mock implementation of {@link IFile}.
|
||||
* <p/>Supported methods:
|
||||
* <ul>
|
||||
* </ul>
|
||||
*/
|
||||
public class FileMock implements IFile {
|
||||
|
||||
private String mName;
|
||||
|
||||
public FileMock(String name) {
|
||||
mName = name;
|
||||
}
|
||||
|
||||
// -------- MOCKED METHODS ----------------
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
// -------- UNIMPLEMENTED METHODS ----------------
|
||||
|
||||
public void appendContents(InputStream source, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void appendContents(InputStream source, boolean force, boolean keepHistory,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void create(InputStream source, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void create(InputStream source, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void createLink(IPath localLocation, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void createLink(URI location, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(boolean force, boolean keepHistory, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getCharset() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getCharset(boolean checkImplicit) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getCharsetFor(Reader reader) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IContentDescription getContentDescription() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public InputStream getContents() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public InputStream getContents(boolean force) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int getEncoding() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getFullPath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFileState[] getHistory(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IPath destination, boolean force, boolean keepHistory, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setCharset(String newCharset) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setCharset(String newCharset, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setContents(InputStream source, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setContents(IFileState source, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setContents(InputStream source, boolean force, boolean keepHistory,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setContents(IFileState source, boolean force, boolean keepHistory,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceProxyVisitor visitor, int memberFlags) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor, int depth, boolean includePhantoms)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor, int depth, int memberFlags) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void clearHistory(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IPath destination, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IPath destination, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IProjectDescription description, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IProjectDescription description, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker createMarker(String type) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResourceProxy createProxy() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(boolean force, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void deleteMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean exists() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker findMarker(long id) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker[] findMarkers(String type, boolean includeSubtypes, int depth)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int findMaxProblemSeverity(String type, boolean includeSubtypes, int depth)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getFileExtension() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long getLocalTimeStamp() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getLocation() {
|
||||
return new Path(mName);
|
||||
}
|
||||
|
||||
public URI getLocationURI() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker getMarker(long id) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long getModificationStamp() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IContainer getParent() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getPersistentProperty(QualifiedName key) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getProjectRelativePath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getRawLocation() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public URI getRawLocationURI() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ResourceAttributes getResourceAttributes() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Object getSessionProperty(QualifiedName key) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IWorkspace getWorkspace() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isAccessible() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isDerived() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLinked() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLinked(int options) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLocal(int depth) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isPhantom() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isSynchronized(int depth) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isTeamPrivateMember() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IPath destination, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IPath destination, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IProjectDescription description, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IProjectDescription description, boolean force, boolean keepHistory,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void revertModificationStamp(long value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDerived(boolean isDerived) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setLocal(boolean flag, int depth, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long setLocalTimeStamp(long value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setPersistentProperty(QualifiedName key, String value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setResourceAttributes(ResourceAttributes attributes) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setSessionProperty(QualifiedName key, Object value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setTeamPrivateMember(boolean isTeamPrivate) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void touch(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAdapter(Class adapter) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean contains(ISchedulingRule rule) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isConflicting(ISchedulingRule rule) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Map getPersistentProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Map getSessionProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isDerived(int options) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setHidden(boolean isHidden) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,451 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.mock;
|
||||
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceProxy;
|
||||
import org.eclipse.core.resources.IResourceProxyVisitor;
|
||||
import org.eclipse.core.resources.IResourceVisitor;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourceAttributes;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Mock implementation of {@link IFolder}.
|
||||
* <p/>Supported methods:
|
||||
* <ul>
|
||||
* <li>{@link #getName()}</li>
|
||||
* <li>{@link #members()}</li>
|
||||
* </ul>
|
||||
*/
|
||||
public final class FolderMock implements IFolder {
|
||||
|
||||
private String mName;
|
||||
private IResource[] mMembers;
|
||||
|
||||
public FolderMock(String name) {
|
||||
mName = name;
|
||||
mMembers = new IResource[0];
|
||||
}
|
||||
|
||||
public FolderMock(String name, IResource[] members) {
|
||||
mName = name;
|
||||
mMembers = members;
|
||||
}
|
||||
|
||||
// -------- MOCKED METHODS ----------------
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public IResource[] members() throws CoreException {
|
||||
return mMembers;
|
||||
}
|
||||
|
||||
// -------- UNIMPLEMENTED METHODS ----------------
|
||||
|
||||
public void create(boolean force, boolean local, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void create(int updateFlags, boolean local, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void createLink(IPath localLocation, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void createLink(URI location, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(boolean force, boolean keepHistory, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFile getFile(String name) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFolder getFolder(String name) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IPath destination, boolean force, boolean keepHistory, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean exists(IPath path) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFile[] findDeletedMembersWithHistory(int depth, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource findMember(String name) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource findMember(IPath path) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource findMember(String name, boolean includePhantoms) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource findMember(IPath path, boolean includePhantoms) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getDefaultCharset() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getDefaultCharset(boolean checkImplicit) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFile getFile(IPath path) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFolder getFolder(IPath path) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource[] members(boolean includePhantoms) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource[] members(int memberFlags) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDefaultCharset(String charset) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDefaultCharset(String charset, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceProxyVisitor visitor, int memberFlags) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor, int depth, boolean includePhantoms)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor, int depth, int memberFlags) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void clearHistory(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IPath destination, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IPath destination, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IProjectDescription description, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IProjectDescription description, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker createMarker(String type) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResourceProxy createProxy() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(boolean force, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void deleteMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean exists() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker findMarker(long id) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker[] findMarkers(String type, boolean includeSubtypes, int depth)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int findMaxProblemSeverity(String type, boolean includeSubtypes, int depth)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getFileExtension() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getFullPath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long getLocalTimeStamp() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getLocation() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public URI getLocationURI() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker getMarker(long id) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long getModificationStamp() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IContainer getParent() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getPersistentProperty(QualifiedName key) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getProjectRelativePath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getRawLocation() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public URI getRawLocationURI() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ResourceAttributes getResourceAttributes() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Object getSessionProperty(QualifiedName key) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IWorkspace getWorkspace() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isAccessible() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isDerived() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLinked() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLinked(int options) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLocal(int depth) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isPhantom() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isSynchronized(int depth) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isTeamPrivateMember() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IPath destination, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IPath destination, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IProjectDescription description, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IProjectDescription description, boolean force, boolean keepHistory,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void revertModificationStamp(long value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDerived(boolean isDerived) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setLocal(boolean flag, int depth, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long setLocalTimeStamp(long value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setPersistentProperty(QualifiedName key, String value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setResourceAttributes(ResourceAttributes attributes) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setSessionProperty(QualifiedName key, Object value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setTeamPrivateMember(boolean isTeamPrivate) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void touch(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAdapter(Class adapter) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean contains(ISchedulingRule rule) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isConflicting(ISchedulingRule rule) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Map getPersistentProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Map getSessionProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isDerived(int options) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setHidden(boolean isHidden) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,414 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.mock;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.jdt.core.IBuffer;
|
||||
import org.eclipse.jdt.core.IClasspathEntry;
|
||||
import org.eclipse.jdt.core.IJavaElement;
|
||||
import org.eclipse.jdt.core.IJavaModel;
|
||||
import org.eclipse.jdt.core.IJavaProject;
|
||||
import org.eclipse.jdt.core.IOpenable;
|
||||
import org.eclipse.jdt.core.IPackageFragment;
|
||||
import org.eclipse.jdt.core.IPackageFragmentRoot;
|
||||
import org.eclipse.jdt.core.IRegion;
|
||||
import org.eclipse.jdt.core.IType;
|
||||
import org.eclipse.jdt.core.ITypeHierarchy;
|
||||
import org.eclipse.jdt.core.JavaCore;
|
||||
import org.eclipse.jdt.core.JavaModelException;
|
||||
import org.eclipse.jdt.core.WorkingCopyOwner;
|
||||
import org.eclipse.jdt.core.eval.IEvaluationContext;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class JavaProjectMock implements IJavaProject {
|
||||
|
||||
private IProject mProject;
|
||||
|
||||
private IClasspathEntry[] mEntries;
|
||||
private IPath mOutputLocation;
|
||||
private String mCompilerCompliance = "1.4"; //$NON-NLS-1
|
||||
private String mCompilerSource = "1.4"; //$NON-NLS-1
|
||||
private String mCompilerTarget = "1.4"; //$NON-NLS-1
|
||||
|
||||
public JavaProjectMock(IClasspathEntry[] entries, IPath outputLocation) {
|
||||
mEntries = entries;
|
||||
mOutputLocation = outputLocation;
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
if (mProject == null) {
|
||||
mProject = new ProjectMock();
|
||||
}
|
||||
|
||||
return mProject;
|
||||
}
|
||||
|
||||
|
||||
public void setRawClasspath(IClasspathEntry[] entries, IProgressMonitor monitor)
|
||||
throws JavaModelException {
|
||||
mEntries = entries;
|
||||
}
|
||||
|
||||
public void setRawClasspath(IClasspathEntry[] entries, IPath outputLocation,
|
||||
IProgressMonitor monitor) throws JavaModelException {
|
||||
mEntries = entries;
|
||||
mOutputLocation = outputLocation;
|
||||
}
|
||||
|
||||
public IClasspathEntry[] getRawClasspath() throws JavaModelException {
|
||||
return mEntries;
|
||||
}
|
||||
|
||||
public IPath getOutputLocation() throws JavaModelException {
|
||||
return mOutputLocation;
|
||||
}
|
||||
|
||||
public String getOption(String optionName, boolean inheritJavaCoreOptions) {
|
||||
if (optionName.equals(JavaCore.COMPILER_COMPLIANCE)) {
|
||||
return mCompilerCompliance;
|
||||
} else if (optionName.equals(JavaCore.COMPILER_SOURCE)) {
|
||||
return mCompilerSource;
|
||||
} else if (optionName.equals(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM)) {
|
||||
return mCompilerTarget;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setOption(String optionName, String optionValue) {
|
||||
if (optionName.equals(JavaCore.COMPILER_COMPLIANCE)) {
|
||||
mCompilerCompliance = optionValue;
|
||||
} else if (optionName.equals(JavaCore.COMPILER_SOURCE)) {
|
||||
mCompilerSource = optionValue;
|
||||
} else if (optionName.equals(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM)) {
|
||||
mCompilerTarget = optionValue;
|
||||
} else {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -------- UNIMPLEMENTED METHODS ----------------
|
||||
|
||||
public IClasspathEntry decodeClasspathEntry(String encodedEntry) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String encodeClasspathEntry(IClasspathEntry classpathEntry) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaElement findElement(IPath path) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaElement findElement(IPath path, WorkingCopyOwner owner) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragment findPackageFragment(IPath path) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragmentRoot findPackageFragmentRoot(IPath path) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragmentRoot[] findPackageFragmentRoots(IClasspathEntry entry) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IType findType(String fullyQualifiedName) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IType findType(String fullyQualifiedName, IProgressMonitor progressMonitor)
|
||||
throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IType findType(String fullyQualifiedName, WorkingCopyOwner owner)
|
||||
throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IType findType(String packageName, String typeQualifiedName) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IType findType(String fullyQualifiedName, WorkingCopyOwner owner,
|
||||
IProgressMonitor progressMonitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IType findType(String packageName, String typeQualifiedName,
|
||||
IProgressMonitor progressMonitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IType findType(String packageName, String typeQualifiedName, WorkingCopyOwner owner)
|
||||
throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IType findType(String packageName, String typeQualifiedName, WorkingCopyOwner owner,
|
||||
IProgressMonitor progressMonitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragmentRoot[] getAllPackageFragmentRoots() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Object[] getNonJavaResources() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map getOptions(boolean inheritJavaCoreOptions) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragmentRoot getPackageFragmentRoot(String jarPath) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragmentRoot getPackageFragmentRoot(IResource resource) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragmentRoot[] getPackageFragmentRoots() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragmentRoot[] getPackageFragmentRoots(IClasspathEntry entry) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragment[] getPackageFragments() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String[] getRequiredProjectNames() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IClasspathEntry[] getResolvedClasspath(boolean ignoreUnresolvedEntry)
|
||||
throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean hasBuildState() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean hasClasspathCycle(IClasspathEntry[] entries) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isOnClasspath(IJavaElement element) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isOnClasspath(IResource resource) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEvaluationContext newEvaluationContext() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ITypeHierarchy newTypeHierarchy(IRegion region, IProgressMonitor monitor)
|
||||
throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ITypeHierarchy newTypeHierarchy(IRegion region, WorkingCopyOwner owner,
|
||||
IProgressMonitor monitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ITypeHierarchy newTypeHierarchy(IType type, IRegion region, IProgressMonitor monitor)
|
||||
throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ITypeHierarchy newTypeHierarchy(IType type, IRegion region, WorkingCopyOwner owner,
|
||||
IProgressMonitor monitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath readOutputLocation() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IClasspathEntry[] readRawClasspath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setOptions(Map newOptions) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setOutputLocation(IPath path, IProgressMonitor monitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setRawClasspath(IClasspathEntry[] entries, boolean canModifyResources,
|
||||
IProgressMonitor monitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setRawClasspath(IClasspathEntry[] entries, IPath outputLocation,
|
||||
boolean canModifyResources, IProgressMonitor monitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaElement[] getChildren() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean hasChildren() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean exists() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaElement getAncestor(int ancestorType) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getAttachedJavadoc(IProgressMonitor monitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource getCorrespondingResource() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getElementName() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int getElementType() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getHandleIdentifier() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaModel getJavaModel() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaProject getJavaProject() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IOpenable getOpenable() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaElement getParent() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getPath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaElement getPrimaryElement() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource getResource() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ISchedulingRule getSchedulingRule() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource getUnderlyingResource() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isStructureKnown() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAdapter(Class adapter) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void close() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String findRecommendedLineSeparator() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IBuffer getBuffer() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean hasUnsavedChanges() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isConsistent() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void makeConsistent(IProgressMonitor progress) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void open(IProgressMonitor progress) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void save(IProgressMonitor progress, boolean force) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaElement findElement(String bindingKey, WorkingCopyOwner owner)
|
||||
throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,499 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.mock;
|
||||
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.resources.IProjectNature;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceProxy;
|
||||
import org.eclipse.core.resources.IResourceProxyVisitor;
|
||||
import org.eclipse.core.resources.IResourceVisitor;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourceAttributes;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IPluginDescriptor;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.core.runtime.content.IContentTypeMatcher;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
public class ProjectMock implements IProject {
|
||||
|
||||
public void build(int kind, IProgressMonitor monitor) throws CoreException {
|
||||
// pass
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void build(int kind, String builderName, Map args, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
// pass
|
||||
}
|
||||
|
||||
// -------- UNIMPLEMENTED METHODS ----------------
|
||||
|
||||
|
||||
public void close(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void create(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void create(IProjectDescription description, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(boolean deleteContent, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IContentTypeMatcher getContentTypeMatcher() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IProjectDescription getDescription() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFile getFile(String name) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFolder getFolder(String name) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IProjectNature getNature(String natureId) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public IPath getPluginWorkingLocation(IPluginDescriptor plugin) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IProject[] getReferencedProjects() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IProject[] getReferencingProjects() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getWorkingLocation(String id) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean hasNature(String natureId) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isNatureEnabled(String natureId) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IProjectDescription description, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void open(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void open(int updateFlags, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDescription(IProjectDescription description, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDescription(IProjectDescription description, int updateFlags,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean exists(IPath path) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFile[] findDeletedMembersWithHistory(int depth, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource findMember(String name) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource findMember(IPath path) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource findMember(String name, boolean includePhantoms) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource findMember(IPath path, boolean includePhantoms) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getDefaultCharset() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getDefaultCharset(boolean checkImplicit) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFile getFile(IPath path) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFolder getFolder(IPath path) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource[] members() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource[] members(boolean includePhantoms) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource[] members(int memberFlags) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDefaultCharset(String charset) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDefaultCharset(String charset, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceProxyVisitor visitor, int memberFlags) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor, int depth, boolean includePhantoms)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor, int depth, int memberFlags) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void clearHistory(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IPath destination, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IPath destination, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IProjectDescription description, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IProjectDescription description, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker createMarker(String type) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResourceProxy createProxy() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(boolean force, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void deleteMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean exists() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker findMarker(long id) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker[] findMarkers(String type, boolean includeSubtypes, int depth)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int findMaxProblemSeverity(String type, boolean includeSubtypes, int depth)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getFileExtension() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getFullPath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long getLocalTimeStamp() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getLocation() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public URI getLocationURI() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker getMarker(long id) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long getModificationStamp() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IContainer getParent() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getPersistentProperty(QualifiedName key) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getProjectRelativePath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getRawLocation() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public URI getRawLocationURI() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ResourceAttributes getResourceAttributes() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Object getSessionProperty(QualifiedName key) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IWorkspace getWorkspace() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isAccessible() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isDerived() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLinked() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLinked(int options) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLocal(int depth) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isPhantom() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isSynchronized(int depth) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isTeamPrivateMember() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IPath destination, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IPath destination, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IProjectDescription description, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IProjectDescription description, boolean force, boolean keepHistory,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void revertModificationStamp(long value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDerived(boolean isDerived) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setLocal(boolean flag, int depth, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long setLocalTimeStamp(long value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setPersistentProperty(QualifiedName key, String value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setResourceAttributes(ResourceAttributes attributes) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setSessionProperty(QualifiedName key, Object value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setTeamPrivateMember(boolean isTeamPrivate) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void touch(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Object getAdapter(Class adapter) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean contains(ISchedulingRule rule) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isConflicting(ISchedulingRule rule) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void create(IProjectDescription description, int updateFlags,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Map getPersistentProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Map getSessionProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isDerived(int options) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setHidden(boolean isHidden) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
|
||||
<jardesc>
|
||||
<jar path="jar_example.jar"/>
|
||||
<options buildIfNeeded="true" compress="true" descriptionLocation="/common/tests/data/jar_example.jardesc" exportErrors="false" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
|
||||
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
|
||||
<selectedProjects/>
|
||||
<manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
|
||||
<sealing sealJar="false">
|
||||
<packagesToSeal/>
|
||||
<packagesToUnSeal/>
|
||||
</sealing>
|
||||
</manifest>
|
||||
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
|
||||
<javaElement handleIdentifier="=common/tests<jar.example"/>
|
||||
</selectedElements>
|
||||
</jardesc>
|
||||
@@ -0,0 +1,318 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
-->
|
||||
<resources>
|
||||
<!-- WARNING !!! THIS IS A MOCK FILE. DO NOT USE FOR DOCUMENTATION PURPOSES.
|
||||
This file has been trimmed down to only extract a number of interest cases
|
||||
for unit tests.
|
||||
|
||||
What this contains:
|
||||
- View
|
||||
- ViewGroup
|
||||
- some attributes which format are defined in Theme
|
||||
- orientation, gravity and layout_gravity defined before they are used
|
||||
- ViewGroup_Layout
|
||||
- ViewGroup_MarginLayout
|
||||
- LinearLayout
|
||||
- LinearLayout_Layout
|
||||
- TableLayout
|
||||
|
||||
Note that TableLayout does not have a TableLayout_Layout definition here
|
||||
where these is a class TableLayout.LayoutData.
|
||||
-->
|
||||
|
||||
<!-- These are the standard attributes that make up a complete theme. -->
|
||||
<declare-styleable name="Theme">
|
||||
|
||||
<!-- Defines the scrollbars size. -->
|
||||
<attr name="scrollbarSize" format="dimension" />
|
||||
|
||||
</declare-styleable>
|
||||
|
||||
|
||||
<!-- Standard orientation constant. -->
|
||||
<attr name="orientation">
|
||||
<!-- Defines an horizontal widget. -->
|
||||
<enum name="horizontal" value="0" />
|
||||
<!-- Defines a vertical widget. -->
|
||||
<enum name="vertical" value="1" />
|
||||
</attr>
|
||||
|
||||
<!-- Specifies how to place an object, both
|
||||
its x and y axis, within a larger containing object. -->
|
||||
<attr name="gravity">
|
||||
<!-- Push object to the top of its container, not changing its size. -->
|
||||
<flag name="top" value="0x30" />
|
||||
<!-- Push object to the bottom of its container, not changing its size. -->
|
||||
<flag name="bottom" value="0x50" />
|
||||
<!-- Push object to the left of its container, not changing its size. -->
|
||||
<flag name="left" value="0x03" />
|
||||
<!-- Push object to the right of its container, not changing its size. -->
|
||||
<flag name="right" value="0x05" />
|
||||
<!-- Place object in the vertical center of its container, not changing its size. -->
|
||||
<flag name="center_vertical" value="0x10" />
|
||||
<!-- Grow the vertical size of the object if needed so it completely fills its container. -->
|
||||
<flag name="fill_vertical" value="0x70" />
|
||||
<!-- Place object in the horizontal center of its container, not changing its size. -->
|
||||
<flag name="center_horizontal" value="0x01" />
|
||||
<!-- Grow the horizontal size of the object if needed so it completely fills its container. -->
|
||||
<flag name="fill_horizontal" value="0x07" />
|
||||
<!-- Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. -->
|
||||
<flag name="center" value="0x11" />
|
||||
<!-- Grow the horizontal and vertical size of the object if needed so it completely fills its container. -->
|
||||
<flag name="fill" value="0x77" />
|
||||
</attr>
|
||||
|
||||
<!-- Standard gravity constant that a child can supply to its parent.
|
||||
Defines how to place an object, both
|
||||
its x and y axis, within a larger containing object. -->
|
||||
<attr name="layout_gravity">
|
||||
<!-- Push object to the top of its container, not changing its size. -->
|
||||
<flag name="top" value="0x30" />
|
||||
<!-- Push object to the bottom of its container, not changing its size. -->
|
||||
<flag name="bottom" value="0x50" />
|
||||
<!-- Push object to the left of its container, not changing its size. -->
|
||||
<flag name="left" value="0x03" />
|
||||
<!-- Push object to the right of its container, not changing its size. -->
|
||||
<flag name="right" value="0x05" />
|
||||
<!-- Place object in the vertical center of its container, not changing its size. -->
|
||||
<flag name="center_vertical" value="0x10" />
|
||||
<!-- Grow the vertical size of the object if needed so it completely fills its container. -->
|
||||
<flag name="fill_vertical" value="0x70" />
|
||||
<!-- Place object in the horizontal center of its container, not changing its size. -->
|
||||
<flag name="center_horizontal" value="0x01" />
|
||||
<!-- Grow the horizontal size of the object if needed so it completely fills its container. -->
|
||||
<flag name="fill_horizontal" value="0x07" />
|
||||
<!-- Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. -->
|
||||
<flag name="center" value="0x11" />
|
||||
<!-- Grow the horizontal and vertical size of the object if needed so it completely fills its container. -->
|
||||
<flag name="fill" value="0x77" />
|
||||
</attr>
|
||||
|
||||
<declare-styleable name="View">
|
||||
<!-- NOTE: View does not have a javadoc. Do not place a comment BEFORE View to make sure it
|
||||
is NOT interpreted as Javadoc -->
|
||||
|
||||
<!-- Supply an identifier name for this view, to later retrieve it
|
||||
with {@link android.view.View#findViewById View.findViewById()} or
|
||||
{@link android.app.Activity#findViewById Activity.findViewById()}.
|
||||
This must be a
|
||||
resource reference; typically you set this using the
|
||||
<code>@+</code> syntax to create a new ID resources.
|
||||
For example: <code>android:id="@+id/my_id"</code> which
|
||||
allows you to later retrieve the view
|
||||
with <code>findViewById(R.id.my_id)</code>. -->
|
||||
<attr name="id" format="reference" />
|
||||
|
||||
<!-- Supply a tag for this view containing a String, to be retrieved
|
||||
later with {@link android.view.View#getTag View.getTag()} or
|
||||
searched for with {@link android.view.View#findViewWithTag
|
||||
View.findViewWithTag()}. It is generally preferable to use
|
||||
IDs (through the android:id attribute) instead of tags because
|
||||
they are faster and allow for compile-time type checking. -->
|
||||
<attr name="tag" format="string" />
|
||||
|
||||
<!-- The initial horizontal scroll offset, in pixels.-->
|
||||
<attr name="scrollX" format="dimension" />
|
||||
|
||||
<!-- The initial vertical scroll offset, in pixels. -->
|
||||
<attr name="scrollY" format="dimension" />
|
||||
|
||||
<!-- A drawable to use as the background. This can be either a reference
|
||||
to a full drawable resource (such as a PNG image, 9-patch,
|
||||
XML state list description, etc), or a solid color such as "#ff000000"
|
||||
(black). -->
|
||||
<attr name="background" format="reference|color" />
|
||||
|
||||
<!-- Boolean that controls whether a view can take focus. By default the user can not
|
||||
move focus to a view; by setting this attribute to true the view is
|
||||
allowed to take focus. This value does not impact the behavior of
|
||||
directly calling {@link android.view.View#requestFocus}, which will
|
||||
always request focus regardless of this view. It only impacts where
|
||||
focus navigation will try to move focus. -->
|
||||
<attr name="focusable" format="boolean" />
|
||||
|
||||
<!-- Sets the circumstances under which this view will take focus. There are
|
||||
two choices: "weak" or "normal". The default value is "normal" for
|
||||
any focusable views. The focus type only applies if the view
|
||||
has been set to be focusable. -->
|
||||
<attr name="focusType">
|
||||
<!-- This view is focusable, but only if none of its descendants are already focused. -->
|
||||
<enum name="normal" value="0" />
|
||||
<!-- This view will always claim to be focusable. -->
|
||||
<enum name="weak" value="1" />
|
||||
</attr>
|
||||
|
||||
<!-- Controls the initial visibility of the view. -->
|
||||
<attr name="visibility">
|
||||
<!-- Visible on screen; the default value. -->
|
||||
<enum name="visible" value="0" />
|
||||
<!-- Not displayed, but taken into account during layout (space is left for it). -->
|
||||
<enum name="invisible" value="1" />
|
||||
<!-- Completely hidden, as if the view had not been added. -->
|
||||
<enum name="gone" value="2" />
|
||||
</attr>
|
||||
|
||||
<!-- Defines which scrollbars should be displayed on scrolling or not. -->
|
||||
<attr name="scrollbars">
|
||||
<!-- No scrollbar is displayed. -->
|
||||
<flag name="none" value="0x00000000" />
|
||||
<!-- Displays horizontal scrollbar only. -->
|
||||
<flag name="horizontal" value="0x00000100" />
|
||||
<!-- Displays vertical scrollbar only. -->
|
||||
<flag name="vertical" value="0x00000200" />
|
||||
</attr>
|
||||
|
||||
<!-- Sets the width of vertical scrollbars and height of horizontal scrollbars. -->
|
||||
<attr name="scrollbarSize" />
|
||||
|
||||
<!-- Text to display. (copied from TextView for the extra localization) -->
|
||||
<attr name="text" format="string" localization="suggested" />
|
||||
|
||||
</declare-styleable>
|
||||
|
||||
<!-- Attributes that can be used with a {@link android.view.ViewGroup} or any
|
||||
of its subclasses. Also see {@link #ViewGroup_Layout} for
|
||||
attributes that this class processes in its children. -->
|
||||
<declare-styleable name="ViewGroup">
|
||||
<!-- Defines whether a child is limited to draw inside of its bounds or not.
|
||||
This is useful with animations that scale the size of the children to more
|
||||
than 100% for instance. In such a case, this property should be set to false
|
||||
to allow the children to draw outside of their bounds. The default value of
|
||||
this property is true. -->
|
||||
<attr name="clipChildren" format="boolean" />
|
||||
<!-- Defines the layout animation to use the first time the ViewGroup is laid out.
|
||||
Layout animations can also be started manually after the first layout. -->
|
||||
<attr name="layoutAnimation" format="reference" />
|
||||
<!-- Defines whether a child's animation should be kept when it is over. Keeping
|
||||
the animations is useful with animation whose final state is different from
|
||||
the initial state of the View. This is particularly useful with animation
|
||||
whose fillAfter property is enabled. This property is set to false by default. -->
|
||||
<attr name="persistentDrawingCache">
|
||||
<!-- The drawing cache is not persisted after use. -->
|
||||
<flag name="none" value="0x0" />
|
||||
<!-- The drawing cache is persisted after a layout animation. -->
|
||||
<flag name="animation" value="0x1" />
|
||||
<!-- The drawing cache is persisted after a scroll. -->
|
||||
<flag name="scrolling" value="0x2" />
|
||||
<!-- The drawing cache is always persisted. -->
|
||||
<flag name="all" value="0x3" />
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<!-- This is the basic set of layout attributes that are common to all
|
||||
layout managers. These attributes are specified with the rest of
|
||||
a view's normal attributes (such as {@link android.R.attr#background},
|
||||
but will be parsed by the view's parent and ignored by the child.
|
||||
<p>The values defined here correspond to the base layout attribute
|
||||
class {@link android.view.ViewGroup.LayoutParams}. -->
|
||||
<declare-styleable name="ViewGroup_Layout">
|
||||
<!-- Specifies the basic width of the view. This is a required attribute
|
||||
for any view inside of a containing layout manager. Its value may
|
||||
be a dimension (such as "12dip") for a constant width or one of
|
||||
the special constants. -->
|
||||
<attr name="layout_width" format="dimension">
|
||||
<!-- The view should be as big as its parent (minus padding). -->
|
||||
<enum name="fill_parent" value="-1" />
|
||||
<!-- The view should be only big enough to enclose its content (plus padding). -->
|
||||
<enum name="wrap_content" value="-2" />
|
||||
</attr>
|
||||
|
||||
<!-- Specifies the basic height of the view. This is a required attribute
|
||||
for any view inside of a containing layout manager. Its value may
|
||||
be a dimension (such as "12dip") for a constant height or one of
|
||||
the special constants. -->
|
||||
<attr name="layout_height" format="dimension">
|
||||
<!-- The view should be as big as its parent (minus padding). -->
|
||||
<enum name="fill_parent" value="-1" />
|
||||
<!-- The view should be only big enough to enclose its content (plus padding). -->
|
||||
<enum name="wrap_content" value="-2" />
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<!-- This is the basic set of layout attributes for layout managers that
|
||||
wish to place margins around their child views.
|
||||
These attributes are specified with the rest of
|
||||
a view's normal attributes (such as {@link android.R.attr#background},
|
||||
but will be parsed by the view's parent and ignored by the child.
|
||||
<p>The values defined here correspond to the base layout attribute
|
||||
class {@link android.view.ViewGroup.MarginLayoutParams}. -->
|
||||
<declare-styleable name="ViewGroup_MarginLayout">
|
||||
<attr name="layout_width" />
|
||||
<attr name="layout_height" />
|
||||
<!-- Specifies extra space on the left side of this view.
|
||||
This space is outside this view's bounds. -->
|
||||
<attr name="layout_marginLeft" format="dimension" />
|
||||
<!-- Specifies extra space on the top side of this view.
|
||||
This space is outside this view's bounds. -->
|
||||
<attr name="layout_marginTop" format="dimension" />
|
||||
<!-- Specifies extra space on the right side of this view.
|
||||
This space is outside this view's bounds. -->
|
||||
<attr name="layout_marginRight" format="dimension" />
|
||||
<!-- Specifies extra space on the bottom side of this view.
|
||||
This space is outside this view's bounds. -->
|
||||
<attr name="layout_marginBottom" format="dimension" />
|
||||
</declare-styleable>
|
||||
|
||||
<!-- This is a linear layout. -->
|
||||
<declare-styleable name="LinearLayout">
|
||||
<!-- Should the layout be a column or a row? Use "horizontal"
|
||||
for a row, "vertical" for a column. The default is
|
||||
horizontal. -->
|
||||
<attr name="orientation" />
|
||||
<attr name="baselineAligned" format="boolean|reference" />
|
||||
<!-- When a linear layout is part of another layout that is baseline
|
||||
aligned, it can specify which of its children to baseline align to
|
||||
(i.e which child TextView).-->
|
||||
<attr name="baselineAlignedChildIndex" format="integer|color" min="0"/>
|
||||
<!-- Defines the maximum weight sum. If unspecified, the sum is computed
|
||||
by adding the layout_weight of all of the children. This can be
|
||||
used for instance to give a single child 50% of the total available
|
||||
space by giving it a layout_weight of 0.5 and setting the weightSum
|
||||
to 1.0. -->
|
||||
<attr name="weightSum" format="float" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="LinearLayout_Layout">
|
||||
<attr name="layout_width" />
|
||||
<attr name="layout_height" />
|
||||
<attr name="layout_weight" format="float" />
|
||||
<attr name="layout_gravity" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="TableLayout">
|
||||
<!-- The 0 based index of the columns to stretch. The column indices
|
||||
must be separated by a comma: 1, 2, 5. Illegal and duplicate
|
||||
indices are ignored. You can stretch all columns by using the
|
||||
value "*" instead. Note that a column can be marked stretchable
|
||||
and shrinkable at the same time. -->
|
||||
<attr name="stretchColumns" format="string" />
|
||||
<!-- The 0 based index of the columns to shrink. The column indices
|
||||
must be separated by a comma: 1, 2, 5. Illegal and duplicate
|
||||
indices are ignored. You can shrink all columns by using the
|
||||
value "*" instead. Note that a column can be marked stretchable
|
||||
and shrinkable at the same time. -->
|
||||
<attr name="shrinkColumns" format="string" />
|
||||
<!-- The 0 based index of the columns to collapse. The column indices
|
||||
must be separated by a comma: 1, 2, 5. Illegal and duplicate
|
||||
indices are ignored. -->
|
||||
<attr name="collapseColumns" format="string" />
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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 jar.example;
|
||||
|
||||
public class Class1 {
|
||||
|
||||
public static final int sStaticField = 1;
|
||||
|
||||
/** constructor */
|
||||
public Class1() {
|
||||
int a = 1;
|
||||
}
|
||||
|
||||
public static class InnerStaticClass1 {
|
||||
|
||||
}
|
||||
|
||||
public class InnerClass2 {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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 jar.example;
|
||||
|
||||
public class Class2 extends Class1 {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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 mock_android.view;
|
||||
|
||||
public class View {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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 mock_android.view;
|
||||
|
||||
public class ViewGroup extends View {
|
||||
|
||||
public class MarginLayoutParams extends LayoutParams {
|
||||
|
||||
}
|
||||
|
||||
public class LayoutParams {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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 mock_android.widget;
|
||||
|
||||
import mock_android.view.ViewGroup;
|
||||
|
||||
public class LinearLayout extends ViewGroup {
|
||||
|
||||
public class LayoutParams extends mock_android.view.ViewGroup.LayoutParams {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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 mock_android.widget;
|
||||
|
||||
import mock_android.view.ViewGroup;
|
||||
|
||||
public class TableLayout extends ViewGroup {
|
||||
|
||||
public class LayoutParams extends MarginLayoutParams {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user