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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java

Issue 2905073002: Revert of Redirecting off-origin navigations in PWAs to CCT. (Closed)
Patch Set: 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
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();
}
}

Powered by Google App Engine
This is Rietveld 408576698