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

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

Issue 1284743003: Add referrer through service connection in custom tabs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java
index 551f01189e2dfee7c3fa07de6f1a55d959037713..56c1b36357050a512b13ad00d8f3be9e9c5948e6 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java
@@ -30,6 +30,7 @@ import org.chromium.base.library_loader.LibraryProcessType;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ChromeTabbedActivity;
+import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.document.BrandColorUtils;
import org.chromium.chrome.browser.document.DocumentActivity;
import org.chromium.chrome.browser.tab.EmptyTabObserver;
@@ -43,6 +44,7 @@ import org.chromium.content.browser.BrowserStartupController.StartupCallback;
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 org.chromium.content_public.browser.LoadUrlParams;
import java.util.ArrayList;
import java.util.concurrent.Callable;
@@ -438,6 +440,46 @@ public class CustomTabActivityTest extends CustomTabActivityTestBase {
}));
}
+ @SmallTest
+ public void testReferrerAddedAutomatically() throws InterruptedException {
+ final IBinder session = warmUpAndLaunchUrlWithSession();
+ assertEquals(mActivity.getIntentDataProvider().getSession(), session);
+ final Context context = getInstrumentation().getTargetContext().getApplicationContext();
+ CustomTabsConnection connection = CustomTabsConnection.getInstance((Application) context);
+ String packageName = context.getPackageName();
+ final String referrer =
+ IntentHandler.constructValidReferrerForAuthority(packageName).getUrl();
+ assertEquals(referrer, connection.getReferrerForSession(session).getUrl());
+
+ final Tab tab = mActivity.getActivityTab();
+ final CallbackHelper pageLoadFinishedHelper = new CallbackHelper();
+ tab.addObserver(new EmptyTabObserver() {
+ @Override
+ public void onLoadUrl(Tab tab, LoadUrlParams params, int loadType) {
+ assertEquals(referrer, params.getReferrer().getUrl());
+ }
+
+ @Override
+ public void onPageLoadFinished(Tab tab) {
+ pageLoadFinishedHelper.notifyCalled();
+ }
+ });
+ assertTrue("CustomTabContentHandler can't handle intent with same session",
+ ThreadUtils.runOnUiThreadBlockingNoException(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ return CustomTabActivity.handleInActiveContentIfNeeded(
+ CustomTabsTestUtils.createMinimalCustomTabIntent(context,
+ TEST_PAGE_2, session));
+ }
+ }));
+ try {
+ pageLoadFinishedHelper.waitForCallback(0);
+ } catch (TimeoutException e) {
+ fail();
+ }
+ }
+
private IBinder warmUpAndLaunchUrlWithSession() throws InterruptedException {
final Context context = getInstrumentation().getTargetContext().getApplicationContext();
CustomTabsConnection connection = CustomTabsConnection.getInstance((Application) context);
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698