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

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

Issue 1674263002: headless: Initial headless embedder API implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add pak file generation. Created 4 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/run_loop.h"
6 #include "content/public/test/browser_test.h"
7 #include "headless/public/headless_browser.h"
8 #include "headless/public/headless_web_contents.h"
9 #include "headless/test/headless_browser_test.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/gfx/geometry/size.h"
12 #include "url/gurl.h"
13
14 namespace headless {
15
16 class HeadlessWebContentsTest : public HeadlessBrowserTest {};
17
18 class WaitForNavigationObserver : public HeadlessWebContents::Observer {
19 public:
20 WaitForNavigationObserver(base::RunLoop* run_loop,
21 HeadlessWebContents* web_contents)
22 : HeadlessWebContents::Observer(web_contents), run_loop_(run_loop) {}
23
24 void DocumentOnLoadCompletedInMainFrame() override { run_loop_->Quit(); }
25
26 private:
27 base::RunLoop* run_loop_;
28
29 DISALLOW_COPY_AND_ASSIGN(WaitForNavigationObserver);
30 };
31
32 IN_PROC_BROWSER_TEST_F(HeadlessWebContentsTest, Navigation) {
33 ASSERT_TRUE(embedded_test_server()->Start());
34 scoped_ptr<HeadlessWebContents> web_contents =
35 browser()->CreateWebContents({800, 600});
36
37 base::RunLoop run_loop;
38 base::MessageLoop::ScopedNestableTaskAllower nestable_allower(
39 base::MessageLoop::current());
40 WaitForNavigationObserver observer(&run_loop, web_contents.get());
41
42 web_contents->OpenURL(embedded_test_server()->GetURL("/hello.html"));
43 run_loop.Run();
44 }
45
46 } // namespace headless
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698