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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/tab/TabRedirectHandlerTest.java

Issue 1039013002: Use fallback URL more extensively (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.tab; 5 package org.chromium.chrome.browser.tab;
6 6
7 import android.content.Intent; 7 import android.content.Intent;
8 import android.content.pm.ActivityInfo; 8 import android.content.pm.ActivityInfo;
9 import android.content.pm.PackageManager; 9 import android.content.pm.PackageManager;
10 import android.content.pm.ResolveInfo; 10 import android.content.pm.ResolveInfo;
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 SystemClock.sleep(1); 251 SystemClock.sleep(1);
252 handler.updateNewUrlLoading(PageTransition.LINK, false, SystemClock.elap sedRealtime(), 2); 252 handler.updateNewUrlLoading(PageTransition.LINK, false, SystemClock.elap sedRealtime(), 2);
253 assertFalse(handler.shouldStayInChrome()); 253 assertFalse(handler.shouldStayInChrome());
254 254
255 assertTrue(handler.isOnNavigation()); 255 assertTrue(handler.isOnNavigation());
256 assertEquals(2, handler.getLastCommittedEntryIndexBeforeStartingNavigati on()); 256 assertEquals(2, handler.getLastCommittedEntryIndexBeforeStartingNavigati on());
257 } 257 }
258 258
259 @SmallTest 259 @SmallTest
260 @Feature({"IntentHandling"}) 260 @Feature({"IntentHandling"})
261 public void testRedirectFromCurrentNavigationShouldStayInChrome() { 261 public void testRedirectFromCurrentNavigationShouldNotOverrideUrlLoading() {
262 ///////////////////////////////////////////////////// 262 /////////////////////////////////////////////////////
263 // 1. 3XX redirection should stay in Chrome. 263 // 1. 3XX redirection should not override URL loading.
264 ///////////////////////////////////////////////////// 264 /////////////////////////////////////////////////////
265 TabRedirectHandler handler = new TabRedirectHandler(mContext); 265 TabRedirectHandler handler = new TabRedirectHandler(mContext);
266 handler.updateIntent(sYtIntent); 266 handler.updateIntent(sYtIntent);
267 assertFalse(handler.shouldStayInChrome()); 267 assertFalse(handler.shouldNotOverrideUrlLoading());
268 268
269 handler.updateNewUrlLoading(PageTransition.LINK, false, 0, 0); 269 handler.updateNewUrlLoading(PageTransition.LINK, false, 0, 0);
270 handler.setShouldStayInChromeUntilNewUrlLoading(); 270 handler.setShouldNotOverrideUrlLoadingUntilNewUrlLoading();
271 271
272 handler.updateNewUrlLoading(PageTransition.LINK, true, 0, 0); 272 handler.updateNewUrlLoading(PageTransition.LINK, true, 0, 0);
273 assertTrue(handler.shouldStayInChrome()); 273 assertTrue(handler.shouldNotOverrideUrlLoading());
274 assertEquals(0, handler.getLastCommittedEntryIndexBeforeStartingNavigati on()); 274 assertEquals(0, handler.getLastCommittedEntryIndexBeforeStartingNavigati on());
275 275
276 ///////////////////////////////////////////////////// 276 /////////////////////////////////////////////////////
277 // 2. Effective redirection should stay in Chrome. 277 // 2. Effective redirection should not override URL loading.
278 ///////////////////////////////////////////////////// 278 /////////////////////////////////////////////////////
279 handler = new TabRedirectHandler(mContext); 279 handler = new TabRedirectHandler(mContext);
280 handler.updateIntent(sYtIntent); 280 handler.updateIntent(sYtIntent);
281 assertFalse(handler.shouldStayInChrome()); 281 assertFalse(handler.shouldNotOverrideUrlLoading());
282 282
283 handler.updateNewUrlLoading(PageTransition.LINK, false, 0, 0); 283 handler.updateNewUrlLoading(PageTransition.LINK, false, 0, 0);
284 handler.setShouldStayInChromeUntilNewUrlLoading(); 284 handler.setShouldNotOverrideUrlLoadingUntilNewUrlLoading();
285 285
286 // Effective redirection should stay in Chrome. 286 // Effective redirection occurred.
287 handler.updateNewUrlLoading(PageTransition.LINK, false, 0, 1); 287 handler.updateNewUrlLoading(PageTransition.LINK, false, 0, 1);
288 assertTrue(handler.shouldStayInChrome()); 288 assertTrue(handler.shouldNotOverrideUrlLoading());
289 assertEquals(0, handler.getLastCommittedEntryIndexBeforeStartingNavigati on()); 289 assertEquals(0, handler.getLastCommittedEntryIndexBeforeStartingNavigati on());
290 290
291 ///////////////////////////////////////////////////// 291 /////////////////////////////////////////////////////
292 // 3. New URL loading should not be affected. 292 // 3. New URL loading should not be affected.
293 ///////////////////////////////////////////////////// 293 /////////////////////////////////////////////////////
294 SystemClock.sleep(1); 294 SystemClock.sleep(1);
295 handler.updateNewUrlLoading(PageTransition.LINK, false, SystemClock.elap sedRealtime(), 2); 295 handler.updateNewUrlLoading(PageTransition.LINK, false, SystemClock.elap sedRealtime(), 2);
296 assertFalse(handler.shouldStayInChrome()); 296 assertFalse(handler.shouldNotOverrideUrlLoading());
297 assertEquals(2, handler.getLastCommittedEntryIndexBeforeStartingNavigati on()); 297 assertEquals(2, handler.getLastCommittedEntryIndexBeforeStartingNavigati on());
298 } 298 }
299 299
300 private static class TestPackageManager extends MockPackageManager { 300 private static class TestPackageManager extends MockPackageManager {
301 @Override 301 @Override
302 public List<ResolveInfo> queryIntentActivities(Intent intent, int flags) { 302 public List<ResolveInfo> queryIntentActivities(Intent intent, int flags) {
303 List<ResolveInfo> resolves = new ArrayList<ResolveInfo>(); 303 List<ResolveInfo> resolves = new ArrayList<ResolveInfo>();
304 if (intent.getDataString().startsWith("http://m.youtube.com") 304 if (intent.getDataString().startsWith("http://m.youtube.com")
305 || intent.getDataString().startsWith("http://youtube.com")) { 305 || intent.getDataString().startsWith("http://youtube.com")) {
306 ResolveInfo youTubeApp = new ResolveInfo(); 306 ResolveInfo youTubeApp = new ResolveInfo();
(...skipping 18 matching lines...) Expand all
325 return new TestPackageManager(); 325 return new TestPackageManager();
326 } 326 }
327 327
328 @Override 328 @Override
329 public String getPackageName() { 329 public String getPackageName() {
330 return TEST_PACKAGE_NAME; 330 return TEST_PACKAGE_NAME;
331 } 331 }
332 332
333 } 333 }
334 } 334 }
OLDNEW
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698