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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/search/instant_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 95d5d138aaa3d1659ccde27314466576eb4e82c0..eee8e2e0ded9453e20542a62ed47d4671741c1dc 100644
--- a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
+++ b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
@@ -7,6 +7,7 @@
#include "base/prefs/pref_service.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
+#include "base/strings/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/autocomplete/autocomplete_controller.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
@@ -35,6 +36,7 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/webui/theme_source.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/thumbnail_score.h"
#include "chrome/common/url_constants.h"
@@ -820,6 +822,88 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ProcessIsolation) {
active_tab->GetRenderProcessHost()->GetID()));
}
+// Test that a search query will not be displayed for navsuggest queries.
+IN_PROC_BROWSER_TEST_F(
+ InstantExtendedTest, SearchQueryNotDisplayedForNavsuggest) {
+ ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
+
+ ASSERT_FALSE(chrome::IsLocalOnlyInstantExtendedAPIEnabled());
+
+ // Use only the local overlay.
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kEnableLocalOnlyInstantExtendedAPI);
+ ASSERT_TRUE(chrome::IsLocalOnlyInstantExtendedAPIEnabled());
+
+ // Focus omnibox and confirm overlay isn't shown.
+ FocusOmniboxAndWaitForInstantExtendedSupport();
+
+ // Typing in the omnibox should show the overlay.
+ 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.
+ EXPECT_TRUE(instant()->model()->mode().is_search_suggestions());
+
+ // Add a navsuggest suggestion.
+ instant()->SetSuggestions(
+ instant()->overlay()->contents(),
+ std::vector<InstantSuggestion>(
+ 1,
+ InstantSuggestion(ASCIIToUTF16("http://facemash.com"),
+ INSTANT_COMPLETE_NOW,
+ INSTANT_SUGGESTION_URL,
+ ASCIIToUTF16("http://face"))));
+
+ while (!omnibox()->model()->autocomplete_controller()->done()) {
+ content::WindowedNotificationObserver autocomplete_observer(
+ chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY,
+ content::NotificationService::AllSources());
+ autocomplete_observer.Wait();
+ }
+
+ // Create an event listener that opens the top suggestion in a new tab.
+ content::WebContents* overlay = instant()->GetOverlayContents();
+ int i = 0;
+ std::string nativeSuggestionString =
+ "chrome.embeddedSearch.searchBox.nativeSuggestions";
+ while (true) {
+ std::string nativeSuggestionsAtIndex =
+ nativeSuggestionString + "[" + base::IntToString(i) + "]";
+
+ // Break if this nativeSuggestions index doesn't exist
+ // (dougw: Note: will change this logic for the next upload so that the
+ // test doesn't always fail)
+ bool indexExists;
+ EXPECT_TRUE(GetBoolFromJS(overlay, nativeSuggestionString +
+ ".hasOwnProperty('" + base::IntToString(i) + "')", &indexExists));
+ if (!indexExists) {
+ LOG (ERROR) << "***************nativeSuggestions has no elements";
+ break;
+ }
+
+ bool isSearchPropertyExists;
+ EXPECT_TRUE(GetBoolFromJS(overlay, nativeSuggestionsAtIndex +
+ ".hasOwnProperty('is_search')", &isSearchPropertyExists));
+
+ // Verify that if this is a search suggestion the type is not navsuggest.
+ if (isSearchPropertyExists) {
+ bool is_search;
+ EXPECT_TRUE(GetBoolFromJS(
+ overlay, nativeSuggestionsAtIndex + ".is_search", &is_search));
+
+ std::string type;
+ EXPECT_TRUE(
+ GetStringFromJS(overlay, nativeSuggestionsAtIndex + ".type", &type));
+ LOG (ERROR) << "***************type (isSearchPropertyExists):" << type;
+
+ EXPECT_FALSE(is_search && type == "navsuggest");
+ } else {
+ std::string type;
+ EXPECT_TRUE(
+ GetStringFromJS(overlay, nativeSuggestionsAtIndex + ".type", &type));
+ LOG (ERROR) << "***************type (!isSearchPropertyExists):" << type;
+ }
+ ++i;
+ }
+}
+
// Verification of fix for BUG=176365. Ensure that each Instant WebContents in
// a tab uses a new BrowsingInstance, to avoid conflicts in the
// NavigationController.
« 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