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

Side by Side Diff: util/win/exception_handler_server_test.cc

Issue 1406993008: win: Rename CrashpadClient::SetHandler() to SetHandlerIPCPipe() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Revise comment Created 5 years, 1 month 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 | « snapshot/win/crashpad_snapshot_test_dump_without_crashing.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 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "util/win/exception_handler_server.h" 15 #include "util/win/exception_handler_server.h"
16 16
17 #include <windows.h> 17 #include <windows.h>
18 18
19 #include <string> 19 #include <string>
20 #include <vector> 20 #include <vector>
21 21
22 #include "base/basictypes.h" 22 #include "base/basictypes.h"
23 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
24 #include "base/strings/utf_string_conversions.h"
24 #include "client/crashpad_client.h" 25 #include "client/crashpad_client.h"
25 #include "gtest/gtest.h" 26 #include "gtest/gtest.h"
26 #include "test/win/win_child_process.h" 27 #include "test/win/win_child_process.h"
27 #include "util/thread/thread.h" 28 #include "util/thread/thread.h"
28 #include "util/win/address_types.h" 29 #include "util/win/address_types.h"
29 #include "util/win/registration_protocol_win.h" 30 #include "util/win/registration_protocol_win.h"
30 #include "util/win/scoped_handle.h" 31 #include "util/win/scoped_handle.h"
31 32
32 namespace crashpad { 33 namespace crashpad {
33 namespace test { 34 namespace test {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 &server(), &server_thread()); 128 &server(), &server_thread());
128 ASSERT_NO_FATAL_FAILURE(delegate().WaitForStart()); 129 ASSERT_NO_FATAL_FAILURE(delegate().WaitForStart());
129 } 130 }
130 131
131 TEST_F(ExceptionHandlerServerTest, StopWhileConnected) { 132 TEST_F(ExceptionHandlerServerTest, StopWhileConnected) {
132 server_thread().Start(); 133 server_thread().Start();
133 ScopedStopServerAndJoinThread scoped_stop_server_and_join_thread( 134 ScopedStopServerAndJoinThread scoped_stop_server_and_join_thread(
134 &server(), &server_thread()); 135 &server(), &server_thread());
135 ASSERT_NO_FATAL_FAILURE(delegate().WaitForStart()); 136 ASSERT_NO_FATAL_FAILURE(delegate().WaitForStart());
136 CrashpadClient client; 137 CrashpadClient client;
137 client.SetHandler(pipe_name()); // Connect to server. 138 client.SetHandlerIPCPipe(base::UTF8ToUTF16(pipe_name()));
138 // Leaving this scope causes the server to be stopped, while the connection 139 // Leaving this scope causes the server to be stopped, while the connection
139 // is still open. 140 // is still open.
140 } 141 }
141 142
142 std::string ReadString(FileHandle handle) { 143 std::string ReadString(FileHandle handle) {
143 size_t length = 0; 144 size_t length = 0;
144 EXPECT_TRUE(LoggingReadFile(handle, &length, sizeof(length))); 145 EXPECT_TRUE(LoggingReadFile(handle, &length, sizeof(length)));
145 scoped_ptr<char[]> buffer(new char[length]); 146 scoped_ptr<char[]> buffer(new char[length]);
146 EXPECT_TRUE(LoggingReadFile(handle, &buffer[0], length)); 147 EXPECT_TRUE(LoggingReadFile(handle, &buffer[0], length));
147 return std::string(&buffer[0], length); 148 return std::string(&buffer[0], length);
148 } 149 }
149 150
150 void WriteString(FileHandle handle, const std::string& str) { 151 void WriteString(FileHandle handle, const std::string& str) {
151 size_t length = str.size(); 152 size_t length = str.size();
152 EXPECT_TRUE(LoggingWriteFile(handle, &length, sizeof(length))); 153 EXPECT_TRUE(LoggingWriteFile(handle, &length, sizeof(length)));
153 EXPECT_TRUE(LoggingWriteFile(handle, &str[0], length)); 154 EXPECT_TRUE(LoggingWriteFile(handle, &str[0], length));
154 } 155 }
155 156
156 class TestClient final : public WinChildProcess { 157 class TestClient final : public WinChildProcess {
157 public: 158 public:
158 TestClient() : WinChildProcess() {} 159 TestClient() : WinChildProcess() {}
159 160
160 ~TestClient() {} 161 ~TestClient() {}
161 162
162 private: 163 private:
163 int Run() override { 164 int Run() override {
164 std::string pipe_name = ReadString(ReadPipeHandle()); 165 std::wstring pipe_name = base::UTF8ToUTF16(ReadString(ReadPipeHandle()));
165 CrashpadClient client; 166 CrashpadClient client;
166 if (!client.SetHandler(pipe_name)) { 167 if (!client.SetHandlerIPCPipe(pipe_name)) {
167 ADD_FAILURE(); 168 ADD_FAILURE();
168 return EXIT_FAILURE; 169 return EXIT_FAILURE;
169 } 170 }
170 if (!client.UseHandler()) { 171 if (!client.UseHandler()) {
171 ADD_FAILURE(); 172 ADD_FAILURE();
172 return EXIT_FAILURE; 173 return EXIT_FAILURE;
173 } 174 }
174 WriteString(WritePipeHandle(), "OK"); 175 WriteString(WritePipeHandle(), "OK");
175 return EXIT_SUCCESS; 176 return EXIT_SUCCESS;
176 } 177 }
(...skipping 22 matching lines...) Expand all
199 200
200 ASSERT_EQ("OK", ReadString(handles_3->read.get())); 201 ASSERT_EQ("OK", ReadString(handles_3->read.get()));
201 ASSERT_EQ("OK", ReadString(handles_2->read.get())); 202 ASSERT_EQ("OK", ReadString(handles_2->read.get()));
202 ASSERT_EQ("OK", ReadString(handles_1->read.get())); 203 ASSERT_EQ("OK", ReadString(handles_1->read.get()));
203 } 204 }
204 } 205 }
205 206
206 } // namespace 207 } // namespace
207 } // namespace test 208 } // namespace test
208 } // namespace crashpad 209 } // namespace crashpad
OLDNEW
« no previous file with comments | « snapshot/win/crashpad_snapshot_test_dump_without_crashing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698