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

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: 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 "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 317
318 daemon_controller_delegate_ = new MockDaemonControllerDelegate(); 318 daemon_controller_delegate_ = new MockDaemonControllerDelegate();
319 scoped_refptr<DaemonController> daemon_controller( 319 scoped_refptr<DaemonController> daemon_controller(
320 new DaemonController(make_scoped_ptr(daemon_controller_delegate_))); 320 new DaemonController(make_scoped_ptr(daemon_controller_delegate_)));
321 321
322 scoped_refptr<PairingRegistry> pairing_registry = 322 scoped_refptr<PairingRegistry> pairing_registry =
323 new SynchronousPairingRegistry( 323 new SynchronousPairingRegistry(
324 make_scoped_ptr(new MockPairingRegistryDelegate())); 324 make_scoped_ptr(new MockPairingRegistryDelegate()));
325 325
326 scoped_ptr<extensions::NativeMessagingChannel> channel( 326 scoped_ptr<extensions::NativeMessagingChannel> channel(
327 new PipeMessagingChannel(input_read_file.Pass(), 327 new PipeMessagingChannel(std::move(input_read_file),
328 output_write_file.Pass())); 328 std::move(output_write_file)));
329 329
330 scoped_ptr<OAuthClient> oauth_client( 330 scoped_ptr<OAuthClient> oauth_client(
331 new MockOAuthClient("fake_user_email", "fake_refresh_token")); 331 new MockOAuthClient("fake_user_email", "fake_refresh_token"));
332 332
333 host_.reset(new Me2MeNativeMessagingHost(false, 0, channel.Pass(), 333 host_.reset(new Me2MeNativeMessagingHost(false, 0, std::move(channel),
334 daemon_controller, pairing_registry, 334 daemon_controller, pairing_registry,
335 oauth_client.Pass())); 335 std::move(oauth_client)));
336 host_->Start(base::Bind(&Me2MeNativeMessagingHostTest::StopHost, 336 host_->Start(base::Bind(&Me2MeNativeMessagingHostTest::StopHost,
337 base::Unretained(this))); 337 base::Unretained(this)));
338 338
339 // Notify the test that the host has finished starting up. 339 // Notify the test that the host has finished starting up.
340 test_message_loop_->task_runner()->PostTask( 340 test_message_loop_->task_runner()->PostTask(
341 FROM_HERE, test_run_loop_->QuitClosure()); 341 FROM_HERE, test_run_loop_->QuitClosure());
342 } 342 }
343 343
344 void Me2MeNativeMessagingHostTest::StopHost() { 344 void Me2MeNativeMessagingHostTest::StopHost() {
345 DCHECK(host_task_runner_->RunsTasksOnCurrentThread()); 345 DCHECK(host_task_runner_->RunsTasksOnCurrentThread());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 good_message.SetString("type", "hello"); 431 good_message.SetString("type", "hello");
432 432
433 // This test currently relies on synchronous processing of hello messages and 433 // This test currently relies on synchronous processing of hello messages and
434 // message parameters verification. 434 // message parameters verification.
435 WriteMessageToInputPipe(good_message); 435 WriteMessageToInputPipe(good_message);
436 WriteMessageToInputPipe(message); 436 WriteMessageToInputPipe(message);
437 WriteMessageToInputPipe(good_message); 437 WriteMessageToInputPipe(good_message);
438 438
439 // Read from output pipe, and verify responses. 439 // Read from output pipe, and verify responses.
440 scoped_ptr<base::DictionaryValue> response = ReadMessageFromOutputPipe(); 440 scoped_ptr<base::DictionaryValue> response = ReadMessageFromOutputPipe();
441 VerifyHelloResponse(response.Pass()); 441 VerifyHelloResponse(std::move(response));
442 442
443 response = ReadMessageFromOutputPipe(); 443 response = ReadMessageFromOutputPipe();
444 EXPECT_FALSE(response); 444 EXPECT_FALSE(response);
445 } 445 }
446 446
447 // TODO (weitaosu): crbug.com/323306. Re-enable these tests. 447 // TODO (weitaosu): crbug.com/323306. Re-enable these tests.
448 // Test all valid request-types. 448 // Test all valid request-types.
449 TEST_F(Me2MeNativeMessagingHostTest, All) { 449 TEST_F(Me2MeNativeMessagingHostTest, All) {
450 int next_id = 0; 450 int next_id = 0;
451 base::DictionaryValue message; 451 base::DictionaryValue message;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 for (int i = 0; i < next_id; ++i) { 524 for (int i = 0; i < next_id; ++i) {
525 scoped_ptr<base::DictionaryValue> response = ReadMessageFromOutputPipe(); 525 scoped_ptr<base::DictionaryValue> response = ReadMessageFromOutputPipe();
526 526
527 // Make sure that id is available and is in the range. 527 // Make sure that id is available and is in the range.
528 int id; 528 int id;
529 ASSERT_TRUE(response->GetInteger("id", &id)); 529 ASSERT_TRUE(response->GetInteger("id", &id));
530 ASSERT_TRUE(0 <= id && id < next_id); 530 ASSERT_TRUE(0 <= id && id < next_id);
531 531
532 // Call the verification routine corresponding to the message id. 532 // Call the verification routine corresponding to the message id.
533 ASSERT_TRUE(verify_routines[id]); 533 ASSERT_TRUE(verify_routines[id]);
534 verify_routines[id](response.Pass()); 534 verify_routines[id](std::move(response));
535 535
536 // Clear the pointer so that the routine cannot be called the second time. 536 // Clear the pointer so that the routine cannot be called the second time.
537 verify_routines[id] = nullptr; 537 verify_routines[id] = nullptr;
538 } 538 }
539 } 539 }
540 540
541 // Verify that response ID matches request ID. 541 // Verify that response ID matches request ID.
542 TEST_F(Me2MeNativeMessagingHostTest, Id) { 542 TEST_F(Me2MeNativeMessagingHostTest, Id) {
543 base::DictionaryValue message; 543 base::DictionaryValue message;
544 message.SetString("type", "hello"); 544 message.SetString("type", "hello");
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 } 618 }
619 619
620 // Verify rejection if getCredentialsFromAuthCode has no auth code. 620 // Verify rejection if getCredentialsFromAuthCode has no auth code.
621 TEST_F(Me2MeNativeMessagingHostTest, GetCredentialsFromAuthCodeNoAuthCode) { 621 TEST_F(Me2MeNativeMessagingHostTest, GetCredentialsFromAuthCodeNoAuthCode) {
622 base::DictionaryValue message; 622 base::DictionaryValue message;
623 message.SetString("type", "getCredentialsFromAuthCode"); 623 message.SetString("type", "getCredentialsFromAuthCode");
624 TestBadRequest(message); 624 TestBadRequest(message);
625 } 625 }
626 626
627 } // namespace remoting 627 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698