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

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

Issue 2774763002: Kick incognito tabs from CCTs to tabbed mode. (Closed)
Patch Set: Rebase Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/multiwindow/MultiWindowUtils.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.customtabs; 5 package org.chromium.chrome.browser.customtabs;
6 6
7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_E ND_DEVICE; 7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_E ND_DEVICE;
8 8
9 import android.app.Activity; 9 import android.app.Activity;
10 import android.app.Application; 10 import android.app.Application;
(...skipping 14 matching lines...) Expand all
25 import android.os.Build; 25 import android.os.Build;
26 import android.os.Bundle; 26 import android.os.Bundle;
27 import android.os.SystemClock; 27 import android.os.SystemClock;
28 import android.support.customtabs.CustomTabsCallback; 28 import android.support.customtabs.CustomTabsCallback;
29 import android.support.customtabs.CustomTabsClient; 29 import android.support.customtabs.CustomTabsClient;
30 import android.support.customtabs.CustomTabsIntent; 30 import android.support.customtabs.CustomTabsIntent;
31 import android.support.customtabs.CustomTabsService; 31 import android.support.customtabs.CustomTabsService;
32 import android.support.customtabs.CustomTabsServiceConnection; 32 import android.support.customtabs.CustomTabsServiceConnection;
33 import android.support.customtabs.CustomTabsSession; 33 import android.support.customtabs.CustomTabsSession;
34 import android.support.customtabs.CustomTabsSessionToken; 34 import android.support.customtabs.CustomTabsSessionToken;
35 import android.support.test.filters.MediumTest;
35 import android.support.test.filters.SmallTest; 36 import android.support.test.filters.SmallTest;
36 import android.text.TextUtils; 37 import android.text.TextUtils;
37 import android.view.Menu; 38 import android.view.Menu;
38 import android.view.MenuItem; 39 import android.view.MenuItem;
39 import android.view.View; 40 import android.view.View;
40 import android.view.ViewGroup; 41 import android.view.ViewGroup;
41 import android.widget.EditText; 42 import android.widget.EditText;
42 import android.widget.ImageButton; 43 import android.widget.ImageButton;
43 44
45 import org.chromium.base.ActivityState;
46 import org.chromium.base.ApplicationStatus;
47 import org.chromium.base.ApplicationStatus.ActivityStateListener;
44 import org.chromium.base.ObserverList.RewindableIterator; 48 import org.chromium.base.ObserverList.RewindableIterator;
45 import org.chromium.base.PathUtils; 49 import org.chromium.base.PathUtils;
46 import org.chromium.base.ThreadUtils; 50 import org.chromium.base.ThreadUtils;
47 import org.chromium.base.library_loader.LibraryLoader; 51 import org.chromium.base.library_loader.LibraryLoader;
48 import org.chromium.base.library_loader.LibraryProcessType; 52 import org.chromium.base.library_loader.LibraryProcessType;
49 import org.chromium.base.test.util.CallbackHelper; 53 import org.chromium.base.test.util.CallbackHelper;
50 import org.chromium.base.test.util.CommandLineFlags; 54 import org.chromium.base.test.util.CommandLineFlags;
51 import org.chromium.base.test.util.DisabledTest; 55 import org.chromium.base.test.util.DisabledTest;
52 import org.chromium.base.test.util.Restriction; 56 import org.chromium.base.test.util.Restriction;
53 import org.chromium.base.test.util.RetryOnFailure; 57 import org.chromium.base.test.util.RetryOnFailure;
(...skipping 25 matching lines...) Expand all
79 import org.chromium.content.browser.BrowserStartupController; 83 import org.chromium.content.browser.BrowserStartupController;
80 import org.chromium.content.browser.BrowserStartupController.StartupCallback; 84 import org.chromium.content.browser.BrowserStartupController.StartupCallback;
81 import org.chromium.content.browser.test.util.Criteria; 85 import org.chromium.content.browser.test.util.Criteria;
82 import org.chromium.content.browser.test.util.CriteriaHelper; 86 import org.chromium.content.browser.test.util.CriteriaHelper;
83 import org.chromium.content.browser.test.util.DOMUtils; 87 import org.chromium.content.browser.test.util.DOMUtils;
84 import org.chromium.content.browser.test.util.JavaScriptUtils; 88 import org.chromium.content.browser.test.util.JavaScriptUtils;
85 import org.chromium.content_public.browser.LoadUrlParams; 89 import org.chromium.content_public.browser.LoadUrlParams;
86 import org.chromium.content_public.browser.WebContentsObserver; 90 import org.chromium.content_public.browser.WebContentsObserver;
87 import org.chromium.net.test.EmbeddedTestServer; 91 import org.chromium.net.test.EmbeddedTestServer;
88 import org.chromium.net.test.util.TestWebServer; 92 import org.chromium.net.test.util.TestWebServer;
93 import org.chromium.ui.mojom.WindowOpenDisposition;
89 94
90 import java.util.ArrayList; 95 import java.util.ArrayList;
91 import java.util.concurrent.Callable; 96 import java.util.concurrent.Callable;
92 import java.util.concurrent.TimeoutException; 97 import java.util.concurrent.TimeoutException;
93 import java.util.concurrent.atomic.AtomicBoolean; 98 import java.util.concurrent.atomic.AtomicBoolean;
94 import java.util.concurrent.atomic.AtomicReference; 99 import java.util.concurrent.atomic.AtomicReference;
95 100
96 /** 101 /**
97 * Instrumentation tests for app menu, context menu, and toolbar of a {@link Cus tomTabActivity}. 102 * Instrumentation tests for app menu, context menu, and toolbar of a {@link Cus tomTabActivity}.
98 */ 103 */
(...skipping 1760 matching lines...) Expand 10 before | Expand all | Expand 10 after
1859 public void testClientCanSetReferrer() throws Exception { 1864 public void testClientCanSetReferrer() throws Exception {
1860 String referrerUrl = "android-app://com.foo.me/"; 1865 String referrerUrl = "android-app://com.foo.me/";
1861 maybePrerenderAndLaunchWithReferrers(mTestPage, false, null, referrerUrl ); 1866 maybePrerenderAndLaunchWithReferrers(mTestPage, false, null, referrerUrl );
1862 1867
1863 Tab tab = mActivity.getActivityTab(); 1868 Tab tab = mActivity.getActivityTab();
1864 // The Referrer is correctly set. 1869 // The Referrer is correctly set.
1865 CriteriaHelper.pollInstrumentationThread( 1870 CriteriaHelper.pollInstrumentationThread(
1866 new TabsOpenedFromExternalAppTest.ReferrerCriteria(tab, referrer Url), 2000, 200); 1871 new TabsOpenedFromExternalAppTest.ReferrerCriteria(tab, referrer Url), 2000, 200);
1867 } 1872 }
1868 1873
1874 @MediumTest
1875 public void testLaunchIncognitoURL() throws Exception {
1876 Intent intent = createMinimalCustomTabIntent();
1877 startCustomTabActivityWithIntent(intent);
1878
1879 final CustomTabActivity cctActivity = getActivity();
1880 final CallbackHelper mCctHiddenCallback = new CallbackHelper();
1881 final CallbackHelper mTabbedModeShownCallback = new CallbackHelper();
1882 final AtomicReference<ChromeTabbedActivity> tabbedActivity = new AtomicR eference<>();
1883
1884 ActivityStateListener listener = new ActivityStateListener() {
1885 @Override
1886 public void onActivityStateChange(Activity activity, int newState) {
1887 if (activity == cctActivity
1888 && (newState == ActivityState.STOPPED
1889 || newState == ActivityState.DESTROYED)) {
1890 mCctHiddenCallback.notifyCalled();
1891 }
1892
1893 if (activity instanceof ChromeTabbedActivity && newState == Acti vityState.RESUMED) {
1894 mTabbedModeShownCallback.notifyCalled();
1895 tabbedActivity.set((ChromeTabbedActivity) activity);
1896 }
1897 }
1898 };
1899 ApplicationStatus.registerStateListenerForAllActivities(listener);
1900
1901 ThreadUtils.runOnUiThread(new Runnable() {
1902 @Override
1903 public void run() {
1904 cctActivity.getActivityTab().getTabWebContentsDelegateAndroid(). openNewTab(
1905 "about:blank", null, null, WindowOpenDisposition.OFF_THE _RECORD, false);
1906 }
1907 });
1908
1909 mCctHiddenCallback.waitForCallback("CCT not hidden.", 0);
1910 mTabbedModeShownCallback.waitForCallback("Tabbed mode not shown.", 0);
1911
1912 CriteriaHelper.pollUiThread(Criteria.equals(true, new Callable<Boolean>( ) {
1913 @Override
1914 public Boolean call() throws Exception {
1915 return tabbedActivity.get().areTabModelsInitialized();
1916 }
1917 }));
1918
1919 CriteriaHelper.pollUiThread(new Criteria() {
1920 @Override
1921 public boolean isSatisfied() {
1922 Tab tab = tabbedActivity.get().getActivityTab();
1923 if (tab == null) {
1924 updateFailureReason("Tab is null");
1925 return false;
1926 }
1927 if (!tab.isIncognito()) {
1928 updateFailureReason("Incognito tab not selected");
1929 return false;
1930 }
1931 if (!TextUtils.equals(tab.getUrl(), "about:blank")) {
1932 updateFailureReason("Wrong URL loaded in incognito tab");
1933 return false;
1934 }
1935 return true;
1936 }
1937 });
1938
1939 ApplicationStatus.unregisterActivityStateListener(listener);
1940 }
1941
1869 /** 1942 /**
1870 * Tests that a Weblite URL from an external app uses the lite_url param whe n Data Reduction 1943 * Tests that a Weblite URL from an external app uses the lite_url param whe n Data Reduction
1871 * Proxy previews are being used. 1944 * Proxy previews are being used.
1872 */ 1945 */
1873 @SmallTest 1946 @SmallTest
1874 @CommandLineFlags.Add({"enable-spdy-proxy-auth", "data-reduction-proxy-lo-fi =always-on", 1947 @CommandLineFlags.Add({"enable-spdy-proxy-auth", "data-reduction-proxy-lo-fi =always-on",
1875 "enable-data-reduction-proxy-lite-page"}) 1948 "enable-data-reduction-proxy-lite-page"})
1876 @RetryOnFailure 1949 @RetryOnFailure
1877 public void testLaunchWebLiteURL() throws Exception { 1950 public void testLaunchWebLiteURL() throws Exception {
1878 final String testUrl = WEBLITE_PREFIX + mTestPage; 1951 final String testUrl = WEBLITE_PREFIX + mTestPage;
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
2204 if (jsonText.equalsIgnoreCase("null")) jsonText = ""; 2277 if (jsonText.equalsIgnoreCase("null")) jsonText = "";
2205 value = jsonText; 2278 value = jsonText;
2206 } catch (InterruptedException | TimeoutException e) { 2279 } catch (InterruptedException | TimeoutException e) {
2207 e.printStackTrace(); 2280 e.printStackTrace();
2208 return false; 2281 return false;
2209 } 2282 }
2210 return TextUtils.equals(mExpected, value); 2283 return TextUtils.equals(mExpected, value);
2211 } 2284 }
2212 } 2285 }
2213 } 2286 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/multiwindow/MultiWindowUtils.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698