| Index: chrome/test/ui_test_utils.cc
|
| ===================================================================
|
| --- chrome/test/ui_test_utils.cc (revision 35721)
|
| +++ chrome/test/ui_test_utils.cc (working copy)
|
| @@ -254,6 +254,33 @@
|
| DISALLOW_COPY_AND_ASSIGN(SimpleNotificationObserver);
|
| };
|
|
|
| +class LanguageDetectionNotificationObserver : public NotificationObserver {
|
| + public:
|
| + explicit LanguageDetectionNotificationObserver(
|
| + RenderViewHost* render_view_host) {
|
| + registrar_.Add(this, NotificationType::TAB_LANGUAGE_DETERMINED,
|
| + Source<RenderViewHost>(render_view_host));
|
| + ui_test_utils::RunMessageLoop();
|
| + }
|
| +
|
| + virtual void Observe(NotificationType type,
|
| + const NotificationSource& source,
|
| + const NotificationDetails& details) {
|
| + language_ = *(Details<std::string>(details).ptr());
|
| + MessageLoopForUI::current()->Quit();
|
| + }
|
| +
|
| + std::string language() const {
|
| + return language_;
|
| + }
|
| +
|
| + private:
|
| + NotificationRegistrar registrar_;
|
| + std::string language_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(LanguageDetectionNotificationObserver);
|
| +};
|
| +
|
| class FindInPageNotificationObserver : public NotificationObserver {
|
| public:
|
| explicit FindInPageNotificationObserver(TabContents* parent_tab)
|
| @@ -484,6 +511,11 @@
|
| browser);
|
| }
|
|
|
| +std::string WaitForLanguageDetection(TabContents* tab) {
|
| + LanguageDetectionNotificationObserver observer(tab->render_view_host());
|
| + return observer.language();
|
| +}
|
| +
|
| int FindInPage(TabContents* tab_contents, const string16& search_string,
|
| bool forward, bool match_case, int* ordinal) {
|
| tab_contents->StartFinding(search_string, forward, match_case);
|
|
|