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

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

Issue 2919433005: customtabs: Don't always destroy the spare WebContents before prerender. (Closed)
Patch Set: Add a test/ Created 3 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
« 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/CustomTabsConnectionTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabsConnectionTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabsConnectionTest.java
index 96d4bc8667cd78c36fc07ce887d86f83ec89e448..2a1179e030aba5b1ff6b90bcf9515177851f5b37 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabsConnectionTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabsConnectionTest.java
@@ -160,13 +160,13 @@ public class CustomTabsConnectionTest {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
- Assert.assertFalse(WarmupManager.getInstance().hasSpareWebContents());
String referrer =
mCustomTabsConnection.getReferrerForSession(token).getUrl();
WebContents webContents =
mCustomTabsConnection.takePrerenderedUrl(token, URL, referrer);
Assert.assertNotNull(webContents);
webContents.destroy();
+ Assert.assertFalse(WarmupManager.getInstance().hasSpareWebContents());
}
});
}
@@ -357,9 +357,10 @@ public class CustomTabsConnectionTest {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
- Assert.assertNull(WarmupManager.getInstance().takeSpareWebContents(false, false));
+ Assert.assertEquals(URL, mCustomTabsConnection.getSpeculatedUrl(token));
}
});
+
Assert.assertTrue(mCustomTabsConnection.mayLaunchUrl(token, null, null, null));
// mayLaunchUrl() posts a task, the following has to run after it.
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@@ -635,4 +636,52 @@ public class CustomTabsConnectionTest {
});
}
}
+
+ @Test
+ @SmallTest
+ @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
+ public void testCellularPrerenderingDoesntKillSpareRenderer() throws Exception {
+ final CustomTabsSessionToken token =
+ CustomTabsSessionToken.createDummySessionTokenForTesting();
+ Assert.assertTrue(mCustomTabsConnection.newSession(token));
+ mCustomTabsConnection.setShouldPrerenderOnCellularForSession(token, true);
+ mCustomTabsConnection.warmup(0);
+
+ Assert.assertTrue(mCustomTabsConnection.mayLaunchUrl(token, Uri.parse(URL), null, null));
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ Assert.assertTrue(WarmupManager.getInstance().hasSpareWebContents());
+ String referrer = mCustomTabsConnection.getReferrerForSession(token).getUrl();
+ WebContents webContents =
+ mCustomTabsConnection.takePrerenderedUrl(token, URL, referrer);
+ Assert.assertNotNull(webContents);
+ webContents.destroy();
+ // destroyed when the prerender is used.
+ Assert.assertFalse(WarmupManager.getInstance().hasSpareWebContents());
+ }
+ });
+ }
+
+ @Test
+ @SmallTest
+ @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
+ public void testUnmatchedCellularPrerenderingDoesntKillSpareRenderer() throws Exception {
+ final CustomTabsSessionToken token =
+ CustomTabsSessionToken.createDummySessionTokenForTesting();
+ Assert.assertTrue(mCustomTabsConnection.newSession(token));
+ mCustomTabsConnection.setShouldPrerenderOnCellularForSession(token, true);
+ mCustomTabsConnection.warmup(0);
+
+ Assert.assertTrue(mCustomTabsConnection.mayLaunchUrl(token, Uri.parse(URL), null, null));
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ Assert.assertTrue(WarmupManager.getInstance().hasSpareWebContents());
+ String referrer = mCustomTabsConnection.getReferrerForSession(token).getUrl();
+ Assert.assertNull(mCustomTabsConnection.takePrerenderedUrl(token, URL2, referrer));
+ Assert.assertTrue(WarmupManager.getInstance().hasSpareWebContents());
+ }
+ });
+ }
}
« 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