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

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

Issue 14562006: Handle Esc key press event in Local NTP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test 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
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/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 class InstantExtendedTest : public InProcessBrowserTest, 103 class InstantExtendedTest : public InProcessBrowserTest,
104 public InstantTestBase { 104 public InstantTestBase {
105 public: 105 public:
106 InstantExtendedTest() 106 InstantExtendedTest()
107 : on_most_visited_change_calls_(0), 107 : on_most_visited_change_calls_(0),
108 most_visited_items_count_(0), 108 most_visited_items_count_(0),
109 first_most_visited_item_id_(0), 109 first_most_visited_item_id_(0),
110 on_native_suggestions_calls_(0), 110 on_native_suggestions_calls_(0),
111 on_change_calls_(0), 111 on_change_calls_(0),
112 submit_count_(0) { 112 submit_count_(0),
113 on_esc_key_press_event_calls_(0) {
113 } 114 }
114 protected: 115 protected:
115 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 116 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
116 chrome::EnableInstantExtendedAPIForTesting(); 117 chrome::EnableInstantExtendedAPIForTesting();
117 ASSERT_TRUE(https_test_server().Start()); 118 ASSERT_TRUE(https_test_server().Start());
118 GURL instant_url = https_test_server().GetURL( 119 GURL instant_url = https_test_server().GetURL(
119 "files/instant_extended.html?strk=1&"); 120 "files/instant_extended.html?strk=1&");
120 InstantTestBase::Init(instant_url); 121 InstantTestBase::Init(instant_url);
121 } 122 }
122 123
(...skipping 30 matching lines...) Expand all
153 &most_visited_items_count_) && 154 &most_visited_items_count_) &&
154 GetIntFromJS(contents, "firstMostVisitedItemId", 155 GetIntFromJS(contents, "firstMostVisitedItemId",
155 &first_most_visited_item_id_) && 156 &first_most_visited_item_id_) &&
156 GetIntFromJS(contents, "onNativeSuggestionsCalls", 157 GetIntFromJS(contents, "onNativeSuggestionsCalls",
157 &on_native_suggestions_calls_) && 158 &on_native_suggestions_calls_) &&
158 GetIntFromJS(contents, "onChangeCalls", 159 GetIntFromJS(contents, "onChangeCalls",
159 &on_change_calls_) && 160 &on_change_calls_) &&
160 GetIntFromJS(contents, "submitCount", 161 GetIntFromJS(contents, "submitCount",
161 &submit_count_) && 162 &submit_count_) &&
162 GetStringFromJS(contents, "apiHandle.value", 163 GetStringFromJS(contents, "apiHandle.value",
163 &query_value_); 164 &query_value_) &&
165 GetIntFromJS(contents, "onEscKeyPressedCalls",
166 &on_esc_key_press_event_calls_);
164 } 167 }
165 168
166 TemplateURL* GetDefaultSearchProviderTemplateURL() { 169 TemplateURL* GetDefaultSearchProviderTemplateURL() {
167 TemplateURLService* template_url_service = 170 TemplateURLService* template_url_service =
168 TemplateURLServiceFactory::GetForProfile(browser()->profile()); 171 TemplateURLServiceFactory::GetForProfile(browser()->profile());
169 if (template_url_service) 172 if (template_url_service)
170 return template_url_service->GetDefaultSearchProvider(); 173 return template_url_service->GetDefaultSearchProvider();
171 return NULL; 174 return NULL;
172 } 175 }
173 176
(...skipping 29 matching lines...) Expand all
203 return omnibox()->model()->autocomplete_controller()->search_provider()-> 206 return omnibox()->model()->autocomplete_controller()->search_provider()->
204 matches().size(); 207 matches().size();
205 } 208 }
206 209
207 int on_most_visited_change_calls_; 210 int on_most_visited_change_calls_;
208 int most_visited_items_count_; 211 int most_visited_items_count_;
209 int first_most_visited_item_id_; 212 int first_most_visited_item_id_;
210 int on_native_suggestions_calls_; 213 int on_native_suggestions_calls_;
211 int on_change_calls_; 214 int on_change_calls_;
212 int submit_count_; 215 int submit_count_;
216 int on_esc_key_press_event_calls_;
213 std::string query_value_; 217 std::string query_value_;
214 }; 218 };
215 219
216 // Test class used to verify chrome-search: scheme and access policy from the 220 // Test class used to verify chrome-search: scheme and access policy from the
217 // Instant overlay. This is a subclass of |ExtensionBrowserTest| because it 221 // Instant overlay. This is a subclass of |ExtensionBrowserTest| because it
218 // loads a theme that provides a background image. 222 // loads a theme that provides a background image.
219 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase { 223 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase {
220 public: 224 public:
221 InstantPolicyTest() {} 225 InstantPolicyTest() {}
222 226
(...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after
1941 SetOmniboxText(""); 1945 SetOmniboxText("");
1942 1946
1943 EXPECT_TRUE(GetIntFromJS( 1947 EXPECT_TRUE(GetIntFromJS(
1944 overlay, 1948 overlay,
1945 "chrome.embeddedSearch.searchBox.nativeSuggestions.length", 1949 "chrome.embeddedSearch.searchBox.nativeSuggestions.length",
1946 &num_autocomplete_results)); 1950 &num_autocomplete_results));
1947 EXPECT_EQ(0, num_autocomplete_results); 1951 EXPECT_EQ(0, num_autocomplete_results);
1948 } 1952 }
1949 1953
1950 // Test that hitting Esc to clear the omnibox works. http://crbug.com/231744. 1954 // Test that hitting Esc to clear the omnibox works. http://crbug.com/231744.
1951 // TODO(sreeram): reenable once ESC bug is actually fixed. 1955 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, EscapeClearsOmnibox) {
1952 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_EscapeClearsOmnibox) {
1953 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 1956 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1954 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); 1957 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport();
1955 1958
1956 // Navigate to the Instant NTP, and wait for it to be recognized. 1959 // Navigate to the Instant NTP, and wait for it to be recognized.
1957 content::WindowedNotificationObserver instant_tab_observer( 1960 content::WindowedNotificationObserver instant_tab_observer(
1958 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, 1961 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
1959 content::NotificationService::AllSources()); 1962 content::NotificationService::AllSources());
1960 ui_test_utils::NavigateToURLWithDisposition(browser(), 1963 ui_test_utils::NavigateToURLWithDisposition(
1961 GURL(chrome::kChromeUINewTabURL), 1964 browser(),
1962 CURRENT_TAB, 1965 GURL(chrome::kChromeUINewTabURL),
1963 ui_test_utils::BROWSER_TEST_NONE); 1966 CURRENT_TAB,
1967 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
1964 instant_tab_observer.Wait(); 1968 instant_tab_observer.Wait();
1965 1969
1966 content::WebContents* contents = 1970 content::WebContents* contents =
1967 browser()->tab_strip_model()->GetActiveWebContents(); 1971 browser()->tab_strip_model()->GetActiveWebContents();
1968 1972
1969 // Type a query. Verify that the query is seen by the page. 1973 // Type a query. Verify that the query is seen by the page.
1970 SetOmniboxText("mojo"); 1974 SetOmniboxText("mojo");
1971 std::string query; 1975 std::string query;
1972 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value", 1976 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value",
1973 &query)); 1977 &query));
1974 EXPECT_EQ("mojo", query); 1978 EXPECT_EQ("mojo", query);
1975 1979
1976 EXPECT_TRUE(content::ExecuteScript(contents, 1980 EXPECT_TRUE(content::ExecuteScript(contents,
1977 "onChangeCalls = submitCount = 0;")); 1981 "onChangeCalls = submitCount = 0;"));
1978 1982
1979 // Hit Escape, and verify that the page sees that the query is cleared. 1983 // Hit Escape, and verify that the page sees that the query is cleared.
1980 SendEscape(); 1984 SendEscape();
1981 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value", 1985 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value",
1982 &query)); 1986 &query));
1983 EXPECT_EQ("", query); 1987 EXPECT_EQ("", query);
1984 EXPECT_EQ("", GetOmniboxText()); 1988 EXPECT_EQ("", GetOmniboxText());
1985 1989
1986 EXPECT_TRUE(UpdateSearchState(contents)); 1990 EXPECT_TRUE(UpdateSearchState(contents));
1987 EXPECT_LT(0, on_change_calls_); 1991 EXPECT_LT(0, on_change_calls_);
1988 EXPECT_EQ(0, submit_count_); 1992 EXPECT_EQ(0, submit_count_);
1993 EXPECT_LT(0, on_esc_key_press_event_calls_);
1989 } 1994 }
1990 1995
1991 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OnDefaultSearchProviderChanged) { 1996 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OnDefaultSearchProviderChanged) {
1992 InstantService* instant_service = 1997 InstantService* instant_service =
1993 InstantServiceFactory::GetForProfile(browser()->profile()); 1998 InstantServiceFactory::GetForProfile(browser()->profile());
1994 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); 1999 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service);
1995 2000
1996 // Setup Instant. 2001 // Setup Instant.
1997 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 2002 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1998 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); 2003 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport();
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
2318 content::WindowedNotificationObserver autocomplete_observer( 2323 content::WindowedNotificationObserver autocomplete_observer(
2319 chrome::NOTIFICATION_INSTANT_SENT_AUTOCOMPLETE_RESULTS, 2324 chrome::NOTIFICATION_INSTANT_SENT_AUTOCOMPLETE_RESULTS,
2320 content::NotificationService::AllSources()); 2325 content::NotificationService::AllSources());
2321 2326
2322 SetOmniboxText("http://www.example.com"); 2327 SetOmniboxText("http://www.example.com");
2323 2328
2324 autocomplete_observer.Wait(); 2329 autocomplete_observer.Wait();
2325 ASSERT_TRUE(omnibox()->model()->autocomplete_controller()-> 2330 ASSERT_TRUE(omnibox()->model()->autocomplete_controller()->
2326 search_provider()->IsNonInstantSearchDone()); 2331 search_provider()->IsNonInstantSearchDone());
2327 } 2332 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698