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

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

Issue 2841953002: headless: Add support for net logging (Closed)
Patch Set: 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_enumerator.h" 8 #include "base/files/file_enumerator.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 content::PermissionManager* permission_manager = 782 content::PermissionManager* permission_manager =
783 web_contents->browser_context()->GetPermissionManager(); 783 web_contents->browser_context()->GetPermissionManager();
784 EXPECT_NE(nullptr, permission_manager); 784 EXPECT_NE(nullptr, permission_manager);
785 785
786 // Check that the permission manager returns ASK for a given permission type. 786 // Check that the permission manager returns ASK for a given permission type.
787 EXPECT_EQ(blink::mojom::PermissionStatus::ASK, 787 EXPECT_EQ(blink::mojom::PermissionStatus::ASK,
788 permission_manager->GetPermissionStatus( 788 permission_manager->GetPermissionStatus(
789 content::PermissionType::NOTIFICATIONS, url, url)); 789 content::PermissionType::NOTIFICATIONS, url, url));
790 } 790 }
791 791
792 class HeadlessBrowserTestWithNetLog : public HeadlessBrowserTest {
793 public:
794 HeadlessBrowserTestWithNetLog() {}
795
796 void SetUp() override {
Eric Seckler 2017/04/25 17:00:51 Maybe SetUp() can be called on a different thread
Sami 2017/04/25 18:22:31 I think it's more likely that something else reset
797 base::ThreadRestrictions::SetIOAllowed(true);
798 EXPECT_TRUE(base::CreateTemporaryFile(&net_log_));
799 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII("--log-net-log",
800 net_log_.value());
801 HeadlessBrowserTest::SetUp();
802 }
803
804 void TearDown() override {
805 HeadlessBrowserTest::TearDown();
806 base::DeleteFile(net_log_, false);
807 }
808
809 protected:
810 base::FilePath net_log_;
811 };
812
813 IN_PROC_BROWSER_TEST_F(HeadlessBrowserTestWithNetLog, WriteNetLog) {
814 EXPECT_TRUE(embedded_test_server()->Start());
815
816 HeadlessBrowserContext* browser_context =
817 browser()->CreateBrowserContextBuilder().Build();
818
819 HeadlessWebContents* web_contents =
820 browser_context->CreateWebContentsBuilder()
821 .SetInitialURL(embedded_test_server()->GetURL("/hello.html"))
822 .Build();
823 EXPECT_TRUE(WaitForLoad(web_contents));
824 browser()->Shutdown();
825
826 std::string net_log_data;
827 EXPECT_TRUE(base::ReadFileToString(net_log_, &net_log_data));
828 EXPECT_GE(net_log_data.find("hello.html"), 0u);
829 }
830
792 } // namespace headless 831 } // namespace headless
OLDNEW
« 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