| Index: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java
|
| index e74b1e38a0600a49143309eb79778644c5ba83bc..afa5078c503317197ce212e0abd4d253d9f32af9 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java
|
| @@ -9,7 +9,6 @@
|
| import android.support.test.filters.LargeTest;
|
|
|
| import org.junit.After;
|
| -import org.junit.Assert;
|
| import org.junit.Before;
|
| import org.junit.Rule;
|
| import org.junit.Test;
|
| @@ -19,10 +18,8 @@
|
| import org.chromium.base.test.util.Feature;
|
| import org.chromium.base.test.util.RetryOnFailure;
|
| import org.chromium.base.test.util.ScalableTimeout;
|
| -import org.chromium.chrome.browser.ChromeActivity;
|
| import org.chromium.chrome.browser.ChromeSwitches;
|
| import org.chromium.chrome.browser.ShortcutHelper;
|
| -import org.chromium.chrome.browser.customtabs.CustomTabActivity;
|
| import org.chromium.chrome.test.ChromeActivityTestRule;
|
| import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
|
| import org.chromium.chrome.test.util.ChromeTabUtils;
|
| @@ -40,9 +37,6 @@
|
| public final ChromeActivityTestRule<WebApkActivity> mActivityTestRule =
|
| new ChromeActivityTestRule<>(WebApkActivity.class);
|
|
|
| - @Rule
|
| - public final TopActivityListener activityListener = new TopActivityListener();
|
| -
|
| private static final long STARTUP_TIMEOUT = ScalableTimeout.scaleTimeout(10000);
|
|
|
| private EmbeddedTestServer mTestServer;
|
| @@ -54,13 +48,9 @@
|
| intent.putExtra(WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, webApkPackageName);
|
| intent.putExtra(ShortcutHelper.EXTRA_URL, startUrl);
|
| intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
| -
|
| - WebApkActivity webApkActivity =
|
| + mActivityTestRule.setActivity(
|
| (WebApkActivity) InstrumentationRegistry.getInstrumentation().startActivitySync(
|
| - intent);
|
| - webApkActivity.mWebappInfo.setScopeForTest(
|
| - startUrl.substring(0, startUrl.lastIndexOf('/') + 1));
|
| - mActivityTestRule.setActivity(webApkActivity);
|
| + intent));
|
| InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
|
|
| CriteriaHelper.pollInstrumentationThread(new Criteria() {
|
| @@ -104,41 +94,9 @@
|
| @LargeTest
|
| @Feature({"WebApk"})
|
| @RetryOnFailure
|
| - public void testLaunchAndNavigateOffOrigin() throws Exception {
|
| + public void testLaunch() throws InterruptedException {
|
| startWebApkActivity("org.chromium.webapk.test",
|
| mTestServer.getURL("/chrome/test/data/android/test.html"));
|
| waitUntilSplashscreenHides();
|
| -
|
| - WebApkActivity webApkActivity = mActivityTestRule.getActivity();
|
| - waitForFinishLoading(webApkActivity);
|
| -
|
| - Assert.assertSame(webApkActivity, activityListener.getMostRecentActivity());
|
| - Assert.assertEquals(mTestServer.getURL("/chrome/test/data/android/test.html"),
|
| - webApkActivity.getActivityTab().getUrl());
|
| -
|
| - // We navigate outside origin and expect Custom Tab to open on top of WebApkActivity.
|
| - mActivityTestRule.runJavaScriptCodeInCurrentTab(
|
| - "window.top.location = 'https://www.google.com/'");
|
| -
|
| - activityListener.waitFor(CustomTabActivity.class);
|
| -
|
| - final CustomTabActivity customTab =
|
| - (CustomTabActivity) activityListener.getMostRecentActivity();
|
| -
|
| - waitForFinishLoading(customTab);
|
| -
|
| - // Dropping the TLD as Google can redirect to a local site, so this could fail outside US.
|
| - Assert.assertTrue(customTab.getActivityTab().getUrl().startsWith("https://www.google."));
|
| - }
|
| -
|
| - private void waitForFinishLoading(final ChromeActivity chromeActivity) {
|
| - CriteriaHelper.pollInstrumentationThread(new Criteria() {
|
| - @Override
|
| - public boolean isSatisfied() {
|
| - return chromeActivity.getActivityTab() != null
|
| - && !chromeActivity.getActivityTab().isLoading();
|
| - }
|
| - }, STARTUP_TIMEOUT, CriteriaHelper.DEFAULT_POLLING_INTERVAL);
|
| - InstrumentationRegistry.getInstrumentation().waitForIdleSync();
|
| }
|
| }
|
|
|