Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(579)

Unified Diff: chrome/test/android/javatests/src/org/chromium/chrome/test/util/ApplicationTestUtils.java

Issue 2847263003: Add tests to make sure closed CCT activities are not leaked. (Closed)
Patch Set: Revert debugging Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTestBase.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/android/javatests/src/org/chromium/chrome/test/util/ApplicationTestUtils.java
diff --git a/chrome/test/android/javatests/src/org/chromium/chrome/test/util/ApplicationTestUtils.java b/chrome/test/android/javatests/src/org/chromium/chrome/test/util/ApplicationTestUtils.java
index b7402e37b0ebdc5d325aac51945f05ccc1af6c2d..6f425eff9e2b76dee1c41df8d4c15ebe7e99660f 100644
--- a/chrome/test/android/javatests/src/org/chromium/chrome/test/util/ApplicationTestUtils.java
+++ b/chrome/test/android/javatests/src/org/chromium/chrome/test/util/ApplicationTestUtils.java
@@ -123,6 +123,23 @@ public class ApplicationTestUtils {
/** Finishes the given activity and waits for its onDestroy() to be called. */
public static void finishActivity(final Activity activity) throws Exception {
+ closeActivity(activity, new ActivityCloser<Activity>() {
+ @Override
+ public void close(Activity activity) {
+ activity.finish();
+ }
+ });
+ }
+
+ /**
+ * Encapsulates activity closing logic. Invoked on UI thread.
+ * @param <A> Activity type.
+ */
+ public interface ActivityCloser<A extends Activity> { void close(A activity); }
+
+ /** Closes the given activity and waits for its onDestroy() to be called. */
+ public static <A extends Activity> void closeActivity(
+ final A activity, final ActivityCloser<A> closer) throws Exception {
final CallbackHelper callbackHelper = new CallbackHelper();
final ApplicationStatus.ActivityStateListener activityStateListener =
new ApplicationStatus.ActivityStateListener() {
@@ -143,7 +160,7 @@ public class ApplicationTestUtils {
}
ApplicationStatus.registerStateListenerForActivity(
activityStateListener, activity);
- activity.finish();
+ closer.close(activity);
return false;
}
});
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTestBase.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698