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

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

Issue 1278473005: Reland : Add custom tabs tests using intents with non-null sessions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add startup callback on UI thread. Created 5 years, 4 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 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;
- }
}

Powered by Google App Engine
This is Rietveld 408576698