OLD | NEW |
---|---|
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 "headless/test/headless_browser_test.h" | 5 #include "headless/test/headless_browser_test.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
12 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
13 #include "content/public/common/url_constants.h" | 13 #include "content/public/common/url_constants.h" |
14 #include "headless/lib/browser/headless_browser_impl.h" | 14 #include "headless/lib/browser/headless_browser_impl.h" |
15 #include "headless/lib/headless_content_main_delegate.h" | 15 #include "headless/lib/headless_content_main_delegate.h" |
16 #include "headless/public/domains/network.h" | 16 #include "headless/public/domains/network.h" |
17 #include "headless/public/domains/page.h" | 17 #include "headless/public/domains/page.h" |
18 #include "headless/public/domains/runtime.h" | 18 #include "headless/public/domains/runtime.h" |
19 #include "headless/public/headless_devtools_client.h" | 19 #include "headless/public/headless_devtools_client.h" |
20 #include "headless/public/headless_devtools_target.h" | 20 #include "headless/public/headless_devtools_target.h" |
21 #include "headless/public/headless_web_contents.h" | 21 #include "headless/public/headless_web_contents.h" |
22 #include "ui/gfx/geometry/size.h" | |
23 #include "url/gurl.h" | |
22 | 24 |
23 namespace headless { | 25 namespace headless { |
24 namespace { | 26 namespace { |
25 | 27 |
26 class WaitForLoadObserver : public page::Observer, public network::Observer { | 28 class WaitForLoadObserver : public page::Observer, public network::Observer { |
27 public: | 29 public: |
28 WaitForLoadObserver(HeadlessBrowserTest* browser_test, | 30 WaitForLoadObserver(HeadlessBrowserTest* browser_test, |
29 HeadlessWebContents* web_contents) | 31 HeadlessWebContents* web_contents) |
30 : browser_test_(browser_test), | 32 : browser_test_(browser_test), |
31 web_contents_(web_contents), | 33 web_contents_(web_contents), |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 EXPECT_FALSE(run_loop_); | 168 EXPECT_FALSE(run_loop_); |
167 run_loop_ = base::WrapUnique(new base::RunLoop()); | 169 run_loop_ = base::WrapUnique(new base::RunLoop()); |
168 run_loop_->Run(); | 170 run_loop_->Run(); |
169 run_loop_ = nullptr; | 171 run_loop_ = nullptr; |
170 } | 172 } |
171 | 173 |
172 void HeadlessBrowserTest::FinishAsynchronousTest() { | 174 void HeadlessBrowserTest::FinishAsynchronousTest() { |
173 run_loop_->Quit(); | 175 run_loop_->Quit(); |
174 } | 176 } |
175 | 177 |
178 HeadlessAsyncDevTooledBrowserTest::HeadlessAsyncDevTooledBrowserTest() | |
179 : web_contents_(nullptr), | |
180 devtools_client_(HeadlessDevToolsClient::Create()) {} | |
181 | |
182 HeadlessAsyncDevTooledBrowserTest::~HeadlessAsyncDevTooledBrowserTest() {} | |
183 | |
184 void HeadlessAsyncDevTooledBrowserTest::DevToolsTargetReady() { | |
Sami
2016/06/03 11:46:24
Is this correctly indented? (git cl format should
Eric Seckler
2016/06/03 13:40:38
Done.
| |
185 EXPECT_TRUE(web_contents_->GetDevToolsTarget()); | |
186 web_contents_->GetDevToolsTarget()->AttachClient(devtools_client_.get()); | |
187 RunDevTooledTest(); | |
188 } | |
189 | |
190 void HeadlessAsyncDevTooledBrowserTest::RunTest() { | |
191 web_contents_ = | |
192 browser()->CreateWebContents(GURL("about:blank"), gfx::Size(800, 600)); | |
193 web_contents_->AddObserver(this); | |
194 | |
195 RunAsynchronousTest(); | |
196 | |
197 web_contents_->GetDevToolsTarget()->DetachClient(devtools_client_.get()); | |
198 web_contents_->RemoveObserver(this); | |
199 web_contents_->Close(); | |
200 web_contents_ = nullptr; | |
201 } | |
202 | |
176 } // namespace headless | 203 } // namespace headless |
OLD | NEW |