summaryrefslogtreecommitdiffstats
path: root/test-runner
diff options
context:
space:
mode:
authorBrett Chabot <brettchabot@android.com>2010-02-11 20:07:17 -0800
committerBrett Chabot <brettchabot@android.com>2010-02-12 11:09:26 -0800
commit90762d35a99e32ed22cdfb1f81252544ee22e30b (patch)
treeeadc40dab7605e4ccce6493bafc211b1becfb98b /test-runner
parent30e694aea1b7fac450ff3c668094dcfe921e9421 (diff)
downloadframeworks_base-90762d35a99e32ed22cdfb1f81252544ee22e30b.zip
frameworks_base-90762d35a99e32ed22cdfb1f81252544ee22e30b.tar.gz
frameworks_base-90762d35a99e32ed22cdfb1f81252544ee22e30b.tar.bz2
Modify ActivityInstrumentationTestCase2 to not require hardcoded package name.
Deprecate old constructor. Bug 2440167
Diffstat (limited to 'test-runner')
-rw-r--r--test-runner/android/test/ActivityInstrumentationTestCase.java24
-rw-r--r--test-runner/android/test/ActivityInstrumentationTestCase2.java31
2 files changed, 32 insertions, 23 deletions
diff --git a/test-runner/android/test/ActivityInstrumentationTestCase.java b/test-runner/android/test/ActivityInstrumentationTestCase.java
index f6b31ad..d12ff6f 100644
--- a/test-runner/android/test/ActivityInstrumentationTestCase.java
+++ b/test-runner/android/test/ActivityInstrumentationTestCase.java
@@ -40,29 +40,26 @@ public abstract class ActivityInstrumentationTestCase<T extends Activity>
boolean mInitialTouchMode = false;
/**
- * <b>NOTE:</b> The parameter <i>pkg</i> must refer to the package identifier of the
- * package hosting the activity to be launched, which is specified in the AndroidManifest.xml
- * file. This is not necessarily the same as the java package name.
+ * Creates an {@link ActivityInstrumentationTestCase} in non-touch mode.
*
- * @param pkg The package hosting the activity to be launched.
- * @param activityClass The activity to test.
+ * @param pkg ignored - no longer in use.
+ * @param activityClass The activity to test. This must be a class in the instrumentation
+ * targetPackage specified in the AndroidManifest.xml
*/
public ActivityInstrumentationTestCase(String pkg, Class<T> activityClass) {
this(pkg, activityClass, false);
}
/**
- * <b>NOTE:</b> The parameter <i>pkg</i> must refer to the package identifier of the
- * package hosting the activity to be launched, which is specified in the AndroidManifest.xml
- * file. This is not necessarily the same as the java package name.
- *
- * @param pkg The package hosting the activity to be launched.
- * @param activityClass The activity to test.
+ * Creates an {@link ActivityInstrumentationTestCase}.
+ *
+ * @param pkg ignored - no longer in use.
+ * @param activityClass The activity to test. This must be a class in the instrumentation
+ * targetPackage specified in the AndroidManifest.xml
* @param initialTouchMode true = in touch mode
*/
public ActivityInstrumentationTestCase(String pkg, Class<T> activityClass,
boolean initialTouchMode) {
- mPackage = pkg;
mActivityClass = activityClass;
mInitialTouchMode = initialTouchMode;
}
@@ -77,7 +74,8 @@ public abstract class ActivityInstrumentationTestCase<T extends Activity>
super.setUp();
// set initial touch mode
getInstrumentation().setInTouchMode(mInitialTouchMode);
- setActivity(launchActivity(mPackage, mActivityClass, null));
+ final String targetPackageName = getInstrumentation().getTargetContext().getPackageName();
+ setActivity(launchActivity(targetPackageName, mActivityClass, null));
}
@Override
diff --git a/test-runner/android/test/ActivityInstrumentationTestCase2.java b/test-runner/android/test/ActivityInstrumentationTestCase2.java
index 679f634..e8570bd 100644
--- a/test-runner/android/test/ActivityInstrumentationTestCase2.java
+++ b/test-runner/android/test/ActivityInstrumentationTestCase2.java
@@ -40,21 +40,31 @@ import java.lang.reflect.Method;
*/
public abstract class ActivityInstrumentationTestCase2<T extends Activity>
extends ActivityTestCase {
- String mPackage;
Class<T> mActivityClass;
boolean mInitialTouchMode = false;
Intent mActivityIntent = null;
/**
- * <b>NOTE:</b> The parameter <i>pkg</i> must refer to the package identifier of the
- * package hosting the activity to be launched, which is specified in the AndroidManifest.xml
- * file. This is not necessarily the same as the java package name.
- *
- * @param pkg The package hosting the activity to be launched.
- * @param activityClass The activity to test.
+ * Creates an {@link ActivityInstrumentationTestCase2}.
+ *
+ * @param pkg ignored - no longer in use.
+ * @param activityClass The activity to test. This must be a class in the instrumentation
+ * targetPackage specified in the AndroidManifest.xml
+ *
+ * @deprecated use {@link #ActivityInstrumentationTestCase2(Class)} instead
*/
+ @Deprecated
public ActivityInstrumentationTestCase2(String pkg, Class<T> activityClass) {
- mPackage = pkg;
+ this(activityClass);
+ }
+
+ /**
+ * Creates an {@link ActivityInstrumentationTestCase2}.
+ *
+ * @param activityClass The activity to test. This must be a class in the instrumentation
+ * targetPackage specified in the AndroidManifest.xml
+ */
+ public ActivityInstrumentationTestCase2(Class<T> activityClass) {
mActivityClass = activityClass;
}
@@ -82,11 +92,12 @@ public abstract class ActivityInstrumentationTestCase2<T extends Activity>
if (a == null) {
// set initial touch mode
getInstrumentation().setInTouchMode(mInitialTouchMode);
+ final String targetPackage = getInstrumentation().getTargetContext().getPackageName();
// inject custom intent, if provided
if (mActivityIntent == null) {
- a = launchActivity(mPackage, mActivityClass, null);
+ a = launchActivity(targetPackage, mActivityClass, null);
} else {
- a = launchActivityWithIntent(mPackage, mActivityClass, mActivityIntent);
+ a = launchActivityWithIntent(targetPackage, mActivityClass, mActivityIntent);
}
setActivity(a);
}