Merge commit 'remotes/korg/cupcake' into cupcake_to_master
This commit is contained in:
@@ -5,6 +5,6 @@
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="lib" path="kxml2-2.3.0.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/SdkLib"/>
|
||||
<classpathentry kind="lib" path="/adt/sdklib.jar" sourcepath="/SdkLib"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -13,7 +13,7 @@ Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.jdt.launching,
|
||||
org.eclipse.ui.views,
|
||||
com.android.ide.eclipse.ddms
|
||||
Eclipse-LazyStart: true
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-Vendor: The Android Open Source Project
|
||||
Bundle-ClassPath: kxml2-2.3.0.jar,
|
||||
.
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (C) 2009 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.launch;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class JUnitLaunchConfigDelegateTest extends TestCase {
|
||||
|
||||
public void testAbleToFetchJunitJar() throws IOException {
|
||||
assertTrue(JUnitLaunchConfigDelegate.getJunitJarLocation().endsWith("junit.jar"));
|
||||
}
|
||||
|
||||
public void testFixBootpathExtWithAndroidJar() {
|
||||
String[][] testArray = {
|
||||
null,
|
||||
{ "android.jar"},
|
||||
null,
|
||||
{ "some_other_jar.jar" },
|
||||
};
|
||||
|
||||
String[][] expectedArray = {
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
{ "some_other_jar.jar" },
|
||||
};
|
||||
|
||||
assertEqualsArrays(expectedArray, JUnitLaunchConfigDelegate.fixBootpathExt(testArray));
|
||||
}
|
||||
|
||||
public void testFixBootpathExtWithNoAndroidJar() {
|
||||
String[][] testArray = {
|
||||
null,
|
||||
{ "somejar.jar"},
|
||||
null,
|
||||
};
|
||||
|
||||
String[][] expectedArray = {
|
||||
null,
|
||||
{ "somejar.jar"},
|
||||
null,
|
||||
};
|
||||
|
||||
assertEqualsArrays(expectedArray, JUnitLaunchConfigDelegate.fixBootpathExt(testArray));
|
||||
}
|
||||
|
||||
public void testFixClasspathWithJunitJar() throws IOException {
|
||||
String[] testArray = {
|
||||
JUnitLaunchConfigDelegate.getJunitJarLocation(),
|
||||
};
|
||||
|
||||
String[] expectedArray = {
|
||||
JUnitLaunchConfigDelegate.getJunitJarLocation(),
|
||||
};
|
||||
|
||||
assertEqualsArrays(expectedArray,
|
||||
JUnitLaunchConfigDelegate.fixClasspath(testArray, "test"));
|
||||
}
|
||||
|
||||
public void testFixClasspathWithoutJunitJar() throws IOException {
|
||||
String[] testArray = {
|
||||
"random.jar",
|
||||
};
|
||||
|
||||
String[] expectedArray = {
|
||||
"random.jar",
|
||||
JUnitLaunchConfigDelegate.getJunitJarLocation(),
|
||||
};
|
||||
|
||||
assertEqualsArrays(expectedArray,
|
||||
JUnitLaunchConfigDelegate.fixClasspath(testArray, "test"));
|
||||
}
|
||||
|
||||
|
||||
public void testFixClasspathWithNoJars() throws IOException {
|
||||
String[] testArray = {
|
||||
};
|
||||
|
||||
String[] expectedArray = {
|
||||
JUnitLaunchConfigDelegate.getJunitJarLocation(),
|
||||
};
|
||||
|
||||
assertEqualsArrays(expectedArray,
|
||||
JUnitLaunchConfigDelegate.fixClasspath(testArray, "test"));
|
||||
}
|
||||
|
||||
private void assertEqualsArrays(String[][] a1, String[][] a2) {
|
||||
assertTrue(Arrays.deepEquals(a1, a2));
|
||||
}
|
||||
|
||||
private void assertEqualsArrays(String[] a1, String[] a2) {
|
||||
assertTrue(Arrays.deepEquals(a1, a2));
|
||||
}
|
||||
}
|
||||
@@ -15,15 +15,14 @@
|
||||
*/
|
||||
package com.android.ide.eclipse.tests;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Class for collecting all test cases in an eclipse plugin
|
||||
@@ -31,8 +30,6 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
public class EclipseTestCollector {
|
||||
|
||||
private static final Logger sLogger = Logger.getLogger(EclipseTestCollector.class.getName());
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@@ -49,13 +46,13 @@ public class EclipseTestCollector {
|
||||
*/
|
||||
public void addTestCases(TestSuite suite, Plugin plugin, String expectedPackage) {
|
||||
if (plugin != null) {
|
||||
Enumeration entries = plugin.getBundle().findEntries("/", "*.class", true);
|
||||
Enumeration<?> entries = plugin.getBundle().findEntries("/", "*.class", true);
|
||||
|
||||
while (entries.hasMoreElements()) {
|
||||
URL entry = (URL)entries.nextElement();
|
||||
String filePath = entry.getPath().replace(".class", "");
|
||||
try {
|
||||
Class testClass = getClass(filePath, expectedPackage);
|
||||
Class<?> testClass = getClass(filePath, expectedPackage);
|
||||
if (isTestClass(testClass)) {
|
||||
suite.addTestSuite(testClass);
|
||||
}
|
||||
@@ -69,11 +66,11 @@ public class EclipseTestCollector {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if given class shouk\ld be added to suite
|
||||
* Returns true if given class should be added to suite
|
||||
* @param testClass
|
||||
* @return
|
||||
*/
|
||||
protected boolean isTestClass(Class testClass) {
|
||||
protected boolean isTestClass(Class<?> testClass) {
|
||||
return TestCase.class.isAssignableFrom(testClass) &&
|
||||
Modifier.isPublic(testClass.getModifiers()) &&
|
||||
hasPublicConstructor(testClass);
|
||||
@@ -84,7 +81,7 @@ public class EclipseTestCollector {
|
||||
* @param testClass
|
||||
* @return
|
||||
*/
|
||||
protected boolean hasPublicConstructor(Class testClass) {
|
||||
protected boolean hasPublicConstructor(Class<?> testClass) {
|
||||
try {
|
||||
TestSuite.getTestConstructor(testClass);
|
||||
} catch(NoSuchMethodException e) {
|
||||
@@ -100,7 +97,7 @@ public class EclipseTestCollector {
|
||||
* @return
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
protected Class getClass(String filePath, String expectedPackage) throws ClassNotFoundException {
|
||||
protected Class<?> getClass(String filePath, String expectedPackage) throws ClassNotFoundException {
|
||||
String dotPath = filePath.replace('/', '.');
|
||||
// remove the output folders, by finding where package name starts
|
||||
int index = dotPath.indexOf(expectedPackage);
|
||||
|
||||
@@ -49,7 +49,7 @@ public class UnitTests {
|
||||
* Override parent class to exclude functional tests
|
||||
*/
|
||||
@Override
|
||||
protected boolean isTestClass(Class testClass) {
|
||||
protected boolean isTestClass(Class<?> testClass) {
|
||||
return super.isTestClass(testClass) &&
|
||||
!testClass.getPackage().getName().startsWith(FuncTests.FUNC_TEST_PACKAGE);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ 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;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.HashMap;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Unit Test for {@link FrameworkClassLoader}.
|
||||
* Unit Test for {@link AndroidJarLoader}.
|
||||
*
|
||||
* Uses the classes jar.example.Class1/Class2 stored in tests/data/jar_example.jar.
|
||||
*/
|
||||
@@ -36,7 +36,7 @@ public class AndroidJarLoaderTest extends TestCase {
|
||||
|
||||
private AndroidJarLoader mFrameworkClassLoader;
|
||||
|
||||
/** Creates an instance of {@link FrameworkClassLoader} on our test data JAR */
|
||||
/** Creates an instance of {@link AndroidJarLoader} on our test data JAR */
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
String jarfilePath = AdtTestData.getInstance().getTestFilePath("jar_example.jar"); //$NON-NLS-1$
|
||||
|
||||
@@ -35,7 +35,7 @@ import junit.framework.TestCase;
|
||||
* Test the inner private methods of PlatformDataParser.
|
||||
*
|
||||
* Convention: method names that start with an underscore are actually local wrappers
|
||||
* that call private methods from {@link FrameworkResourceParser} using reflection.
|
||||
* that call private methods from {@link AndroidTargetParser} using reflection.
|
||||
* This is inspired by the Python coding rule which mandates underscores prefixes for
|
||||
* "private" methods.
|
||||
*/
|
||||
@@ -131,6 +131,7 @@ public class LayoutParamsParserTest extends TestCase {
|
||||
//---- access to private methods
|
||||
|
||||
/** Calls the private constructor of the parser */
|
||||
@SuppressWarnings("unused")
|
||||
private AndroidTargetParser _Constructor(String osJarPath) throws Exception {
|
||||
Constructor<AndroidTargetParser> constructor =
|
||||
AndroidTargetParser.class.getDeclaredConstructor(String.class);
|
||||
@@ -139,6 +140,7 @@ public class LayoutParamsParserTest extends TestCase {
|
||||
}
|
||||
|
||||
/** calls the private getLayoutClasses() of the parser */
|
||||
@SuppressWarnings("unused")
|
||||
private void _getLayoutClasses() throws Exception {
|
||||
Method method = AndroidTargetParser.class.getDeclaredMethod("getLayoutClasses"); //$NON-NLS-1$
|
||||
method.setAccessible(true);
|
||||
@@ -146,6 +148,7 @@ public class LayoutParamsParserTest extends TestCase {
|
||||
}
|
||||
|
||||
/** calls the private addGroup() of the parser */
|
||||
@SuppressWarnings("unused")
|
||||
private ViewClassInfo _addGroup(Class<?> groupClass) throws Exception {
|
||||
Method method = LayoutParamsParser.class.getDeclaredMethod("addGroup", //$NON-NLS-1$
|
||||
IClassDescriptor.class);
|
||||
@@ -154,6 +157,7 @@ public class LayoutParamsParserTest extends TestCase {
|
||||
}
|
||||
|
||||
/** calls the private addLayoutParams() of the parser */
|
||||
@SuppressWarnings("unused")
|
||||
private LayoutParamsInfo _addLayoutParams(Class<?> groupClass) throws Exception {
|
||||
Method method = LayoutParamsParser.class.getDeclaredMethod("addLayoutParams", //$NON-NLS-1$
|
||||
IClassDescriptor.class);
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.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,94 @@
|
||||
/*
|
||||
* 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 junit.framework.TestCase;
|
||||
|
||||
import com.android.ide.eclipse.mock.FileMock;
|
||||
|
||||
/**
|
||||
* Tests for {@link AndroidManifestParser}
|
||||
*/
|
||||
public class AndroidManifestParserTest extends TestCase {
|
||||
private AndroidManifestParser mManifest;
|
||||
|
||||
private static final String PACKAGE_NAME = "com.android.testapp"; //$NON-NLS-1$
|
||||
private static final String ACTIVITY_NAME = "com.android.testapp.MainActivity"; //$NON-NLS-1$
|
||||
private static final String LIBRARY_NAME = "android.test.runner"; //$NON-NLS-1$
|
||||
private static final String INSTRUMENTATION_NAME = "android.test.InstrumentationTestRunner"; //$NON-NLS-1$
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
// create the test data
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); //$NON-NLS-1$
|
||||
sb.append("<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n"); //$NON-NLS-1$
|
||||
sb.append(" package=\""); //$NON-NLS-1$
|
||||
sb.append(PACKAGE_NAME);
|
||||
sb.append("\">\n"); //$NON-NLS-1$
|
||||
sb.append(" <application android:icon=\"@drawable/icon\">\n"); //$NON-NLS-1$
|
||||
sb.append(" <activity android:name=\""); //$NON-NLS-1$
|
||||
sb.append(ACTIVITY_NAME);
|
||||
sb.append("\" android:label=\"@string/app_name\">\n"); //$NON-NLS-1$
|
||||
sb.append(" <intent-filter>\n"); //$NON-NLS-1$
|
||||
sb.append(" <action android:name=\"android.intent.action.MAIN\" />\n"); //$NON-NLS-1$
|
||||
sb.append(" <category android:name=\"android.intent.category.LAUNCHER\" />\"\n"); //$NON-NLS-1$
|
||||
sb.append(" <category android:name=\"android.intent.category.DEFAULT\" />\n"); //$NON-NLS-1$
|
||||
sb.append(" </intent-filter>\n"); //$NON-NLS-1$
|
||||
sb.append(" </activity>\n"); //$NON-NLS-1$
|
||||
sb.append(" <uses-library android:name=\""); //$NON-NLS-1$
|
||||
sb.append(LIBRARY_NAME);
|
||||
sb.append("\" />\n"); //$NON-NLS-1$
|
||||
sb.append(" </application>"); //$NON-NLS-1$
|
||||
sb.append(" <instrumentation android:name=\""); //$NON-NLS-1$
|
||||
sb.append(INSTRUMENTATION_NAME);
|
||||
sb.append("\"\n");
|
||||
sb.append(" android:targetPackage=\"com.example.android.apis\"\n");
|
||||
sb.append(" android:label=\"Tests for Api Demos.\"/>\n");
|
||||
sb.append("</manifest>\n"); //$NON-NLS-1$
|
||||
|
||||
FileMock mockFile = new FileMock("AndroidManifest.xml", sb.toString().getBytes());
|
||||
|
||||
mManifest = AndroidManifestParser.parseForData(mockFile);
|
||||
assertNotNull(mManifest);
|
||||
}
|
||||
|
||||
public void testGetPackage() {
|
||||
assertEquals("com.android.testapp", mManifest.getPackage());
|
||||
}
|
||||
|
||||
public void testGetActivities() {
|
||||
assertEquals(1, mManifest.getActivities().length);
|
||||
assertEquals(ACTIVITY_NAME, mManifest.getActivities()[0]);
|
||||
}
|
||||
|
||||
public void testGetLauncherActivity() {
|
||||
assertEquals(ACTIVITY_NAME, mManifest.getLauncherActivity());
|
||||
}
|
||||
|
||||
public void testGetUsesLibraries() {
|
||||
assertEquals(1, mManifest.getUsesLibraries().length);
|
||||
assertEquals(LIBRARY_NAME, mManifest.getUsesLibraries()[0]);
|
||||
}
|
||||
|
||||
public void testGetInstrumentations() {
|
||||
assertEquals(1, mManifest.getInstrumentations().length);
|
||||
assertEquals(INSTRUMENTATION_NAME, mManifest.getInstrumentations()[0]);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,6 @@ 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;
|
||||
|
||||
@@ -47,7 +46,6 @@ public class ConfigMatchTest extends TestCase {
|
||||
private FolderConfiguration config2;
|
||||
private FolderConfiguration config1;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.android.ide.eclipse.editors.resources.configurations.FolderConfigurat
|
||||
import com.android.ide.eclipse.editors.resources.configurations.ResourceQualifier;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
@@ -41,7 +40,6 @@ public class QualifierListTest extends TestCase {
|
||||
mManager = null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testQualifierList() {
|
||||
try {
|
||||
// get the list of qualifier in the resource manager
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.net.URI;
|
||||
@@ -44,16 +45,28 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* Mock implementation of {@link IFile}.
|
||||
*
|
||||
* Optionally backed by an in-memory byte array
|
||||
*
|
||||
* <p/>Supported methods:
|
||||
* <ul>
|
||||
* <li>getName()</li>
|
||||
* <li>getContents()</li>
|
||||
* <li>getContents(boolean force)</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class FileMock implements IFile {
|
||||
|
||||
private String mName;
|
||||
private byte[] mContentData;
|
||||
|
||||
public FileMock(String name) {
|
||||
this(name, new byte[0]);
|
||||
}
|
||||
|
||||
public FileMock(String name, byte[] fileData) {
|
||||
mName = name;
|
||||
mContentData = fileData;
|
||||
}
|
||||
|
||||
// -------- MOCKED METHODS ----------------
|
||||
@@ -62,6 +75,15 @@ public class FileMock implements IFile {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public InputStream getContents() throws CoreException {
|
||||
return new ByteArrayInputStream(mContentData);
|
||||
}
|
||||
|
||||
public InputStream getContents(boolean force) throws CoreException {
|
||||
// ignore force
|
||||
return getContents();
|
||||
}
|
||||
|
||||
// -------- UNIMPLEMENTED METHODS ----------------
|
||||
|
||||
public void appendContents(InputStream source, int updateFlags, IProgressMonitor monitor)
|
||||
@@ -115,14 +137,6 @@ public class FileMock implements IFile {
|
||||
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();
|
||||
}
|
||||
@@ -139,7 +153,8 @@ public class FileMock implements IFile {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IPath destination, boolean force, boolean keepHistory, IProgressMonitor monitor)
|
||||
public void move(IPath destination, boolean force, boolean keepHistory,
|
||||
IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -229,7 +244,8 @@ public class FileMock implements IFile {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void deleteMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {
|
||||
public void deleteMarkers(String type, boolean includeSubtypes, int depth)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -424,24 +440,26 @@ public class FileMock implements IFile {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Map getPersistentProperties() throws CoreException {
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map getPersistentProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public Map getSessionProperties() throws CoreException {
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map getSessionProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDerived(int options) {
|
||||
public boolean isDerived(int options) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
public boolean isHidden() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public void setHidden(boolean isHidden) throws CoreException {
|
||||
public void setHidden(boolean isHidden) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -428,11 +428,11 @@ public final class FolderMock implements IFolder {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Map getPersistentProperties() throws CoreException {
|
||||
public Map<?,?> getPersistentProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Map getSessionProperties() throws CoreException {
|
||||
public Map<?,?> getSessionProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ProjectMock implements IProject {
|
||||
|
||||
public void build(int kind, IProgressMonitor monitor) throws CoreException {
|
||||
@@ -95,7 +96,6 @@ public class ProjectMock implements IProject {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public IPath getPluginWorkingLocation(IPluginDescriptor plugin) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -459,6 +459,8 @@ public class ProjectMock implements IProject {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAdapter(Class adapter) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -476,11 +478,11 @@ public class ProjectMock implements IProject {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Map getPersistentProperties() throws CoreException {
|
||||
public Map<?,?> getPersistentProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Map getSessionProperties() throws CoreException {
|
||||
public Map<?,?> getSessionProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user