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.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.content.ComponentName; | 8 import android.content.ComponentName; |
9 import android.content.Context; | 9 import android.content.Context; |
10 import android.content.Intent; | 10 import android.content.Intent; |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT, | 596 OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT, |
597 START_ACTIVITY); | 597 START_ACTIVITY); |
598 | 598 |
599 Intent invokedIntent = mDelegate.startActivityIntent; | 599 Intent invokedIntent = mDelegate.startActivityIntent; |
600 assertTrue(invokedIntent.getData().toString().startsWith("market://")); | 600 assertTrue(invokedIntent.getData().toString().startsWith("market://")); |
601 assertEquals(null, mDelegate.getNewUrlAfterClobbering()); | 601 assertEquals(null, mDelegate.getNewUrlAfterClobbering()); |
602 assertEquals(null, mDelegate.getReferrerUrlForClobbering()); | 602 assertEquals(null, mDelegate.getReferrerUrlForClobbering()); |
603 } | 603 } |
604 | 604 |
605 @SmallTest | 605 @SmallTest |
| 606 public void testFallback_UseFallbackUrlForRedirectionFromTypedInUrl() { |
| 607 TabRedirectHandler redirectHandler = new TabRedirectHandler(null); |
| 608 |
| 609 redirectHandler.updateNewUrlLoading(PageTransition.TYPED, false, 0, 0); |
| 610 check("http://goo.gl/abcdefg", null, /* referrer */ |
| 611 false, /* incognito */ |
| 612 PageTransition.TYPED, NO_REDIRECT, true, false, redirectHandler, |
| 613 OverrideUrlLoadingResult.NO_OVERRIDE, IGNORE); |
| 614 |
| 615 redirectHandler.updateNewUrlLoading(PageTransition.TYPED, true, 0, 0); |
| 616 check(INTENT_URL_WITH_FALLBACK_URL_WITHOUT_PACKAGE_NAME, null, /* referr
er */ |
| 617 false, /* incognito */ |
| 618 PageTransition.TYPED, REDIRECT, true, false, redirectHandler, |
| 619 OverrideUrlLoadingResult.OVERRIDE_WITH_CLOBBERING_TAB, IGNORE); |
| 620 |
| 621 // Now the user opens a link. |
| 622 redirectHandler.updateNewUrlLoading(PageTransition.LINK, false, 0, 1); |
| 623 check("http://m.youtube.com/", null, /* referrer */ |
| 624 false, /* incognito */ |
| 625 PageTransition.LINK, NO_REDIRECT, true, false, redirectHandler, |
| 626 OverrideUrlLoadingResult.NO_OVERRIDE, IGNORE); |
| 627 } |
| 628 |
| 629 @SmallTest |
606 public void testIgnoreEffectiveRedirectFromIntentFallbackUrl() { | 630 public void testIgnoreEffectiveRedirectFromIntentFallbackUrl() { |
607 // We cannot resolve any intent, so fall-back URL will be used. | 631 // We cannot resolve any intent, so fall-back URL will be used. |
608 mDelegate.setCanResolveActivity(false); | 632 mDelegate.setCanResolveActivity(false); |
609 | 633 |
610 TabRedirectHandler redirectHandler = new TabRedirectHandler(null); | 634 TabRedirectHandler redirectHandler = new TabRedirectHandler(null); |
611 | 635 |
612 redirectHandler.updateNewUrlLoading(PageTransition.LINK, false, 0, 0); | 636 redirectHandler.updateNewUrlLoading(PageTransition.LINK, false, 0, 0); |
613 check(INTENT_URL_WITH_CHAIN_FALLBACK_URL, | 637 check(INTENT_URL_WITH_CHAIN_FALLBACK_URL, |
614 null, /* referrer */ | 638 null, /* referrer */ |
615 false, /* incognito */ | 639 false, /* incognito */ |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 return new TestPackageManager(); | 1011 return new TestPackageManager(); |
988 } | 1012 } |
989 | 1013 |
990 @Override | 1014 @Override |
991 public String getPackageName() { | 1015 public String getPackageName() { |
992 return "test.app.name"; | 1016 return "test.app.name"; |
993 } | 1017 } |
994 | 1018 |
995 } | 1019 } |
996 } | 1020 } |
OLD | NEW |