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

Unified Diff: headless/lib/headless_web_contents_browsertest.cc

Issue 1906423003: headless: Remove old load observer API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update headless shell. 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
« no previous file with comments | « headless/lib/headless_browser_browsertest.cc ('k') | headless/public/headless_web_contents.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/lib/headless_web_contents_browsertest.cc
diff --git a/headless/lib/headless_web_contents_browsertest.cc b/headless/lib/headless_web_contents_browsertest.cc
index 2298b8bcf1326076915b9cbe0199dacb2411cc6e..30faee5e65ef2edf70551c8d55a642af152f4333 100644
--- a/headless/lib/headless_web_contents_browsertest.cc
+++ b/headless/lib/headless_web_contents_browsertest.cc
@@ -16,38 +16,11 @@ namespace headless {
class HeadlessWebContentsTest : public HeadlessBrowserTest {};
-class NavigationObserver : public HeadlessWebContents::Observer {
- public:
- NavigationObserver(HeadlessWebContentsTest* browser_test)
- : browser_test_(browser_test), navigation_succeeded_(false) {}
- ~NavigationObserver() override {}
-
- void DocumentOnLoadCompletedInMainFrame() override {
- browser_test_->FinishAsynchronousTest();
- }
-
- void DidFinishNavigation(bool success) override {
- navigation_succeeded_ = success;
- }
-
- bool navigation_succeeded() const { return navigation_succeeded_; }
-
- private:
- HeadlessWebContentsTest* browser_test_; // Not owned.
- bool navigation_succeeded_;
-};
-
IN_PROC_BROWSER_TEST_F(HeadlessWebContentsTest, Navigation) {
EXPECT_TRUE(embedded_test_server()->Start());
HeadlessWebContents* web_contents = browser()->CreateWebContents(
embedded_test_server()->GetURL("/hello.html"), gfx::Size(800, 600));
- NavigationObserver observer(this);
- web_contents->AddObserver(&observer);
-
- RunAsynchronousTest();
-
- EXPECT_TRUE(observer.navigation_succeeded());
- web_contents->RemoveObserver(&observer);
+ EXPECT_TRUE(WaitForLoad(web_contents));
std::vector<HeadlessWebContents*> all_web_contents =
browser()->GetAllWebContents();
@@ -61,13 +34,7 @@ IN_PROC_BROWSER_TEST_F(HeadlessWebContentsTest, WindowOpen) {
HeadlessWebContents* web_contents = browser()->CreateWebContents(
embedded_test_server()->GetURL("/window_open.html"), gfx::Size(800, 600));
- NavigationObserver observer(this);
- web_contents->AddObserver(&observer);
-
- RunAsynchronousTest();
-
- EXPECT_TRUE(observer.navigation_succeeded());
- web_contents->RemoveObserver(&observer);
+ EXPECT_TRUE(WaitForLoad(web_contents));
std::vector<HeadlessWebContents*> all_web_contents =
browser()->GetAllWebContents();
« no previous file with comments | « headless/lib/headless_browser_browsertest.cc ('k') | headless/public/headless_web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698