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

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

Issue 2762593002: Add --headless flag to Windows (Closed)
Patch Set: readded headless_lib target 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
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 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 619
620 // We should have sent the matching cookies this time. 620 // We should have sent the matching cookies this time.
621 EXPECT_EQ(1u, sent_cookies.size()); 621 EXPECT_EQ(1u, sent_cookies.size());
622 EXPECT_EQ("shape", sent_cookies[0].Name()); 622 EXPECT_EQ("shape", sent_cookies[0].Name());
623 EXPECT_EQ("oblong", sent_cookies[0].Value()); 623 EXPECT_EQ("oblong", sent_cookies[0].Value());
624 } 624 }
625 625
626 // TODO(skyostil): This test currently relies on being able to run a shell 626 // TODO(skyostil): This test currently relies on being able to run a shell
627 // script. 627 // script.
628 #if defined(OS_POSIX) 628 #if defined(OS_POSIX)
629 #define MAYBE_RendererCommandPrefixTest RendererCommandPrefixTest 629 IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, RendererCommandPrefixTest) {
630 #else
631 #define MAYBE_RendererCommandPrefixTest DISABLED_RendererCommandPrefixTest
632 #endif // defined(OS_POSIX)
633 IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, MAYBE_RendererCommandPrefixTest) {
634 base::ThreadRestrictions::SetIOAllowed(true); 630 base::ThreadRestrictions::SetIOAllowed(true);
635 base::FilePath launcher_stamp; 631 base::FilePath launcher_stamp;
636 base::CreateTemporaryFile(&launcher_stamp); 632 base::CreateTemporaryFile(&launcher_stamp);
637 633
638 base::FilePath launcher_script; 634 base::FilePath launcher_script;
639 FILE* launcher_file = base::CreateAndOpenTemporaryFile(&launcher_script); 635 FILE* launcher_file = base::CreateAndOpenTemporaryFile(&launcher_script);
640 fprintf(launcher_file, "#!/bin/sh\n"); 636 fprintf(launcher_file, "#!/bin/sh\n");
641 fprintf(launcher_file, "echo $@ > %s\n", launcher_stamp.value().c_str()); 637 fprintf(launcher_file, "echo $@ > %s\n", launcher_stamp.value().c_str());
642 fprintf(launcher_file, "exec $@\n"); 638 fprintf(launcher_file, "exec $@\n");
643 fclose(launcher_file); 639 fclose(launcher_file);
(...skipping 17 matching lines...) Expand all
661 EXPECT_TRUE(WaitForLoad(web_contents)); 657 EXPECT_TRUE(WaitForLoad(web_contents));
662 658
663 // Make sure the launcher was invoked when starting the renderer. 659 // Make sure the launcher was invoked when starting the renderer.
664 std::string stamp; 660 std::string stamp;
665 EXPECT_TRUE(base::ReadFileToString(launcher_stamp, &stamp)); 661 EXPECT_TRUE(base::ReadFileToString(launcher_stamp, &stamp));
666 EXPECT_GE(stamp.find("--type=renderer"), 0u); 662 EXPECT_GE(stamp.find("--type=renderer"), 0u);
667 663
668 base::DeleteFile(launcher_script, false); 664 base::DeleteFile(launcher_script, false);
669 base::DeleteFile(launcher_stamp, false); 665 base::DeleteFile(launcher_stamp, false);
670 } 666 }
667 #endif // defined(OS_POSIX)
671 668
672 class CrashReporterTest : public HeadlessBrowserTest, 669 class CrashReporterTest : public HeadlessBrowserTest,
673 public HeadlessWebContents::Observer, 670 public HeadlessWebContents::Observer,
674 inspector::ExperimentalObserver { 671 inspector::ExperimentalObserver {
675 public: 672 public:
676 CrashReporterTest() : devtools_client_(HeadlessDevToolsClient::Create()) {} 673 CrashReporterTest() : devtools_client_(HeadlessDevToolsClient::Create()) {}
677 ~CrashReporterTest() override {} 674 ~CrashReporterTest() override {}
678 675
679 void SetUp() override { 676 void SetUp() override {
680 base::ThreadRestrictions::SetIOAllowed(true); 677 base::ThreadRestrictions::SetIOAllowed(true);
681 base::CreateNewTempDirectory("CrashReporterTest", &crash_dumps_dir_); 678 base::CreateNewTempDirectory(FILE_PATH_LITERAL("CrashReporterTest"),
679 &crash_dumps_dir_);
682 EXPECT_FALSE(options()->enable_crash_reporter); 680 EXPECT_FALSE(options()->enable_crash_reporter);
683 options()->enable_crash_reporter = true; 681 options()->enable_crash_reporter = true;
684 options()->crash_dumps_dir = crash_dumps_dir_; 682 options()->crash_dumps_dir = crash_dumps_dir_;
685 HeadlessBrowserTest::SetUp(); 683 HeadlessBrowserTest::SetUp();
686 } 684 }
687 685
688 void TearDown() override { 686 void TearDown() override {
689 base::ThreadRestrictions::SetIOAllowed(true); 687 base::ThreadRestrictions::SetIOAllowed(true);
690 base::DeleteFile(crash_dumps_dir_, /* recursive */ false); 688 base::DeleteFile(crash_dumps_dir_, /* recursive */ false);
691 } 689 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 // The target has crashed and should no longer be there. 732 // The target has crashed and should no longer be there.
735 EXPECT_FALSE(web_contents_->GetDevToolsTarget()); 733 EXPECT_FALSE(web_contents_->GetDevToolsTarget());
736 734
737 // Check that one minidump got created. 735 // Check that one minidump got created.
738 { 736 {
739 base::ThreadRestrictions::SetIOAllowed(true); 737 base::ThreadRestrictions::SetIOAllowed(true);
740 base::FileEnumerator it(crash_dumps_dir_, /* recursive */ false, 738 base::FileEnumerator it(crash_dumps_dir_, /* recursive */ false,
741 base::FileEnumerator::FILES); 739 base::FileEnumerator::FILES);
742 base::FilePath minidump = it.Next(); 740 base::FilePath minidump = it.Next();
743 EXPECT_FALSE(minidump.empty()); 741 EXPECT_FALSE(minidump.empty());
744 EXPECT_EQ(".dmp", minidump.Extension()); 742 EXPECT_EQ(FILE_PATH_LITERAL(".dmp"), minidump.Extension());
745 EXPECT_TRUE(it.Next().empty()); 743 EXPECT_TRUE(it.Next().empty());
746 } 744 }
747 745
748 web_contents_->RemoveObserver(this); 746 web_contents_->RemoveObserver(this);
749 web_contents_->Close(); 747 web_contents_->Close();
750 web_contents_ = nullptr; 748 web_contents_ = nullptr;
751 749
752 browser_context_->Close(); 750 browser_context_->Close();
753 browser_context_ = nullptr; 751 browser_context_ = nullptr;
754 } 752 }
755 753
756 } // namespace headless 754 } // namespace headless
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698