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

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: Created 7 years, 8 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) {
828 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
829
830 ASSERT_FALSE(chrome::IsLocalOnlyInstantExtendedAPIEnabled());
831
832 // Use only the local overlay.
833 CommandLine::ForCurrentProcess()->AppendSwitch(
834 switches::kEnableLocalOnlyInstantExtendedAPI);
835 ASSERT_TRUE(chrome::IsLocalOnlyInstantExtendedAPIEnabled());
836
837 // Focus omnibox and confirm overlay isn't shown.
838 FocusOmniboxAndWaitForInstantExtendedSupport();
839
840 // Typing in the omnibox should show the overlay.
841 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("http://face"));
sreeram 2013/04/25 02:02:25 Still wrong. The query should be "face". The sugge
dougw 2013/04/25 02:09:06 Done.
842 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions());
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("http://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 // Create an event listener that opens the top suggestion in a new tab.
862 content::WebContents* overlay = instant()->GetOverlayContents();
863 int i = 0;
864 std::string nativeSuggestionString =
865 "chrome.embeddedSearch.searchBox.nativeSuggestions";
866 while (true) {
867 std::string nativeSuggestionsAtIndex =
868 nativeSuggestionString + "[" + base::IntToString(i) + "]";
869
870 // Break if this nativeSuggestions index doesn't exist
871 // (dougw: Note: will change this logic for the next upload so that the
872 // test doesn't always fail)
873 bool indexExists;
874 EXPECT_TRUE(GetBoolFromJS(overlay, nativeSuggestionString +
875 ".hasOwnProperty('" + base::IntToString(i) + "')", &indexExists));
876 if (!indexExists) {
877 LOG (ERROR) << "***************nativeSuggestions has no elements";
878 break;
879 }
880
881 bool isSearchPropertyExists;
882 EXPECT_TRUE(GetBoolFromJS(overlay, nativeSuggestionsAtIndex +
883 ".hasOwnProperty('is_search')", &isSearchPropertyExists));
884
885 // Verify that if this is a search suggestion the type is not navsuggest.
886 if (isSearchPropertyExists) {
887 bool is_search;
888 EXPECT_TRUE(GetBoolFromJS(
889 overlay, nativeSuggestionsAtIndex + ".is_search", &is_search));
890
891 std::string type;
892 EXPECT_TRUE(
893 GetStringFromJS(overlay, nativeSuggestionsAtIndex + ".type", &type));
894 LOG (ERROR) << "***************type (isSearchPropertyExists):" << type;
895
896 EXPECT_FALSE(is_search && type == "navsuggest");
897 } else {
898 std::string type;
899 EXPECT_TRUE(
900 GetStringFromJS(overlay, nativeSuggestionsAtIndex + ".type", &type));
901 LOG (ERROR) << "***************type (!isSearchPropertyExists):" << type;
902 }
903 ++i;
904 }
905 }
906
823 // Verification of fix for BUG=176365. Ensure that each Instant WebContents in 907 // Verification of fix for BUG=176365. Ensure that each Instant WebContents in
824 // a tab uses a new BrowsingInstance, to avoid conflicts in the 908 // a tab uses a new BrowsingInstance, to avoid conflicts in the
825 // NavigationController. 909 // NavigationController.
826 // Flaky: http://crbug.com/177516 910 // Flaky: http://crbug.com/177516
827 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_UnrelatedSiteInstance) { 911 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_UnrelatedSiteInstance) {
828 // Setup Instant. 912 // Setup Instant.
829 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 913 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
830 FocusOmniboxAndWaitForInstantExtendedSupport(); 914 FocusOmniboxAndWaitForInstantExtendedSupport();
831 915
832 // Check that the uncommited ntp page and uncommited overlay have unrelated 916 // 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(); 1820 SendEscape();
1737 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value", 1821 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value",
1738 &query)); 1822 &query));
1739 EXPECT_EQ("", query); 1823 EXPECT_EQ("", query);
1740 EXPECT_EQ("", GetOmniboxText()); 1824 EXPECT_EQ("", GetOmniboxText());
1741 1825
1742 EXPECT_TRUE(UpdateSearchState(contents)); 1826 EXPECT_TRUE(UpdateSearchState(contents));
1743 EXPECT_LT(0, on_change_calls_); 1827 EXPECT_LT(0, on_change_calls_);
1744 EXPECT_EQ(0, submit_count_); 1828 EXPECT_EQ(0, submit_count_);
1745 } 1829 }
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