summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_focus_uitest.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-23 16:21:28 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-23 16:21:28 +0000
commit1d000681ef18ea1ebd39a19bf17a7bfccd3ed352 (patch)
treeba970b56596e6ea791b260227a8a7d73ffc696e8 /chrome/browser/browser_focus_uitest.cc
parent6679aafaaa6a213759623e4a056281d209158523 (diff)
downloadchromium_src-1d000681ef18ea1ebd39a19bf17a7bfccd3ed352.zip
chromium_src-1d000681ef18ea1ebd39a19bf17a7bfccd3ed352.tar.gz
chromium_src-1d000681ef18ea1ebd39a19bf17a7bfccd3ed352.tar.bz2
Adds ui_test_utils::SendAndWaitForKeyPress and converts callers (where
appropriate) to use it. Hopefully this will help isolate why tests are failing on bot. BUG=none TEST=none; test only change. Review URL: http://codereview.chromium.org/3117030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57064 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_focus_uitest.cc')
-rw-r--r--chrome/browser/browser_focus_uitest.cc71
1 files changed, 32 insertions, 39 deletions
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index 6f2e0ad..7c28705 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(