예제 #1
0
 @UiThreadTest
 @SmallTest
 @Feature({"Android-AppBase"})
 public void testRefererUrl_extraHeadersOnlyReferer() {
   // Check that invalid header specified in EXTRA_HEADERS isn't used.
   Context context = getInstrumentation().getTargetContext();
   Bundle bundle = new Bundle();
   bundle.putString("Referer", GOOGLE_URL);
   Intent headersIntent = new Intent(Intent.ACTION_VIEW);
   headersIntent.putExtra(Browser.EXTRA_HEADERS, bundle);
   assertNull(IntentHandler.getReferrerUrlIncludingExtraHeaders(headersIntent, context));
 }
예제 #2
0
  @UiThreadTest
  @SmallTest
  @Feature({"Android-AppBase"})
  public void testRefererUrl_extraReferrer() {
    // Check that EXTRA_REFERRER is not accepted with a random URL.
    Context context = getInstrumentation().getTargetContext();
    Intent foreignIntent = new Intent(Intent.ACTION_VIEW);
    foreignIntent.putExtra(Intent.EXTRA_REFERRER, GOOGLE_URL);
    assertNull(IntentHandler.getReferrerUrlIncludingExtraHeaders(foreignIntent, context));

    // Check that EXTRA_REFERRER with android-app URL works.
    final String appUrl = "android-app://com.application/http/www.application.com";
    Intent appIntent = new Intent(Intent.ACTION_VIEW);
    appIntent.putExtra(Intent.EXTRA_REFERRER, Uri.parse(appUrl));
    assertEquals(appUrl, IntentHandler.getReferrerUrlIncludingExtraHeaders(appIntent, context));

    // Check that EXTRA_REFERRER_NAME with android-app works.
    Intent nameIntent = new Intent(Intent.ACTION_VIEW);
    nameIntent.putExtra(Intent.EXTRA_REFERRER_NAME, appUrl);
    assertEquals(appUrl, IntentHandler.getReferrerUrlIncludingExtraHeaders(nameIntent, context));
  }
예제 #3
0
 @UiThreadTest
 @SmallTest
 @Feature({"Android-AppBase"})
 public void testRefererUrl_extraHeadersValidReferrer() {
   Context context = getInstrumentation().getTargetContext();
   String validReferer = "android-app://package/http/url";
   Bundle bundle = new Bundle();
   bundle.putString("Referer", validReferer);
   Intent headersIntent = new Intent(Intent.ACTION_VIEW);
   headersIntent.putExtra(Browser.EXTRA_HEADERS, bundle);
   assertEquals(
       validReferer, IntentHandler.getReferrerUrlIncludingExtraHeaders(headersIntent, context));
   assertNull(IntentHandler.getExtraHeadersFromIntent(headersIntent));
 }