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

Side by Side Diff: headless/lib/headless_web_contents_browsertest.cc

Issue 1891843004: [headless] AddWindowTreeClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to latest master 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <memory> 5 #include <memory>
6 6
7 #include "content/public/test/browser_test.h" 7 #include "content/public/test/browser_test.h"
8 #include "headless/public/headless_browser.h" 8 #include "headless/public/headless_browser.h"
9 #include "headless/public/headless_web_contents.h" 9 #include "headless/public/headless_web_contents.h"
10 #include "headless/test/headless_browser_test.h" 10 #include "headless/test/headless_browser_test.h"
(...skipping 21 matching lines...) Expand all
32 32
33 bool navigation_succeeded() const { return navigation_succeeded_; } 33 bool navigation_succeeded() const { return navigation_succeeded_; }
34 34
35 private: 35 private:
36 HeadlessWebContentsTest* browser_test_; // Not owned. 36 HeadlessWebContentsTest* browser_test_; // Not owned.
37 bool navigation_succeeded_; 37 bool navigation_succeeded_;
38 }; 38 };
39 39
40 IN_PROC_BROWSER_TEST_F(HeadlessWebContentsTest, Navigation) { 40 IN_PROC_BROWSER_TEST_F(HeadlessWebContentsTest, Navigation) {
41 EXPECT_TRUE(embedded_test_server()->Start()); 41 EXPECT_TRUE(embedded_test_server()->Start());
42 std::unique_ptr<HeadlessWebContents> web_contents = 42 HeadlessWebContents* web_contents = browser()->CreateWebContents(
43 browser()->CreateWebContents( 43 embedded_test_server()->GetURL("/hello.html"), gfx::Size(800, 600));
44 embedded_test_server()->GetURL("/hello.html"), gfx::Size(800, 600));
45 NavigationObserver observer(this); 44 NavigationObserver observer(this);
46 web_contents->AddObserver(&observer); 45 web_contents->AddObserver(&observer);
47 46
48 RunAsynchronousTest(); 47 RunAsynchronousTest();
49 48
50 EXPECT_TRUE(observer.navigation_succeeded()); 49 EXPECT_TRUE(observer.navigation_succeeded());
51 web_contents->RemoveObserver(&observer); 50 web_contents->RemoveObserver(&observer);
51
52 std::vector<HeadlessWebContents*> all_web_contents =
53 browser()->GetAllWebContents();
54
55 EXPECT_EQ(static_cast<size_t>(1), all_web_contents.size());
56 EXPECT_EQ(web_contents, all_web_contents[0]);
57 }
58
59 IN_PROC_BROWSER_TEST_F(HeadlessWebContentsTest, WindowOpen) {
60 EXPECT_TRUE(embedded_test_server()->Start());
61
62 HeadlessWebContents* web_contents = browser()->CreateWebContents(
63 embedded_test_server()->GetURL("/window_open.html"), gfx::Size(800, 600));
64 NavigationObserver observer(this);
65 web_contents->AddObserver(&observer);
66
67 RunAsynchronousTest();
68
69 EXPECT_TRUE(observer.navigation_succeeded());
70 web_contents->RemoveObserver(&observer);
71
72 std::vector<HeadlessWebContents*> all_web_contents =
73 browser()->GetAllWebContents();
74
75 EXPECT_EQ(static_cast<size_t>(2), all_web_contents.size());
52 } 76 }
53 77
54 } // namespace headless 78 } // namespace headless
OLDNEW
« no previous file with comments | « headless/lib/headless_devtools_client_browsertest.cc ('k') | headless/public/headless_browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698