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

Unified 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, 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 side-by-side diff with in-line comments
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 »
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 7fc123ebb52cc43402c3919cd351477d2af4cd07..5c1230126bccdd05eb90b9ad3d9274e30b9079b9 100644
--- a/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
+++ b/chrome/browser/ui/search/instant_extended_interactive_uitest.cc
@@ -118,7 +118,9 @@ class InstantExtendedTest : public InProcessBrowserTest,
on_native_suggestions_calls_(0),
on_change_calls_(0),
submit_count_(0),
- on_esc_key_press_event_calls_(0) {
+ on_esc_key_press_event_calls_(0),
+ on_focus_changed_calls_(0),
+ is_focused_(false) {
}
protected:
virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
@@ -182,7 +184,11 @@ class InstantExtendedTest : public InProcessBrowserTest,
GetStringFromJS(contents, "apiHandle.value",
&query_value_) &&
GetIntFromJS(contents, "onEscKeyPressedCalls",
- &on_esc_key_press_event_calls_);
+ &on_esc_key_press_event_calls_) &&
+ GetIntFromJS(contents, "onFocusChangedCalls",
+ &on_focus_changed_calls_) &&
+ GetBoolFromJS(contents, "isFocused",
+ &is_focused_);
}
TemplateURL* GetDefaultSearchProviderTemplateURL() {
@@ -234,6 +240,8 @@ class InstantExtendedTest : public InProcessBrowserTest,
int submit_count_;
int on_esc_key_press_event_calls_;
std::string query_value_;
+ int on_focus_changed_calls_;
+ bool is_focused_;
};
// Test class used to verify chrome-search: scheme and access policy from the
@@ -1969,6 +1977,63 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, EscapeClearsOmnibox) {
EXPECT_LT(0, on_esc_key_press_event_calls_);
}
+IN_PROC_BROWSER_TEST_F(InstantExtendedTest, FocusApiRespondsToFocusChange) {
+ ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
+ ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
+ EXPECT_FALSE(is_focused_);
+ EXPECT_EQ(0, on_focus_changed_calls_);
+
+ // Focus the omnibox.
+ FocusOmniboxAndWaitForInstantOverlaySupport();
+ ASSERT_TRUE(UpdateSearchState(instant()->GetOverlayContents()));
+ EXPECT_TRUE(is_focused_);
+ EXPECT_EQ(1, on_focus_changed_calls_);
+
+ // Now unfocus the omnibox.
+ ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
+ ASSERT_TRUE(UpdateSearchState(instant()->GetOverlayContents()));
+ EXPECT_FALSE(is_focused_);
+ EXPECT_EQ(2, on_focus_changed_calls_);
+
+ // Focus the omnibox again.
+ // The first focus may have worked only due to initial-state anomalies.
+ FocusOmnibox();
+ ASSERT_TRUE(UpdateSearchState(instant()->GetOverlayContents()));
+ EXPECT_TRUE(is_focused_);
+ EXPECT_EQ(3, on_focus_changed_calls_);
+}
+
+IN_PROC_BROWSER_TEST_F(InstantExtendedTest, FocusApiIgnoresRedundantFocus) {
+ ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
+ ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
+ EXPECT_FALSE(is_focused_);
+ EXPECT_EQ(0, on_focus_changed_calls_);
+
+ // Focus the Omnibox.
+ FocusOmniboxAndWaitForInstantOverlaySupport();
+ ASSERT_TRUE(UpdateSearchState(instant()->GetOverlayContents()));
+ EXPECT_TRUE(is_focused_);
+ EXPECT_EQ(1, on_focus_changed_calls_);
+
+ // When we focus the omnibox again, nothing should change.
+ FocusOmnibox();
+ ASSERT_TRUE(UpdateSearchState(instant()->GetOverlayContents()));
+ EXPECT_TRUE(is_focused_);
+ EXPECT_EQ(1, on_focus_changed_calls_);
+
+ // Now unfocus the omnibox.
+ ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
+ ASSERT_TRUE(UpdateSearchState(instant()->GetOverlayContents()));
+ EXPECT_FALSE(is_focused_);
+ EXPECT_EQ(2, on_focus_changed_calls_);
+
+ // When we unfocus again, nothing should change.
+ ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
+ ASSERT_TRUE(UpdateSearchState(instant()->GetOverlayContents()));
+ EXPECT_FALSE(is_focused_);
+ EXPECT_EQ(2, on_focus_changed_calls_);
+}
+
IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OnDefaultSearchProviderChanged) {
InstantService* instant_service =
InstantServiceFactory::GetForProfile(browser()->profile());
« 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