Index: headless/test/headless_browser_test.h |
diff --git a/headless/test/headless_browser_test.h b/headless/test/headless_browser_test.h |
index f46fb90ba60c74f6867b391d9008f3da5d4bf88c..f4875a217c464a7189d7c6116ddd0c8d5591fdba 100644 |
--- a/headless/test/headless_browser_test.h |
+++ b/headless/test/headless_browser_test.h |
@@ -5,14 +5,24 @@ |
#ifndef HEADLESS_TEST_HEADLESS_BROWSER_TEST_H_ |
#define HEADLESS_TEST_HEADLESS_BROWSER_TEST_H_ |
+#include <memory> |
#include "content/public/test/browser_test_base.h" |
#include "headless/public/headless_browser.h" |
+namespace base { |
+class RunLoop; |
+} |
+ |
namespace headless { |
class HeadlessWebContents; |
// Base class for tests which require a full instance of the headless browser. |
class HeadlessBrowserTest : public content::BrowserTestBase { |
+ public: |
+ // Notify that an asynchronous test is now complete and the test runner should |
+ // exit. |
+ void FinishAsynchronousTest(); |
+ |
protected: |
HeadlessBrowserTest(); |
~HeadlessBrowserTest() override; |
@@ -27,15 +37,20 @@ class HeadlessBrowserTest : public content::BrowserTestBase { |
// pumps) cannot be set via this method. |
void SetBrowserOptions(const HeadlessBrowser::Options& options); |
- // Navigate to |url| and wait for the document load to complete. |
- bool NavigateAndWaitForLoad(HeadlessWebContents* web_contents, |
- const GURL& url); |
+ // Run an asynchronous test in a nested run loop. The caller should call |
+ // FinishAsynchronousTest() to notify that the test should finish. |
+ void RunAsynchronousTest(); |
+ |
+ // Synchronously waits for a tab to finish loading. |
+ bool WaitForLoad(HeadlessWebContents* web_contents); |
protected: |
// Returns the browser for the test. |
HeadlessBrowser* browser() const; |
private: |
+ std::unique_ptr<base::RunLoop> run_loop_; |
+ |
DISALLOW_COPY_AND_ASSIGN(HeadlessBrowserTest); |
}; |