| Index: chrome/browser/ui/search/instant_extended_interactive_uitest.cc
|
| diff --git a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
|
| index 83752412ffafe48627045a36c4c56be0736c15c2..dfbba4836c38a8734e57fdb6bce0e3597f9c777c 100644
|
| --- a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
|
| +++ b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
|
| @@ -46,8 +46,6 @@
|
| #include "chrome/browser/ui/browser_list.h"
|
| #include "chrome/browser/ui/browser_tabstrip.h"
|
| #include "chrome/browser/ui/omnibox/omnibox_view.h"
|
| -#include "chrome/browser/ui/search/instant_ntp.h"
|
| -#include "chrome/browser/ui/search/instant_ntp_prerenderer.h"
|
| #include "chrome/browser/ui/search/instant_tab.h"
|
| #include "chrome/browser/ui/search/instant_test_utils.h"
|
| #include "chrome/browser/ui/search/search_tab_helper.h"
|
| @@ -153,7 +151,9 @@ class InstantExtendedTest : public InProcessBrowserTest,
|
| ASSERT_TRUE(https_test_server().Start());
|
| GURL instant_url = https_test_server().GetURL(
|
| "files/instant_extended.html?strk=1&");
|
| - InstantTestBase::Init(instant_url, false);
|
| + GURL ntp_url = https_test_server().GetURL(
|
| + "files/instant_extended_ntp.html?strk=1&");
|
| + InstantTestBase::Init(instant_url, ntp_url, false);
|
| }
|
|
|
| int64 GetHistogramCount(const char* name) {
|
| @@ -167,24 +167,6 @@ class InstantExtendedTest : public InProcessBrowserTest,
|
| return histogram->SnapshotSamples()->TotalCount();
|
| }
|
|
|
| - void SendDownArrow() {
|
| - omnibox()->model()->OnUpOrDownKeyPressed(1);
|
| - // Wait for JavaScript to run the key handler by executing a blank script.
|
| - EXPECT_TRUE(ExecuteScript(std::string()));
|
| - }
|
| -
|
| - void SendUpArrow() {
|
| - omnibox()->model()->OnUpOrDownKeyPressed(-1);
|
| - // Wait for JavaScript to run the key handler by executing a blank script.
|
| - EXPECT_TRUE(ExecuteScript(std::string()));
|
| - }
|
| -
|
| - void SendEscape() {
|
| - omnibox()->model()->OnEscapeKeyPressed();
|
| - // Wait for JavaScript to run the key handler by executing a blank script.
|
| - EXPECT_TRUE(ExecuteScript(std::string()));
|
| - }
|
| -
|
| bool UpdateSearchState(content::WebContents* contents) WARN_UNUSED_RESULT {
|
| return GetIntFromJS(contents, "onMostVisitedChangedCalls",
|
| &on_most_visited_change_calls_) &&
|
| @@ -279,13 +261,15 @@ class InstantExtendedPrefetchTest : public InstantExtendedTest {
|
| ASSERT_TRUE(https_test_server().Start());
|
| GURL instant_url = https_test_server().GetURL(
|
| "files/instant_extended.html?strk=1&");
|
| - InstantTestBase::Init(instant_url, true);
|
| + GURL ntp_url = https_test_server().GetURL(
|
| + "files/instant_extended_ntp.html?strk=1&");
|
| + InstantTestBase::Init(instant_url, ntp_url, true);
|
| }
|
|
|
| virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
|
| command_line->AppendSwitchASCII(
|
| switches::kForceFieldTrials,
|
| - "EmbeddedSearch/Group11 prefetch_results_srp:1 use_cacheable_ntp:0/");
|
| + "EmbeddedSearch/Group11 prefetch_results_srp:1/");
|
| }
|
|
|
| net::FakeURLFetcherFactory* fake_factory() { return fake_factory_.get(); }
|
| @@ -335,7 +319,9 @@ class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase {
|
| ASSERT_TRUE(https_test_server().Start());
|
| GURL instant_url = https_test_server().GetURL(
|
| "files/instant_extended.html?strk=1&");
|
| - InstantTestBase::Init(instant_url, false);
|
| + GURL ntp_url = https_test_server().GetURL(
|
| + "files/instant_extended_ntp.html?strk=1&");
|
| + InstantTestBase::Init(instant_url, ntp_url, false);
|
| }
|
|
|
| void InstallThemeSource() {
|
| @@ -366,84 +352,9 @@ class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase {
|
| DISALLOW_COPY_AND_ASSIGN(InstantPolicyTest);
|
| };
|
|
|
| -IN_PROC_BROWSER_TEST_F(InstantExtendedNetworkTest, NTPReactsToNetworkChanges) {
|
| - // Setup Instant.
|
| - ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
| -
|
| - InstantService* instant_service =
|
| - InstantServiceFactory::GetForProfile(browser()->profile());
|
| - ASSERT_NE(static_cast<InstantService*>(NULL), instant_service);
|
| -
|
| - // The setup first initializes the platform specific NetworkChangeNotifier.
|
| - // The InstantExtendedNetworkTest replaces it with a fake, but by the time,
|
| - // InstantNTPPrerenderer has already registered itself. So the
|
| - // InstantNTPPrerenderer needs to register itself as NetworkChangeObserver
|
| - // again.
|
| - net::NetworkChangeNotifier::AddNetworkChangeObserver(
|
| - instant_service->ntp_prerenderer());
|
| -
|
| - // The fake network change notifier will provide the network state to be
|
| - // offline, so the ntp will be local.
|
| - ASSERT_NE(static_cast<InstantNTP*>(NULL),
|
| - instant_service->ntp_prerenderer()->ntp());
|
| - EXPECT_TRUE(instant_service->ntp_prerenderer()->ntp()->IsLocal());
|
| -
|
| - // Change the connect state, and wait for the notifications to be run, and NTP
|
| - // support to be determined.
|
| - SetConnectionType(net::NetworkChangeNotifier::CONNECTION_ETHERNET);
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
| -
|
| - // Verify the network state is fine, and InstantNTPPrerenderer doesn't want
|
| - // to switch to local NTP anymore.
|
| - EXPECT_FALSE(net::NetworkChangeNotifier::IsOffline());
|
| - EXPECT_FALSE(instant_service->ntp_prerenderer()->ShouldSwitchToLocalNTP());
|
| -
|
| - // Open new tab.
|
| - ui_test_utils::NavigateToURLWithDisposition(
|
| - browser(),
|
| - GURL(chrome::kChromeUINewTabURL),
|
| - NEW_FOREGROUND_TAB,
|
| - ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
|
| - content::WebContents* active_tab =
|
| - browser()->tab_strip_model()->GetActiveWebContents();
|
| -
|
| - // Verify new NTP is not local.
|
| - EXPECT_TRUE(chrome::IsInstantNTP(active_tab));
|
| - EXPECT_NE(instant_service->ntp_prerenderer()->GetLocalInstantURL(),
|
| - active_tab->GetURL().spec());
|
| - ASSERT_NE(static_cast<InstantNTP*>(NULL),
|
| - instant_service->ntp_prerenderer()->ntp());
|
| - EXPECT_FALSE(instant_service->ntp_prerenderer()->ntp()->IsLocal());
|
| -
|
| - SetConnectionType(net::NetworkChangeNotifier::CONNECTION_NONE);
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
| -
|
| - // Verify the network state is fine, and InstantNTPPrerenderer doesn't want
|
| - // to switch to local NTP anymore.
|
| - EXPECT_TRUE(net::NetworkChangeNotifier::IsOffline());
|
| - EXPECT_TRUE(instant_service->ntp_prerenderer()->ShouldSwitchToLocalNTP());
|
| -
|
| - // Open new tab. Preloaded NTP contents should have been used.
|
| - ui_test_utils::NavigateToURLWithDisposition(
|
| - browser(),
|
| - GURL(chrome::kChromeUINewTabURL),
|
| - NEW_FOREGROUND_TAB,
|
| - ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
|
| - active_tab = browser()->tab_strip_model()->GetActiveWebContents();
|
| -
|
| - // Verify new NTP is not local.
|
| - EXPECT_TRUE(chrome::IsInstantNTP(active_tab));
|
| - EXPECT_EQ(instant_service->ntp_prerenderer()->GetLocalInstantURL(),
|
| - active_tab->GetURL().spec());
|
| - ASSERT_NE(static_cast<InstantNTP*>(NULL),
|
| - instant_service->ntp_prerenderer()->ntp());
|
| - EXPECT_TRUE(instant_service->ntp_prerenderer()->ntp()->IsLocal());
|
| -}
|
| -
|
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, SearchReusesInstantTab) {
|
| ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
| + FocusOmnibox();
|
|
|
| content::WindowedNotificationObserver observer(
|
| chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
|
| @@ -472,7 +383,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, SearchReusesInstantTab) {
|
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
|
| SearchDoesntReuseInstantTabWithoutSupport) {
|
| ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
| + FocusOmnibox();
|
|
|
| // Don't wait for the navigation to complete.
|
| SetOmniboxText("flowers");
|
| @@ -490,7 +401,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
|
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
|
| TypedSearchURLDoesntReuseInstantTab) {
|
| ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
| + FocusOmnibox();
|
|
|
| // Create an observer to wait for the instant tab to support Instant.
|
| content::WindowedNotificationObserver observer_1(
|
| @@ -522,7 +433,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
|
|
|
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxMarginSetForSearchURLs) {
|
| ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
| + FocusOmnibox();
|
|
|
| // Create an observer to wait for the instant tab to support Instant.
|
| content::WindowedNotificationObserver observer(
|
| @@ -545,14 +456,14 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxMarginSetForSearchURLs) {
|
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoMostVisitedChangedOnTabSwitch) {
|
| // Initialize Instant.
|
| ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
|
|
| - // Open new tab. Preloaded NTP contents should have been used.
|
| + // Open new tab.
|
| ui_test_utils::NavigateToURLWithDisposition(
|
| browser(),
|
| GURL(chrome::kChromeUINewTabURL),
|
| NEW_FOREGROUND_TAB,
|
| - ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
|
| + ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
|
| + ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
|
| EXPECT_EQ(2, browser()->tab_strip_model()->count());
|
|
|
| // Make sure new tab received the onmostvisitedchanged event once.
|
| @@ -577,7 +488,6 @@ IN_PROC_BROWSER_TEST_F(InstantPolicyTest, ThemeBackgroundAccess) {
|
| InstallThemeSource();
|
| ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme"));
|
| ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
|
|
| // The "Instant" New Tab should have access to chrome-search: scheme but not
|
| // chrome: scheme.
|
| @@ -585,7 +495,8 @@ IN_PROC_BROWSER_TEST_F(InstantPolicyTest, ThemeBackgroundAccess) {
|
| browser(),
|
| GURL(chrome::kChromeUINewTabURL),
|
| NEW_FOREGROUND_TAB,
|
| - ui_test_utils::BROWSER_TEST_NONE);
|
| + ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
|
| + ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
|
|
|
| content::RenderViewHost* rvh =
|
| browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost();
|
| @@ -604,18 +515,18 @@ IN_PROC_BROWSER_TEST_F(InstantPolicyTest,
|
| NoThemeBackgroundChangeEventOnTabSwitch) {
|
| InstallThemeSource();
|
| ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
|
|
| // Install a theme.
|
| ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme"));
|
| EXPECT_EQ(1, browser()->tab_strip_model()->count());
|
|
|
| - // Open new tab. Preloaded NTP contents should have been used.
|
| + // Open new tab.
|
| ui_test_utils::NavigateToURLWithDisposition(
|
| browser(),
|
| GURL(chrome::kChromeUINewTabURL),
|
| NEW_FOREGROUND_TAB,
|
| - ui_test_utils::BROWSER_TEST_NONE);
|
| + ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
|
| + ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
|
| EXPECT_EQ(2, browser()->tab_strip_model()->count());
|
|
|
| content::WebContents* active_tab =
|
| @@ -653,17 +564,17 @@ IN_PROC_BROWSER_TEST_F(InstantPolicyTest,
|
| MAYBE_SendThemeBackgroundChangedEvent) {
|
| InstallThemeSource();
|
| ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
|
|
| // Install a theme.
|
| ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme"));
|
|
|
| - // Open new tab. Preloaded NTP contents should have been used.
|
| + // Open new tab.
|
| ui_test_utils::NavigateToURLWithDisposition(
|
| browser(),
|
| GURL(chrome::kChromeUINewTabURL),
|
| NEW_FOREGROUND_TAB,
|
| - ui_test_utils::BROWSER_TEST_NONE);
|
| + ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
|
| + ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
|
| EXPECT_EQ(2, browser()->tab_strip_model()->count());
|
|
|
| // Make sure new tab received an onthemechanged event.
|
| @@ -698,7 +609,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
|
| ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
|
|
| // Focus omnibox and confirm overlay isn't shown.
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
| + FocusOmnibox();
|
|
|
| // Create an observer to wait for the instant tab to support Instant.
|
| content::WindowedNotificationObserver observer(
|
| @@ -745,7 +656,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
|
| ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
|
|
| // Focus omnibox and confirm overlay isn't shown.
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
| + FocusOmnibox();
|
|
|
| // Create an observer to wait for the instant tab to support Instant.
|
| content::WindowedNotificationObserver observer(
|
| @@ -798,14 +709,15 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
|
| // Flaky on all bots since re-enabled in r208032, crbug.com/253092
|
| IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_NavigateBackToNTP) {
|
| ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
| + FocusOmnibox();
|
|
|
| // Open a new tab page.
|
| ui_test_utils::NavigateToURLWithDisposition(
|
| browser(),
|
| GURL(chrome::kChromeUINewTabURL),
|
| NEW_FOREGROUND_TAB,
|
| - ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
|
| + ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
|
| + ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
|
| EXPECT_EQ(2, browser()->tab_strip_model()->count());
|
|
|
| content::WindowedNotificationObserver observer(
|
| @@ -858,14 +770,15 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
|
| DISABLED_DispatchMVChangeEventWhileNavigatingBackToNTP) {
|
| // Setup Instant.
|
| ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
| + FocusOmnibox();
|
|
|
| - // Open new tab. Preloaded NTP contents should have been used.
|
| + // Open new tab.
|
| ui_test_utils::NavigateToURLWithDisposition(
|
| browser(),
|
| GURL(chrome::kChromeUINewTabURL),
|
| NEW_FOREGROUND_TAB,
|
| - ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
|
| + ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB |
|
| + ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
|
|
|
| content::WebContents* active_tab =
|
| browser()->tab_strip_model()->GetActiveWebContents();
|
| @@ -899,7 +812,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
|
|
|
| IN_PROC_BROWSER_TEST_F(InstantExtendedPrefetchTest, SetPrefetchQuery) {
|
| ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
| + FocusOmnibox();
|
|
|
| content::WindowedNotificationObserver new_tab_observer(
|
| content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| @@ -959,7 +872,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedPrefetchTest, SetPrefetchQuery) {
|
|
|
| IN_PROC_BROWSER_TEST_F(InstantExtendedPrefetchTest, ClearPrefetchedResults) {
|
| ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
| + FocusOmnibox();
|
|
|
| content::WindowedNotificationObserver new_tab_observer(
|
| content::NOTIFICATION_NAV_ENTRY_COMMITTED,
|
| @@ -1051,7 +964,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, Referrer) {
|
| GURL result_url =
|
| test_server()->GetURL("files/referrer_policy/referrer-policy-log.html");
|
| ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
|
| - FocusOmniboxAndWaitForInstantNTPSupport();
|
| + FocusOmnibox();
|
|
|
| // Type a query and press enter to get results.
|
| SetOmniboxText("query");
|
|
|