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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/find_bar_view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/find_bar_views_interactive_uitest.cc
diff --git a/chrome/browser/ui/views/find_bar_views_interactive_uitest.cc b/chrome/browser/ui/views/find_bar_views_interactive_uitest.cc
index b3acc50f100129985cd64392d6061b1541944726..e98961c729873c56cf378aec29414450cccd9d4a 100644
--- a/chrome/browser/ui/views/find_bar_views_interactive_uitest.cc
+++ b/chrome/browser/ui/views/find_bar_views_interactive_uitest.cc
@@ -31,8 +31,8 @@ using base::ASCIIToUTF16;
using content::WebContents;
namespace {
-
static const char kSimplePage[] = "/find_in_page/simple.html";
+} // namespace
class FindInPageTest : public InProcessBrowserTest {
public:
@@ -51,12 +51,15 @@ class FindInPageTest : public InProcessBrowserTest {
return find_bar->GetFindSelectedText();
}
+ 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.
+ FindBar* find_bar = browser()->GetFindBarController()->find_bar();
+ return static_cast<FindBarHost*>(find_bar)->find_bar_view();
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(FindInPageTest);
};
-} // namespace
-
// Flaky because the test server fails to start? See: http://crbug.com/96594.
IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) {
ASSERT_TRUE(embedded_test_server()->Start());
@@ -130,10 +133,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, NavigationByKeyEvent) {
VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON));
}
-// TODO(mpistrich): Enable again when ui_test_utils::ClickOnView works with find
-// bar view IDs.
-// http://crbug.com/584043
-IN_PROC_BROWSER_TEST_F(FindInPageTest, DISABLED_NavigationByMouse) {
+IN_PROC_BROWSER_TEST_F(FindInPageTest, NoFocusChangesOnClick) {
ASSERT_TRUE(embedded_test_server()->Start());
// Make sure Chrome is in the foreground, otherwise sending input
// won't do anything and the test will hang.
@@ -148,18 +148,37 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, DISABLED_NavigationByMouse) {
ui_test_utils::FindInPage(
browser()->tab_strip_model()->GetActiveWebContents(), ASCIIToUTF16("a"),
true, false, NULL, NULL);
-
- // The textfield should be focused after clicking on any button.
- ui_test_utils::ClickOnView(browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON);
EXPECT_TRUE(
- ui_test_utils::IsViewFocused(browser(),
- VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
+ ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
+
+ views::View* find_bar_view = GetFindBarView();
+ views::View* previous_button =
+ find_bar_view->GetViewByID(VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON);
+ views::View* next_button =
+ find_bar_view->GetViewByID(VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON);
- // The textfield should be focused after clicking on any button.
- ui_test_utils::ClickOnView(browser(), VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON);
+ // Clicking the next and previous buttons should not alter the focused view.
+ ui_test_utils::MoveMouseToCenterAndPress(previous_button, ui_controls::LEFT,
+ ui_controls::DOWN | ui_controls::UP,
+ base::Closure());
EXPECT_TRUE(
- ui_test_utils::IsViewFocused(browser(),
- VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
+ ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
+ ui_test_utils::MoveMouseToCenterAndPress(next_button, ui_controls::LEFT,
+ ui_controls::DOWN | ui_controls::UP,
+ base::Closure());
+ EXPECT_TRUE(
+ ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
+
+ // Clicking next shouldn't change focus, even if previous is focused.
+ ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_TAB, false,
+ false, false, false));
+ EXPECT_TRUE(ui_test_utils::IsViewFocused(
+ browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON));
+ ui_test_utils::MoveMouseToCenterAndPress(next_button, ui_controls::LEFT,
+ ui_controls::DOWN | ui_controls::UP,
+ base::Closure());
+ EXPECT_TRUE(ui_test_utils::IsViewFocused(
+ browser(), VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON));
}
IN_PROC_BROWSER_TEST_F(FindInPageTest, ButtonsDisabledWithoutText) {
« 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