Chromium Code Reviews| 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 c9a66666bec172e9b272fa08090c8b1459b654b3..696e111d2b648e8256792bdfd3d3a7d35c33bba4 100644 |
| --- a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc |
| +++ b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc |
| @@ -2714,52 +2714,6 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, MAYBE_KeyboardTogglesVoiceSearch) { |
| EXPECT_EQ(1, on_toggle_voice_search_calls_); |
| } |
| -// Test to verify that the omnibox search query is updated on browser |
| -// back/forward button press events. |
| -IN_PROC_BROWSER_TEST_F(InstantExtendedTest, UpdateSearchQueryOnNavigation) { |
| - ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| - |
| - // Focus omnibox and confirm overlay isn't shown. |
| - FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| - content::WebContents* overlay = instant()->GetOverlayContents(); |
| - EXPECT_TRUE(overlay); |
| - EXPECT_TRUE(instant()->model()->mode().is_default()); |
| - EXPECT_FALSE(instant()->IsOverlayingSearchResults()); |
| - |
| - // Typing in the omnibox should show the overlay. |
| - SetOmniboxTextAndWaitForOverlayToShow("flowers"); |
| - EXPECT_TRUE(instant()->IsOverlayingSearchResults()); |
| - EXPECT_EQ(overlay, instant()->GetOverlayContents()); |
| - |
| - // Commit the search by pressing 'Enter'. |
| - PressEnterAndWaitForNavigation(); |
| - EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText()); |
| - |
| - // Typing in the new search query in omnibox. |
| - SetOmniboxText("cattles"); |
| - // Commit the search by pressing 'Enter'. |
| - PressEnterAndWaitForNavigation(); |
| - // 'Enter' commits the query as it was typed. This creates a navigation entry |
| - // in the history. |
| - EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText()); |
| - |
| - content::WebContents* active_tab = |
| - browser()->tab_strip_model()->GetActiveWebContents(); |
| - EXPECT_TRUE(active_tab->GetController().CanGoBack()); |
| - content::WindowedNotificationObserver load_stop_observer( |
| - content::NOTIFICATION_LOAD_STOP, |
| - content::Source<content::NavigationController>( |
| - &active_tab->GetController())); |
| - active_tab->GetController().GoBack(); |
| - load_stop_observer.Wait(); |
| - |
| - EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText()); |
| - // Commit the search by pressing 'Enter'. |
| - FocusOmnibox(); |
| - PressEnterAndWaitForNavigation(); |
| - EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText()); |
| -} |
| - |
| #endif // HTML_INSTANT_EXTENDED_POPUP |
| #if !defined(HTML_INSTANT_EXTENDED_POPUP) |
| @@ -2897,3 +2851,173 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoMostVisitedChangedOnTabSwitch) { |
| EXPECT_TRUE(UpdateSearchState(active_tab)); |
| EXPECT_EQ(2, on_most_visited_change_calls_); |
| } |
| + |
| +// Test to verify that the omnibox search query is updated on browser |
| +// back button press event. |
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, UpdateSearchQueryOnBackNavigation) { |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| + |
| + // Focus omnibox and confirm overlay isn't shown. |
| + FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| + |
| + // Create an observer to wait for the instant tab to support Instant. |
| + content::WindowedNotificationObserver observer( |
| + chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, |
| + content::NotificationService::AllSources()); |
| + |
| + SetOmniboxText("flowers"); |
| + // Commit the search by pressing 'Enter'. |
| + PressEnterAndWaitForNavigation(); |
| + observer.Wait(); |
| + |
| + EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText()); |
| + |
| + // Typing in the new search query in omnibox. |
| + SetOmniboxText("cattles"); |
| + // Commit the search by pressing 'Enter'. |
| + PressEnterAndWaitForNavigation(); |
| + // 'Enter' commits the query as it was typed. This creates a navigation entry |
| + // in the history. |
| + EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText()); |
| + |
| + content::WebContents* active_tab = |
| + browser()->tab_strip_model()->GetActiveWebContents(); |
| + EXPECT_TRUE(active_tab->GetController().CanGoBack()); |
| + content::WindowedNotificationObserver load_stop_observer( |
| + content::NOTIFICATION_LOAD_STOP, |
| + content::Source<content::NavigationController>( |
| + &active_tab->GetController())); |
| + active_tab->GetController().GoBack(); |
| + load_stop_observer.Wait(); |
| + |
| + EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText()); |
| + // Commit the search by pressing 'Enter'. |
| + FocusOmnibox(); |
| + PressEnterAndWaitForNavigation(); |
| + EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText()); |
| +} |
| + |
| +// Test to verify that the omnibox search query is updated on browser |
| +// forward button press events. |
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| + UpdateSearchQueryOnForwardNavigation) { |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| + |
| + // Focus omnibox and confirm overlay isn't shown. |
| + FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| + |
| + // Create an observer to wait for the instant tab to support Instant. |
| + content::WindowedNotificationObserver observer( |
| + chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, |
| + content::NotificationService::AllSources()); |
| + |
| + SetOmniboxText("flowers"); |
| + // Commit the search by pressing 'Enter'. |
| + PressEnterAndWaitForNavigation(); |
| + observer.Wait(); |
| + |
| + EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText()); |
| + |
| + // Typing in the new search query in omnibox. |
| + SetOmniboxText("cattles"); |
| + // Commit the search by pressing 'Enter'. |
| + PressEnterAndWaitForNavigation(); |
| + // 'Enter' commits the query as it was typed. This creates a navigation entry |
| + // in the history. |
| + EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText()); |
| + |
| + content::WebContents* active_tab = |
| + browser()->tab_strip_model()->GetActiveWebContents(); |
| + EXPECT_TRUE(active_tab->GetController().CanGoBack()); |
| + content::WindowedNotificationObserver load_stop_observer( |
| + content::NOTIFICATION_LOAD_STOP, |
| + content::Source<content::NavigationController>( |
| + &active_tab->GetController())); |
| + active_tab->GetController().GoBack(); |
| + load_stop_observer.Wait(); |
| + |
| + EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText()); |
| + |
| + active_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| + EXPECT_TRUE(active_tab->GetController().CanGoForward()); |
| + content::WindowedNotificationObserver load_stop_observer_2( |
| + content::NOTIFICATION_LOAD_STOP, |
| + content::Source<content::NavigationController>( |
| + &active_tab->GetController())); |
| + active_tab->GetController().GoForward(); |
| + load_stop_observer_2.Wait(); |
| + |
| + // Commit the search by pressing 'Enter'. |
| + FocusOmnibox(); |
| + EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText()); |
| + PressEnterAndWaitForNavigation(); |
| + EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText()); |
| +} |
| + |
| +// Flaky on Mac Tests bot. |
| +#if defined(OS_MACOSX) |
| +#define MAYBE_NavigateBackToNTP DISABLED_NavigateBackToNTP |
| +#else |
| +#define MAYBE_NavigateBackToNTP NavigateBackToNTP |
| +#endif |
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, MAYBE_NavigateBackToNTP) { |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| + FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); |
| + |
| + // Open a new tab page. |
| + ui_test_utils::NavigateToURLWithDisposition( |
| + browser(), |
| + GURL(chrome::kChromeUINewTabURL), |
| + NEW_FOREGROUND_TAB, |
| + ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| + EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| + |
| + content::WindowedNotificationObserver observer( |
| + chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, |
| + content::NotificationService::AllSources()); |
| + SetOmniboxText("flowers"); |
| + PressEnterAndWaitForNavigation(); |
| + observer.Wait(); |
| + |
| + EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText()); |
| + |
| + // Typing in the new search query in omnibox. |
| + // Commit the search by pressing 'Enter'. |
| + SetOmniboxText("cattles"); |
| + PressEnterAndWaitForNavigation(); |
| + |
| + // 'Enter' commits the query as it was typed. This creates a navigation entry |
| + // in the history. |
| + EXPECT_EQ(ASCIIToUTF16("cattles"), omnibox()->GetText()); |
| + |
| + // Navigate back to "flowers" search result page. |
| + content::WebContents* active_tab = |
| + browser()->tab_strip_model()->GetActiveWebContents(); |
| + EXPECT_TRUE(active_tab->GetController().CanGoBack()); |
| + content::WindowedNotificationObserver load_stop_observer( |
| + content::NOTIFICATION_LOAD_STOP, |
| + content::Source<content::NavigationController>( |
| + &active_tab->GetController())); |
| + active_tab->GetController().GoBack(); |
| + load_stop_observer.Wait(); |
| + |
| + EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText()); |
| + |
| + // Commit the search by pressing 'Enter'. |
|
Jered
2013/06/19 22:44:55
Why do we press enter here before going back again
kmadhusu
2013/06/21 17:00:59
Good catch. Removed.
|
| + FocusOmnibox(); |
| + PressEnterAndWaitForNavigation(); |
| + EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText()); |
| + |
| + // Navigate back to NTP. |
| + active_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| + EXPECT_TRUE(active_tab->GetController().CanGoBack()); |
| + content::WindowedNotificationObserver load_stop_observer_2( |
| + content::NOTIFICATION_LOAD_STOP, |
| + content::Source<content::NavigationController>( |
| + &active_tab->GetController())); |
| + active_tab->GetController().GoBack(); |
| + load_stop_observer_2.Wait(); |
| + |
| + active_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| + EXPECT_TRUE(chrome::IsInstantNTP(active_tab)); |
| +} |