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

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

Issue 2158843003: customtabs: Don't crash when the death notificaton is sent to a random thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/customtabs/CustomTabsConnection.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.Application; 9 import android.app.Application;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 String referrer = 139 String referrer =
140 mCustomTabsConnection.getReferrerForSession(token).getUr l(); 140 mCustomTabsConnection.getReferrerForSession(token).getUr l();
141 WebContents webContents = 141 WebContents webContents =
142 mCustomTabsConnection.takePrerenderedUrl(token, URL, ref errer); 142 mCustomTabsConnection.takePrerenderedUrl(token, URL, ref errer);
143 assertNotNull(webContents); 143 assertNotNull(webContents);
144 webContents.destroy(); 144 webContents.destroy();
145 } 145 }
146 }); 146 });
147 } 147 }
148 148
149 /*
150 * Tests that when the disconnection notification comes from a non-UI thread , Chrome doesn't
151 * crash. Non-regression test for crbug.com/623128.
152 */
153 @SmallTest
154 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
155 public void testPrerenderAndDisconnectOnOtherThread() {
156 final CustomTabsSessionToken token = assertWarmupAndMayLaunchUrl(null, U RL, true);
157 final Thread otherThread = new Thread(new Runnable() {
158 @Override
159 public void run() {
160 mCustomTabsConnection.cleanUpSession(token);
161 }
162 });
163
164 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
165 @Override
166 public void run() {
167 otherThread.start();
168 }
169 });
170 // Should not crash, hence no assertions below.
171 }
172
149 @SmallTest 173 @SmallTest
150 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) 174 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
151 public void testMayLaunchUrlKeepsSpareRendererWithoutPrerendering() { 175 public void testMayLaunchUrlKeepsSpareRendererWithoutPrerendering() {
152 assertTrue(mCustomTabsConnection.warmup(0)); 176 assertTrue(mCustomTabsConnection.warmup(0));
153 final CustomTabsSessionToken token = 177 final CustomTabsSessionToken token =
154 CustomTabsSessionToken.createDummySessionTokenForTesting(); 178 CustomTabsSessionToken.createDummySessionTokenForTesting();
155 assertTrue(mCustomTabsConnection.newSession(token)); 179 assertTrue(mCustomTabsConnection.newSession(token));
156 180
157 Bundle extras = new Bundle(); 181 Bundle extras = new Bundle();
158 extras.putBoolean(CustomTabsConnection.NO_PRERENDERING_KEY, true); 182 extras.putBoolean(CustomTabsConnection.NO_PRERENDERING_KEY, true);
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 } finally { 557 } finally {
534 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 558 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
535 @Override 559 @Override
536 public void run() { 560 public void run() {
537 PrefServiceBridge.getInstance().setNetworkPredictionEnabled( enabled); 561 PrefServiceBridge.getInstance().setNetworkPredictionEnabled( enabled);
538 } 562 }
539 }); 563 });
540 } 564 }
541 } 565 }
542 } 566 }
OLDNEW
« 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