Deprecated platform Android testing APIs
- Deprecated most android.test.* APIs
- Kept ProviderTestCase2 and LoaderTestCase since we don't have a
replacement yet
- Deprecated android.test.suitebuilder
- Added Javadoc to all deprecated APIs with links to corresponding
Android Testing Support Library APIs
- Removed all trailing whitespace
Bug: 22314304
Change-Id: I1b1f0dd5132364110f1dfd4e3eb2dd044700d859
diff --git a/test-runner/src/android/test/ActivityUnitTestCase.java b/test-runner/src/android/test/ActivityUnitTestCase.java
index 40cca90..a191445 100644
--- a/test-runner/src/android/test/ActivityUnitTestCase.java
+++ b/test-runner/src/android/test/ActivityUnitTestCase.java
@@ -32,14 +32,14 @@
/**
* This class provides isolated testing of a single activity. The activity under test will
- * be created with minimal connection to the system infrastructure, and you can inject mocked or
+ * be created with minimal connection to the system infrastructure, and you can inject mocked or
* wrappered versions of many of Activity's dependencies. Most of the work is handled
* automatically here by {@link #setUp} and {@link #tearDown}.
- *
+ *
* <p>If you prefer a functional test, see {@link android.test.ActivityInstrumentationTestCase}.
- *
+ *
* <p>It must be noted that, as a true unit test, your Activity will not be running in the
- * normal system and will not participate in the normal interactions with other Activities.
+ * normal system and will not participate in the normal interactions with other Activities.
* The following methods should not be called in this configuration - most of them will throw
* exceptions:
* <ul>
@@ -54,17 +54,17 @@
* <li>{@link android.app.Activity#isTaskRoot()}</li>
* <li>{@link android.app.Activity#moveTaskToBack(boolean)}</li>
* </ul>
- *
- * <p>The following methods may be called but will not do anything. For test purposes, you can use
- * the methods {@link #getStartedActivityIntent()} and {@link #getStartedActivityRequest()} to
+ *
+ * <p>The following methods may be called but will not do anything. For test purposes, you can use
+ * the methods {@link #getStartedActivityIntent()} and {@link #getStartedActivityRequest()} to
* inspect the parameters that they were called with.
* <ul>
* <li>{@link android.app.Activity#startActivity(Intent)}</li>
* <li>{@link android.app.Activity#startActivityForResult(Intent, int)}</li>
* </ul>
*
- * <p>The following methods may be called but will not do anything. For test purposes, you can use
- * the methods {@link #isFinishCalled()} and {@link #getFinishedActivityRequest()} to inspect the
+ * <p>The following methods may be called but will not do anything. For test purposes, you can use
+ * the methods {@link #isFinishCalled()} and {@link #getFinishedActivityRequest()} to inspect the
* parameters that they were called with.
* <ul>
* <li>{@link android.app.Activity#finish()}</li>
@@ -72,8 +72,12 @@
* <li>{@link android.app.Activity#finishActivity(int requestCode)}</li>
* </ul>
*
+ * @deprecated Write
+ * <a href="{@docRoot}training/testing/unit-testing/local-unit-tests.html">Local Unit Tests</a>
+ * instead.
*/
-public abstract class ActivityUnitTestCase<T extends Activity>
+@Deprecated
+public abstract class ActivityUnitTestCase<T extends Activity>
extends ActivityTestCase {
private static final String TAG = "ActivityUnitTestCase";
@@ -102,31 +106,31 @@
// default value for target context, as a default
mActivityContext = getInstrumentation().getTargetContext();
}
-
+
/**
* Start the activity under test, in the same way as if it was started by
- * {@link android.content.Context#startActivity Context.startActivity()}, providing the
+ * {@link android.content.Context#startActivity Context.startActivity()}, providing the
* arguments it supplied. When you use this method to start the activity, it will automatically
* be stopped by {@link #tearDown}.
- *
- * <p>This method will call onCreate(), but if you wish to further exercise Activity life
+ *
+ * <p>This method will call onCreate(), but if you wish to further exercise Activity life
* cycle methods, you must call them yourself from your test case.
- *
+ *
* <p><i>Do not call from your setUp() method. You must call this method from each of your
* test methods.</i>
- *
+ *
* @param intent The Intent as if supplied to {@link android.content.Context#startActivity}.
* @param savedInstanceState The instance state, if you are simulating this part of the life
* cycle. Typically null.
- * @param lastNonConfigurationInstance This Object will be available to the
- * Activity if it calls {@link android.app.Activity#getLastNonConfigurationInstance()}.
+ * @param lastNonConfigurationInstance This Object will be available to the
+ * Activity if it calls {@link android.app.Activity#getLastNonConfigurationInstance()}.
* Typically null.
* @return Returns the Activity that was created
*/
protected T startActivity(Intent intent, Bundle savedInstanceState,
Object lastNonConfigurationInstance) {
assertFalse("Activity already created", mCreated);
-
+
if (!mAttached) {
assertNotNull(mActivityClass);
setActivity(null);
@@ -154,7 +158,7 @@
assertNotNull(newActivity);
setActivity(newActivity);
-
+
mAttached = true;
}
@@ -165,22 +169,22 @@
}
return result;
}
-
+
@Override
protected void tearDown() throws Exception {
-
+
setActivity(null);
-
- // Scrub out members - protects against memory leaks in the case where someone
+
+ // Scrub out members - protects against memory leaks in the case where someone
// creates a non-static inner class (thus referencing the test case) and gives it to
// someone else to hold onto
scrubClass(ActivityInstrumentationTestCase.class);
super.tearDown();
}
-
+
/**
- * Set the application for use during the test. You must call this function before calling
+ * Set the application for use during the test. You must call this function before calling
* {@link #startActivity}. If your test does not call this method,
* @param application The Application object that will be injected into the Activity under test.
*/
@@ -198,7 +202,7 @@
}
/**
- * This method will return the value if your Activity under test calls
+ * This method will return the value if your Activity under test calls
* {@link android.app.Activity#setRequestedOrientation}.
*/
public int getRequestedOrientation() {
@@ -207,10 +211,10 @@
}
return 0;
}
-
+
/**
- * This method will return the launch intent if your Activity under test calls
- * {@link android.app.Activity#startActivity(Intent)} or
+ * This method will return the launch intent if your Activity under test calls
+ * {@link android.app.Activity#startActivity(Intent)} or
* {@link android.app.Activity#startActivityForResult(Intent, int)}.
* @return The Intent provided in the start call, or null if no start call was made.
*/
@@ -220,9 +224,9 @@
}
return null;
}
-
+
/**
- * This method will return the launch request code if your Activity under test calls
+ * This method will return the launch request code if your Activity under test calls
* {@link android.app.Activity#startActivityForResult(Intent, int)}.
* @return The request code provided in the start call, or -1 if no start call was made.
*/
@@ -234,9 +238,9 @@
}
/**
- * This method will notify you if the Activity under test called
- * {@link android.app.Activity#finish()},
- * {@link android.app.Activity#finishFromChild(Activity)}, or
+ * This method will notify you if the Activity under test called
+ * {@link android.app.Activity#finish()},
+ * {@link android.app.Activity#finishFromChild(Activity)}, or
* {@link android.app.Activity#finishActivity(int)}.
* @return Returns true if one of the listed finish methods was called.
*/
@@ -246,9 +250,9 @@
}
return false;
}
-
+
/**
- * This method will return the request code if the Activity under test called
+ * This method will return the request code if the Activity under test called
* {@link android.app.Activity#finishActivity(int)}.
* @return The request code provided in the start call, or -1 if no finish call was made.
*/
@@ -258,7 +262,7 @@
}
return 0;
}
-
+
/**
* This mock Activity represents the "parent" activity. By injecting this, we allow the user
* to call a few more Activity methods, including:
@@ -269,7 +273,7 @@
* <li>{@link android.app.Activity#finishActivity(int requestCode)}</li>
* <li>{@link android.app.Activity#finishFromChild(Activity child)}</li>
* </ul>
- *
+ *
* TODO: Make this overrideable, and the unit test can look for calls to other methods
*/
private static class MockParent extends Activity {
@@ -303,7 +307,7 @@
public Window getWindow() {
return null;
}
-
+
/**
* By defining this in the parent, we allow the tested activity to call
* <ul>
@@ -316,7 +320,7 @@
mStartedActivityIntent = intent;
mStartedActivityRequest = requestCode;
}
-
+
/**
* By defining this in the parent, we allow the tested activity to call
* <ul>