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

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

Issue 2258573002: Move InstantApps stuff into a separate package. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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/InstantAppsHandlerTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/InstantAppsHandlerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/InstantAppsHandlerTest.java
deleted file mode 100644
index 6aa05ebc573d47885592e8e78a5cc2948a8d245f..0000000000000000000000000000000000000000
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/InstantAppsHandlerTest.java
+++ /dev/null
@@ -1,145 +0,0 @@
-// Copyright 2016 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;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.net.Uri;
-import android.provider.Browser;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import org.chromium.base.ContextUtils;
-
-/**
- * Unit tests for {@link InstantAppsHandler}.
- */
-public class InstantAppsHandlerTest extends InstrumentationTestCase {
-
- private TestInstantAppsHandler mHandler;
- private Context mContext;
-
- private static final Uri URI = Uri.parse("http://sampleurl.com/foo");
-
- private Intent createViewIntent() {
- return new Intent(Intent.ACTION_VIEW, URI);
- }
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
-
- mContext = getInstrumentation().getTargetContext();
- mHandler = new TestInstantAppsHandler();
-
- SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
- SharedPreferences.Editor editor = prefs.edit();
- editor.putBoolean("applink.app_link_enabled", true);
- editor.putBoolean("applink.chrome_default_browser", true);
- editor.apply();
- }
-
- @Override
- public void tearDown() throws Exception {
- ContextUtils.getAppSharedPreferences().edit().clear().apply();
- super.tearDown();
- }
-
- @SmallTest
- public void testInstantAppsDisabled_disabledByFlag() {
- SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
- SharedPreferences.Editor editor = prefs.edit();
- editor.putBoolean("applink.app_link_enabled", false);
- editor.apply();
-
- assertFalse(mHandler.handleIncomingIntent(mContext, createViewIntent(), false));
- assertFalse(mHandler.handleIncomingIntent(mContext, createViewIntent(), true));
- }
-
- @SmallTest
- public void testInstantAppsDisabled_incognito() {
- Intent i = createViewIntent();
- i.putExtra(IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, true);
-
- assertFalse(mHandler.handleIncomingIntent(mContext, i, false));
- }
-
-
- @SmallTest
- public void testInstantAppsDisabled_doNotLaunch() {
- Intent i = createViewIntent();
- i.putExtra("com.google.android.gms.instantapps.DO_NOT_LAUNCH_INSTANT_APP", true);
-
- assertFalse(mHandler.handleIncomingIntent(mContext, i, false));
- }
-
- @SmallTest
- public void testInstantAppsDisabled_dataReductionProxy() {
- SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
- SharedPreferences.Editor editor = prefs.edit();
- editor.putBoolean("BANDWIDTH_REDUCTION_PROXY_ENABLED", true);
- editor.apply();
-
- assertFalse(mHandler.handleIncomingIntent(mContext, createViewIntent(), false));
- }
-
- @SmallTest
- public void testInstantAppsDisabled_mainIntent() {
- Intent i = new Intent(Intent.ACTION_MAIN);
- assertFalse(mHandler.handleIncomingIntent(mContext, i, false));
- }
-
- @SmallTest
- public void testInstantAppsDisabled_intentOriginatingFromChrome() {
- Intent i = createViewIntent();
- i.putExtra(Browser.EXTRA_APPLICATION_ID, mContext.getPackageName());
-
- assertFalse(mHandler.handleIncomingIntent(mContext, i, false));
-
- Intent signedIntent = createViewIntent();
- signedIntent.setPackage(mContext.getPackageName());
- IntentHandler.addTrustedIntentExtras(signedIntent, mContext);
-
- assertFalse(mHandler.handleIncomingIntent(mContext, signedIntent, false));
- }
-
- @SmallTest
- public void testChromeNotDefault() {
- SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
- SharedPreferences.Editor editor = prefs.edit();
- editor.putBoolean("applink.chrome_default_browser", false);
- editor.apply();
-
- assertFalse(mHandler.handleIncomingIntent(mContext, createViewIntent(), false));
-
- // Even if Chrome is not default, launch Instant Apps for CustomTabs since those never
- // show disambiguation dialogs.
- Intent cti = createViewIntent()
- .putExtra("android.support.customtabs.extra.EXTRA_ENABLE_INSTANT_APPS", true);
- assertTrue(mHandler.handleIncomingIntent(mContext, cti, true));
- }
-
- @SmallTest
- public void testInstantAppsEnabled() {
- Intent i = createViewIntent();
- assertTrue(mHandler.handleIncomingIntent(getInstrumentation().getContext(), i, false));
-
- // Check that identical intent wouldn't be enabled for CustomTab flow.
- assertFalse(mHandler.handleIncomingIntent(getInstrumentation().getContext(), i, true));
-
- // Add CustomTab specific extra and check it's now enabled.
- i.putExtra("android.support.customtabs.extra.EXTRA_ENABLE_INSTANT_APPS", true);
- assertTrue(mHandler.handleIncomingIntent(getInstrumentation().getContext(), i, true));
- }
-
- static class TestInstantAppsHandler extends InstantAppsHandler {
- @Override
- protected boolean tryLaunchingInstantApp(Context context, Intent intent,
- boolean isCustomTabsIntent, Intent fallbackIntent) {
- return true;
- }
- }
-}

Powered by Google App Engine
This is Rietveld 408576698