Commit f334c44c authored by Mustafa Emre Acer's avatar Mustafa Emre Acer Committed by Commit Bot

Add an Android test for the lookalike interstitial

This test sanity checks that we display a lookalike interstitial for a relevant domain name.
The test is adapted from chrome/browser/ssl/CaptivePortalTest.java.

Bug: 936565
Change-Id: Ic92be9630c15ec4d88043411a79edf0a07ed78ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1497767Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Reviewed-by: default avatarEmily Stark <estark@chromium.org>
Commit-Queue: Mustafa Emre Acer <meacer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638241}
parent f3f987b3
...@@ -244,6 +244,8 @@ public abstract class ChromeFeatureList { ...@@ -244,6 +244,8 @@ public abstract class ChromeFeatureList {
public static final String INTEREST_FEED_CONTENT_SUGGESTIONS = "InterestFeedContentSuggestions"; public static final String INTEREST_FEED_CONTENT_SUGGESTIONS = "InterestFeedContentSuggestions";
public static final String JELLY_BEAN_SUPPORTED = "JellyBeanSupported"; public static final String JELLY_BEAN_SUPPORTED = "JellyBeanSupported";
public static final String LANGUAGES_PREFERENCE = "LanguagesPreference"; public static final String LANGUAGES_PREFERENCE = "LanguagesPreference";
public static final String LOOKALIKE_NAVIGATION_URL_SUGGESTIONS_UI =
"LookalikeUrlNavigationSuggestionsUI";
public static final String SEARCH_ENGINE_PROMO_EXISTING_DEVICE = public static final String SEARCH_ENGINE_PROMO_EXISTING_DEVICE =
"SearchEnginePromo.ExistingDevice"; "SearchEnginePromo.ExistingDevice";
public static final String SEARCH_ENGINE_PROMO_NEW_DEVICE = "SearchEnginePromo.NewDevice"; public static final String SEARCH_ENGINE_PROMO_NEW_DEVICE = "SearchEnginePromo.NewDevice";
......
...@@ -2071,6 +2071,7 @@ chrome_test_java_sources = [ ...@@ -2071,6 +2071,7 @@ chrome_test_java_sources = [
"javatests/src/org/chromium/chrome/browser/init/ChromeBrowserInitializerTest.java", "javatests/src/org/chromium/chrome/browser/init/ChromeBrowserInitializerTest.java",
"javatests/src/org/chromium/chrome/browser/input/SelectPopupOtherContentViewTest.java", "javatests/src/org/chromium/chrome/browser/input/SelectPopupOtherContentViewTest.java",
"javatests/src/org/chromium/chrome/browser/instantapps/InstantAppsHandlerTest.java", "javatests/src/org/chromium/chrome/browser/instantapps/InstantAppsHandlerTest.java",
"javatests/src/org/chromium/chrome/browser/interstitials/LookalikeInterstitialTest.java",
"javatests/src/org/chromium/chrome/browser/invalidation/ChromeBrowserSyncAdapterTest.java", "javatests/src/org/chromium/chrome/browser/invalidation/ChromeBrowserSyncAdapterTest.java",
"javatests/src/org/chromium/chrome/browser/invalidation/DelayedInvalidationsControllerTest.java", "javatests/src/org/chromium/chrome/browser/invalidation/DelayedInvalidationsControllerTest.java",
"javatests/src/org/chromium/chrome/browser/invalidation/InvalidationServiceTest.java", "javatests/src/org/chromium/chrome/browser/invalidation/InvalidationServiceTest.java",
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.interstitials;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.MediumTest;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.parameter.CommandLineParameter;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.ChromeTabUtils;
import org.chromium.chrome.test.util.browser.TabTitleObserver;
import org.chromium.content_public.common.ContentSwitches;
import org.chromium.net.test.EmbeddedTestServer;
/** Tests for the Lookalike URL interstitial (aka confusables). */
@RunWith(ChromeJUnit4ClassRunner.class)
@MediumTest
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
ContentSwitches.HOST_RESOLVER_RULES + "=MAP * 127.0.0.1"})
@CommandLineParameter(
{"", "enable-features=" + ChromeFeatureList.LOOKALIKE_NAVIGATION_URL_SUGGESTIONS_UI})
public class LookalikeInterstitialTest {
private static final String INTERSTITIAL_TITLE_PREFIX = "Did you mean?";
private static final int INTERSTITIAL_TITLE_UPDATE_TIMEOUT_SECONDS = 5;
private EmbeddedTestServer mServer;
@Rule
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
@Before
public void setUp() throws Exception {
mActivityTestRule.startMainActivityFromLauncher();
mServer = EmbeddedTestServer.createAndStartServer(InstrumentationRegistry.getContext());
}
@After
public void tearDown() throws Exception {
mServer.stopAndDestroyServer();
}
@Test
public void testBasicInterstitialShown() throws Exception {
Tab tab = mActivityTestRule.getActivity().getActivityTab();
ChromeTabUtils.loadUrlOnUiThread(tab,
mServer.getURLWithHostName("xn--googl-fsa.com", // googlé.com
"/chrome/test/data/android/navigate/simple.html"));
// Wait for the interstitial page to commit and check the page title.
new TabTitleObserver(tab, INTERSTITIAL_TITLE_PREFIX)
.waitForTitleUpdate(INTERSTITIAL_TITLE_UPDATE_TIMEOUT_SECONDS);
Assert.assertEquals(0, tab.getTitle().indexOf(INTERSTITIAL_TITLE_PREFIX));
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment