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

Unified Diff: chrome/browser/browser_focus_uitest.cc

Issue 3117030: Adds ui_test_utils::SendAndWaitForKeyPress and converts callers (where (Closed)
Patch Set: Addressed review comments Created 10 years, 4 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
Index: chrome/browser/browser_focus_uitest.cc
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index 6f2e0ade1abb6ad9f7ce691af8d7d21c0a6b1bed..7c2870565a3d8ef588107b8f0ec8794b70bb72d0 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -305,10 +305,8 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocus) {
VIEW_ID_LOCATION_BAR;
ASSERT_TRUE(IsViewFocused(vid));
- ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_TAB, true,
- false, false, false,
- new MessageLoop::QuitTask());
- ui_test_utils::RunMessageLoop();
+ ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
+ window, base::VKEY_TAB, true, false, false, false));
}
// As above, but with ctrl+shift+tab.
@@ -318,10 +316,8 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocus) {
VIEW_ID_LOCATION_BAR;
ASSERT_TRUE(IsViewFocused(vid));
- ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_TAB, true,
- true, false, false,
- new MessageLoop::QuitTask());
- ui_test_utils::RunMessageLoop();
+ ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
+ window, base::VKEY_TAB, true, true, false, false));
}
}
}
@@ -488,11 +484,13 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversal) {
false, false, false, false));
if (j < arraysize(kExpElementIDs) - 1) {
- ui_test_utils::WaitForFocusChange(browser()->GetSelectedTabContents()->
- render_view_host());
+ ASSERT_NO_FATAL_FAILURE(
+ ui_test_utils::WaitForFocusChange(
+ browser()->GetSelectedTabContents()->render_view_host()));
} else {
// On the last tab key press, the focus returns to the browser.
- ui_test_utils::WaitForFocusInBrowser(browser());
+ ASSERT_NO_FATAL_FAILURE(
+ ui_test_utils::WaitForFocusInBrowser(browser()));
}
}
@@ -515,11 +513,13 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversal) {
false, true, false, false));
if (j < arraysize(kExpElementIDs) - 1) {
- ui_test_utils::WaitForFocusChange(browser()->GetSelectedTabContents()->
- render_view_host());
+ ASSERT_NO_FATAL_FAILURE(
+ ui_test_utils::WaitForFocusChange(
+ browser()->GetSelectedTabContents()->render_view_host()));
} else {
// On the last tab key press, the focus returns to the browser.
- ui_test_utils::WaitForFocusInBrowser(browser());
+ ASSERT_NO_FATAL_FAILURE(
+ ui_test_utils::WaitForFocusInBrowser(browser()));
}
// Let's make sure the focus is on the expected element in the page.
@@ -588,10 +588,11 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) {
false, false, false, false));
if (j < arraysize(kExpElementIDs) - 1) {
- interstitial_page->WaitForFocusChange();
+ ASSERT_NO_FATAL_FAILURE(interstitial_page->WaitForFocusChange());
} else {
// On the last tab key press, the focus returns to the browser.
- ui_test_utils::WaitForFocusInBrowser(browser());
+ ASSERT_NO_FATAL_FAILURE(
+ ui_test_utils::WaitForFocusInBrowser(browser()));
}
}
@@ -612,10 +613,11 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) {
false, true, false, false));
if (j < arraysize(kExpElementIDs) - 1) {
- interstitial_page->WaitForFocusChange();
+ ASSERT_NO_FATAL_FAILURE(interstitial_page->WaitForFocusChange());
} else {
// On the last tab key press, the focus returns to the browser.
- ui_test_utils::WaitForFocusInBrowser(browser());
+ ASSERT_NO_FATAL_FAILURE(
+ ui_test_utils::WaitForFocusInBrowser(browser()));
}
// Let's make sure the focus is on the expected element in the page.
@@ -679,16 +681,13 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) {
#if defined(OS_MACOSX)
// Press Cmd+F, which will make the Find box open and request focus.
- ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, false,
- false, false, true,
- new MessageLoop::QuitTask());
+ ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
+ window, base::VKEY_F, false, false, false, true));
#else
// Press Ctrl+F, which will make the Find box open and request focus.
- ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, true,
- false, false, false,
- new MessageLoop::QuitTask());
+ ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
+ window, base::VKEY_F, true, false, false, false));
#endif
- ui_test_utils::RunMessageLoop();
// Ideally, we wouldn't sleep here and instead would intercept the
// RenderViewHostDelegate::HandleKeyboardEvent() callback. To do that, we
@@ -706,15 +705,12 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) {
// Now press Ctrl+F again and focus should move to the Find box.
#if defined(OS_MACOSX)
- ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, false,
- false, false, true,
- new MessageLoop::QuitTask());
+ ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
+ window, base::VKEY_F, false, false, false, true));
#else
- ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, true,
- false, false, false,
- new MessageLoop::QuitTask());
+ ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
+ window, base::VKEY_F, true, false, false, false));
#endif
- ui_test_utils::RunMessageLoop();
ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
// Set focus to the page.
@@ -723,15 +719,12 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) {
// Now press Ctrl+F again and focus should move to the Find box.
#if defined(OS_MACOSX)
- ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, false,
- false, false, true,
- new MessageLoop::QuitTask());
+ ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
+ window, base::VKEY_F, false, false, false, true));
#else
- ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, true,
- false, false, false,
- new MessageLoop::QuitTask());
+ ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
+ window, base::VKEY_F, true, false, false, false));
#endif
- ui_test_utils::RunMessageLoop();
// See remark above on why we wait.
MessageLoop::current()->PostDelayedTask(

Powered by Google App Engine
This is Rietveld 408576698