Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: chrome/browser/ui/search/instant_extended_interactive_uitest.cc

Issue 16035020: Move instant support to SearchTabHelper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed nits Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/search/instant_controller.cc ('k') | chrome/browser/ui/search/instant_page.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <sstream> 5 #include <sstream>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram_base.h" 9 #include "base/metrics/histogram_base.h"
10 #include "base/metrics/histogram_samples.h" 10 #include "base/metrics/histogram_samples.h"
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 #if defined(OS_LINUX) 358 #if defined(OS_LINUX)
359 #define MAYBE_UsesOverlayIfTabNotReady DISABLED_UsesOverlayIfTabNotReady 359 #define MAYBE_UsesOverlayIfTabNotReady DISABLED_UsesOverlayIfTabNotReady
360 #else 360 #else
361 #define MAYBE_UsesOverlayIfTabNotReady UsesOverlayIfTabNotReady 361 #define MAYBE_UsesOverlayIfTabNotReady UsesOverlayIfTabNotReady
362 #endif 362 #endif
363 363
364 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, MAYBE_UsesOverlayIfTabNotReady) { 364 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, MAYBE_UsesOverlayIfTabNotReady) {
365 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 365 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
366 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); 366 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport();
367 367
368 // Open a new tab and start typing before InstantTab is properly hooked up. 368 // Open a new tab and navigate to instant URL. Start typing before InstantTab
369 // Should use the overlay. 369 // is properly hooked up. Should use the overlay.
370 ui_test_utils::NavigateToURLWithDisposition( 370 ui_test_utils::NavigateToURLWithDisposition(
371 browser(), 371 browser(),
372 GURL(chrome::kChromeUINewTabURL), 372 instant_url(),
373 NEW_FOREGROUND_TAB, 373 NEW_BACKGROUND_TAB,
374 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); 374 ui_test_utils::BROWSER_TEST_NONE);
375 EXPECT_EQ(2, browser()->tab_strip_model()->count());
376 browser()->tab_strip_model()->ActivateTabAt(1, false);
375 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query")); 377 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("query"));
376 378
377 // But Instant tab should still exist. 379 // But Instant tab should still exist.
378 ASSERT_NE(static_cast<InstantTab*>(NULL), instant()->instant_tab()); 380 ASSERT_NE(static_cast<InstantTab*>(NULL), instant()->instant_tab());
379 EXPECT_FALSE(instant()->UseTabForSuggestions()); 381 EXPECT_FALSE(instant()->UseTabForSuggestions());
380 382
381 // Wait for Instant Tab support if it still hasn't finished loading. 383 // Wait for Instant Tab support if it still hasn't finished loading.
382 if (!instant()->instant_tab()->supports_instant()) { 384 if (!instant()->instant_tab()->supports_instant()) {
383 content::WindowedNotificationObserver instant_tab_observer( 385 content::WindowedNotificationObserver instant_tab_observer(
384 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, 386 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
(...skipping 2375 matching lines...) Expand 10 before | Expand all | Expand 10 after
2760 EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText()); 2762 EXPECT_EQ(ASCIIToUTF16("flowers"), omnibox()->GetText());
2761 } 2763 }
2762 2764
2763 #endif // HTML_INSTANT_EXTENDED_POPUP 2765 #endif // HTML_INSTANT_EXTENDED_POPUP
2764 2766
2765 #if !defined(HTML_INSTANT_EXTENDED_POPUP) 2767 #if !defined(HTML_INSTANT_EXTENDED_POPUP)
2766 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, SearchReusesInstantTab) { 2768 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, SearchReusesInstantTab) {
2767 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 2769 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
2768 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); 2770 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport();
2769 2771
2770 // Create an observer to wait for the instant tab to support Instant.
2771 content::WindowedNotificationObserver observer( 2772 content::WindowedNotificationObserver observer(
2772 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, 2773 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
2773 content::NotificationService::AllSources()); 2774 content::NotificationService::AllSources());
2774
2775 SetOmniboxText("flowers"); 2775 SetOmniboxText("flowers");
2776 browser()->window()->GetLocationBar()->AcceptInput(); 2776 PressEnterAndWaitForNavigation();
2777 observer.Wait(); 2777 observer.Wait();
2778 2778
2779 // Just did a regular search. 2779 // Just did a regular search.
2780 ASSERT_THAT( 2780 content::WebContents* active_tab =
2781 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec(), 2781 browser()->tab_strip_model()->GetActiveWebContents();
2782 HasSubstr("q=flowers")); 2782 ASSERT_THAT(active_tab->GetURL().spec(), HasSubstr("q=flowers"));
2783 ASSERT_TRUE(UpdateSearchState(instant()->instant_tab()->contents())); 2783 ASSERT_TRUE(UpdateSearchState(active_tab));
2784 ASSERT_EQ(0, submit_count_); 2784 ASSERT_EQ(0, submit_count_);
2785 2785
2786 SetOmniboxText("puppies"); 2786 SetOmniboxText("puppies");
2787 browser()->window()->GetLocationBar()->AcceptInput(); 2787 PressEnterAndWaitForNavigation();
2788 2788
2789 // Should have reused the tab and sent an onsubmit message. 2789 // Should have reused the tab and sent an onsubmit message.
2790 ASSERT_THAT( 2790 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
2791 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec(), 2791 ASSERT_THAT(active_tab->GetURL().spec(), HasSubstr("q=puppies"));
2792 HasSubstr("q=flowers")); 2792 ASSERT_TRUE(UpdateSearchState(active_tab));
2793 ASSERT_TRUE(UpdateSearchState(instant()->instant_tab()->contents()));
2794 EXPECT_EQ(1, submit_count_); 2793 EXPECT_EQ(1, submit_count_);
2795 } 2794 }
2796 2795
2797 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, 2796 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
2798 SearchDoesntReuseInstantTabWithoutSupport) { 2797 SearchDoesntReuseInstantTabWithoutSupport) {
2799 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 2798 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
2800 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); 2799 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport();
2801 2800
2802 // Don't wait for the navigation to complete. 2801 // Don't wait for the navigation to complete.
2803 SetOmniboxText("flowers"); 2802 SetOmniboxText("flowers");
2804 browser()->window()->GetLocationBar()->AcceptInput(); 2803 browser()->window()->GetLocationBar()->AcceptInput();
2805 2804
2806 SetOmniboxText("puppies"); 2805 SetOmniboxText("puppies");
2807 browser()->window()->GetLocationBar()->AcceptInput(); 2806 browser()->window()->GetLocationBar()->AcceptInput();
2808 2807
2809 // Should not have reused the tab. 2808 // Should not have reused the tab.
2810 ASSERT_THAT( 2809 ASSERT_THAT(
2811 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec(), 2810 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec(),
2812 HasSubstr("q=puppies")); 2811 HasSubstr("q=puppies"));
2813 } 2812 }
2814 2813
2815 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, 2814 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
2816 TypedSearchURLDoesntReuseInstantTab) { 2815 TypedSearchURLDoesntReuseInstantTab) {
2817 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 2816 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
2818 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); 2817 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport();
2819 2818
2820 // Create an observer to wait for the instant tab to support Instant. 2819 // Create an observer to wait for the instant tab to support Instant.
2821 content::WindowedNotificationObserver observer( 2820 content::WindowedNotificationObserver observer_1(
2822 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, 2821 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
2823 content::NotificationService::AllSources()); 2822 content::NotificationService::AllSources());
2824
2825 SetOmniboxText("flowers"); 2823 SetOmniboxText("flowers");
2826 browser()->window()->GetLocationBar()->AcceptInput(); 2824 PressEnterAndWaitForNavigation();
2827 observer.Wait(); 2825 observer_1.Wait();
2828 2826
2829 // Just did a regular search. 2827 // Just did a regular search.
2830 ASSERT_THAT( 2828 content::WebContents* active_tab =
2831 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec(), 2829 browser()->tab_strip_model()->GetActiveWebContents();
2832 HasSubstr("q=flowers")); 2830 ASSERT_THAT(active_tab->GetURL().spec(), HasSubstr("q=flowers"));
2833 ASSERT_TRUE(UpdateSearchState(instant()->instant_tab()->contents())); 2831 ASSERT_TRUE(UpdateSearchState(active_tab));
2834 ASSERT_EQ(0, submit_count_); 2832 ASSERT_EQ(0, submit_count_);
2835 2833
2836 // Typed in a search URL "by hand". 2834 // Typed in a search URL "by hand".
2835 content::WindowedNotificationObserver observer_2(
2836 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
2837 content::NotificationService::AllSources());
2837 SetOmniboxText(instant_url().spec() + "#q=puppies"); 2838 SetOmniboxText(instant_url().spec() + "#q=puppies");
2838 browser()->window()->GetLocationBar()->AcceptInput(); 2839 PressEnterAndWaitForNavigation();
2840 observer_2.Wait();
2839 2841
2840 // Should not have reused the tab. 2842 // Should not have reused the tab.
2841 ASSERT_THAT( 2843 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
2842 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().spec(), 2844 ASSERT_THAT(active_tab->GetURL().spec(), HasSubstr("q=puppies"));
2843 HasSubstr("q=puppies"));
2844 } 2845 }
2845 2846
2846 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxMarginSetForSearchURLs) { 2847 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxMarginSetForSearchURLs) {
2847 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 2848 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
2848 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); 2849 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport();
2849 2850
2850 // Create an observer to wait for the instant tab to support Instant. 2851 // Create an observer to wait for the instant tab to support Instant.
2851 content::WindowedNotificationObserver observer( 2852 content::WindowedNotificationObserver observer(
2852 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, 2853 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
2853 content::NotificationService::AllSources()); 2854 content::NotificationService::AllSources());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2890 browser()->tab_strip_model()->ActivateTabAt(0, false); 2891 browser()->tab_strip_model()->ActivateTabAt(0, false);
2891 2892
2892 // Switch back to new tab. 2893 // Switch back to new tab.
2893 browser()->tab_strip_model()->ActivateTabAt(1, false); 2894 browser()->tab_strip_model()->ActivateTabAt(1, false);
2894 2895
2895 // Confirm that new tab got no onmostvisitedchanged event. 2896 // Confirm that new tab got no onmostvisitedchanged event.
2896 active_tab = browser()->tab_strip_model()->GetActiveWebContents(); 2897 active_tab = browser()->tab_strip_model()->GetActiveWebContents();
2897 EXPECT_TRUE(UpdateSearchState(active_tab)); 2898 EXPECT_TRUE(UpdateSearchState(active_tab));
2898 EXPECT_EQ(2, on_most_visited_change_calls_); 2899 EXPECT_EQ(2, on_most_visited_change_calls_);
2899 } 2900 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/instant_controller.cc ('k') | chrome/browser/ui/search/instant_page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698