diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-08 16:16:55 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-08 16:16:55 +0000 |
commit | 3e59bacae6bff857dfb5e3d3e8359dbde60ccb04 (patch) | |
tree | bfa6a819deb40647392a5b4db31d26e428eb0e37 /chrome/test/ui_test_utils.h | |
parent | 714786e1b9566ca76388497904d2ebdb7fd111f5 (diff) | |
download | chromium_src-3e59bacae6bff857dfb5e3d3e8359dbde60ccb04.zip chromium_src-3e59bacae6bff857dfb5e3d3e8359dbde60ccb04.tar.gz chromium_src-3e59bacae6bff857dfb5e3d3e8359dbde60ccb04.tar.bz2 |
Revert 43950 - Revert 43931 [GTTF] Clean up browser tests:
[original revert broke compile; will disable tests in another CL instead]
use more ui_test_utils functions to simplify the code
expose more consistent and powerful utilities in ui_test_utils
minor style improvements
move some tests from DISABLED to FLAKY so we don't lose coverage
remove redundant timeouts
check more return values
TEST=browser_tests
BUG=none
Review URL: http://codereview.chromium.org/1571002
TBR=phajdan.jr@chromium.org
Review URL: http://codereview.chromium.org/1520026
TBR=viettrungluu@chromium.org, phajdan.jr@chromium.org
Review URL: http://codereview.chromium.org/1518020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43951 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/ui_test_utils.h')
-rw-r--r-- | chrome/test/ui_test_utils.h | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/chrome/test/ui_test_utils.h b/chrome/test/ui_test_utils.h index b247a19..9543f9d 100644 --- a/chrome/test/ui_test_utils.h +++ b/chrome/test/ui_test_utils.h @@ -175,10 +175,14 @@ bool IsViewFocused(const Browser* browser, ViewID vid); // Simulates a mouse click on a View in the browser. void ClickOnView(const Browser* browser, ViewID vid); -// Register |observer| for the given |type| and run the message loop until -// the observer posts a quit task. -void RegisterAndWait(NotificationType::Type type, - NotificationObserver* observer); +// Blocks until a notification for given |type| is received. +void WaitForNotification(NotificationType::Type type); + +// Register |observer| for the given |type| and |source| and run +// the message loop until the observer posts a quit task. +void RegisterAndWait(NotificationObserver* observer, + NotificationType::Type type, + const NotificationSource& source); // Run a message loop only for the specified amount of time. class TimedMessageLoopRunner { @@ -252,6 +256,34 @@ class TestWebSocketServer { DISALLOW_COPY_AND_ASSIGN(TestWebSocketServer); }; +// A notification observer which quits the message loop when a notification +// is received. It also records the source and details of the notification. +class TestNotificationObserver : public NotificationObserver { + public: + TestNotificationObserver() : source_(NotificationService::AllSources()) { + } + + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + source_ = source; + details_ = details; + MessageLoopForUI::current()->Quit(); + } + + const NotificationSource& source() const { + return source_; + } + + const NotificationDetails& details() const { + return details_; + } + + private: + NotificationSource source_; + NotificationDetails details_; +}; + // A WindowedNotificationObserver allows code to watch for a notification // over a window of time. Typically testing code will need to do something // like this: |