| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.webapps; | 5 package org.chromium.chrome.browser.webapps; |
| 6 | 6 |
| 7 import android.content.Intent; | 7 import android.content.Intent; |
| 8 import android.support.test.InstrumentationRegistry; | 8 import android.support.test.InstrumentationRegistry; |
| 9 import android.support.test.filters.LargeTest; | 9 import android.support.test.filters.LargeTest; |
| 10 | 10 |
| 11 import org.junit.After; | 11 import org.junit.After; |
| 12 import org.junit.Before; | 12 import org.junit.Before; |
| 13 import org.junit.Rule; | 13 import org.junit.Rule; |
| 14 import org.junit.Test; | 14 import org.junit.Test; |
| 15 import org.junit.runner.RunWith; | 15 import org.junit.runner.RunWith; |
| 16 | 16 |
| 17 import org.chromium.base.test.util.CommandLineFlags; | 17 import org.chromium.base.test.util.CommandLineFlags; |
| 18 import org.chromium.base.test.util.Feature; | 18 import org.chromium.base.test.util.Feature; |
| 19 import org.chromium.base.test.util.RetryOnFailure; | |
| 20 import org.chromium.base.test.util.ScalableTimeout; | 19 import org.chromium.base.test.util.ScalableTimeout; |
| 21 import org.chromium.chrome.browser.ChromeActivity; | 20 import org.chromium.chrome.browser.ChromeActivity; |
| 22 import org.chromium.chrome.browser.ChromeSwitches; | 21 import org.chromium.chrome.browser.ChromeSwitches; |
| 23 import org.chromium.chrome.browser.ShortcutHelper; | 22 import org.chromium.chrome.browser.ShortcutHelper; |
| 24 import org.chromium.chrome.browser.customtabs.CustomTabActivity; | 23 import org.chromium.chrome.browser.customtabs.CustomTabActivity; |
| 25 import org.chromium.chrome.test.ChromeActivityTestRule; | 24 import org.chromium.chrome.test.ChromeActivityTestRule; |
| 26 import org.chromium.chrome.test.ChromeJUnit4ClassRunner; | 25 import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
| 27 import org.chromium.chrome.test.util.ChromeTabUtils; | 26 import org.chromium.chrome.test.util.ChromeTabUtils; |
| 28 import org.chromium.content.browser.test.util.Criteria; | 27 import org.chromium.content.browser.test.util.Criteria; |
| 29 import org.chromium.content.browser.test.util.CriteriaHelper; | 28 import org.chromium.content.browser.test.util.CriteriaHelper; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 mTestServer.stopAndDestroyServer(); | 92 mTestServer.stopAndDestroyServer(); |
| 94 } | 93 } |
| 95 | 94 |
| 96 /** | 95 /** |
| 97 * Test launching a WebAPK. Test that loading the start page works and that
the splashscreen | 96 * Test launching a WebAPK. Test that loading the start page works and that
the splashscreen |
| 98 * eventually hides. | 97 * eventually hides. |
| 99 */ | 98 */ |
| 100 @Test | 99 @Test |
| 101 @LargeTest | 100 @LargeTest |
| 102 @Feature({"WebApk"}) | 101 @Feature({"WebApk"}) |
| 103 @RetryOnFailure | |
| 104 public void testLaunchAndNavigateOffOrigin() throws Exception { | 102 public void testLaunchAndNavigateOffOrigin() throws Exception { |
| 105 startWebApkActivity("org.chromium.webapk.test", | 103 startWebApkActivity("org.chromium.webapk.test", |
| 106 mTestServer.getURL("/chrome/test/data/android/test.html")); | 104 mTestServer.getURL("/chrome/test/data/android/test.html")); |
| 107 waitUntilSplashscreenHides(); | 105 waitUntilSplashscreenHides(); |
| 108 | 106 |
| 109 // We navigate outside origin and expect Custom Tab to open on top of We
bApkActivity. | 107 // We navigate outside origin and expect Custom Tab to open on top of We
bApkActivity. |
| 110 mActivityTestRule.runJavaScriptCodeInCurrentTab( | 108 mActivityTestRule.runJavaScriptCodeInCurrentTab( |
| 111 "window.top.location = 'https://www.google.com/'"); | 109 "window.top.location = 'https://www.google.com/'"); |
| 112 | 110 |
| 113 CriteriaHelper.pollUiThread(new Criteria() { | 111 CriteriaHelper.pollUiThread(new Criteria() { |
| 114 @Override | 112 @Override |
| 115 public boolean isSatisfied() { | 113 public boolean isSatisfied() { |
| 116 ChromeActivity activity = (ChromeActivity) activityListener.getM
ostRecentActivity(); | 114 ChromeActivity activity = (ChromeActivity) activityListener.getM
ostRecentActivity(); |
| 117 return activity instanceof CustomTabActivity | 115 return activity instanceof CustomTabActivity |
| 118 && activity.getActivityTab() != null | 116 && activity.getActivityTab() != null |
| 119 // Dropping the TLD as Google can redirect to a local si
te. | 117 // Dropping the TLD as Google can redirect to a local si
te. |
| 120 && activity.getActivityTab().getUrl().startsWith("https:
//www.google."); | 118 && activity.getActivityTab().getUrl().startsWith("https:
//www.google."); |
| 121 } | 119 } |
| 122 }); | 120 }); |
| 123 } | 121 } |
| 124 } | 122 } |
| OLD | NEW |