Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: headless/test/headless_browser_test.h

Issue 1858403003: headless: Require the user to pass in an initial URL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
};

Powered by Google App Engine
This is Rietveld 408576698