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

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: git cl upload 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') | chrome/browser/ui/search/instant_page.h » ('j') | 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/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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 class InstantExtendedTest : public InProcessBrowserTest, 105 class InstantExtendedTest : public InProcessBrowserTest,
106 public InstantTestBase { 106 public InstantTestBase {
107 public: 107 public:
108 InstantExtendedTest() 108 InstantExtendedTest()
109 : on_most_visited_change_calls_(0), 109 : on_most_visited_change_calls_(0),
110 most_visited_items_count_(0), 110 most_visited_items_count_(0),
111 first_most_visited_item_id_(0), 111 first_most_visited_item_id_(0),
112 on_native_suggestions_calls_(0), 112 on_native_suggestions_calls_(0),
113 on_change_calls_(0), 113 on_change_calls_(0),
114 submit_count_(0) { 114 submit_count_(0),
115 on_esc_key_press_event_calls_(0) {
115 } 116 }
116 protected: 117 protected:
117 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 118 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
118 chrome::EnableInstantExtendedAPIForTesting(); 119 chrome::EnableInstantExtendedAPIForTesting();
119 ASSERT_TRUE(https_test_server().Start()); 120 ASSERT_TRUE(https_test_server().Start());
120 GURL instant_url = https_test_server().GetURL( 121 GURL instant_url = https_test_server().GetURL(
121 "files/instant_extended.html?strk=1&"); 122 "files/instant_extended.html?strk=1&");
122 InstantTestBase::Init(instant_url); 123 InstantTestBase::Init(instant_url);
123 } 124 }
124 125
(...skipping 30 matching lines...) Expand all
155 &most_visited_items_count_) && 156 &most_visited_items_count_) &&
156 GetIntFromJS(contents, "firstMostVisitedItemId", 157 GetIntFromJS(contents, "firstMostVisitedItemId",
157 &first_most_visited_item_id_) && 158 &first_most_visited_item_id_) &&
158 GetIntFromJS(contents, "onNativeSuggestionsCalls", 159 GetIntFromJS(contents, "onNativeSuggestionsCalls",
159 &on_native_suggestions_calls_) && 160 &on_native_suggestions_calls_) &&
160 GetIntFromJS(contents, "onChangeCalls", 161 GetIntFromJS(contents, "onChangeCalls",
161 &on_change_calls_) && 162 &on_change_calls_) &&
162 GetIntFromJS(contents, "submitCount", 163 GetIntFromJS(contents, "submitCount",
163 &submit_count_) && 164 &submit_count_) &&
164 GetStringFromJS(contents, "apiHandle.value", 165 GetStringFromJS(contents, "apiHandle.value",
165 &query_value_); 166 &query_value_) &&
167 GetIntFromJS(contents, "onEscKeyPressedCalls",
168 &on_esc_key_press_event_calls_);
166 } 169 }
167 170
168 TemplateURL* GetDefaultSearchProviderTemplateURL() { 171 TemplateURL* GetDefaultSearchProviderTemplateURL() {
169 TemplateURLService* template_url_service = 172 TemplateURLService* template_url_service =
170 TemplateURLServiceFactory::GetForProfile(browser()->profile()); 173 TemplateURLServiceFactory::GetForProfile(browser()->profile());
171 if (template_url_service) 174 if (template_url_service)
172 return template_url_service->GetDefaultSearchProvider(); 175 return template_url_service->GetDefaultSearchProvider();
173 return NULL; 176 return NULL;
174 } 177 }
175 178
(...skipping 29 matching lines...) Expand all
205 return omnibox()->model()->autocomplete_controller()->search_provider()-> 208 return omnibox()->model()->autocomplete_controller()->search_provider()->
206 matches().size(); 209 matches().size();
207 } 210 }
208 211
209 int on_most_visited_change_calls_; 212 int on_most_visited_change_calls_;
210 int most_visited_items_count_; 213 int most_visited_items_count_;
211 int first_most_visited_item_id_; 214 int first_most_visited_item_id_;
212 int on_native_suggestions_calls_; 215 int on_native_suggestions_calls_;
213 int on_change_calls_; 216 int on_change_calls_;
214 int submit_count_; 217 int submit_count_;
218 int on_esc_key_press_event_calls_;
215 std::string query_value_; 219 std::string query_value_;
216 }; 220 };
217 221
218 // Test class used to verify chrome-search: scheme and access policy from the 222 // Test class used to verify chrome-search: scheme and access policy from the
219 // Instant overlay. This is a subclass of |ExtensionBrowserTest| because it 223 // Instant overlay. This is a subclass of |ExtensionBrowserTest| because it
220 // loads a theme that provides a background image. 224 // loads a theme that provides a background image.
221 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase { 225 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase {
222 public: 226 public:
223 InstantPolicyTest() {} 227 InstantPolicyTest() {}
224 228
(...skipping 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after
1944 SetOmniboxText(""); 1948 SetOmniboxText("");
1945 1949
1946 EXPECT_TRUE(GetIntFromJS( 1950 EXPECT_TRUE(GetIntFromJS(
1947 overlay, 1951 overlay,
1948 "chrome.embeddedSearch.searchBox.nativeSuggestions.length", 1952 "chrome.embeddedSearch.searchBox.nativeSuggestions.length",
1949 &num_autocomplete_results)); 1953 &num_autocomplete_results));
1950 EXPECT_EQ(0, num_autocomplete_results); 1954 EXPECT_EQ(0, num_autocomplete_results);
1951 } 1955 }
1952 1956
1953 // Test that hitting Esc to clear the omnibox works. http://crbug.com/231744. 1957 // Test that hitting Esc to clear the omnibox works. http://crbug.com/231744.
1954 // TODO(sreeram): reenable once ESC bug is actually fixed. 1958 // TODO(kmadhusu): Investigate and re-enable this test.
1955 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_EscapeClearsOmnibox) { 1959 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_EscapeClearsOmnibox) {
1956 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 1960 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1957 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); 1961 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport();
1958 1962
1959 // Navigate to the Instant NTP, and wait for it to be recognized. 1963 // Navigate to the Instant NTP, and wait for it to be recognized.
1960 content::WindowedNotificationObserver instant_tab_observer( 1964 content::WindowedNotificationObserver instant_tab_observer(
1961 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, 1965 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
1962 content::NotificationService::AllSources()); 1966 content::NotificationService::AllSources());
1963 ui_test_utils::NavigateToURLWithDisposition(browser(), 1967 ui_test_utils::NavigateToURLWithDisposition(
1964 GURL(chrome::kChromeUINewTabURL), 1968 browser(),
1965 CURRENT_TAB, 1969 GURL(chrome::kChromeUINewTabURL),
1966 ui_test_utils::BROWSER_TEST_NONE); 1970 CURRENT_TAB,
1971 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
1967 instant_tab_observer.Wait(); 1972 instant_tab_observer.Wait();
1968 1973
1969 content::WebContents* contents = 1974 content::WebContents* contents =
1970 browser()->tab_strip_model()->GetActiveWebContents(); 1975 browser()->tab_strip_model()->GetActiveWebContents();
1971 1976
1972 // Type a query. Verify that the query is seen by the page. 1977 // Type a query. Verify that the query is seen by the page.
1973 SetOmniboxText("mojo"); 1978 SetOmniboxText("mojo");
1974 std::string query; 1979 std::string query;
1975 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value", 1980 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value",
1976 &query)); 1981 &query));
1977 EXPECT_EQ("mojo", query); 1982 EXPECT_EQ("mojo", query);
1978 1983
1979 EXPECT_TRUE(content::ExecuteScript(contents, 1984 EXPECT_TRUE(content::ExecuteScript(contents,
1980 "onChangeCalls = submitCount = 0;")); 1985 "onChangeCalls = submitCount = 0;"));
1981 1986
1982 // Hit Escape, and verify that the page sees that the query is cleared. 1987 // Hit Escape, and verify that the page sees that the query is cleared.
1983 SendEscape(); 1988 SendEscape();
1984 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value", 1989 EXPECT_TRUE(GetStringFromJS(contents, "chrome.embeddedSearch.searchBox.value",
1985 &query)); 1990 &query));
1986 EXPECT_EQ("", query); 1991 EXPECT_EQ("", query);
1987 EXPECT_EQ("", GetOmniboxText()); 1992 EXPECT_EQ("", GetOmniboxText());
1988 1993
1989 EXPECT_TRUE(UpdateSearchState(contents)); 1994 EXPECT_TRUE(UpdateSearchState(contents));
1990 EXPECT_LT(0, on_change_calls_); 1995 EXPECT_LT(0, on_change_calls_);
1991 EXPECT_EQ(0, submit_count_); 1996 EXPECT_EQ(0, submit_count_);
1997 EXPECT_LT(0, on_esc_key_press_event_calls_);
1992 } 1998 }
1993 1999
1994 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OnDefaultSearchProviderChanged) { 2000 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OnDefaultSearchProviderChanged) {
1995 InstantService* instant_service = 2001 InstantService* instant_service =
1996 InstantServiceFactory::GetForProfile(browser()->profile()); 2002 InstantServiceFactory::GetForProfile(browser()->profile());
1997 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); 2003 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service);
1998 2004
1999 // Setup Instant. 2005 // Setup Instant.
2000 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 2006 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
2001 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); 2007 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport();
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 EXPECT_TRUE(instant()->ntp()->IsLocal()); 2378 EXPECT_TRUE(instant()->ntp()->IsLocal());
2373 2379
2374 // Overlay contents should be preloaded. 2380 // Overlay contents should be preloaded.
2375 ASSERT_NE(static_cast<InstantOverlay*>(NULL), instant()->overlay()); 2381 ASSERT_NE(static_cast<InstantOverlay*>(NULL), instant()->overlay());
2376 EXPECT_TRUE(instant()->overlay()->IsLocal()); 2382 EXPECT_TRUE(instant()->overlay()->IsLocal());
2377 2383
2378 // Instant tab contents should be preloaded. 2384 // Instant tab contents should be preloaded.
2379 ASSERT_NE(static_cast<InstantTab*>(NULL), instant()->instant_tab()); 2385 ASSERT_NE(static_cast<InstantTab*>(NULL), instant()->instant_tab());
2380 EXPECT_TRUE(instant()->instant_tab()->IsLocal()); 2386 EXPECT_TRUE(instant()->instant_tab()->IsLocal());
2381 } 2387 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/instant_controller.cc ('k') | chrome/browser/ui/search/instant_page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698