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

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

Issue 14646034: Add onfocuschange to the Extended Search API, with associated isFocused attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Trying again after rebase master. Created 7 years, 6 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
« 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/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram_base.h" 9 #include "base/metrics/histogram_base.h"
10 #include "base/metrics/histogram_samples.h" 10 #include "base/metrics/histogram_samples.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 class InstantExtendedTest : public InProcessBrowserTest, 111 class InstantExtendedTest : public InProcessBrowserTest,
112 public InstantTestBase { 112 public InstantTestBase {
113 public: 113 public:
114 InstantExtendedTest() 114 InstantExtendedTest()
115 : on_most_visited_change_calls_(0), 115 : on_most_visited_change_calls_(0),
116 most_visited_items_count_(0), 116 most_visited_items_count_(0),
117 first_most_visited_item_id_(0), 117 first_most_visited_item_id_(0),
118 on_native_suggestions_calls_(0), 118 on_native_suggestions_calls_(0),
119 on_change_calls_(0), 119 on_change_calls_(0),
120 submit_count_(0), 120 submit_count_(0),
121 on_esc_key_press_event_calls_(0) { 121 on_esc_key_press_event_calls_(0),
122 on_focus_changed_calls_(0),
123 is_focused_(false) {
122 } 124 }
123 protected: 125 protected:
124 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 126 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
125 chrome::EnableInstantExtendedAPIForTesting(); 127 chrome::EnableInstantExtendedAPIForTesting();
126 ASSERT_TRUE(https_test_server().Start()); 128 ASSERT_TRUE(https_test_server().Start());
127 GURL instant_url = https_test_server().GetURL( 129 GURL instant_url = https_test_server().GetURL(
128 "files/instant_extended.html?strk=1&"); 130 "files/instant_extended.html?strk=1&");
129 InstantTestBase::Init(instant_url); 131 InstantTestBase::Init(instant_url);
130 } 132 }
131 133
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 &first_most_visited_item_id_) && 177 &first_most_visited_item_id_) &&
176 GetIntFromJS(contents, "onNativeSuggestionsCalls", 178 GetIntFromJS(contents, "onNativeSuggestionsCalls",
177 &on_native_suggestions_calls_) && 179 &on_native_suggestions_calls_) &&
178 GetIntFromJS(contents, "onChangeCalls", 180 GetIntFromJS(contents, "onChangeCalls",
179 &on_change_calls_) && 181 &on_change_calls_) &&
180 GetIntFromJS(contents, "submitCount", 182 GetIntFromJS(contents, "submitCount",
181 &submit_count_) && 183 &submit_count_) &&
182 GetStringFromJS(contents, "apiHandle.value", 184 GetStringFromJS(contents, "apiHandle.value",
183 &query_value_) && 185 &query_value_) &&
184 GetIntFromJS(contents, "onEscKeyPressedCalls", 186 GetIntFromJS(contents, "onEscKeyPressedCalls",
185 &on_esc_key_press_event_calls_); 187 &on_esc_key_press_event_calls_) &&
188 GetIntFromJS(contents, "onFocusChangedCalls",
189 &on_focus_changed_calls_) &&
190 GetBoolFromJS(contents, "isFocused",
191 &is_focused_);
186 } 192 }
187 193
188 TemplateURL* GetDefaultSearchProviderTemplateURL() { 194 TemplateURL* GetDefaultSearchProviderTemplateURL() {
189 TemplateURLService* template_url_service = 195 TemplateURLService* template_url_service =
190 TemplateURLServiceFactory::GetForProfile(browser()->profile()); 196 TemplateURLServiceFactory::GetForProfile(browser()->profile());
191 if (template_url_service) 197 if (template_url_service)
192 return template_url_service->GetDefaultSearchProvider(); 198 return template_url_service->GetDefaultSearchProvider();
193 return NULL; 199 return NULL;
194 } 200 }
195 201
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 233 }
228 234
229 int on_most_visited_change_calls_; 235 int on_most_visited_change_calls_;
230 int most_visited_items_count_; 236 int most_visited_items_count_;
231 int first_most_visited_item_id_; 237 int first_most_visited_item_id_;
232 int on_native_suggestions_calls_; 238 int on_native_suggestions_calls_;
233 int on_change_calls_; 239 int on_change_calls_;
234 int submit_count_; 240 int submit_count_;
235 int on_esc_key_press_event_calls_; 241 int on_esc_key_press_event_calls_;
236 std::string query_value_; 242 std::string query_value_;
243 int on_focus_changed_calls_;
244 bool is_focused_;
237 }; 245 };
238 246
239 // Test class used to verify chrome-search: scheme and access policy from the 247 // Test class used to verify chrome-search: scheme and access policy from the
240 // Instant overlay. This is a subclass of |ExtensionBrowserTest| because it 248 // Instant overlay. This is a subclass of |ExtensionBrowserTest| because it
241 // loads a theme that provides a background image. 249 // loads a theme that provides a background image.
242 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase { 250 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase {
243 public: 251 public:
244 InstantPolicyTest() {} 252 InstantPolicyTest() {}
245 253
246 protected: 254 protected:
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 &query)); 1970 &query));
1963 EXPECT_EQ("", query); 1971 EXPECT_EQ("", query);
1964 EXPECT_EQ("", GetOmniboxText()); 1972 EXPECT_EQ("", GetOmniboxText());
1965 1973
1966 EXPECT_TRUE(UpdateSearchState(contents)); 1974 EXPECT_TRUE(UpdateSearchState(contents));
1967 EXPECT_LT(0, on_change_calls_); 1975 EXPECT_LT(0, on_change_calls_);
1968 EXPECT_EQ(0, submit_count_); 1976 EXPECT_EQ(0, submit_count_);
1969 EXPECT_LT(0, on_esc_key_press_event_calls_); 1977 EXPECT_LT(0, on_esc_key_press_event_calls_);
1970 } 1978 }
1971 1979
1980 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, FocusApiRespondsToFocusChange) {
1981 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1982 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
1983 EXPECT_FALSE(is_focused_);
1984 EXPECT_EQ(0, on_focus_changed_calls_);
1985
1986 // Focus the omnibox.
1987 FocusOmniboxAndWaitForInstantOverlaySupport();
1988 ASSERT_TRUE(UpdateSearchState(instant()->GetOverlayContents()));
1989 EXPECT_TRUE(is_focused_);
1990 EXPECT_EQ(1, on_focus_changed_calls_);
1991
1992 // Now unfocus the omnibox.
1993 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
1994 ASSERT_TRUE(UpdateSearchState(instant()->GetOverlayContents()));
1995 EXPECT_FALSE(is_focused_);
1996 EXPECT_EQ(2, on_focus_changed_calls_);
1997
1998 // Focus the omnibox again.
1999 // The first focus may have worked only due to initial-state anomalies.
2000 FocusOmnibox();
2001 ASSERT_TRUE(UpdateSearchState(instant()->GetOverlayContents()));
2002 EXPECT_TRUE(is_focused_);
2003 EXPECT_EQ(3, on_focus_changed_calls_);
2004 }
2005
2006 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, FocusApiIgnoresRedundantFocus) {
2007 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
2008 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
2009 EXPECT_FALSE(is_focused_);
2010 EXPECT_EQ(0, on_focus_changed_calls_);
2011
2012 // Focus the Omnibox.
2013 FocusOmniboxAndWaitForInstantOverlaySupport();
2014 ASSERT_TRUE(UpdateSearchState(instant()->GetOverlayContents()));
2015 EXPECT_TRUE(is_focused_);
2016 EXPECT_EQ(1, on_focus_changed_calls_);
2017
2018 // When we focus the omnibox again, nothing should change.
2019 FocusOmnibox();
2020 ASSERT_TRUE(UpdateSearchState(instant()->GetOverlayContents()));
2021 EXPECT_TRUE(is_focused_);
2022 EXPECT_EQ(1, on_focus_changed_calls_);
2023
2024 // Now unfocus the omnibox.
2025 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
2026 ASSERT_TRUE(UpdateSearchState(instant()->GetOverlayContents()));
2027 EXPECT_FALSE(is_focused_);
2028 EXPECT_EQ(2, on_focus_changed_calls_);
2029
2030 // When we unfocus again, nothing should change.
2031 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
2032 ASSERT_TRUE(UpdateSearchState(instant()->GetOverlayContents()));
2033 EXPECT_FALSE(is_focused_);
2034 EXPECT_EQ(2, on_focus_changed_calls_);
2035 }
2036
1972 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OnDefaultSearchProviderChanged) { 2037 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OnDefaultSearchProviderChanged) {
1973 InstantService* instant_service = 2038 InstantService* instant_service =
1974 InstantServiceFactory::GetForProfile(browser()->profile()); 2039 InstantServiceFactory::GetForProfile(browser()->profile());
1975 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service); 2040 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service);
1976 2041
1977 // Setup Instant. 2042 // Setup Instant.
1978 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 2043 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1979 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); 2044 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport();
1980 EXPECT_EQ(1, instant_service->GetInstantProcessCount()); 2045 EXPECT_EQ(1, instant_service->GetInstantProcessCount());
1981 2046
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
2513 2578
2514 // Test that if the LogDropdownShown() call records a histogram value. 2579 // Test that if the LogDropdownShown() call records a histogram value.
2515 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, LogDropdownShown) { 2580 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, LogDropdownShown) {
2516 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 2581 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
2517 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport(); 2582 FocusOmniboxAndWaitForInstantOverlayAndNTPSupport();
2518 int64 histogramValue = GetHistogramCount("Instant.TimeToFirstShowFromWeb"); 2583 int64 histogramValue = GetHistogramCount("Instant.TimeToFirstShowFromWeb");
2519 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("a")); 2584 ASSERT_TRUE(SetOmniboxTextAndWaitForOverlayToShow("a"));
2520 EXPECT_EQ(histogramValue + 1, 2585 EXPECT_EQ(histogramValue + 1,
2521 GetHistogramCount("Instant.TimeToFirstShowFromWeb")); 2586 GetHistogramCount("Instant.TimeToFirstShowFromWeb"));
2522 } 2587 }
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