summaryrefslogtreecommitdiffstats
path: root/chrome/test/ui_test_utils.h
diff options
context:
space:
mode:
authorjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-19 05:29:14 +0000
committerjcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-19 05:29:14 +0000
commiteb3895186d79897fc17310cae771ce2d8df32066 (patch)
treec6423387ba3366c7503db22c4450e280e0d0375a /chrome/test/ui_test_utils.h
parentd6abb667e3ef8fcdf3a01e287e01bb3729b77f18 (diff)
downloadchromium_src-eb3895186d79897fc17310cae771ce2d8df32066.zip
chromium_src-eb3895186d79897fc17310cae771ce2d8df32066.tar.gz
chromium_src-eb3895186d79897fc17310cae771ce2d8df32066.tar.bz2
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
Diffstat (limited to 'chrome/test/ui_test_utils.h')
-rw-r--r--chrome/test/ui_test_utils.h39
1 files changed, 35 insertions, 4 deletions
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 <map>
#include <string>
#include <set>
@@ -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 T, class U>
+class WindowedNotificationObserverWithDetails
+ : public WindowedNotificationObserver<T> {
+ public:
+ WindowedNotificationObserverWithDetails(NotificationType notification_type,
+ T* source)
+ : WindowedNotificationObserver<T>(notification_type, source) {}
+
+ // Fills |details| with the details of the notification received for |source|.
+ bool GetDetailsFor(T* source, U* details) {
+ typename std::map<T*, U>::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<T>(source).ptr()] = *Details<U>(details).ptr();
+ WindowedNotificationObserver<T>::Observe(type, source, details);
+ }
+
+ private:
+ std::map<T*, U> details_;
+
+ DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserverWithDetails);
+};
+
} // namespace ui_test_utils
#endif // CHROME_TEST_UI_TEST_UTILS_H_