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

Side by Side Diff: remoting/host/it2me/it2me_native_messaging_host_unittest.cc

Issue 1547473005: Switch to standard integer types in remoting/host/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "remoting/host/it2me/it2me_native_messaging_host.h" 5 #include "remoting/host/it2me/it2me_native_messaging_host.h"
6 6
7 #include "base/basictypes.h" 7 #include <stdint.h>
8
8 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
9 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/macros.h"
11 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h" 14 #include "base/run_loop.h"
13 #include "base/stl_util.h" 15 #include "base/stl_util.h"
14 #include "base/strings/stringize_macros.h" 16 #include "base/strings/stringize_macros.h"
15 #include "base/values.h" 17 #include "base/values.h"
16 #include "net/base/file_stream.h" 18 #include "net/base/file_stream.h"
17 #include "net/base/net_util.h" 19 #include "net/base/net_util.h"
18 #include "remoting/base/auto_thread_task_runner.h" 20 #include "remoting/base/auto_thread_task_runner.h"
19 #include "remoting/host/chromoting_host_context.h" 21 #include "remoting/host/chromoting_host_context.h"
20 #include "remoting/host/native_messaging/log_message_handler.h" 22 #include "remoting/host/native_messaging/log_message_handler.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 EXPECT_FALSE(response); 257 EXPECT_FALSE(response);
256 258
257 // The It2MeNativeMessagingHost dtor closes the handles that are passed to it. 259 // The It2MeNativeMessagingHost dtor closes the handles that are passed to it.
258 // So the only handle left to close is |output_read_file_|. 260 // So the only handle left to close is |output_read_file_|.
259 output_read_file_.Close(); 261 output_read_file_.Close();
260 } 262 }
261 263
262 scoped_ptr<base::DictionaryValue> 264 scoped_ptr<base::DictionaryValue>
263 It2MeNativeMessagingHostTest::ReadMessageFromOutputPipe() { 265 It2MeNativeMessagingHostTest::ReadMessageFromOutputPipe() {
264 while (true) { 266 while (true) {
265 uint32 length; 267 uint32_t length;
266 int read_result = output_read_file_.ReadAtCurrentPos( 268 int read_result = output_read_file_.ReadAtCurrentPos(
267 reinterpret_cast<char*>(&length), sizeof(length)); 269 reinterpret_cast<char*>(&length), sizeof(length));
268 if (read_result != sizeof(length)) { 270 if (read_result != sizeof(length)) {
269 // The output pipe has been closed, return an empty message. 271 // The output pipe has been closed, return an empty message.
270 return nullptr; 272 return nullptr;
271 } 273 }
272 274
273 std::string message_json(length, '\0'); 275 std::string message_json(length, '\0');
274 read_result = output_read_file_.ReadAtCurrentPos( 276 read_result = output_read_file_.ReadAtCurrentPos(
275 string_as_array(&message_json), length); 277 string_as_array(&message_json), length);
(...skipping 18 matching lines...) Expand all
294 return result; 296 return result;
295 } 297 }
296 } 298 }
297 } 299 }
298 300
299 void It2MeNativeMessagingHostTest::WriteMessageToInputPipe( 301 void It2MeNativeMessagingHostTest::WriteMessageToInputPipe(
300 const base::Value& message) { 302 const base::Value& message) {
301 std::string message_json; 303 std::string message_json;
302 base::JSONWriter::Write(message, &message_json); 304 base::JSONWriter::Write(message, &message_json);
303 305
304 uint32 length = message_json.length(); 306 uint32_t length = message_json.length();
305 input_write_file_.WriteAtCurrentPos(reinterpret_cast<char*>(&length), 307 input_write_file_.WriteAtCurrentPos(reinterpret_cast<char*>(&length),
306 sizeof(length)); 308 sizeof(length));
307 input_write_file_.WriteAtCurrentPos(message_json.data(), length); 309 input_write_file_.WriteAtCurrentPos(message_json.data(), length);
308 } 310 }
309 311
310 void It2MeNativeMessagingHostTest::VerifyHelloResponse(int request_id) { 312 void It2MeNativeMessagingHostTest::VerifyHelloResponse(int request_id) {
311 scoped_ptr<base::DictionaryValue> response = ReadMessageFromOutputPipe(); 313 scoped_ptr<base::DictionaryValue> response = ReadMessageFromOutputPipe();
312 VerifyCommonProperties(response.Pass(), "helloResponse", request_id); 314 VerifyCommonProperties(response.Pass(), "helloResponse", request_id);
313 } 315 }
314 316
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 } 544 }
543 545
544 // Verify rejection if type is unrecognized. 546 // Verify rejection if type is unrecognized.
545 TEST_F(It2MeNativeMessagingHostTest, InvalidType) { 547 TEST_F(It2MeNativeMessagingHostTest, InvalidType) {
546 base::DictionaryValue message; 548 base::DictionaryValue message;
547 message.SetString("type", "xxx"); 549 message.SetString("type", "xxx");
548 TestBadRequest(message, true); 550 TestBadRequest(message, true);
549 } 551 }
550 552
551 } // namespace remoting 553 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/it2me/it2me_native_messaging_host_main.cc ('k') | remoting/host/it2me_desktop_environment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698