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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/document/DocumentModeReferrerTest.java

Issue 2011433003: [Hera] Excise a bunch of document mode code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Deprecate histograms, clean up another unused one. Created 4 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/document/DocumentModeReferrerTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/document/DocumentModeReferrerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/document/DocumentModeReferrerTest.java
deleted file mode 100644
index 8f19189d0d7e14546b7a80b1da1cf9da27253301..0000000000000000000000000000000000000000
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/document/DocumentModeReferrerTest.java
+++ /dev/null
@@ -1,259 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.chrome.browser.document;
-
-import android.app.Instrumentation;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Build;
-import android.provider.Browser;
-import android.test.suitebuilder.annotation.MediumTest;
-
-import org.chromium.base.test.util.DisabledTest;
-import org.chromium.base.test.util.MinAndroidSdkLevel;
-import org.chromium.chrome.browser.ChromeApplication;
-import org.chromium.chrome.browser.IntentHandler;
-import org.chromium.chrome.browser.tab.Tab;
-import org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver;
-import org.chromium.chrome.browser.tabmodel.document.DocumentTabModelSelector;
-import org.chromium.chrome.test.util.ApplicationTestUtils;
-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.concurrent.Callable;
-
-/**
- * Tests that Document mode handles referrers correctly.
- */
-@MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP)
-@DisabledTest
-public class DocumentModeReferrerTest extends DocumentModeTestBase {
- private static final int ACTIVITY_START_TIMEOUT = 1000;
-
- private String mUrl;
- private String mReferrer;
- private TabModelSelectorTabObserver mObserver;
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- if (mObserver != null) {
- mObserver.destroy();
- mObserver = null;
- }
- }
-
- @MediumTest
- public void testReferrerExtra() throws Exception {
- Instrumentation.ActivityMonitor monitor = getInstrumentation().addMonitor(
- DocumentActivity.class.getName(), null, false);
- ApplicationTestUtils.launchChrome(mContext);
-
- // Wait for tab model to become initialized.
- CriteriaHelper.pollInstrumentationThread(new Criteria() {
- @Override
- public boolean isSatisfied() {
- return ChromeApplication.isDocumentTabModelSelectorInitializedForTests();
- }
- });
-
- DocumentTabModelSelector selector = ChromeApplication.getDocumentTabModelSelector();
- mObserver = new TabModelSelectorTabObserver(selector) {
- @Override
- public void onLoadUrl(Tab tab, LoadUrlParams params, int loadType) {
- mUrl = params.getUrl();
- if (params.getReferrer() != null) {
- mReferrer = params.getReferrer().getUrl();
- }
- }
- };
-
- // Wait for document activity from the main intent to launch before firing the next
- // intent.
- DocumentActivity doc = (DocumentActivity) monitor.waitForActivityWithTimeout(
- ACTIVITY_START_TIMEOUT);
- assertNotNull("DocumentActivity did not start", doc);
-
- mUrl = null;
- mReferrer = null;
-
- // Fire the Intent with EXTRA_REFERRER.
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(URL_1));
- intent.setClassName(mContext.getPackageName(), ChromeLauncherActivity.class.getName());
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(Intent.EXTRA_REFERRER, Uri.parse(URL_2));
- IntentHandler.addTrustedIntentExtras(intent, mContext);
- mContext.startActivity(intent);
-
- CriteriaHelper.pollUiThread(Criteria.equals(URL_1, new Callable<String>() {
- @Override
- public String call() {
- return mUrl;
- }
- }));
-
- assertEquals(URL_2, mReferrer);
- }
-
- @MediumTest
- public void testReferrerExtraAndroidApp() throws Exception {
- Instrumentation.ActivityMonitor monitor = getInstrumentation().addMonitor(
- DocumentActivity.class.getName(), null, false);
- ApplicationTestUtils.launchChrome(mContext);
-
- // Wait for tab model to become initialized.
- CriteriaHelper.pollInstrumentationThread(new Criteria() {
- @Override
- public boolean isSatisfied() {
- return ChromeApplication.isDocumentTabModelSelectorInitializedForTests();
- }
- });
-
- DocumentTabModelSelector selector = ChromeApplication.getDocumentTabModelSelector();
- mObserver = new TabModelSelectorTabObserver(selector) {
- @Override
- public void onLoadUrl(Tab tab, LoadUrlParams params, int loadType) {
- mUrl = params.getUrl();
- if (params.getReferrer() != null) {
- mReferrer = params.getReferrer().getUrl();
- }
- }
- };
-
- // Wait for document activity from the main intent to launch before firing the next
- // intent.
- DocumentActivity doc = (DocumentActivity) monitor.waitForActivityWithTimeout(
- ACTIVITY_START_TIMEOUT);
- assertNotNull("DocumentActivity did not start", doc);
-
- mUrl = null;
- mReferrer = null;
-
- // Fire the Intent with EXTRA_REFERRER using android-app scheme.
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(URL_1));
- intent.setClassName(mContext.getPackageName(), ChromeLauncherActivity.class.getName());
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- final String androidAppReferrer = "android-app://com.imdb.mobile/http/www.imdb.com";
- intent.putExtra(Intent.EXTRA_REFERRER, Uri.parse(androidAppReferrer));
- mContext.startActivity(intent);
-
- CriteriaHelper.pollUiThread(Criteria.equals(URL_1, new Callable<String>() {
- @Override
- public String call() {
- return mUrl;
- }
- }));
-
- assertEquals(androidAppReferrer, mReferrer);
- }
-
- @MediumTest
- public void testReferrerExtraNotAndroidApp() throws Exception {
- Instrumentation.ActivityMonitor monitor = getInstrumentation().addMonitor(
- DocumentActivity.class.getName(), null, false);
- ApplicationTestUtils.launchChrome(mContext);
-
- // Wait for tab model to become initialized.
- CriteriaHelper.pollInstrumentationThread(new Criteria() {
- @Override
- public boolean isSatisfied() {
- return ChromeApplication.isDocumentTabModelSelectorInitializedForTests();
- }
- });
-
- DocumentTabModelSelector selector = ChromeApplication.getDocumentTabModelSelector();
- mObserver = new TabModelSelectorTabObserver(selector) {
- @Override
- public void onLoadUrl(Tab tab, LoadUrlParams params, int loadType) {
- mUrl = params.getUrl();
- if (params.getReferrer() != null) {
- mReferrer = params.getReferrer().getUrl();
- }
- }
- };
-
- // Wait for document activity from the main intent to launch before firing the next
- // intent.
- DocumentActivity doc = (DocumentActivity) monitor.waitForActivityWithTimeout(
- ACTIVITY_START_TIMEOUT);
- assertNotNull("DocumentActivity did not start", doc);
-
- mUrl = null;
- mReferrer = null;
-
- // Fire the third-party Intent with EXTRA_REFERRER using a regular URL.
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(URL_1));
- intent.setClassName(mContext.getPackageName(), ChromeLauncherActivity.class.getName());
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- final String nonAppExtra = "http://www.imdb.com";
- intent.putExtra(Intent.EXTRA_REFERRER, Uri.parse(nonAppExtra));
- mContext.startActivity(intent);
-
- CriteriaHelper.pollUiThread(Criteria.equals(URL_1, new Callable<String>() {
- @Override
- public String call() {
- return mUrl;
- }
- }));
-
- // Check that referrer is not carried over
- assertNull(mReferrer);
- }
-
- @MediumTest
- public void testReferrerExtraFromExternalIntent() throws Exception {
- Instrumentation.ActivityMonitor monitor = getInstrumentation().addMonitor(
- DocumentActivity.class.getName(), null, false);
- ApplicationTestUtils.launchChrome(mContext);
-
- // Wait for tab model to become initialized.
- CriteriaHelper.pollInstrumentationThread(new Criteria() {
- @Override
- public boolean isSatisfied() {
- return ChromeApplication.isDocumentTabModelSelectorInitializedForTests();
- }
- });
-
- DocumentTabModelSelector selector = ChromeApplication.getDocumentTabModelSelector();
- mObserver = new TabModelSelectorTabObserver(selector) {
- @Override
- public void onLoadUrl(Tab tab, LoadUrlParams params, int loadType) {
- mUrl = params.getUrl();
- if (params.getReferrer() != null) {
- mReferrer = params.getReferrer().getUrl();
- }
- }
- };
-
- // Wait for document activity from the main intent to launch before firing the next
- // intent.
- DocumentActivity doc = (DocumentActivity) monitor.waitForActivityWithTimeout(
- ACTIVITY_START_TIMEOUT);
- assertNotNull("DocumentActivity did not start", doc);
-
- mUrl = null;
- mReferrer = null;
-
- // Simulate a link click inside the application that goes through external navigation
- // handler and then goes back to Chrome.
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(URL_1));
- intent.setClassName(mContext.getPackageName(), ChromeLauncherActivity.class.getName());
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(Browser.EXTRA_APPLICATION_ID, mContext.getPackageName());
- IntentHandler.setPendingReferrer(intent, "http://www.google.com");
- mContext.startActivity(intent);
-
- CriteriaHelper.pollUiThread(Criteria.equals(URL_1, new Callable<String>() {
- @Override
- public String call() {
- return mUrl;
- }
- }));
-
- // Check that referrer is not carried over
- assertEquals("http://www.google.com", mReferrer);
- }
-}

Powered by Google App Engine
This is Rietveld 408576698