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

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: Remove viewIDs for findbar and add them to the exception list. 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
« 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 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
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());
138 // Make sure Chrome is in the foreground, otherwise sending input
139 // won't do anything and the test will hang.
140 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
141 // First we navigate to any page.
142 ui_test_utils::NavigateToURL(browser(),
143 embedded_test_server()->GetURL(kSimplePage));
144 // Show the Find bar.
145 browser()->GetFindBarController()->Show();
146 EXPECT_TRUE(
130 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(
149 browser()->tab_strip_model()->GetActiveWebContents(), ASCIIToUTF16("a"),
150 true, false, NULL, NULL);
151
152 // The textfield should be focused after clicking on any button.
153 ui_test_utils::ClickOnView(browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON);
154 EXPECT_TRUE(
155 ui_test_utils::IsViewFocused(browser(),
156 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
157
158 // The textfield should be focused after clicking on any button.
159 ui_test_utils::ClickOnView(browser(), VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON);
160 EXPECT_TRUE(
161 ui_test_utils::IsViewFocused(browser(),
162 VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
131 } 163 }
132 164
133 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) 165 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
134 // TODO(erg): linux_aura bringup: http://crbug.com/163931 166 // TODO(erg): linux_aura bringup: http://crbug.com/163931
135 #define MAYBE_FocusRestore DISABLED_FocusRestore 167 #define MAYBE_FocusRestore DISABLED_FocusRestore
136 #else 168 #else
137 #define MAYBE_FocusRestore FocusRestore 169 #define MAYBE_FocusRestore FocusRestore
138 #endif 170 #endif
139 171
140 // Flaky because the test server fails to start? See: http://crbug.com/96594. 172 // 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( 507 ui_test_utils::UrlLoadObserver observer(
476 GURL("about:blank"), content::NotificationService::AllSources()); 508 GURL("about:blank"), content::NotificationService::AllSources());
477 509
478 // Send Ctrl-Enter, should cause navigation to about:blank. 510 // Send Ctrl-Enter, should cause navigation to about:blank.
479 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 511 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
480 browser(), ui::VKEY_RETURN, true, false, false, false)); 512 browser(), ui::VKEY_RETURN, true, false, false, false));
481 513
482 observer.Wait(); 514 observer.Wait();
483 } 515 }
484 #endif 516 #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