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

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

Issue 1660273003: Keep focus on Find-In-Page buttons when using the keyboard to navigate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 ui_test_utils::NavigateToURL(browser(), 101 ui_test_utils::NavigateToURL(browser(),
102 embedded_test_server()->GetURL(kSimplePage)); 102 embedded_test_server()->GetURL(kSimplePage));
103 // Show the Find bar. 103 // Show the Find bar.
104 browser()->GetFindBarController()->Show(); 104 browser()->GetFindBarController()->Show();
105 EXPECT_TRUE( 105 EXPECT_TRUE(
106 ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 106 ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
107 ui_test_utils::FindInPage( 107 ui_test_utils::FindInPage(
108 browser()->tab_strip_model()->GetActiveWebContents(), ASCIIToUTF16("a"), 108 browser()->tab_strip_model()->GetActiveWebContents(), ASCIIToUTF16("a"),
109 true, false, NULL, NULL); 109 true, false, NULL, NULL);
110 110
111 // The textfield should be focused after pressing [Enter] on the find button. 111 // The previous button should still be focused after pressing [Enter] on it.
112 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_TAB, false, 112 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_TAB, false,
113 false, false, false)); 113 false, false, false));
114 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_RETURN, false, 114 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_RETURN, false,
115 false, false, false)); 115 false, false, false));
116 EXPECT_TRUE( 116 EXPECT_TRUE(
117 ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 117 ui_test_utils::IsViewFocused(browser(),
118 VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON));
118 119
119 // The textfield should be focused after pressing [Enter] on the find button. 120 // The next button should still be focused after pressing [Enter] on it.
120 ui_test_utils::FindInPage( 121 ui_test_utils::FindInPage(
121 browser()->tab_strip_model()->GetActiveWebContents(), ASCIIToUTF16("b"), 122 browser()->tab_strip_model()->GetActiveWebContents(), ASCIIToUTF16("b"),
122 true, false, NULL, NULL); 123 true, false, NULL, NULL);
123 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_TAB, false, 124 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_TAB, false,
124 false, false, false)); 125 false, false, false));
125 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_TAB, false,
126 false, false, false));
127 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_RETURN, false, 126 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_RETURN, false,
128 false, false, false)); 127 false, false, false));
129 EXPECT_TRUE( 128 EXPECT_TRUE(
129 ui_test_utils::IsViewFocused(browser(),
130 VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON));
131 }
132
133 // TODO(mpistrich): Enable again when ui_test_utils::ClickOnView works with find
msw 2016/02/03 19:58:02 Why doesn't ClickOnView work with these buttons?
Mario Pistrich 2016/02/03 20:41:59 I couldn't figure it out why ClickOnView does not
msw 2016/02/03 21:43:34 Please file a bug and cite in this comment; follow
Mario Pistrich 2016/02/03 23:32:54 Done, see http://crbug.com/584043
134 // bar view IDs.
135 IN_PROC_BROWSER_TEST_F(FindInPageTest, DISABLED_NavigationByMouse) {
136 ASSERT_TRUE(embedded_test_server()->Start());
137 // Make sure Chrome is in the foreground, otherwise sending input
138 // won't do anything and the test will hang.
139 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
140 // First we navigate to any page.
141 ui_test_utils::NavigateToURL(browser(),
142 embedded_test_server()->GetURL(kSimplePage));
143 // Show the Find bar.
144 browser()->GetFindBarController()->Show();
145 EXPECT_TRUE(
130 ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 146 ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
147 ui_test_utils::FindInPage(
148 browser()->tab_strip_model()->GetActiveWebContents(), ASCIIToUTF16("a"),
149 true, false, NULL, NULL);
150
151 // The textfield should be focused after clicking on any button.
152 ui_test_utils::ClickOnView(browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON);
153 EXPECT_TRUE(
154 ui_test_utils::IsViewFocused(browser(),
155 VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON));
msw 2016/02/03 19:58:02 This should be VIEW_ID_FIND_IN_PAGE_TEXT_FIELD
Mario Pistrich 2016/02/03 20:41:59 Done.
156
157 // The textfield should be focused after clicking on any button.
158 ui_test_utils::ClickOnView(browser(), VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON);
159 EXPECT_TRUE(
160 ui_test_utils::IsViewFocused(browser(),
161 VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON));
msw 2016/02/03 19:58:02 Ditto: This should be VIEW_ID_FIND_IN_PAGE_TEXT_FI
Mario Pistrich 2016/02/03 20:41:59 Done.
131 } 162 }
132 163
133 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) 164 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
134 // TODO(erg): linux_aura bringup: http://crbug.com/163931 165 // TODO(erg): linux_aura bringup: http://crbug.com/163931
135 #define MAYBE_FocusRestore DISABLED_FocusRestore 166 #define MAYBE_FocusRestore DISABLED_FocusRestore
136 #else 167 #else
137 #define MAYBE_FocusRestore FocusRestore 168 #define MAYBE_FocusRestore FocusRestore
138 #endif 169 #endif
139 170
140 // Flaky because the test server fails to start? See: http://crbug.com/96594. 171 // Flaky because the test server fails to start? See: http://crbug.com/96594.
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 ui_test_utils::UrlLoadObserver observer( 506 ui_test_utils::UrlLoadObserver observer(
476 GURL("about:blank"), content::NotificationService::AllSources()); 507 GURL("about:blank"), content::NotificationService::AllSources());
477 508
478 // Send Ctrl-Enter, should cause navigation to about:blank. 509 // Send Ctrl-Enter, should cause navigation to about:blank.
479 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 510 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
480 browser(), ui::VKEY_RETURN, true, false, false, false)); 511 browser(), ui::VKEY_RETURN, true, false, false, false));
481 512
482 observer.Wait(); 513 observer.Wait();
483 } 514 }
484 #endif 515 #endif
OLDNEW
« chrome/browser/ui/views/find_bar_view.cc ('K') | « 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