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

Unified Diff: headless/lib/headless_browser_browsertest.cc

Issue 2841953002: headless: Add support for net logging (Closed)
Patch Set: CrOS build fix Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « headless/lib/browser/headless_url_request_context_getter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/lib/headless_browser_browsertest.cc
diff --git a/headless/lib/headless_browser_browsertest.cc b/headless/lib/headless_browser_browsertest.cc
index 8b6e20c70a493b3d92a3dc25531eeb2e0a1c677d..2c85ae0c80b1704977921e687724af65a0d50d3e 100644
--- a/headless/lib/headless_browser_browsertest.cc
+++ b/headless/lib/headless_browser_browsertest.cc
@@ -789,4 +789,44 @@ IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, PermissionManagerAlwaysASK) {
content::PermissionType::NOTIFICATIONS, url, url));
}
+class HeadlessBrowserTestWithNetLog : public HeadlessBrowserTest {
+ public:
+ HeadlessBrowserTestWithNetLog() {}
+
+ void SetUp() override {
+ base::ThreadRestrictions::SetIOAllowed(true);
+ EXPECT_TRUE(base::CreateTemporaryFile(&net_log_));
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII("--log-net-log",
+ net_log_.value());
+ HeadlessBrowserTest::SetUp();
+ }
+
+ void TearDown() override {
+ HeadlessBrowserTest::TearDown();
+ base::DeleteFile(net_log_, false);
+ }
+
+ protected:
+ base::FilePath net_log_;
+};
+
+IN_PROC_BROWSER_TEST_F(HeadlessBrowserTestWithNetLog, WriteNetLog) {
+ EXPECT_TRUE(embedded_test_server()->Start());
+
+ HeadlessBrowserContext* browser_context =
+ browser()->CreateBrowserContextBuilder().Build();
+
+ HeadlessWebContents* web_contents =
+ browser_context->CreateWebContentsBuilder()
+ .SetInitialURL(embedded_test_server()->GetURL("/hello.html"))
+ .Build();
+ EXPECT_TRUE(WaitForLoad(web_contents));
+ browser()->Shutdown();
+
+ base::ThreadRestrictions::SetIOAllowed(true);
+ std::string net_log_data;
+ EXPECT_TRUE(base::ReadFileToString(net_log_, &net_log_data));
+ EXPECT_GE(net_log_data.find("hello.html"), 0u);
+}
+
} // namespace headless
« no previous file with comments | « headless/lib/browser/headless_url_request_context_getter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698