diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-23 16:21:28 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-23 16:21:28 +0000 |
commit | 1d000681ef18ea1ebd39a19bf17a7bfccd3ed352 (patch) | |
tree | ba970b56596e6ea791b260227a8a7d73ffc696e8 /chrome/test | |
parent | 6679aafaaa6a213759623e4a056281d209158523 (diff) | |
download | chromium_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/test')
-rw-r--r-- | chrome/test/in_process_browser_test.cc | 5 | ||||
-rw-r--r-- | chrome/test/ui_test_utils.cc | 20 | ||||
-rw-r--r-- | chrome/test/ui_test_utils.h | 13 |
3 files changed, 35 insertions, 3 deletions
diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc index 9fc2544..61ece39 100644 --- a/chrome/test/in_process_browser_test.cc +++ b/chrome/test/in_process_browser_test.cc @@ -327,9 +327,10 @@ void InProcessBrowserTest::TimedOut() { error_message += base::IntToString(initial_timeout_); error_message += " ms (kInitialTimeoutInMS)."; - GTEST_NONFATAL_FAILURE_(error_message.c_str()); - MessageLoopForUI::current()->Quit(); + + // WARNING: This must be after Quit as it returns. + FAIL() << error_message; } void InProcessBrowserTest::SetInitialTimeoutInMS(int timeout_value) { diff --git a/chrome/test/ui_test_utils.cc b/chrome/test/ui_test_utils.cc index 3d36b6e..9c86038 100644 --- a/chrome/test/ui_test_utils.cc +++ b/chrome/test/ui_test_utils.cc @@ -14,6 +14,7 @@ #include "base/process_util.h" #include "base/utf_string_conversions.h" #include "base/values.h" +#include "chrome/browser/automation/ui_controls.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/dom_operation_notification_details.h" @@ -549,6 +550,25 @@ void WaitForBookmarkModelToLoad(BookmarkModel* model) { ASSERT_TRUE(model->IsLoaded()); } +bool SendKeyPressSync(gfx::NativeWindow window, + base::KeyboardCode key, + bool control, + bool shift, + bool alt, + bool command) { + if (!ui_controls::SendKeyPressNotifyWhenDone( + window, key, control, shift, alt, command, + new MessageLoop::QuitTask())) { + LOG(ERROR) << "ui_controls::SendKeyPressNotifyWhenDone failed"; + return false; + } + // Run the message loop. It'll stop running when either the key was received + // or the test timed out (in which case testing::Test::HasFatalFailure should + // be set). + RunMessageLoop(); + return !testing::Test::HasFatalFailure(); +} + TimedMessageLoopRunner::TimedMessageLoopRunner() : loop_(new MessageLoopForUI()), owned_(true), diff --git a/chrome/test/ui_test_utils.h b/chrome/test/ui_test_utils.h index 8173348..8ca8b02 100644 --- a/chrome/test/ui_test_utils.h +++ b/chrome/test/ui_test_utils.h @@ -10,8 +10,8 @@ #include <string> #include <set> -#include "gfx/native_widget_types.h" #include "base/basictypes.h" +#include "base/keyboard_codes.h" #include "base/message_loop.h" #include "base/scoped_temp_dir.h" #include "base/string16.h" @@ -21,6 +21,7 @@ #include "chrome/common/notification_type.h" #include "chrome/common/notification_service.h" #include "chrome/test/automation/dom_element_proxy.h" +#include "gfx/native_widget_types.h" class AppModalDialog; class BookmarkModel; @@ -188,6 +189,16 @@ void RegisterAndWait(NotificationObserver* observer, // Blocks until |model| finishes loading. void WaitForBookmarkModelToLoad(BookmarkModel* model); +// Sends a key press blocking until the key press is received or the test times +// out. This uses ui_controls::SendKeyPress, see it for details. Returns true +// if the event was successfully sent and received. +bool SendKeyPressSync(gfx::NativeWindow window, + base::KeyboardCode key, + bool control, + bool shift, + bool alt, + bool command) WARN_UNUSED_RESULT; + // Run a message loop only for the specified amount of time. class TimedMessageLoopRunner { public: |