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

Side by Side Diff: headless/test/headless_browser_test.h

Issue 2043603004: headless: Introduce a browser context (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 4 years, 6 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 #ifndef HEADLESS_TEST_HEADLESS_BROWSER_TEST_H_ 5 #ifndef HEADLESS_TEST_HEADLESS_BROWSER_TEST_H_
6 #define HEADLESS_TEST_HEADLESS_BROWSER_TEST_H_ 6 #define HEADLESS_TEST_HEADLESS_BROWSER_TEST_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "content/public/test/browser_test_base.h" 11 #include "content/public/test/browser_test_base.h"
12 #include "headless/public/domains/network.h"
13 #include "headless/public/domains/page.h"
12 #include "headless/public/headless_browser.h" 14 #include "headless/public/headless_browser.h"
13 #include "headless/public/headless_web_contents.h" 15 #include "headless/public/headless_web_contents.h"
14 16
15 namespace base { 17 namespace base {
16 class RunLoop; 18 class RunLoop;
17 } 19 }
18 20
19 namespace headless { 21 namespace headless {
20 namespace runtime { 22 namespace runtime {
21 class EvaluateResult; 23 class EvaluateResult;
22 } 24 }
23 class HeadlessDevToolsClient; 25 class HeadlessDevToolsClient;
24 26
27 // A utility class for asynchronously observing load events.
28 class LoadObserver : public page::Observer, public network::Observer {
29 public:
30 LoadObserver(HeadlessDevToolsClient* devtools_client, base::Closure callback);
31 ~LoadObserver() override;
32
33 // page::Observer implementation:
34 void OnLoadEventFired(const page::LoadEventFiredParams& params) override;
35
36 // network::Observer implementation:
37 void OnResponseReceived(
38 const network::ResponseReceivedParams& params) override;
39
40 bool navigation_succeeded() const { return navigation_succeeded_; }
41
42 private:
43 base::Closure callback_;
44 HeadlessDevToolsClient* devtools_client_; // Not owned.
45
46 bool navigation_succeeded_;
47
48 DISALLOW_COPY_AND_ASSIGN(LoadObserver);
49 };
50
25 // Base class for tests which require a full instance of the headless browser. 51 // Base class for tests which require a full instance of the headless browser.
26 class HeadlessBrowserTest : public content::BrowserTestBase { 52 class HeadlessBrowserTest : public content::BrowserTestBase {
27 public: 53 public:
28 // Notify that an asynchronous test is now complete and the test runner should 54 // Notify that an asynchronous test is now complete and the test runner should
29 // exit. 55 // exit.
30 void FinishAsynchronousTest(); 56 void FinishAsynchronousTest();
31 57
32 protected: 58 protected:
33 HeadlessBrowserTest(); 59 HeadlessBrowserTest();
34 ~HeadlessBrowserTest() override; 60 ~HeadlessBrowserTest() override;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 protected: 115 protected:
90 void RunTest(); 116 void RunTest();
91 117
92 HeadlessWebContents* web_contents_; 118 HeadlessWebContents* web_contents_;
93 std::unique_ptr<HeadlessDevToolsClient> devtools_client_; 119 std::unique_ptr<HeadlessDevToolsClient> devtools_client_;
94 }; 120 };
95 121
96 } // namespace headless 122 } // namespace headless
97 123
98 #endif // HEADLESS_TEST_HEADLESS_BROWSER_TEST_H_ 124 #endif // HEADLESS_TEST_HEADLESS_BROWSER_TEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698