OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdio.h> | 5 #include <stdio.h> |
| 6 |
| 7 #include <memory> |
6 #include <string> | 8 #include <string> |
7 | 9 |
8 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
9 #include "base/environment.h" | 11 #include "base/environment.h" |
10 #include "base/logging.h" | 12 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "breakpad/src/client/windows/crash_generation/client_info.h" | 15 #include "breakpad/src/client/windows/crash_generation/client_info.h" |
15 #include "breakpad/src/client/windows/crash_generation/crash_generation_server.h
" | 16 #include "breakpad/src/client/windows/crash_generation/crash_generation_server.h
" |
16 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 // The name of the environment variable used to pass the crash server pipe name | 22 // The name of the environment variable used to pass the crash server pipe name |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 void InitializeCrashReportingForTest(const wchar_t* pipe_name); | 68 void InitializeCrashReportingForTest(const wchar_t* pipe_name); |
68 | 69 |
69 class BreakpadWinDeathTest : public testing::Test { | 70 class BreakpadWinDeathTest : public testing::Test { |
70 public: | 71 public: |
71 BreakpadWinDeathTest(); | 72 BreakpadWinDeathTest(); |
72 ~BreakpadWinDeathTest() override; | 73 ~BreakpadWinDeathTest() override; |
73 | 74 |
74 void SetUp() override; | 75 void SetUp() override; |
75 | 76 |
76 protected: | 77 protected: |
77 scoped_ptr<google_breakpad::CrashGenerationServer> crash_server_; | 78 std::unique_ptr<google_breakpad::CrashGenerationServer> crash_server_; |
78 scoped_ptr<MockCrashServerCallbacks> callbacks_; | 79 std::unique_ptr<MockCrashServerCallbacks> callbacks_; |
79 std::wstring pipe_name_; | 80 std::wstring pipe_name_; |
80 }; | 81 }; |
81 | 82 |
82 BreakpadWinDeathTest::BreakpadWinDeathTest() { | 83 BreakpadWinDeathTest::BreakpadWinDeathTest() { |
83 } | 84 } |
84 | 85 |
85 BreakpadWinDeathTest::~BreakpadWinDeathTest() { | 86 BreakpadWinDeathTest::~BreakpadWinDeathTest() { |
86 } | 87 } |
87 | 88 |
88 void BreakpadWinDeathTest::SetUp() { | 89 void BreakpadWinDeathTest::SetUp() { |
89 scoped_ptr<base::Environment> environment(base::Environment::Create()); | 90 std::unique_ptr<base::Environment> environment(base::Environment::Create()); |
90 std::string pipe_name; | 91 std::string pipe_name; |
91 if (environment->GetVar(kPipeVariableName, &pipe_name)) { | 92 if (environment->GetVar(kPipeVariableName, &pipe_name)) { |
92 // This is a child process. Initialize crash dump reporting to the crash | 93 // This is a child process. Initialize crash dump reporting to the crash |
93 // dump server. | 94 // dump server. |
94 pipe_name_ = base::UTF8ToWide(pipe_name); | 95 pipe_name_ = base::UTF8ToWide(pipe_name); |
95 InitializeCrashReportingForTest(pipe_name_.c_str()); | 96 InitializeCrashReportingForTest(pipe_name_.c_str()); |
96 } else { | 97 } else { |
97 // This is the parent process. Generate a unique pipe name and setup | 98 // This is the parent process. Generate a unique pipe name and setup |
98 // a dummy crash dump server. | 99 // a dummy crash dump server. |
99 UUID guid = {0}; | 100 UUID guid = {0}; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 TEST_F(BreakpadWinDeathTest, TestDebugbreak) { | 160 TEST_F(BreakpadWinDeathTest, TestDebugbreak) { |
160 if (callbacks_.get()) { | 161 if (callbacks_.get()) { |
161 EXPECT_CALL(*callbacks_, OnClientDumpRequested()); | 162 EXPECT_CALL(*callbacks_, OnClientDumpRequested()); |
162 } | 163 } |
163 | 164 |
164 // See if __debugbreak() is intercepted. | 165 // See if __debugbreak() is intercepted. |
165 ASSERT_DEATH(__debugbreak(), ""); | 166 ASSERT_DEATH(__debugbreak(), ""); |
166 } | 167 } |
167 | 168 |
168 } // namespace remoting | 169 } // namespace remoting |
OLD | NEW |