Chromium Code Reviews| Index: chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java |
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java |
| index fd2d93a561410358a5caeebce1b2e7c15f0386e6..be9b9f00d4b6c35c1f1b4998a12b27bbb1aad7d0 100644 |
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java |
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabActivityTest.java |
| @@ -163,6 +163,7 @@ public class CustomTabActivityTest extends CustomTabActivityTestBase { |
| CustomTabsConnection connection = |
| CustomTabsConnection.getInstance((Application) appContext); |
| connection.setForcePrerender(true); |
| + connection.setPrerenderMode(CustomTabsConnection.DEFAULT_PRERENDER); |
| } |
| @Override |
| @@ -1484,6 +1485,7 @@ public class CustomTabActivityTest extends CustomTabActivityTestBase { |
| CustomTabsSessionToken token = CustomTabsSessionToken.getSessionTokenFromIntent(intent); |
| assertTrue(connection.newSession(token)); |
| Bundle extras = new Bundle(); |
| + // Forcing no prerendering implies falling back to simply creating a spare WebContent |
|
ahemery
2017/03/16 17:28:35
Unrelated comment to help readability
|
| extras.putInt( |
| CustomTabsConnection.DEBUG_OVERRIDE_KEY, CustomTabsConnection.NO_PRERENDERING); |
| assertTrue(connection.mayLaunchUrl(token, Uri.parse(mTestPage), extras, null)); |
| @@ -1637,7 +1639,7 @@ public class CustomTabActivityTest extends CustomTabActivityTestBase { |
| } |
| final Tab tab = mActivity.getActivityTab(); |
| ElementContentCriteria initialVisibilityCriteria = new ElementContentCriteria( |
| - tab, "visibility", ignoreFragments ? "prerender" : "visible"); |
| + tab, "visibility", ignoreFragments ? getBaseExpectedVisibility() : "visible"); |
|
ahemery
2017/03/16 17:28:35
Since prerender visibility is prerender and hidden
|
| ElementContentCriteria initialFragmentCriteria = new ElementContentCriteria( |
| tab, "initial-fragment", ignoreFragments ? initialFragment : fragment); |
| ElementContentCriteria fragmentCriteria = new ElementContentCriteria( |
| @@ -2113,16 +2115,18 @@ public class CustomTabActivityTest extends CustomTabActivityTestBase { |
| private static void ensureCompletedPrerenderForUrl( |
| final CustomTabsConnection connection, final String url) throws Exception { |
| - CriteriaHelper.pollUiThread(new Criteria("No Prerender") { |
| - @Override |
| - public boolean isSatisfied() { |
| - return connection.mSpeculation != null |
| - && connection.mSpeculation.webContents != null |
| - && ExternalPrerenderHandler.hasPrerenderedAndFinishedLoadingUrl( |
| - Profile.getLastUsedProfile(), url, |
| - connection.mSpeculation.webContents); |
| - } |
| - }, LONG_TIMEOUT_MS, CriteriaHelper.DEFAULT_POLLING_INTERVAL); |
| + if (connection.mPrerenderMode == CustomTabsConnection.DEFAULT_PRERENDER) { |
| + CriteriaHelper.pollUiThread(new Criteria("No Prerender") { |
| + @Override |
| + public boolean isSatisfied() { |
| + return connection.mSpeculation != null |
| + && connection.mSpeculation.webContents != null |
| + && ExternalPrerenderHandler.hasPrerenderedAndFinishedLoadingUrl( |
| + Profile.getLastUsedProfile(), url, |
| + connection.mSpeculation.webContents); |
| + } |
| + }, LONG_TIMEOUT_MS, CriteriaHelper.DEFAULT_POLLING_INTERVAL); |
| + } |
| } |
| private CustomTabsSession bindWithCallback(final CustomTabsCallback callback) { |
| @@ -2210,4 +2214,19 @@ public class CustomTabActivityTest extends CustomTabActivityTestBase { |
| return TextUtils.equals(mExpected, value); |
| } |
| } |
| + |
| + private String getBaseExpectedVisibility() { |
| + final Context context = getInstrumentation().getTargetContext().getApplicationContext(); |
| + CustomTabsConnection connection = CustomTabsConnection.getInstance((Application) context); |
| + return getExpectedVisibilityForMode(connection.mPrerenderMode); |
| + } |
| + |
| + private static String getExpectedVisibilityForMode(int mode) { |
| + switch (mode) { |
| + case CustomTabsConnection.DEFAULT_PRERENDER: |
| + return "prerender"; |
| + default: |
| + return "visible"; |
| + } |
| + } |
| } |