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

Side by Side Diff: remoting/host/setup/me2me_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/setup/me2me_native_messaging_host.h" 5 #include "remoting/host/setup/me2me_native_messaging_host.h"
6 6
7 #include "base/basictypes.h" 7 #include <stddef.h>
8 #include <stdint.h>
9
8 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
9 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
13 #include "base/macros.h"
11 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h" 15 #include "base/run_loop.h"
13 #include "base/stl_util.h" 16 #include "base/stl_util.h"
14 #include "base/strings/stringize_macros.h" 17 #include "base/strings/stringize_macros.h"
15 #include "base/values.h" 18 #include "base/values.h"
16 #include "google_apis/gaia/gaia_oauth_client.h" 19 #include "google_apis/gaia/gaia_oauth_client.h"
17 #include "net/base/file_stream.h" 20 #include "net/base/file_stream.h"
18 #include "net/base/net_util.h" 21 #include "net/base/net_util.h"
19 #include "remoting/base/auto_thread_task_runner.h" 22 #include "remoting/base/auto_thread_task_runner.h"
20 #include "remoting/host/native_messaging/log_message_handler.h" 23 #include "remoting/host/native_messaging/log_message_handler.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 EXPECT_FALSE(response); 381 EXPECT_FALSE(response);
379 382
380 // The It2MeMe2MeNativeMessagingHost dtor closes the handles that are passed 383 // The It2MeMe2MeNativeMessagingHost dtor closes the handles that are passed
381 // to it. So the only handle left to close is |output_read_file_|. 384 // to it. So the only handle left to close is |output_read_file_|.
382 output_read_file_.Close(); 385 output_read_file_.Close();
383 } 386 }
384 387
385 scoped_ptr<base::DictionaryValue> 388 scoped_ptr<base::DictionaryValue>
386 Me2MeNativeMessagingHostTest::ReadMessageFromOutputPipe() { 389 Me2MeNativeMessagingHostTest::ReadMessageFromOutputPipe() {
387 while (true) { 390 while (true) {
388 uint32 length; 391 uint32_t length;
389 int read_result = output_read_file_.ReadAtCurrentPos( 392 int read_result = output_read_file_.ReadAtCurrentPos(
390 reinterpret_cast<char*>(&length), sizeof(length)); 393 reinterpret_cast<char*>(&length), sizeof(length));
391 if (read_result != sizeof(length)) { 394 if (read_result != sizeof(length)) {
392 return nullptr; 395 return nullptr;
393 } 396 }
394 397
395 std::string message_json(length, '\0'); 398 std::string message_json(length, '\0');
396 read_result = output_read_file_.ReadAtCurrentPos( 399 read_result = output_read_file_.ReadAtCurrentPos(
397 string_as_array(&message_json), length); 400 string_as_array(&message_json), length);
398 if (read_result != static_cast<int>(length)) { 401 if (read_result != static_cast<int>(length)) {
(...skipping 14 matching lines...) Expand all
413 return result; 416 return result;
414 } 417 }
415 } 418 }
416 } 419 }
417 420
418 void Me2MeNativeMessagingHostTest::WriteMessageToInputPipe( 421 void Me2MeNativeMessagingHostTest::WriteMessageToInputPipe(
419 const base::Value& message) { 422 const base::Value& message) {
420 std::string message_json; 423 std::string message_json;
421 base::JSONWriter::Write(message, &message_json); 424 base::JSONWriter::Write(message, &message_json);
422 425
423 uint32 length = message_json.length(); 426 uint32_t length = message_json.length();
424 input_write_file_.WriteAtCurrentPos(reinterpret_cast<char*>(&length), 427 input_write_file_.WriteAtCurrentPos(reinterpret_cast<char*>(&length),
425 sizeof(length)); 428 sizeof(length));
426 input_write_file_.WriteAtCurrentPos(message_json.data(), length); 429 input_write_file_.WriteAtCurrentPos(message_json.data(), length);
427 } 430 }
428 431
429 void Me2MeNativeMessagingHostTest::TestBadRequest(const base::Value& message) { 432 void Me2MeNativeMessagingHostTest::TestBadRequest(const base::Value& message) {
430 base::DictionaryValue good_message; 433 base::DictionaryValue good_message;
431 good_message.SetString("type", "hello"); 434 good_message.SetString("type", "hello");
432 435
433 // This test currently relies on synchronous processing of hello messages and 436 // This test currently relies on synchronous processing of hello messages and
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 } 621 }
619 622
620 // Verify rejection if getCredentialsFromAuthCode has no auth code. 623 // Verify rejection if getCredentialsFromAuthCode has no auth code.
621 TEST_F(Me2MeNativeMessagingHostTest, GetCredentialsFromAuthCodeNoAuthCode) { 624 TEST_F(Me2MeNativeMessagingHostTest, GetCredentialsFromAuthCodeNoAuthCode) {
622 base::DictionaryValue message; 625 base::DictionaryValue message;
623 message.SetString("type", "getCredentialsFromAuthCode"); 626 message.SetString("type", "getCredentialsFromAuthCode");
624 TestBadRequest(message); 627 TestBadRequest(message);
625 } 628 }
626 629
627 } // namespace remoting 630 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/setup/me2me_native_messaging_host_main.cc ('k') | remoting/host/setup/oauth_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698