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

Side by Side Diff: remoting/host/setup/me2me_native_messaging_host_unittest.cc

Issue 1549493004: Use std::move() instead of .Pass() in remoting/host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_not_pass
Patch Set: include <utility> Created 4 years, 12 months 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility>
11
10 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
11 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
12 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
13 #include "base/macros.h" 15 #include "base/macros.h"
14 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
15 #include "base/run_loop.h" 17 #include "base/run_loop.h"
16 #include "base/stl_util.h" 18 #include "base/stl_util.h"
17 #include "base/strings/stringize_macros.h" 19 #include "base/strings/stringize_macros.h"
18 #include "base/values.h" 20 #include "base/values.h"
19 #include "google_apis/gaia/gaia_oauth_client.h" 21 #include "google_apis/gaia/gaia_oauth_client.h"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 322
321 daemon_controller_delegate_ = new MockDaemonControllerDelegate(); 323 daemon_controller_delegate_ = new MockDaemonControllerDelegate();
322 scoped_refptr<DaemonController> daemon_controller( 324 scoped_refptr<DaemonController> daemon_controller(
323 new DaemonController(make_scoped_ptr(daemon_controller_delegate_))); 325 new DaemonController(make_scoped_ptr(daemon_controller_delegate_)));
324 326
325 scoped_refptr<PairingRegistry> pairing_registry = 327 scoped_refptr<PairingRegistry> pairing_registry =
326 new SynchronousPairingRegistry( 328 new SynchronousPairingRegistry(
327 make_scoped_ptr(new MockPairingRegistryDelegate())); 329 make_scoped_ptr(new MockPairingRegistryDelegate()));
328 330
329 scoped_ptr<extensions::NativeMessagingChannel> channel( 331 scoped_ptr<extensions::NativeMessagingChannel> channel(
330 new PipeMessagingChannel(input_read_file.Pass(), 332 new PipeMessagingChannel(std::move(input_read_file),
331 output_write_file.Pass())); 333 std::move(output_write_file)));
332 334
333 scoped_ptr<OAuthClient> oauth_client( 335 scoped_ptr<OAuthClient> oauth_client(
334 new MockOAuthClient("fake_user_email", "fake_refresh_token")); 336 new MockOAuthClient("fake_user_email", "fake_refresh_token"));
335 337
336 host_.reset(new Me2MeNativeMessagingHost(false, 0, channel.Pass(), 338 host_.reset(new Me2MeNativeMessagingHost(false, 0, std::move(channel),
337 daemon_controller, pairing_registry, 339 daemon_controller, pairing_registry,
338 oauth_client.Pass())); 340 std::move(oauth_client)));
339 host_->Start(base::Bind(&Me2MeNativeMessagingHostTest::StopHost, 341 host_->Start(base::Bind(&Me2MeNativeMessagingHostTest::StopHost,
340 base::Unretained(this))); 342 base::Unretained(this)));
341 343
342 // Notify the test that the host has finished starting up. 344 // Notify the test that the host has finished starting up.
343 test_message_loop_->task_runner()->PostTask( 345 test_message_loop_->task_runner()->PostTask(
344 FROM_HERE, test_run_loop_->QuitClosure()); 346 FROM_HERE, test_run_loop_->QuitClosure());
345 } 347 }
346 348
347 void Me2MeNativeMessagingHostTest::StopHost() { 349 void Me2MeNativeMessagingHostTest::StopHost() {
348 DCHECK(host_task_runner_->RunsTasksOnCurrentThread()); 350 DCHECK(host_task_runner_->RunsTasksOnCurrentThread());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 good_message.SetString("type", "hello"); 436 good_message.SetString("type", "hello");
435 437
436 // This test currently relies on synchronous processing of hello messages and 438 // This test currently relies on synchronous processing of hello messages and
437 // message parameters verification. 439 // message parameters verification.
438 WriteMessageToInputPipe(good_message); 440 WriteMessageToInputPipe(good_message);
439 WriteMessageToInputPipe(message); 441 WriteMessageToInputPipe(message);
440 WriteMessageToInputPipe(good_message); 442 WriteMessageToInputPipe(good_message);
441 443
442 // Read from output pipe, and verify responses. 444 // Read from output pipe, and verify responses.
443 scoped_ptr<base::DictionaryValue> response = ReadMessageFromOutputPipe(); 445 scoped_ptr<base::DictionaryValue> response = ReadMessageFromOutputPipe();
444 VerifyHelloResponse(response.Pass()); 446 VerifyHelloResponse(std::move(response));
445 447
446 response = ReadMessageFromOutputPipe(); 448 response = ReadMessageFromOutputPipe();
447 EXPECT_FALSE(response); 449 EXPECT_FALSE(response);
448 } 450 }
449 451
450 // TODO (weitaosu): crbug.com/323306. Re-enable these tests. 452 // TODO (weitaosu): crbug.com/323306. Re-enable these tests.
451 // Test all valid request-types. 453 // Test all valid request-types.
452 TEST_F(Me2MeNativeMessagingHostTest, All) { 454 TEST_F(Me2MeNativeMessagingHostTest, All) {
453 int next_id = 0; 455 int next_id = 0;
454 base::DictionaryValue message; 456 base::DictionaryValue message;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 for (int i = 0; i < next_id; ++i) { 529 for (int i = 0; i < next_id; ++i) {
528 scoped_ptr<base::DictionaryValue> response = ReadMessageFromOutputPipe(); 530 scoped_ptr<base::DictionaryValue> response = ReadMessageFromOutputPipe();
529 531
530 // Make sure that id is available and is in the range. 532 // Make sure that id is available and is in the range.
531 int id; 533 int id;
532 ASSERT_TRUE(response->GetInteger("id", &id)); 534 ASSERT_TRUE(response->GetInteger("id", &id));
533 ASSERT_TRUE(0 <= id && id < next_id); 535 ASSERT_TRUE(0 <= id && id < next_id);
534 536
535 // Call the verification routine corresponding to the message id. 537 // Call the verification routine corresponding to the message id.
536 ASSERT_TRUE(verify_routines[id]); 538 ASSERT_TRUE(verify_routines[id]);
537 verify_routines[id](response.Pass()); 539 verify_routines[id](std::move(response));
538 540
539 // Clear the pointer so that the routine cannot be called the second time. 541 // Clear the pointer so that the routine cannot be called the second time.
540 verify_routines[id] = nullptr; 542 verify_routines[id] = nullptr;
541 } 543 }
542 } 544 }
543 545
544 // Verify that response ID matches request ID. 546 // Verify that response ID matches request ID.
545 TEST_F(Me2MeNativeMessagingHostTest, Id) { 547 TEST_F(Me2MeNativeMessagingHostTest, Id) {
546 base::DictionaryValue message; 548 base::DictionaryValue message;
547 message.SetString("type", "hello"); 549 message.SetString("type", "hello");
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 } 623 }
622 624
623 // Verify rejection if getCredentialsFromAuthCode has no auth code. 625 // Verify rejection if getCredentialsFromAuthCode has no auth code.
624 TEST_F(Me2MeNativeMessagingHostTest, GetCredentialsFromAuthCodeNoAuthCode) { 626 TEST_F(Me2MeNativeMessagingHostTest, GetCredentialsFromAuthCodeNoAuthCode) {
625 base::DictionaryValue message; 627 base::DictionaryValue message;
626 message.SetString("type", "getCredentialsFromAuthCode"); 628 message.SetString("type", "getCredentialsFromAuthCode");
627 TestBadRequest(message); 629 TestBadRequest(message);
628 } 630 }
629 631
630 } // namespace remoting 632 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/setup/me2me_native_messaging_host_main.cc ('k') | remoting/host/shaped_desktop_capturer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698