| 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 <memory> |
| 6 |
| 5 #include "content/public/test/browser_test.h" | 7 #include "content/public/test/browser_test.h" |
| 6 #include "headless/public/headless_browser.h" | 8 #include "headless/public/headless_browser.h" |
| 7 #include "headless/public/headless_web_contents.h" | 9 #include "headless/public/headless_web_contents.h" |
| 8 #include "headless/test/headless_browser_test.h" | 10 #include "headless/test/headless_browser_test.h" |
| 9 #include "net/test/spawned_test_server/spawned_test_server.h" | 11 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
| 12 | 14 |
| 13 namespace headless { | 15 namespace headless { |
| 14 | 16 |
| 15 IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, CreateAndDestroyWebContents) { | 17 IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, CreateAndDestroyWebContents) { |
| 16 scoped_ptr<HeadlessWebContents> web_contents = | 18 std::unique_ptr<HeadlessWebContents> web_contents = |
| 17 browser()->CreateWebContents(gfx::Size(800, 600)); | 19 browser()->CreateWebContents(gfx::Size(800, 600)); |
| 18 EXPECT_TRUE(web_contents); | 20 EXPECT_TRUE(web_contents); |
| 19 // TODO(skyostil): Verify viewport dimensions once we can. | 21 // TODO(skyostil): Verify viewport dimensions once we can. |
| 20 web_contents.reset(); | 22 web_contents.reset(); |
| 21 } | 23 } |
| 22 | 24 |
| 23 class HeadlessBrowserTestWithProxy : public HeadlessBrowserTest { | 25 class HeadlessBrowserTestWithProxy : public HeadlessBrowserTest { |
| 24 public: | 26 public: |
| 25 HeadlessBrowserTestWithProxy() | 27 HeadlessBrowserTestWithProxy() |
| 26 : proxy_server_(net::SpawnedTestServer::TYPE_HTTP, | 28 : proxy_server_(net::SpawnedTestServer::TYPE_HTTP, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 42 | 44 |
| 43 private: | 45 private: |
| 44 net::SpawnedTestServer proxy_server_; | 46 net::SpawnedTestServer proxy_server_; |
| 45 }; | 47 }; |
| 46 | 48 |
| 47 IN_PROC_BROWSER_TEST_F(HeadlessBrowserTestWithProxy, SetProxyServer) { | 49 IN_PROC_BROWSER_TEST_F(HeadlessBrowserTestWithProxy, SetProxyServer) { |
| 48 HeadlessBrowser::Options::Builder builder; | 50 HeadlessBrowser::Options::Builder builder; |
| 49 builder.SetProxyServer(proxy_server()->host_port_pair()); | 51 builder.SetProxyServer(proxy_server()->host_port_pair()); |
| 50 SetBrowserOptions(builder.Build()); | 52 SetBrowserOptions(builder.Build()); |
| 51 | 53 |
| 52 scoped_ptr<HeadlessWebContents> web_contents = | 54 std::unique_ptr<HeadlessWebContents> web_contents = |
| 53 browser()->CreateWebContents(gfx::Size(800, 600)); | 55 browser()->CreateWebContents(gfx::Size(800, 600)); |
| 54 | 56 |
| 55 // Load a page which doesn't actually exist, but for which the our proxy | 57 // Load a page which doesn't actually exist, but for which the our proxy |
| 56 // returns valid content anyway. | 58 // returns valid content anyway. |
| 57 EXPECT_TRUE(NavigateAndWaitForLoad( | 59 EXPECT_TRUE(NavigateAndWaitForLoad( |
| 58 web_contents.get(), GURL("http://not-an-actual-domain.tld/hello.html"))); | 60 web_contents.get(), GURL("http://not-an-actual-domain.tld/hello.html"))); |
| 59 } | 61 } |
| 60 | 62 |
| 61 } // namespace headless | 63 } // namespace headless |
| OLD | NEW |