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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTestBase.java

Issue 2866213003: Revert of Add tests to make sure closed CCT activities are not leaked. (Closed)
Patch Set: 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
Index: chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTestBase.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTestBase.java b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTestBase.java
index d21d4e33b64ab2ff13abce42b455e5c514bbf6a0..92df68327eff74d662ac4012037334400d204200 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTestBase.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTestBase.java
@@ -19,13 +19,9 @@
import org.chromium.content.browser.test.util.CriteriaHelper;
import java.lang.ref.WeakReference;
-import java.util.Collections;
-import java.util.IdentityHashMap;
import java.util.List;
-import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicReference;
/**
* Base class for all instrumentation tests that require a {@link CustomTabActivity}.
@@ -46,26 +42,8 @@
@Override
protected void startActivityCompletely(Intent intent) {
- setActivity(launchCustomTabActivityCompletely(intent));
- }
-
- /**
- * Start a {@link CustomTabActivity} with given {@link Intent} and return the
- * activity started. Note that this function doesn't wait for the activity's
- * tab to initialize.
- */
- protected CustomTabActivity launchCustomTabActivityCompletely(Intent intent) {
- final Set<Activity> currentActivities =
- Collections.newSetFromMap(new IdentityHashMap<Activity, Boolean>());
- for (WeakReference<Activity> ref : ApplicationStatus.getRunningActivities()) {
- Activity currentActivity = ref.get();
- if (currentActivity != null) {
- currentActivities.add(currentActivity);
- }
- }
Activity activity = getInstrumentation().startActivitySync(intent);
assertNotNull("Main activity did not start", activity);
- final AtomicReference<CustomTabActivity> launchedActivity = new AtomicReference<>();
CriteriaHelper.pollUiThread(new Criteria() {
@Override
public boolean isSatisfied() {
@@ -73,16 +51,14 @@
for (WeakReference<Activity> ref : list) {
Activity activity = ref.get();
if (activity == null) continue;
- if (currentActivities.contains(activity)) continue;
if (activity instanceof CustomTabActivity) {
- launchedActivity.set((CustomTabActivity) activity);
+ setActivity(activity);
return true;
}
}
return false;
}
});
- return launchedActivity.get();
}
/**
@@ -91,19 +67,13 @@
*/
protected void startCustomTabActivityWithIntent(Intent intent) throws InterruptedException {
startActivityCompletely(intent);
- waitForCustomTab(getActivity());
- }
-
- /** Wait till the activity's tab is initialized. */
- protected static void waitForCustomTab(final CustomTabActivity activity)
- throws InterruptedException {
CriteriaHelper.pollUiThread(new Criteria("Tab never selected/initialized.") {
@Override
public boolean isSatisfied() {
- return activity.getActivityTab() != null;
+ return getActivity().getActivityTab() != null;
}
});
- final Tab tab = activity.getActivityTab();
+ final Tab tab = getActivity().getActivityTab();
final CallbackHelper pageLoadFinishedHelper = new CallbackHelper();
tab.addObserver(new EmptyTabObserver() {
@Override
@@ -129,4 +99,4 @@
assertNotNull(tab.getView());
assertTrue(tab.isCurrentlyACustomTab());
}
-}
+}

Powered by Google App Engine
This is Rietveld 408576698