Index: chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java |
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java |
index 87a615876182c2405fe386bd134046e63f16d0ab..3e1799e5754a0df759230e5df40754f804e084f7 100644 |
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java |
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java |
@@ -65,6 +65,14 @@ public class ExternalNavigationHandlerTest extends InstrumentationTestCase { |
"intent://scan/#Intent;scheme=zxing;" |
+ "S." + ExternalNavigationHandler.EXTRA_BROWSER_FALLBACK_URL + "=" |
+ Uri.encode("http://url.myredirector.com/aaa") + ";end"; |
+ private static final String ENCODED_MARKET_REFERRER = |
+ "_placement%3D{placement}%26network%3D{network}%26device%3D{devicemodel}"; |
+ private static final String INTENT_APP_NOT_INSTALLED_DEFAULT_MARKET_REFERRER = |
+ "intent:///name/nm0000158#Intent;scheme=imdb;package=com.imdb.mobile;end"; |
+ private static final String INTENT_APP_NOT_INSTALLED_WITH_MARKET_REFERRER = |
+ "intent:///name/nm0000158#Intent;scheme=imdb;package=com.imdb.mobile;S." |
+ + ExternalNavigationHandler.EXTRA_MARKET_REFERRER + "=" |
+ + ENCODED_MARKET_REFERRER + ";end"; |
private static final String PLUS_STREAM_URL = "https://plus.google.com/stream"; |
private static final String CALENDAR_URL = "http://www.google.com/calendar"; |
@@ -229,6 +237,35 @@ public class ExternalNavigationHandlerTest extends InstrumentationTestCase { |
} |
@SmallTest |
+ public void testRedirectToMarketWithReferrer() { |
+ mDelegate.setCanResolveActivity(false); |
+ |
+ checkUrl(INTENT_APP_NOT_INSTALLED_WITH_MARKET_REFERRER) |
+ .expecting(OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT, |
+ START_OTHER_ACTIVITY); |
+ |
+ assertNotNull(mDelegate.startActivityIntent); |
+ Uri uri = mDelegate.startActivityIntent.getData(); |
+ assertEquals("market", uri.getScheme()); |
+ assertEquals(Uri.decode(ENCODED_MARKET_REFERRER), uri.getQueryParameter("referrer")); |
+ } |
+ |
+ |
+ @SmallTest |
+ public void testRedirectToMarketWithoutReferrer() { |
+ mDelegate.setCanResolveActivity(false); |
+ |
+ checkUrl(INTENT_APP_NOT_INSTALLED_DEFAULT_MARKET_REFERRER) |
+ .expecting(OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT, |
+ START_OTHER_ACTIVITY); |
+ |
+ assertNotNull(mDelegate.startActivityIntent); |
+ Uri uri = mDelegate.startActivityIntent.getData(); |
+ assertEquals("market", uri.getScheme()); |
+ assertEquals(mDelegate.getPackageName(), uri.getQueryParameter("referrer")); |
+ } |
+ |
+ @SmallTest |
public void testExternalUri() { |
checkUrl("tel:012345678") |
.expecting(OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT, |