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 95d5d138aaa3d1659ccde27314466576eb4e82c0..1675e5f28f591f2696ae12a3941c6d6837925c3c 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,74 @@ 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) { | 
| + // Use only the local overlay. | 
| + CommandLine::ForCurrentProcess()->AppendSwitch( | 
| + switches::kEnableLocalOnlyInstantExtendedAPI); | 
| + ASSERT_TRUE(chrome::IsLocalOnlyInstantExtendedAPIEnabled()); | 
| + | 
| + ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 
| + | 
| + // The second argument indicates to use only the local overlay and NTP. | 
| + instant()->SetInstantEnabled(true, true); | 
| + | 
| + // Focus omnibox and confirm overlay isn't shown. | 
| + FocusOmniboxAndWaitForInstantSupport(); | 
| + | 
| + // Typing in the omnibox should show the overlay. | 
| + SetOmniboxText("face"); | 
| + | 
| + // 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("face")))); | 
| + | 
| + while (!omnibox()->model()->autocomplete_controller()->done()) { | 
| + content::WindowedNotificationObserver autocomplete_observer( | 
| + chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, | 
| + content::NotificationService::AllSources()); | 
| + autocomplete_observer.Wait(); | 
| + } | 
| + | 
| + EXPECT_TRUE(ExecuteScript( | 
| + "var sorted = chrome.embeddedSearch.searchBox.nativeSuggestions.sort(" | 
| + "function (a,b) {" | 
| + "return b.rankingData.relevance - a.rankingData.relevance;" | 
| + "});")); | 
| + | 
| + content::WebContents* overlay = instant()->GetOverlayContents(); | 
| 
 
samarth
2013/04/30 01:03:47
Earlier in this function, L846, you use overlay()-
 
dougw
2013/04/30 01:29:44
Done.
 
 | 
| + | 
| + int suggestions_count = -1; | 
| + EXPECT_TRUE(GetIntFromJS( | 
| + overlay, "sorted.length", &suggestions_count)); | 
| + EXPECT_GT(suggestions_count, 0); | 
| 
 
samarth
2013/04/30 01:03:47
ASSERT_GT .. doesn't make to continue if this fail
 
dougw
2013/04/30 01:29:44
Done.
 
 | 
| + | 
| + std::string type; | 
| + EXPECT_TRUE( | 
| + GetStringFromJS(overlay, "sorted[0].type", &type)); | 
| + EXPECT_EQ("navsuggest", type); | 
| 
 
samarth
2013/04/30 01:03:47
Likewise, ASSERT
 
dougw
2013/04/30 01:29:44
Done.
 
 | 
| + | 
| + bool is_search_property_defined; | 
| + EXPECT_TRUE( | 
| + GetBoolFromJS( | 
| + overlay, "sorted[0].hasOwnProperty('is_search')", | 
| 
 
samarth
2013/04/30 01:03:47
What it you just look up "!!sorted[0].is_search" a
 
dougw
2013/04/30 01:29:44
Done.
 
 | 
| + &is_search_property_defined)); | 
| + | 
| + if (is_search_property_defined) { | 
| + bool is_search; | 
| + EXPECT_TRUE(GetBoolFromJS( | 
| + overlay, "sorted[0].is_search", &is_search)); | 
| + EXPECT_FALSE(is_search); | 
| + } | 
| +} | 
| + | 
| // Verification of fix for BUG=176365. Ensure that each Instant WebContents in | 
| // a tab uses a new BrowsingInstance, to avoid conflicts in the | 
| // NavigationController. |