From eb3895186d79897fc17310cae771ce2d8df32066 Mon Sep 17 00:00:00 2001 From: "jcivelli@chromium.org" Date: Mon, 19 Apr 2010 05:29:14 +0000 Subject: Attempt at fixing flakyness of the browser test: BrowserTest.PageLanguageDetection. BUG=40962 TEST=The test should not be flaky anymore. Review URL: http://codereview.chromium.org/1642002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44903 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/test/ui_test_utils.h | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'chrome/test/ui_test_utils.h') diff --git a/chrome/test/ui_test_utils.h b/chrome/test/ui_test_utils.h index 72c34c2..e125e61 100644 --- a/chrome/test/ui_test_utils.h +++ b/chrome/test/ui_test_utils.h @@ -5,6 +5,7 @@ #ifndef CHROME_TEST_UI_TEST_UTILS_H_ #define CHROME_TEST_UI_TEST_UTILS_H_ +#include #include #include @@ -156,10 +157,6 @@ void WaitForFocusChange(RenderViewHost* rvh); // traversal). void WaitForFocusInBrowser(Browser* browser); -// Waits for the language of the page to have been detected and returns it. -// This should be called right after a navigation notification was received. -std::string WaitForLanguageDetection(TabContents* tab_contents); - // Performs a find in the page of the specified tab. Returns the number of // matches found. |ordinal| is an optional parameter which is set to the index // of the current match. @@ -380,6 +377,40 @@ class WindowedNotificationObserver : public NotificationObserver { DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserver); }; +// Similar to WindowedNotificationObserver but also provides a way of retrieving +// the details associated with the notification. +// Note that in order to use that class the details class should be copiable, +// which is the case with most notifications. +template +class WindowedNotificationObserverWithDetails + : public WindowedNotificationObserver { + public: + WindowedNotificationObserverWithDetails(NotificationType notification_type, + T* source) + : WindowedNotificationObserver(notification_type, source) {} + + // Fills |details| with the details of the notification received for |source|. + bool GetDetailsFor(T* source, U* details) { + typename std::map::const_iterator iter = details_.find(source); + if (iter == details_.end()) + return false; + *details = iter->second; + return true; + } + + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + details_[Source(source).ptr()] = *Details(details).ptr(); + WindowedNotificationObserver::Observe(type, source, details); + } + + private: + std::map details_; + + DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserverWithDetails); +}; + } // namespace ui_test_utils #endif // CHROME_TEST_UI_TEST_UTILS_H_ -- cgit v1.1