| 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> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" |
| 7 #include "content/public/test/browser_test.h" | 8 #include "content/public/test/browser_test.h" |
| 8 #include "headless/public/headless_browser.h" | 9 #include "headless/public/headless_browser.h" |
| 9 #include "headless/public/headless_web_contents.h" | 10 #include "headless/public/headless_web_contents.h" |
| 10 #include "headless/test/headless_browser_test.h" | 11 #include "headless/test/headless_browser_test.h" |
| 11 #include "net/test/spawned_test_server/spawned_test_server.h" | 12 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
| 14 | 15 |
| 15 namespace headless { | 16 namespace headless { |
| 16 | 17 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 EXPECT_TRUE(WaitForLoad(web_contents)); | 75 EXPECT_TRUE(WaitForLoad(web_contents)); |
| 75 EXPECT_EQ(static_cast<size_t>(1), browser()->GetAllWebContents().size()); | 76 EXPECT_EQ(static_cast<size_t>(1), browser()->GetAllWebContents().size()); |
| 76 EXPECT_EQ(web_contents, browser()->GetAllWebContents()[0]); | 77 EXPECT_EQ(web_contents, browser()->GetAllWebContents()[0]); |
| 77 web_contents->Close(); | 78 web_contents->Close(); |
| 78 EXPECT_TRUE(browser()->GetAllWebContents().empty()); | 79 EXPECT_TRUE(browser()->GetAllWebContents().empty()); |
| 79 } | 80 } |
| 80 | 81 |
| 81 IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, SetHostResolverRules) { | 82 IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, SetHostResolverRules) { |
| 82 EXPECT_TRUE(embedded_test_server()->Start()); | 83 EXPECT_TRUE(embedded_test_server()->Start()); |
| 83 HeadlessBrowser::Options::Builder builder; | 84 HeadlessBrowser::Options::Builder builder; |
| 84 builder.SetHostResolverRules("MAP not-an-actual-domain.tld 127.0.0.1"); | 85 builder.SetHostResolverRules( |
| 86 base::StringPrintf("MAP not-an-actual-domain.tld 127.0.0.1:%d", |
| 87 embedded_test_server()->host_port_pair().port())); |
| 85 SetBrowserOptions(builder.Build()); | 88 SetBrowserOptions(builder.Build()); |
| 86 | 89 |
| 87 // Load a page which doesn't actually exist, but which is turned into a valid | 90 // Load a page which doesn't actually exist, but which is turned into a valid |
| 88 // address by our host resolver rules. | 91 // address by our host resolver rules. |
| 89 HeadlessWebContents* web_contents = browser()->CreateWebContents( | 92 HeadlessWebContents* web_contents = browser()->CreateWebContents( |
| 90 GURL("http://not-an-actual-domain.tld/hello.html"), gfx::Size(800, 600)); | 93 GURL("http://not-an-actual-domain.tld/hello.html"), gfx::Size(800, 600)); |
| 91 EXPECT_TRUE(WaitForLoad(web_contents)); | 94 EXPECT_TRUE(WaitForLoad(web_contents)); |
| 92 } | 95 } |
| 93 | 96 |
| 94 } // namespace headless | 97 } // namespace headless |
| OLD | NEW |