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

Side by Side Diff: chrome/browser/ui/views/find_bar_views_interactive_uitest.cc

Issue 2078953003: Remove find bar focus redirection on mouse events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove focus redirection altogether; update FindInPageTest. Created 4 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/views/find_bar_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/macros.h" 5 #include "base/macros.h"
6 #include "base/strings/string_util.h" 6 #include "base/strings/string_util.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 13 matching lines...) Expand all
24 #include "net/test/embedded_test_server/embedded_test_server.h" 24 #include "net/test/embedded_test_server/embedded_test_server.h"
25 #include "ui/base/clipboard/clipboard.h" 25 #include "ui/base/clipboard/clipboard.h"
26 #include "ui/events/keycodes/keyboard_codes.h" 26 #include "ui/events/keycodes/keyboard_codes.h"
27 #include "ui/views/focus/focus_manager.h" 27 #include "ui/views/focus/focus_manager.h"
28 #include "ui/views/view.h" 28 #include "ui/views/view.h"
29 29
30 using base::ASCIIToUTF16; 30 using base::ASCIIToUTF16;
31 using content::WebContents; 31 using content::WebContents;
32 32
33 namespace { 33 namespace {
34
35 static const char kSimplePage[] = "/find_in_page/simple.html"; 34 static const char kSimplePage[] = "/find_in_page/simple.html";
35 } // namespace
36 36
37 class FindInPageTest : public InProcessBrowserTest { 37 class FindInPageTest : public InProcessBrowserTest {
38 public: 38 public:
39 FindInPageTest() { 39 FindInPageTest() {
40 FindBarHost::disable_animations_during_testing_ = true; 40 FindBarHost::disable_animations_during_testing_ = true;
41 } 41 }
42 42
43 base::string16 GetFindBarText() { 43 base::string16 GetFindBarText() {
44 FindBar* find_bar = browser()->GetFindBarController()->find_bar(); 44 FindBar* find_bar = browser()->GetFindBarController()->find_bar();
45 return find_bar->GetFindText(); 45 return find_bar->GetFindText();
46 } 46 }
47 47
48 base::string16 GetFindBarSelectedText() { 48 base::string16 GetFindBarSelectedText() {
49 FindBarTesting* find_bar = 49 FindBarTesting* find_bar =
50 browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); 50 browser()->GetFindBarController()->find_bar()->GetFindBarTesting();
51 return find_bar->GetFindSelectedText(); 51 return find_bar->GetFindSelectedText();
52 } 52 }
53 53
54 FindBarView* GetFindBarView() const {
Peter Kasting 2016/06/18 01:13:25 Nit: Make pointer const or remove const qualifier
msw 2016/06/18 01:28:59 Done.
55 FindBar* find_bar = browser()->GetFindBarController()->find_bar();
56 return static_cast<FindBarHost*>(find_bar)->find_bar_view();
57 }
58
54 private: 59 private:
55 DISALLOW_COPY_AND_ASSIGN(FindInPageTest); 60 DISALLOW_COPY_AND_ASSIGN(FindInPageTest);
56 }; 61 };
57 62
58 } // namespace
59
60 // Flaky because the test server fails to start? See: http://crbug.com/96594. 63 // Flaky because the test server fails to start? See: http://crbug.com/96594.
61 IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) { 64 IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) {
62 ASSERT_TRUE(embedded_test_server()->Start()); 65 ASSERT_TRUE(embedded_test_server()->Start());
63 66
64 // First we navigate to our test page (tab A). 67 // First we navigate to our test page (tab A).
65 GURL url = embedded_test_server()->GetURL(kSimplePage); 68 GURL url = embedded_test_server()->GetURL(kSimplePage);
66 ui_test_utils::NavigateToURL(browser(), url); 69 ui_test_utils::NavigateToURL(browser(), url);
67 70
68 chrome::Find(browser()); 71 chrome::Find(browser());
69 72
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 true, false, NULL, NULL); 126 true, false, NULL, NULL);
124 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_TAB, false, 127 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_TAB, false,
125 false, false, false)); 128 false, false, false));
126 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_RETURN, false, 129 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_RETURN, false,
127 false, false, false)); 130 false, false, false));
128 EXPECT_TRUE( 131 EXPECT_TRUE(
129 ui_test_utils::IsViewFocused(browser(), 132 ui_test_utils::IsViewFocused(browser(),
130 VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON)); 133 VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON));
131 } 134 }
132 135
133 // TODO(mpistrich): Enable again when ui_test_utils::ClickOnView works with find 136 IN_PROC_BROWSER_TEST_F(FindInPageTest, NoFocusChangesOnClick) {
134 // bar view IDs.
135 // http://crbug.com/584043
136 IN_PROC_BROWSER_TEST_F(FindInPageTest, DISABLED_NavigationByMouse) {
137 ASSERT_TRUE(embedded_test_server()->Start()); 137 ASSERT_TRUE(embedded_test_server()->Start());
138 // Make sure Chrome is in the foreground, otherwise sending input 138 // Make sure Chrome is in the foreground, otherwise sending input
139 // won't do anything and the test will hang. 139 // won't do anything and the test will hang.
140 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 140 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
141 // First we navigate to any page. 141 // First we navigate to any page.
142 ui_test_utils::NavigateToURL(browser(), 142 ui_test_utils::NavigateToURL(browser(),
143 embedded_test_server()->GetURL(kSimplePage)); 143 embedded_test_server()->GetURL(kSimplePage));
144 // Show the Find bar. 144 // Show the Find bar.
145 browser()->GetFindBarController()->Show(); 145 browser()->GetFindBarController()->Show();
146 EXPECT_TRUE( 146 EXPECT_TRUE(
147 ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 147 ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
148 ui_test_utils::FindInPage( 148 ui_test_utils::FindInPage(
149 browser()->tab_strip_model()->GetActiveWebContents(), ASCIIToUTF16("a"), 149 browser()->tab_strip_model()->GetActiveWebContents(), ASCIIToUTF16("a"),
150 true, false, NULL, NULL); 150 true, false, NULL, NULL);
151 EXPECT_TRUE(
152 ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
151 153
152 // The textfield should be focused after clicking on any button. 154 views::View* find_bar_view = GetFindBarView();
153 ui_test_utils::ClickOnView(browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON); 155 views::View* previous_button =
156 find_bar_view->GetViewByID(VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON);
157 views::View* next_button =
158 find_bar_view->GetViewByID(VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON);
159
160 // Clicking the next and previous buttons should not alter the focused view.
161 ui_test_utils::MoveMouseToCenterAndPress(previous_button, ui_controls::LEFT,
162 ui_controls::DOWN | ui_controls::UP,
163 base::Closure());
154 EXPECT_TRUE( 164 EXPECT_TRUE(
155 ui_test_utils::IsViewFocused(browser(), 165 ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
156 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 166 ui_test_utils::MoveMouseToCenterAndPress(next_button, ui_controls::LEFT,
167 ui_controls::DOWN | ui_controls::UP,
168 base::Closure());
169 EXPECT_TRUE(
170 ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
157 171
158 // The textfield should be focused after clicking on any button. 172 // Clicking next shouldn't change focus, even if previous is focused.
159 ui_test_utils::ClickOnView(browser(), VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON); 173 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_TAB, false,
160 EXPECT_TRUE( 174 false, false, false));
161 ui_test_utils::IsViewFocused(browser(), 175 EXPECT_TRUE(ui_test_utils::IsViewFocused(
162 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 176 browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON));
177 ui_test_utils::MoveMouseToCenterAndPress(next_button, ui_controls::LEFT,
178 ui_controls::DOWN | ui_controls::UP,
179 base::Closure());
180 EXPECT_TRUE(ui_test_utils::IsViewFocused(
181 browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON));
163 } 182 }
164 183
165 IN_PROC_BROWSER_TEST_F(FindInPageTest, ButtonsDisabledWithoutText) { 184 IN_PROC_BROWSER_TEST_F(FindInPageTest, ButtonsDisabledWithoutText) {
166 ASSERT_TRUE(embedded_test_server()->Start()); 185 ASSERT_TRUE(embedded_test_server()->Start());
167 // Make sure Chrome is in the foreground, otherwise sending input 186 // Make sure Chrome is in the foreground, otherwise sending input
168 // won't do anything and the test will hang. 187 // won't do anything and the test will hang.
169 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 188 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
170 // First we navigate to any page. 189 // First we navigate to any page.
171 ui_test_utils::NavigateToURL(browser(), 190 ui_test_utils::NavigateToURL(browser(),
172 embedded_test_server()->GetURL(kSimplePage)); 191 embedded_test_server()->GetURL(kSimplePage));
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 ui_test_utils::UrlLoadObserver observer( 547 ui_test_utils::UrlLoadObserver observer(
529 GURL("about:blank"), content::NotificationService::AllSources()); 548 GURL("about:blank"), content::NotificationService::AllSources());
530 549
531 // Send Ctrl-Enter, should cause navigation to about:blank. 550 // Send Ctrl-Enter, should cause navigation to about:blank.
532 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 551 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
533 browser(), ui::VKEY_RETURN, true, false, false, false)); 552 browser(), ui::VKEY_RETURN, true, false, false, false));
534 553
535 observer.Wait(); 554 observer.Wait();
536 } 555 }
537 #endif 556 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/find_bar_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698