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

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

Issue 13963014: Local omnibox treats navsuggest suggestions as queries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert renaming change (now in a separate cl). Created 7 years, 7 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') | no next file » | 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/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/strings/string_number_conversions.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/autocomplete/autocomplete_controller.h" 12 #include "chrome/browser/autocomplete/autocomplete_controller.h"
12 #include "chrome/browser/autocomplete/autocomplete_match.h" 13 #include "chrome/browser/autocomplete/autocomplete_match.h"
13 #include "chrome/browser/autocomplete/autocomplete_provider.h" 14 #include "chrome/browser/autocomplete/autocomplete_provider.h"
14 #include "chrome/browser/autocomplete/autocomplete_result.h" 15 #include "chrome/browser/autocomplete/autocomplete_result.h"
15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 16 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
16 #include "chrome/browser/bookmarks/bookmark_utils.h" 17 #include "chrome/browser/bookmarks/bookmark_utils.h"
17 #include "chrome/browser/extensions/extension_browsertest.h" 18 #include "chrome/browser/extensions/extension_browsertest.h"
18 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
19 #include "chrome/browser/favicon/favicon_tab_helper.h" 20 #include "chrome/browser/favicon/favicon_tab_helper.h"
20 #include "chrome/browser/history/history_types.h" 21 #include "chrome/browser/history/history_types.h"
21 #include "chrome/browser/history/top_sites.h" 22 #include "chrome/browser/history/top_sites.h"
22 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/search/instant_service.h" 24 #include "chrome/browser/search/instant_service.h"
24 #include "chrome/browser/search/instant_service_factory.h" 25 #include "chrome/browser/search/instant_service_factory.h"
25 #include "chrome/browser/search/search.h" 26 #include "chrome/browser/search/search.h"
26 #include "chrome/browser/themes/theme_service.h" 27 #include "chrome/browser/themes/theme_service.h"
27 #include "chrome/browser/themes/theme_service_factory.h" 28 #include "chrome/browser/themes/theme_service_factory.h"
28 #include "chrome/browser/ui/omnibox/omnibox_view.h" 29 #include "chrome/browser/ui/omnibox/omnibox_view.h"
29 #include "chrome/browser/ui/search/instant_commit_type.h" 30 #include "chrome/browser/ui/search/instant_commit_type.h"
30 #include "chrome/browser/ui/search/instant_ntp.h" 31 #include "chrome/browser/ui/search/instant_ntp.h"
31 #include "chrome/browser/ui/search/instant_overlay.h" 32 #include "chrome/browser/ui/search/instant_overlay.h"
32 #include "chrome/browser/ui/search/instant_tab.h" 33 #include "chrome/browser/ui/search/instant_tab.h"
33 #include "chrome/browser/ui/search/instant_test_utils.h" 34 #include "chrome/browser/ui/search/instant_test_utils.h"
34 #include "chrome/browser/ui/search/search_tab_helper.h" 35 #include "chrome/browser/ui/search/search_tab_helper.h"
35 #include "chrome/browser/ui/tabs/tab_strip_model.h" 36 #include "chrome/browser/ui/tabs/tab_strip_model.h"
36 #include "chrome/browser/ui/webui/theme_source.h" 37 #include "chrome/browser/ui/webui/theme_source.h"
37 #include "chrome/common/chrome_notification_types.h" 38 #include "chrome/common/chrome_notification_types.h"
39 #include "chrome/common/chrome_switches.h"
38 #include "chrome/common/pref_names.h" 40 #include "chrome/common/pref_names.h"
39 #include "chrome/common/thumbnail_score.h" 41 #include "chrome/common/thumbnail_score.h"
40 #include "chrome/common/url_constants.h" 42 #include "chrome/common/url_constants.h"
41 #include "chrome/test/base/in_process_browser_test.h" 43 #include "chrome/test/base/in_process_browser_test.h"
42 #include "chrome/test/base/interactive_test_utils.h" 44 #include "chrome/test/base/interactive_test_utils.h"
43 #include "chrome/test/base/ui_test_utils.h" 45 #include "chrome/test/base/ui_test_utils.h"
44 #include "content/public/browser/navigation_controller.h" 46 #include "content/public/browser/navigation_controller.h"
45 #include "content/public/browser/navigation_entry.h" 47 #include "content/public/browser/navigation_entry.h"
46 #include "content/public/browser/notification_service.h" 48 #include "content/public/browser/notification_service.h"
47 #include "content/public/browser/render_process_host.h" 49 #include "content/public/browser/render_process_host.h"
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 browser()->tab_strip_model()->GetActiveWebContents(); 815 browser()->tab_strip_model()->GetActiveWebContents();
814 EXPECT_TRUE(instant_service->IsInstantProcess( 816 EXPECT_TRUE(instant_service->IsInstantProcess(
815 active_tab->GetRenderProcessHost()->GetID())); 817 active_tab->GetRenderProcessHost()->GetID()));
816 818
817 // Navigating elsewhere should not use the Instant render process. 819 // Navigating elsewhere should not use the Instant render process.
818 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); 820 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL));
819 EXPECT_FALSE(instant_service->IsInstantProcess( 821 EXPECT_FALSE(instant_service->IsInstantProcess(
820 active_tab->GetRenderProcessHost()->GetID())); 822 active_tab->GetRenderProcessHost()->GetID()));
821 } 823 }
822 824
825 // Test that a search query will not be displayed for navsuggest queries.
826 IN_PROC_BROWSER_TEST_F(
827 InstantExtendedTest, SearchQueryNotDisplayedForNavsuggest) {
sreeram 2013/04/29 22:26:31 Nit: Move "InstantExtendedTest" to the previous li
dougw 2013/04/29 22:48:49 Done.
828 // Use only the local overlay.
829 CommandLine::ForCurrentProcess()->AppendSwitch(
830 switches::kEnableLocalOnlyInstantExtendedAPI);
831 ASSERT_TRUE(chrome::IsLocalOnlyInstantExtendedAPIEnabled());
832
833 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
834
835 // The second argument indicates to use only the local overlay and NTP.
836 instant()->SetInstantEnabled(true, true);
837
838 // Focus omnibox and confirm overlay isn't shown.
839 FocusOmniboxAndWaitForInstantSupport();
sreeram 2013/04/29 22:26:31 FocusOmniboxAndWaitForInstant***Extended***Support
dougw 2013/04/29 22:48:49 This is intentional. The test hangs if we wait for
840
841 // Typing in the omnibox should show the overlay.
842 SetOmniboxText("face");
843
844 // Add a navsuggest suggestion.
845 instant()->SetSuggestions(
846 instant()->overlay()->contents(),
847 std::vector<InstantSuggestion>(
848 1,
849 InstantSuggestion(ASCIIToUTF16("http://facemash.com/"),
850 INSTANT_COMPLETE_NOW,
851 INSTANT_SUGGESTION_URL,
852 ASCIIToUTF16("face"))));
853
854 while (!omnibox()->model()->autocomplete_controller()->done()) {
855 content::WindowedNotificationObserver autocomplete_observer(
856 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY,
857 content::NotificationService::AllSources());
858 autocomplete_observer.Wait();
859 }
860
861 EXPECT_TRUE(
862 ExecuteScript(
863 "var sortedNativeSuggestions = chrome.embeddedSearch.searchBox.native"
864 "Suggestions.sort(function (a,b) {return b.rankingData.relevance - a."
865 "rankingData.relevance});"));
sreeram 2013/04/29 22:26:31 Yikes. This is really hard to read. Please don't s
dougw 2013/04/29 22:48:49 Done.
866
867 // Create an event listener that opens the top suggestion in a new tab.
sreeram 2013/04/29 22:26:31 This comment has nothing to do with the next line.
dougw 2013/04/29 22:48:49 Done.
868 content::WebContents* overlay = instant()->GetOverlayContents();
869
870 int suggestions_count;
sreeram 2013/04/29 22:26:31 Initialize this to an invalid value, such as -1.
dougw 2013/04/29 22:48:49 Done.
871 EXPECT_TRUE(GetIntFromJS(
872 overlay, "sortedNativeSuggestions.length", &suggestions_count));
873 EXPECT_TRUE(suggestions_count > 0);
sreeram 2013/04/29 22:26:31 EXPECT_GT(suggestions_count, 0);
dougw 2013/04/29 22:48:49 Done.
874
875 std::string type;
876 EXPECT_TRUE(
877 GetStringFromJS(overlay, "sortedNativeSuggestions[0].type", &type));
878 ASSERT_TRUE(type == "navsuggest");
sreeram 2013/04/29 22:26:31 EXPECT_EQ("navsuggest", type);
dougw 2013/04/29 22:48:49 Done.
879
880 bool is_search_property_exists;
sreeram 2013/04/29 22:26:31 Nit: Fix bad grammar: "is_search_property_defined"
dougw 2013/04/29 22:48:49 Done. GetBoolFromJS will hang if it is called whe
881 EXPECT_TRUE(
882 GetBoolFromJS(
883 overlay, "sortedNativeSuggestions[0].hasOwnProperty('is_search')",
884 &is_search_property_exists));
885
886 if (is_search_property_exists) {
887 bool is_search;
888 EXPECT_TRUE(GetBoolFromJS(
889 overlay, "sortedNativeSuggestions[0].is_search", &is_search));
890 EXPECT_FALSE(is_search);
891 }
892 }
893
823 // Verification of fix for BUG=176365. Ensure that each Instant WebContents in 894 // Verification of fix for BUG=176365. Ensure that each Instant WebContents in
824 // a tab uses a new BrowsingInstance, to avoid conflicts in the 895 // a tab uses a new BrowsingInstance, to avoid conflicts in the
825 // NavigationController. 896 // NavigationController.
826 // Flaky: http://crbug.com/177516 897 // Flaky: http://crbug.com/177516
827 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_UnrelatedSiteInstance) { 898 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_UnrelatedSiteInstance) {
828 // Setup Instant. 899 // Setup Instant.
829 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 900 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
830 FocusOmniboxAndWaitForInstantExtendedSupport(); 901 FocusOmniboxAndWaitForInstantExtendedSupport();
831 902
832 // Check that the uncommited ntp page and uncommited overlay have unrelated 903 // Check that the uncommited ntp page and uncommited overlay have unrelated
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
1736 SendEscape(); 1807 SendEscape();
1737 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value", 1808 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value",
1738 &query)); 1809 &query));
1739 EXPECT_EQ("", query); 1810 EXPECT_EQ("", query);
1740 EXPECT_EQ("", GetOmniboxText()); 1811 EXPECT_EQ("", GetOmniboxText());
1741 1812
1742 EXPECT_TRUE(UpdateSearchState(contents)); 1813 EXPECT_TRUE(UpdateSearchState(contents));
1743 EXPECT_LT(0, on_change_calls_); 1814 EXPECT_LT(0, on_change_calls_);
1744 EXPECT_EQ(0, submit_count_); 1815 EXPECT_EQ(0, submit_count_);
1745 } 1816 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/instant_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698