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 8744564e206908f7f221688f85e8f5180ee18464..9cf17bd47a6496355302a3cb252eb28aaf469b89 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 |
@@ -6,19 +6,18 @@ package org.chromium.chrome.browser.customtabs; |
import android.app.Activity; |
import android.app.Instrumentation; |
-import android.content.ComponentName; |
import android.content.Intent; |
-import android.net.Uri; |
-import android.support.customtabs.CustomTabsIntent; |
import org.chromium.chrome.browser.DeferredStartupHandler; |
-import org.chromium.chrome.browser.document.ChromeLauncherActivity; |
+import org.chromium.chrome.browser.tab.EmptyTabObserver; |
import org.chromium.chrome.browser.tab.Tab; |
-import org.chromium.chrome.browser.util.IntentUtils; |
import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
+import org.chromium.content.browser.test.util.CallbackHelper; |
import org.chromium.content.browser.test.util.Criteria; |
import org.chromium.content.browser.test.util.CriteriaHelper; |
+import java.util.concurrent.TimeoutException; |
+ |
/** |
* Base class for all instrumentation tests that require a {@link CustomTabActivity}. |
*/ |
@@ -50,7 +49,7 @@ public abstract class CustomTabActivityTestBase extends |
* Start a {@link CustomTabActivity} with given {@link Intent}, and wait till a tab is |
* initialized. |
*/ |
- protected void startCustomTabActivityWithIntent(Intent intent) throws InterruptedException { |
+ protected void startCustomTabActivityWithIntent(Intent intent)throws InterruptedException { |
startActivityCompletely(intent); |
assertTrue("Tab never selected/initialized.", |
CriteriaHelper.pollForUIThreadCriteria(new Criteria() { |
@@ -59,30 +58,27 @@ public abstract class CustomTabActivityTestBase extends |
return getActivity().getActivityTab() != null; |
} |
})); |
- Tab tab = getActivity().getActivityTab(); |
- |
+ final Tab tab = getActivity().getActivityTab(); |
+ final CallbackHelper pageLoadFinishedHelper = new CallbackHelper(); |
+ tab.addObserver(new EmptyTabObserver() { |
+ @Override |
+ public void onPageLoadFinished(Tab tab) { |
+ pageLoadFinishedHelper.notifyCalled(); |
+ } |
+ }); |
+ try { |
+ pageLoadFinishedHelper.waitForCallback(0); |
+ } catch (TimeoutException e) { |
+ fail(); |
+ } |
assertTrue("Deferred startup never completed", |
CriteriaHelper.pollForUIThreadCriteria(new Criteria() { |
@Override |
public boolean isSatisfied() { |
return DeferredStartupHandler.getInstance().isDeferredStartupComplete(); |
} |
- })); |
- |
+ }, 5000, 200)); |
assertNotNull(tab); |
assertNotNull(tab.getView()); |
} |
- |
- /** |
- * Creates the simplest intent that is sufficient to let {@link ChromeLauncherActivity} launch |
- * the {@link CustomTabActivity}. |
- */ |
- protected Intent createMinimalCustomTabIntent(String url) { |
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); |
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
- intent.setComponent(new ComponentName(getInstrumentation().getTargetContext(), |
- ChromeLauncherActivity.class)); |
- IntentUtils.safePutBinderExtra(intent, CustomTabsIntent.EXTRA_SESSION, null); |
- return intent; |
- } |
} |