| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.externalnav; | 5 package org.chromium.chrome.browser.externalnav; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.app.Instrumentation; | 8 import android.app.Instrumentation; |
| 9 import android.app.Instrumentation.ActivityMonitor; | 9 import android.app.Instrumentation.ActivityMonitor; |
| 10 import android.content.Context; | 10 import android.content.Context; |
| 11 import android.content.Intent; | 11 import android.content.Intent; |
| 12 import android.content.IntentFilter; | 12 import android.content.IntentFilter; |
| 13 import android.net.Uri; | 13 import android.net.Uri; |
| 14 import android.os.Environment; |
| 14 import android.os.SystemClock; | 15 import android.os.SystemClock; |
| 15 import android.test.suitebuilder.annotation.SmallTest; | 16 import android.test.suitebuilder.annotation.SmallTest; |
| 16 import android.text.TextUtils; | 17 import android.text.TextUtils; |
| 18 import android.util.Base64; |
| 17 | 19 |
| 18 import org.chromium.base.test.util.Restriction; | 20 import org.chromium.base.test.util.Restriction; |
| 19 import org.chromium.chrome.browser.ChromeActivity; | 21 import org.chromium.chrome.browser.ChromeActivity; |
| 20 import org.chromium.chrome.browser.document.ChromeLauncherActivity; | 22 import org.chromium.chrome.browser.document.ChromeLauncherActivity; |
| 21 import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler.Overrid
eUrlLoadingResult; | 23 import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler.Overrid
eUrlLoadingResult; |
| 22 import org.chromium.chrome.browser.tab.EmptyTabObserver; | 24 import org.chromium.chrome.browser.tab.EmptyTabObserver; |
| 23 import org.chromium.chrome.browser.tab.Tab; | 25 import org.chromium.chrome.browser.tab.Tab; |
| 24 import org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver; | 26 import org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver; |
| 25 import org.chromium.chrome.test.ChromeActivityTestCaseBase; | 27 import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
| 26 import org.chromium.chrome.test.util.ChromeRestriction; | 28 import org.chromium.chrome.test.util.ChromeRestriction; |
| 27 import org.chromium.chrome.test.util.TestHttpServerClient; | |
| 28 import org.chromium.content.browser.test.util.CallbackHelper; | 29 import org.chromium.content.browser.test.util.CallbackHelper; |
| 29 import org.chromium.content.browser.test.util.Criteria; | 30 import org.chromium.content.browser.test.util.Criteria; |
| 30 import org.chromium.content.browser.test.util.CriteriaHelper; | 31 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 31 import org.chromium.content_public.browser.LoadUrlParams; | 32 import org.chromium.content_public.browser.LoadUrlParams; |
| 33 import org.chromium.net.test.EmbeddedTestServer; |
| 32 import org.chromium.ui.base.PageTransition; | 34 import org.chromium.ui.base.PageTransition; |
| 33 | 35 |
| 36 import java.io.UnsupportedEncodingException; |
| 34 import java.util.concurrent.TimeUnit; | 37 import java.util.concurrent.TimeUnit; |
| 35 import java.util.concurrent.TimeoutException; | 38 import java.util.concurrent.TimeoutException; |
| 36 | 39 |
| 37 /** | 40 /** |
| 38 * Test suite for verifying the behavior of various URL overriding actions. | 41 * Test suite for verifying the behavior of various URL overriding actions. |
| 39 */ | 42 */ |
| 40 public class UrlOverridingTest extends ChromeActivityTestCaseBase<ChromeActivity
> { | 43 public class UrlOverridingTest extends ChromeActivityTestCaseBase<ChromeActivity
> { |
| 41 private static final String BASE_URL = "chrome/test/data/android/url_overrid
ing/"; | 44 private static final String BASE_PATH = "/chrome/test/data/android/url_overr
iding/"; |
| 42 private static final String NAVIGATION_FROM_TIMEOUT_PAGE = | 45 private static final String NAVIGATION_FROM_TIMEOUT_PAGE = |
| 43 BASE_URL + "navigation_from_timer.html"; | 46 BASE_PATH + "navigation_from_timer.html"; |
| 44 private static final String NAVIGATION_FROM_TIMEOUT_PARENT_FRAME_PAGE = | 47 private static final String NAVIGATION_FROM_TIMEOUT_PARENT_FRAME_PAGE = |
| 45 BASE_URL + "navigation_from_timer_parent_frame.html"; | 48 BASE_PATH + "navigation_from_timer_parent_frame.html"; |
| 46 private static final String NAVIGATION_FROM_USER_GESTURE_PAGE = | 49 private static final String NAVIGATION_FROM_USER_GESTURE_PAGE = |
| 47 BASE_URL + "navigation_from_user_gesture.html"; | 50 BASE_PATH + "navigation_from_user_gesture.html"; |
| 48 private static final String NAVIGATION_FROM_USER_GESTURE_PARENT_FRAME_PAGE = | 51 private static final String NAVIGATION_FROM_USER_GESTURE_PARENT_FRAME_PAGE = |
| 49 BASE_URL + "navigation_from_user_gesture_parent_frame.html"; | 52 BASE_PATH + "navigation_from_user_gesture_parent_frame.html"; |
| 50 private static final String NAVIGATION_FROM_XHR_CALLBACK_PAGE = | 53 private static final String NAVIGATION_FROM_XHR_CALLBACK_PAGE = |
| 51 BASE_URL + "navigation_from_xhr_callback.html"; | 54 BASE_PATH + "navigation_from_xhr_callback.html"; |
| 52 private static final String NAVIGATION_FROM_XHR_CALLBACK_PARENT_FRAME_PAGE = | 55 private static final String NAVIGATION_FROM_XHR_CALLBACK_PARENT_FRAME_PAGE = |
| 53 BASE_URL + "navigation_from_xhr_callback_parent_frame.html"; | 56 BASE_PATH + "navigation_from_xhr_callback_parent_frame.html"; |
| 54 private static final String NAVIGATION_FROM_XHR_CALLBACK_AND_SHORT_TIMEOUT_P
AGE = | 57 private static final String NAVIGATION_FROM_XHR_CALLBACK_AND_SHORT_TIMEOUT_P
AGE = |
| 55 BASE_URL + "navigation_from_xhr_callback_and_short_timeout.html"; | 58 BASE_PATH + "navigation_from_xhr_callback_and_short_timeout.html"; |
| 56 private static final String NAVIGATION_FROM_XHR_CALLBACK_AND_LONG_TIMEOUT_PA
GE = | 59 private static final String NAVIGATION_FROM_XHR_CALLBACK_AND_LONG_TIMEOUT_PA
GE = |
| 57 BASE_URL + "navigation_from_xhr_callback_and_long_timeout.html"; | 60 BASE_PATH + "navigation_from_xhr_callback_and_long_timeout.html"; |
| 58 private static final String NAVIGATION_WITH_FALLBACK_URL_PAGE = | 61 private static final String NAVIGATION_WITH_FALLBACK_URL_PAGE = |
| 59 BASE_URL + "navigation_with_fallback_url.html"; | 62 BASE_PATH + "navigation_with_fallback_url.html"; |
| 60 private static final String NAVIGATION_WITH_FALLBACK_URL_PARENT_FRAME_PAGE = | 63 private static final String NAVIGATION_WITH_FALLBACK_URL_PARENT_FRAME_PAGE = |
| 61 BASE_URL + "navigation_with_fallback_url_parent_frame.html"; | 64 BASE_PATH + "navigation_with_fallback_url_parent_frame.html"; |
| 62 private static final String FALLBACK_LANDING_URL = BASE_URL + "hello.html"; | 65 private static final String FALLBACK_LANDING_PATH = BASE_PATH + "hello.html"
; |
| 63 private static final String OPEN_WINDOW_FROM_USER_GESTURE_PAGE = | 66 private static final String OPEN_WINDOW_FROM_USER_GESTURE_PAGE = |
| 64 BASE_URL + "open_window_from_user_gesture.html"; | 67 BASE_PATH + "open_window_from_user_gesture.html"; |
| 65 private static final String NAVIGATION_FROM_JAVA_REDIRECTION_PAGE = | 68 private static final String NAVIGATION_FROM_JAVA_REDIRECTION_PAGE = |
| 66 BASE_URL + "navigation_from_java_redirection.html"; | 69 BASE_PATH + "navigation_from_java_redirection.html"; |
| 67 | 70 |
| 68 private static class TestTabObserver extends EmptyTabObserver { | 71 private static class TestTabObserver extends EmptyTabObserver { |
| 69 private final CallbackHelper mFinishCallback; | 72 private final CallbackHelper mFinishCallback; |
| 70 private final CallbackHelper mPageFailCallback; | 73 private final CallbackHelper mPageFailCallback; |
| 71 private final CallbackHelper mLoadFailCallback; | 74 private final CallbackHelper mLoadFailCallback; |
| 72 | 75 |
| 73 TestTabObserver(final CallbackHelper finishCallback, final CallbackHelpe
r pageFailCallback, | 76 TestTabObserver(final CallbackHelper finishCallback, final CallbackHelpe
r pageFailCallback, |
| 74 final CallbackHelper loadFailCallback) { | 77 final CallbackHelper loadFailCallback) { |
| 75 mFinishCallback = finishCallback; | 78 mFinishCallback = finishCallback; |
| 76 mPageFailCallback = pageFailCallback; | 79 mPageFailCallback = pageFailCallback; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 94 } | 97 } |
| 95 | 98 |
| 96 @Override | 99 @Override |
| 97 public void onDestroyed(Tab tab) { | 100 public void onDestroyed(Tab tab) { |
| 98 // A new tab is destroyed when loading is overridden while opening i
t. | 101 // A new tab is destroyed when loading is overridden while opening i
t. |
| 99 mPageFailCallback.notifyCalled(); | 102 mPageFailCallback.notifyCalled(); |
| 100 } | 103 } |
| 101 } | 104 } |
| 102 | 105 |
| 103 private ActivityMonitor mActivityMonitor; | 106 private ActivityMonitor mActivityMonitor; |
| 107 private EmbeddedTestServer mTestServer; |
| 104 | 108 |
| 105 public UrlOverridingTest() { | 109 public UrlOverridingTest() { |
| 106 super(ChromeActivity.class); | 110 super(ChromeActivity.class); |
| 111 mSkipCheckHttpServer = true; |
| 107 } | 112 } |
| 108 | 113 |
| 109 @Override | 114 @Override |
| 110 protected void setUp() throws Exception { | 115 protected void setUp() throws Exception { |
| 111 super.setUp(); | 116 super.setUp(); |
| 112 IntentFilter filter = new IntentFilter(Intent.ACTION_VIEW); | 117 IntentFilter filter = new IntentFilter(Intent.ACTION_VIEW); |
| 113 filter.addCategory(Intent.CATEGORY_BROWSABLE); | 118 filter.addCategory(Intent.CATEGORY_BROWSABLE); |
| 114 filter.addDataScheme("market"); | 119 filter.addDataScheme("market"); |
| 115 mActivityMonitor = getInstrumentation().addMonitor( | 120 mActivityMonitor = getInstrumentation().addMonitor( |
| 116 filter, new Instrumentation.ActivityResult(Activity.RESULT_OK, n
ull), true); | 121 filter, new Instrumentation.ActivityResult(Activity.RESULT_OK, n
ull), true); |
| 122 mTestServer = EmbeddedTestServer.createAndStartFileServer( |
| 123 getInstrumentation().getContext(), Environment.getExternalStorag
eDirectory()); |
| 124 } |
| 125 |
| 126 @Override |
| 127 protected void tearDown() throws Exception { |
| 128 mTestServer.stopAndDestroyServer(); |
| 129 super.tearDown(); |
| 117 } | 130 } |
| 118 | 131 |
| 119 private void loadUrlAndWaitForIntentUrl(final String url, boolean needClick, | 132 private void loadUrlAndWaitForIntentUrl(final String url, boolean needClick, |
| 120 boolean shouldLaunchExternalIntent, boolean isMainFrame) throws Inte
rruptedException { | 133 boolean shouldLaunchExternalIntent, boolean isMainFrame) throws Inte
rruptedException { |
| 121 loadUrlAndWaitForIntentUrl(url, needClick, 0, shouldLaunchExternalIntent
, url, isMainFrame); | 134 loadUrlAndWaitForIntentUrl(url, needClick, 0, shouldLaunchExternalIntent
, url, isMainFrame); |
| 122 } | 135 } |
| 123 | 136 |
| 124 private void loadUrlAndWaitForIntentUrl(final String url, boolean needClick, | 137 private void loadUrlAndWaitForIntentUrl(final String url, boolean needClick, |
| 125 int expectedNewTabCount, final boolean shouldLaunchExternalIntent, | 138 int expectedNewTabCount, final boolean shouldLaunchExternalIntent, |
| 126 final String expectedFinalUrl, boolean isMainFrame) throws Interrupt
edException { | 139 final String expectedFinalUrl, boolean isMainFrame) throws Interrupt
edException { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // and NO_OVERRIDE since tab clobbering will eventually
lead to NO_OVERRIDE. | 203 // and NO_OVERRIDE since tab clobbering will eventually
lead to NO_OVERRIDE. |
| 191 // in the tab. Rather, we check the final URL to disting
uish between | 204 // in the tab. Rather, we check the final URL to disting
uish between |
| 192 // fallback and normal navigation. See crbug.com/487364
for more. | 205 // fallback and normal navigation. See crbug.com/487364
for more. |
| 193 Tab tab = latestTabHolder[0]; | 206 Tab tab = latestTabHolder[0]; |
| 194 if (shouldLaunchExternalIntent | 207 if (shouldLaunchExternalIntent |
| 195 != (OverrideUrlLoadingResult.OVERRIDE_WITH_EXTER
NAL_INTENT | 208 != (OverrideUrlLoadingResult.OVERRIDE_WITH_EXTER
NAL_INTENT |
| 196 == tab.getInterceptNavigationDelegate() | 209 == tab.getInterceptNavigationDelegate() |
| 197 .getLastOverrideUrlLoadingResult
ForTests())) { | 210 .getLastOverrideUrlLoadingResult
ForTests())) { |
| 198 return false; | 211 return false; |
| 199 } | 212 } |
| 213 updateFailureReason("Expected: " + expectedFinalUrl + "
actual: " |
| 214 + tab.getUrl()); |
| 200 return expectedFinalUrl == null | 215 return expectedFinalUrl == null |
| 201 || TextUtils.equals(expectedFinalUrl, tab.getUrl
()); | 216 || TextUtils.equals(expectedFinalUrl, tab.getUrl
()); |
| 202 } | 217 } |
| 203 }); | 218 }); |
| 204 } | 219 } |
| 205 | 220 |
| 206 @SmallTest | 221 @SmallTest |
| 207 public void testNavigationFromTimer() throws InterruptedException { | 222 public void testNavigationFromTimer() throws InterruptedException { |
| 208 loadUrlAndWaitForIntentUrl( | 223 loadUrlAndWaitForIntentUrl( |
| 209 TestHttpServerClient.getUrl(NAVIGATION_FROM_TIMEOUT_PAGE), false
, false, true); | 224 mTestServer.getURL(NAVIGATION_FROM_TIMEOUT_PAGE), false, false,
true); |
| 210 } | 225 } |
| 211 | 226 |
| 212 @SmallTest | 227 @SmallTest |
| 213 public void testNavigationFromTimerInSubFrame() throws InterruptedException
{ | 228 public void testNavigationFromTimerInSubFrame() throws InterruptedException
{ |
| 214 loadUrlAndWaitForIntentUrl( | 229 loadUrlAndWaitForIntentUrl( |
| 215 TestHttpServerClient.getUrl(NAVIGATION_FROM_TIMEOUT_PARENT_FRAME
_PAGE), false, | 230 mTestServer.getURL(NAVIGATION_FROM_TIMEOUT_PARENT_FRAME_PAGE), f
alse, |
| 216 false, false); | 231 false, false); |
| 217 } | 232 } |
| 218 | 233 |
| 219 @SmallTest | 234 @SmallTest |
| 220 public void testNavigationFromUserGesture() throws InterruptedException { | 235 public void testNavigationFromUserGesture() throws InterruptedException { |
| 221 loadUrlAndWaitForIntentUrl( | 236 loadUrlAndWaitForIntentUrl( |
| 222 TestHttpServerClient.getUrl(NAVIGATION_FROM_USER_GESTURE_PAGE),
true, true, true); | 237 mTestServer.getURL(NAVIGATION_FROM_USER_GESTURE_PAGE), true, tru
e, true); |
| 223 } | 238 } |
| 224 | 239 |
| 225 @SmallTest | 240 @SmallTest |
| 226 public void testNavigationFromUserGestureInSubFrame() throws InterruptedExce
ption { | 241 public void testNavigationFromUserGestureInSubFrame() throws InterruptedExce
ption { |
| 227 loadUrlAndWaitForIntentUrl( | 242 loadUrlAndWaitForIntentUrl( |
| 228 TestHttpServerClient.getUrl(NAVIGATION_FROM_USER_GESTURE_PARENT_
FRAME_PAGE), true, | 243 mTestServer.getURL(NAVIGATION_FROM_USER_GESTURE_PARENT_FRAME_PAG
E), true, |
| 229 true, false); | 244 true, false); |
| 230 } | 245 } |
| 231 | 246 |
| 232 @SmallTest | 247 @SmallTest |
| 233 public void testNavigationFromXHRCallback() throws InterruptedException { | 248 public void testNavigationFromXHRCallback() throws InterruptedException { |
| 234 loadUrlAndWaitForIntentUrl( | 249 loadUrlAndWaitForIntentUrl( |
| 235 TestHttpServerClient.getUrl(NAVIGATION_FROM_XHR_CALLBACK_PAGE),
true, true, true); | 250 mTestServer.getURL(NAVIGATION_FROM_XHR_CALLBACK_PAGE), true, tru
e, true); |
| 236 } | 251 } |
| 237 | 252 |
| 238 @SmallTest | 253 @SmallTest |
| 239 public void testNavigationFromXHRCallbackInSubFrame() throws InterruptedExce
ption { | 254 public void testNavigationFromXHRCallbackInSubFrame() throws InterruptedExce
ption { |
| 240 loadUrlAndWaitForIntentUrl( | 255 loadUrlAndWaitForIntentUrl( |
| 241 TestHttpServerClient.getUrl(NAVIGATION_FROM_XHR_CALLBACK_PARENT_
FRAME_PAGE), true, | 256 mTestServer.getURL(NAVIGATION_FROM_XHR_CALLBACK_PARENT_FRAME_PAG
E), true, |
| 242 true, false); | 257 true, false); |
| 243 } | 258 } |
| 244 | 259 |
| 245 @SmallTest | 260 @SmallTest |
| 246 public void testNavigationFromXHRCallbackAndShortTimeout() throws Interrupte
dException { | 261 public void testNavigationFromXHRCallbackAndShortTimeout() throws Interrupte
dException { |
| 247 loadUrlAndWaitForIntentUrl( | 262 loadUrlAndWaitForIntentUrl( |
| 248 TestHttpServerClient.getUrl(NAVIGATION_FROM_XHR_CALLBACK_AND_SHO
RT_TIMEOUT_PAGE), | 263 mTestServer.getURL(NAVIGATION_FROM_XHR_CALLBACK_AND_SHORT_TIMEOU
T_PAGE), |
| 249 true, true, true); | 264 true, true, true); |
| 250 } | 265 } |
| 251 | 266 |
| 252 @SmallTest | 267 @SmallTest |
| 253 public void testNavigationFromXHRCallbackAndLongTimeout() throws Interrupted
Exception { | 268 public void testNavigationFromXHRCallbackAndLongTimeout() throws Interrupted
Exception { |
| 254 loadUrlAndWaitForIntentUrl( | 269 loadUrlAndWaitForIntentUrl( |
| 255 TestHttpServerClient.getUrl(NAVIGATION_FROM_XHR_CALLBACK_AND_LON
G_TIMEOUT_PAGE), | 270 mTestServer.getURL(NAVIGATION_FROM_XHR_CALLBACK_AND_LONG_TIMEOUT
_PAGE), |
| 256 true, false, true); | 271 true, false, true); |
| 257 } | 272 } |
| 258 | 273 |
| 259 @SmallTest | 274 @SmallTest |
| 260 public void testNavigationWithFallbackURL() throws InterruptedException { | 275 public void testNavigationWithFallbackURL() |
| 261 loadUrlAndWaitForIntentUrl(TestHttpServerClient.getUrl(NAVIGATION_WITH_F
ALLBACK_URL_PAGE), | 276 throws InterruptedException, UnsupportedEncodingException { |
| 262 true, 0, false, TestHttpServerClient.getUrl(FALLBACK_LANDING_URL
), true); | 277 String fallbackUrl = mTestServer.getURL(FALLBACK_LANDING_PATH); |
| 278 String originalUrl = mTestServer.getURL( |
| 279 NAVIGATION_WITH_FALLBACK_URL_PAGE + "?replace_text=" |
| 280 + Base64.encodeToString("PARAM_FALLBACK_URL".getBytes("utf-8"),
Base64.URL_SAFE) |
| 281 + ":" + Base64.encodeToString(fallbackUrl.getBytes("utf-8"), Bas
e64.URL_SAFE)); |
| 282 loadUrlAndWaitForIntentUrl(originalUrl, true, 0, false, fallbackUrl, tru
e); |
| 263 } | 283 } |
| 264 | 284 |
| 265 @SmallTest | 285 @SmallTest |
| 266 public void testNavigationWithFallbackURLInSubFrame() throws InterruptedExce
ption { | 286 public void testNavigationWithFallbackURLInSubFrame() |
| 287 throws InterruptedException, UnsupportedEncodingException { |
| 288 // The replace_text parameters for NAVIGATION_WITH_FALLBACK_URL_PAGE, wh
ich is loaded in |
| 289 // the iframe in NAVIGATION_WITH_FALLBACK_URL_PARENT_FRAME_PAGE, have to
go through the |
| 290 // embedded test server twice and, as such, have to be base64-encoded tw
ice. |
| 291 String fallbackUrl = mTestServer.getURL(FALLBACK_LANDING_PATH); |
| 292 byte[] paramBase64Name = "PARAM_BASE64_NAME".getBytes("utf-8"); |
| 293 byte[] base64ParamFallbackUrl = Base64.encode("PARAM_FALLBACK_URL".getBy
tes("utf-8"), |
| 294 Base64.URL_SAFE); |
| 295 byte[] paramBase64Value = "PARAM_BASE64_VALUE".getBytes("utf-8"); |
| 296 byte[] base64FallbackUrl = Base64.encode(fallbackUrl.getBytes("utf-8"),
Base64.URL_SAFE); |
| 297 |
| 298 String originalUrl = mTestServer.getURL( |
| 299 NAVIGATION_WITH_FALLBACK_URL_PARENT_FRAME_PAGE |
| 300 + "?replace_text=" |
| 301 + Base64.encodeToString(paramBase64Name, Base64.URL_SAFE) + ":" |
| 302 + Base64.encodeToString(base64ParamFallbackUrl, Base64.URL_SAFE) |
| 303 + "&replace_text=" |
| 304 + Base64.encodeToString(paramBase64Value, Base64.URL_SAFE) + ":" |
| 305 + Base64.encodeToString(base64FallbackUrl, Base64.URL_SAFE)); |
| 306 |
| 267 // Fallback URL from a subframe will not trigger main or sub frame navig
ation. | 307 // Fallback URL from a subframe will not trigger main or sub frame navig
ation. |
| 268 loadUrlAndWaitForIntentUrl( | 308 loadUrlAndWaitForIntentUrl(originalUrl, true, false, false); |
| 269 TestHttpServerClient.getUrl(NAVIGATION_WITH_FALLBACK_URL_PARENT_
FRAME_PAGE), true, | |
| 270 false, false); | |
| 271 } | 309 } |
| 272 | 310 |
| 273 @SmallTest | 311 @SmallTest |
| 274 @Restriction(ChromeRestriction.RESTRICTION_TYPE_TABLET) | 312 @Restriction(ChromeRestriction.RESTRICTION_TYPE_TABLET) |
| 275 public void testOpenWindowFromUserGesture() throws InterruptedException { | 313 public void testOpenWindowFromUserGesture() throws InterruptedException { |
| 276 loadUrlAndWaitForIntentUrl(TestHttpServerClient.getUrl(OPEN_WINDOW_FROM_
USER_GESTURE_PAGE), | 314 loadUrlAndWaitForIntentUrl(mTestServer.getURL(OPEN_WINDOW_FROM_USER_GEST
URE_PAGE), |
| 277 true, 1, true, null, true); | 315 true, 1, true, null, true); |
| 278 } | 316 } |
| 279 | 317 |
| 280 @SmallTest | 318 @SmallTest |
| 281 public void testRedirectionFromIntent() throws InterruptedException { | 319 public void testRedirectionFromIntent() throws InterruptedException { |
| 282 Intent intent = new Intent(Intent.ACTION_VIEW, | 320 Intent intent = new Intent(Intent.ACTION_VIEW, |
| 283 Uri.parse(TestHttpServerClient.getUrl(NAVIGATION_FROM_JAVA_REDIR
ECTION_PAGE))); | 321 Uri.parse(mTestServer.getURL(NAVIGATION_FROM_JAVA_REDIRECTION_PA
GE))); |
| 284 Context targetContext = getInstrumentation().getTargetContext(); | 322 Context targetContext = getInstrumentation().getTargetContext(); |
| 285 intent.setClassName(targetContext, ChromeLauncherActivity.class.getName(
)); | 323 intent.setClassName(targetContext, ChromeLauncherActivity.class.getName(
)); |
| 286 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | 324 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 287 targetContext.startActivity(intent); | 325 targetContext.startActivity(intent); |
| 288 | 326 |
| 289 CriteriaHelper.pollForUIThreadCriteria(new Criteria() { | 327 CriteriaHelper.pollForUIThreadCriteria(new Criteria() { |
| 290 @Override | 328 @Override |
| 291 public boolean isSatisfied() { | 329 public boolean isSatisfied() { |
| 292 return mActivityMonitor.getHits() == 1; | 330 return mActivityMonitor.getHits() == 1; |
| 293 } | 331 } |
| 294 }); | 332 }); |
| 295 } | 333 } |
| 296 | 334 |
| 297 @Override | 335 @Override |
| 298 public void startMainActivity() throws InterruptedException { | 336 public void startMainActivity() throws InterruptedException { |
| 299 startMainActivityOnBlankPage(); | 337 startMainActivityOnBlankPage(); |
| 300 } | 338 } |
| 301 } | 339 } |
| OLD | NEW |