| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/crash/content/app/fallback_crash_handling_win.h" | 5 #include "components/crash/content/app/fallback_crash_handling_win.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 } // namespace | 56 } // namespace |
| 57 | 57 |
| 58 TEST_F(FallbackCrashHandlingTest, SetupAndRunAsFallbackCrashHandler) { | 58 TEST_F(FallbackCrashHandlingTest, SetupAndRunAsFallbackCrashHandler) { |
| 59 // Launch a subprocess to test the fallback handling implementation. | 59 // Launch a subprocess to test the fallback handling implementation. |
| 60 base::CommandLine cmd_line = base::GetMultiProcessTestChildBaseCommandLine(); | 60 base::CommandLine cmd_line = base::GetMultiProcessTestChildBaseCommandLine(); |
| 61 cmd_line.AppendSwitchPath("database", database_dir_.GetPath()); | 61 cmd_line.AppendSwitchPath("database", database_dir_.GetPath()); |
| 62 | 62 |
| 63 base::LaunchOptions options; | 63 base::LaunchOptions options; |
| 64 options.start_hidden = true; | 64 options.start_hidden = true; |
| 65 base::Process test_child = base::SpawnMultiProcessTestChild( | 65 base::SpawnChildResult spawn_result = base::SpawnMultiProcessTestChild( |
| 66 "FallbackCrashHandlingWinRunHandler", cmd_line, options); | 66 "FallbackCrashHandlingWinRunHandler", cmd_line, options); |
| 67 base::Process test_child = std::move(spawn_result.process); |
| 67 | 68 |
| 68 ASSERT_TRUE(test_child.IsValid()); | 69 ASSERT_TRUE(test_child.IsValid()); |
| 69 int exit_code = -1; | 70 int exit_code = -1; |
| 70 ASSERT_TRUE(test_child.WaitForExit(&exit_code)); | 71 ASSERT_TRUE(test_child.WaitForExit(&exit_code)); |
| 71 ASSERT_EQ(kFallbackCrashTerminationCode, static_cast<uint32_t>(exit_code)); | 72 ASSERT_EQ(kFallbackCrashTerminationCode, static_cast<uint32_t>(exit_code)); |
| 72 | 73 |
| 73 // Validate that the database contains one valid crash dump. | 74 // Validate that the database contains one valid crash dump. |
| 74 std::unique_ptr<crashpad::CrashReportDatabase> database = | 75 std::unique_ptr<crashpad::CrashReportDatabase> database = |
| 75 crashpad::CrashReportDatabase::InitializeWithoutCreating( | 76 crashpad::CrashReportDatabase::InitializeWithoutCreating( |
| 76 database_dir_.GetPath()); | 77 database_dir_.GetPath()); |
| 77 | 78 |
| 78 std::vector<crashpad::CrashReportDatabase::Report> reports; | 79 std::vector<crashpad::CrashReportDatabase::Report> reports; |
| 79 ASSERT_EQ(crashpad::CrashReportDatabase::kNoError, | 80 ASSERT_EQ(crashpad::CrashReportDatabase::kNoError, |
| 80 database->GetPendingReports(&reports)); | 81 database->GetPendingReports(&reports)); |
| 81 | 82 |
| 82 EXPECT_EQ(1U, reports.size()); | 83 EXPECT_EQ(1U, reports.size()); |
| 83 } | 84 } |
| 84 | 85 |
| 85 } // namespace crash_reporter | 86 } // namespace crash_reporter |
| OLD | NEW |