diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2009-07-21 11:16:54 -0700 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2009-07-21 11:16:54 -0700 |
commit | cf4550c3198d6b3d92cdc52707fe70d7cc0caa9f (patch) | |
tree | 6510f35ad004f1a4640b48264c290926e8596d7a /test-runner | |
parent | 4cf03d381b2dff908857fceff0bec445f8d44f36 (diff) | |
download | frameworks_base-cf4550c3198d6b3d92cdc52707fe70d7cc0caa9f.zip frameworks_base-cf4550c3198d6b3d92cdc52707fe70d7cc0caa9f.tar.gz frameworks_base-cf4550c3198d6b3d92cdc52707fe70d7cc0caa9f.tar.bz2 |
donut snapshot
Diffstat (limited to 'test-runner')
-rw-r--r-- | test-runner/android/test/InstrumentationTestRunner.java | 26 | ||||
-rw-r--r-- | test-runner/android/test/MoreAsserts.java | 8 | ||||
-rw-r--r-- | test-runner/android/test/TestLocationProvider.java | 3 | ||||
-rw-r--r-- | test-runner/android/test/mock/MockContext.java | 18 | ||||
-rw-r--r-- | test-runner/android/test/mock/MockPackageManager.java | 21 |
5 files changed, 57 insertions, 19 deletions
diff --git a/test-runner/android/test/InstrumentationTestRunner.java b/test-runner/android/test/InstrumentationTestRunner.java index d5e6459..6658fb0 100644 --- a/test-runner/android/test/InstrumentationTestRunner.java +++ b/test-runner/android/test/InstrumentationTestRunner.java @@ -118,7 +118,8 @@ import java.util.List; * <b>To generate EMMA code coverage:</b> * -e coverage true * Note: this requires an emma instrumented build. By default, the code coverage results file - * will be saved as /sdcard/coverage.ec, unless overridden by coverageFile flag (see below) + * will be saved in a /data/<app>/coverage.ec file, unless overridden by coverageFile flag (see + * below) * <p/> * <b> To specify EMMA code coverage results file path:</b> * -e coverageFile /sdcard/myFile.ec @@ -218,6 +219,11 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu */ private static final String REPORT_KEY_SUITE_ASSIGNMENT = "suiteassignment"; /** + * If included in the status or final bundle sent to an IInstrumentationWatcher, this key + * identifies the path to the generated code coverage file. + */ + private static final String REPORT_KEY_COVERAGE_PATH = "coverageFilePath"; + /** * The test is starting. */ public static final int REPORT_VALUE_RESULT_START = 1; @@ -240,7 +246,8 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu */ public static final String REPORT_KEY_STACK = "stack"; - private static final String DEFAULT_COVERAGE_FILE_PATH = "/sdcard/coverage.ec"; + // Default file name for code coverage + private static final String DEFAULT_COVERAGE_FILE_NAME = "coverage.ec"; private static final String LOG_TAG = "InstrumentationTestRunner"; @@ -456,14 +463,20 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu private void generateCoverageReport() { // use reflection to call emma dump coverage method, to avoid // always statically compiling against emma jar - java.io.File coverageFile = new java.io.File(getCoverageFilePath()); + String coverageFilePath = getCoverageFilePath(); + java.io.File coverageFile = new java.io.File(coverageFilePath); try { Class emmaRTClass = Class.forName("com.vladium.emma.rt.RT"); Method dumpCoverageMethod = emmaRTClass.getMethod("dumpCoverageData", coverageFile.getClass(), boolean.class, boolean.class); dumpCoverageMethod.invoke(null, coverageFile, false, false); - + // output path to generated coverage file so it can be parsed by a test harness if + // needed + mResults.putString(REPORT_KEY_COVERAGE_PATH, coverageFilePath); + // also output a more user friendly msg + mResults.putString(Instrumentation.REPORT_KEY_STREAMRESULT, + String.format("Generated code coverage data to %s", coverageFilePath)); } catch (ClassNotFoundException e) { reportEmmaError("Is emma jar on classpath?", e); } catch (SecurityException e) { @@ -481,8 +494,9 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu private String getCoverageFilePath() { if (mCoverageFilePath == null) { - return DEFAULT_COVERAGE_FILE_PATH; - } + return getTargetContext().getFilesDir().getAbsolutePath() + File.separator + + DEFAULT_COVERAGE_FILE_NAME; + } else { return mCoverageFilePath; } diff --git a/test-runner/android/test/MoreAsserts.java b/test-runner/android/test/MoreAsserts.java index 2e74644..9e0d018 100644 --- a/test-runner/android/test/MoreAsserts.java +++ b/test-runner/android/test/MoreAsserts.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.ArrayList; import java.util.regex.MatchResult; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -316,8 +317,11 @@ public final class MoreAsserts { */ public static void assertContentsInOrder( String message, Iterable<?> actual, Object... expected) { - Assert.assertEquals(message, - Arrays.asList(expected), Lists.newArrayList(actual)); + ArrayList actualList = new ArrayList(); + for (Object o : actual) { + actualList.add(o); + } + Assert.assertEquals(message, Arrays.asList(expected), actualList); } /** diff --git a/test-runner/android/test/TestLocationProvider.java b/test-runner/android/test/TestLocationProvider.java index dded745..2ea020e 100644 --- a/test-runner/android/test/TestLocationProvider.java +++ b/test-runner/android/test/TestLocationProvider.java @@ -159,6 +159,9 @@ public class TestLocationProvider extends ILocationProvider.Stub { public void updateNetworkState(int state) { } + public void updateLocation(Location location) { + } + public boolean sendExtraCommand(String command, Bundle extras) { return false; } diff --git a/test-runner/android/test/mock/MockContext.java b/test-runner/android/test/mock/MockContext.java index bd39a14..b83a44d 100644 --- a/test-runner/android/test/mock/MockContext.java +++ b/test-runner/android/test/mock/MockContext.java @@ -24,6 +24,7 @@ import android.content.IntentFilter; import android.content.BroadcastReceiver; import android.content.ServiceConnection; import android.content.SharedPreferences; +import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.res.AssetManager; import android.content.res.Resources; @@ -100,11 +101,21 @@ public class MockContext extends Context { } @Override + public ApplicationInfo getApplicationInfo() { + throw new UnsupportedOperationException(); + } + + @Override public String getPackageResourcePath() { throw new UnsupportedOperationException(); } @Override + public File getSharedPrefsFile(String name) { + throw new UnsupportedOperationException(); + } + + @Override public String getPackageCodePath() { throw new UnsupportedOperationException(); } @@ -387,11 +398,8 @@ public class MockContext extends Context { throw new UnsupportedOperationException(); } - /** - * @hide - */ @Override - public float getApplicationScale() { - throw new UnsupportedOperationException(); + public boolean isRestricted() { + throw new UnsupportedOperationException(); } } diff --git a/test-runner/android/test/mock/MockPackageManager.java b/test-runner/android/test/mock/MockPackageManager.java index bf1629f..d5cd6ef 100644 --- a/test-runner/android/test/mock/MockPackageManager.java +++ b/test-runner/android/test/mock/MockPackageManager.java @@ -16,10 +16,10 @@ package android.test.mock; -import android.app.PendingIntent; import android.content.ComponentName; import android.content.Intent; import android.content.IntentFilter; +import android.content.IntentSender; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.IPackageDeleteObserver; @@ -57,11 +57,10 @@ public class MockPackageManager extends PackageManager { } @Override - public Intent getLaunchIntentForPackage(String packageName) - throws NameNotFoundException { + public Intent getLaunchIntentForPackage(String packageName) { throw new UnsupportedOperationException(); } - + @Override public int[] getPackageGids(String packageName) throws NameNotFoundException { throw new UnsupportedOperationException(); @@ -327,13 +326,13 @@ public class MockPackageManager extends PackageManager { long idealStorageSize, IPackageDataObserver observer) { throw new UnsupportedOperationException(); } - + /** * @hide - to match hiding in superclass */ @Override public void freeStorage( - long idealStorageSize, PendingIntent onFinishedIntent) { + long idealStorageSize, IntentSender pi) { throw new UnsupportedOperationException(); } @@ -388,6 +387,16 @@ public class MockPackageManager extends PackageManager { throw new UnsupportedOperationException(); } + /** + * @hide - to match hiding in superclass + */ + @Override + public void replacePreferredActivity(IntentFilter filter, + int match, ComponentName[] set, ComponentName activity) { + throw new UnsupportedOperationException(); + } + + @Override public void clearPackagePreferredActivities(String packageName) { throw new UnsupportedOperationException(); |