summaryrefslogtreecommitdiffstats
path: root/chrome/test/base/web_ui_browser_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/test/base/web_ui_browser_test.cc')
-rw-r--r--chrome/test/base/web_ui_browser_test.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/chrome/test/base/web_ui_browser_test.cc b/chrome/test/base/web_ui_browser_test.cc
index cf9a2aa..c82c1d0 100644
--- a/chrome/test/base/web_ui_browser_test.cc
+++ b/chrome/test/base/web_ui_browser_test.cc
@@ -9,6 +9,7 @@
#include "base/lazy_instance.h"
#include "base/memory/ref_counted_memory.h"
+#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/values.h"
@@ -82,6 +83,35 @@ class WebUIJsInjectionReadyObserver : public content::WebContentsObserver {
std::string preload_test_name_;
};
+class WebUIMainObserver : public content::WebContentsObserver {
+ public:
+ explicit WebUIMainObserver(content::WebContents* web_contents)
+ : content::WebContentsObserver(web_contents),
+ message_loop_runner_(new content::MessageLoopRunner),
+ has_fired_(false) {
+ }
+
+ void Wait() {
+ if (has_fired_)
+ return;
+
+ message_loop_runner_->Run();
+ }
+
+ virtual void DidRunWebUIMojoMain() OVERRIDE {
+ has_fired_ = true;
+ message_loop_runner_->Quit();
+ }
+
+ private:
+ // The MessageLoopRunner used to spin the message loop.
+ scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
+
+ bool has_fired_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebUIMainObserver);
+};
+
} // namespace
WebUIBrowserTest::~WebUIBrowserTest() {
@@ -220,6 +250,14 @@ void WebUIBrowserTest::BrowsePreload(const GURL& browse_to) {
navigation_observer.Wait();
}
+void WebUIBrowserTest::BrowsePreloadAndWaitForMain(const GURL& browse_to) {
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+ WebUIMainObserver webui_main_observer(web_contents);
+ BrowsePreload(browse_to);
+ webui_main_observer.Wait();
+}
+
#if defined(ENABLE_FULL_PRINTING)
// This custom ContentBrowserClient is used to get notified when a WebContents