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

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

Issue 609923004: Cleanup usage of scoped_ptr<> in remoting for C++11 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 "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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 321
322 scoped_refptr<PairingRegistry> pairing_registry = 322 scoped_refptr<PairingRegistry> pairing_registry =
323 new SynchronousPairingRegistry(scoped_ptr<PairingRegistry::Delegate>( 323 new SynchronousPairingRegistry(scoped_ptr<PairingRegistry::Delegate>(
324 new MockPairingRegistryDelegate())); 324 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(input_read_file.Pass(),
328 output_write_file.Pass())); 328 output_write_file.Pass()));
329 329
330 host_.reset(new Me2MeNativeMessagingHost( 330 host_.reset(new Me2MeNativeMessagingHost(
331 false, 331 false, 0, channel.Pass(), daemon_controller, pairing_registry, nullptr));
332 0,
333 channel.Pass(),
334 daemon_controller,
335 pairing_registry,
336 scoped_ptr<remoting::OAuthClient>()));
337 host_->Start(base::Bind(&Me2MeNativeMessagingHostTest::StopHost, 332 host_->Start(base::Bind(&Me2MeNativeMessagingHostTest::StopHost,
338 base::Unretained(this))); 333 base::Unretained(this)));
339 334
340 // Notify the test that the host has finished starting up. 335 // Notify the test that the host has finished starting up.
341 test_message_loop_->message_loop_proxy()->PostTask( 336 test_message_loop_->message_loop_proxy()->PostTask(
342 FROM_HERE, test_run_loop_->QuitClosure()); 337 FROM_HERE, test_run_loop_->QuitClosure());
343 } 338 }
344 339
345 void Me2MeNativeMessagingHostTest::StopHost() { 340 void Me2MeNativeMessagingHostTest::StopHost() {
346 DCHECK(host_task_runner_->RunsTasksOnCurrentThread()); 341 DCHECK(host_task_runner_->RunsTasksOnCurrentThread());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // to it. So the only handle left to close is |output_read_file_|. 377 // to it. So the only handle left to close is |output_read_file_|.
383 output_read_file_.Close(); 378 output_read_file_.Close();
384 } 379 }
385 380
386 scoped_ptr<base::DictionaryValue> 381 scoped_ptr<base::DictionaryValue>
387 Me2MeNativeMessagingHostTest::ReadMessageFromOutputPipe() { 382 Me2MeNativeMessagingHostTest::ReadMessageFromOutputPipe() {
388 uint32 length; 383 uint32 length;
389 int read_result = output_read_file_.ReadAtCurrentPos( 384 int read_result = output_read_file_.ReadAtCurrentPos(
390 reinterpret_cast<char*>(&length), sizeof(length)); 385 reinterpret_cast<char*>(&length), sizeof(length));
391 if (read_result != sizeof(length)) { 386 if (read_result != sizeof(length)) {
392 return scoped_ptr<base::DictionaryValue>(); 387 return nullptr;
393 } 388 }
394 389
395 std::string message_json(length, '\0'); 390 std::string message_json(length, '\0');
396 read_result = output_read_file_.ReadAtCurrentPos( 391 read_result = output_read_file_.ReadAtCurrentPos(
397 string_as_array(&message_json), length); 392 string_as_array(&message_json), length);
398 if (read_result != static_cast<int>(length)) { 393 if (read_result != static_cast<int>(length)) {
399 return scoped_ptr<base::DictionaryValue>(); 394 return nullptr;
400 } 395 }
401 396
402 scoped_ptr<base::Value> message(base::JSONReader::Read(message_json)); 397 scoped_ptr<base::Value> message(base::JSONReader::Read(message_json));
403 if (!message || !message->IsType(base::Value::TYPE_DICTIONARY)) { 398 if (!message || !message->IsType(base::Value::TYPE_DICTIONARY)) {
404 return scoped_ptr<base::DictionaryValue>(); 399 return nullptr;
405 } 400 }
406 401
407 return scoped_ptr<base::DictionaryValue>( 402 return scoped_ptr<base::DictionaryValue>(
408 static_cast<base::DictionaryValue*>(message.release())); 403 static_cast<base::DictionaryValue*>(message.release()));
409 } 404 }
410 405
411 void Me2MeNativeMessagingHostTest::WriteMessageToInputPipe( 406 void Me2MeNativeMessagingHostTest::WriteMessageToInputPipe(
412 const base::Value& message) { 407 const base::Value& message) {
413 std::string message_json; 408 std::string message_json;
414 base::JSONWriter::Write(&message, &message_json); 409 base::JSONWriter::Write(&message, &message_json);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 595
601 // Verify rejection if startDaemon request has no "consent" parameter. 596 // Verify rejection if startDaemon request has no "consent" parameter.
602 TEST_F(Me2MeNativeMessagingHostTest, StartDaemonNoConsent) { 597 TEST_F(Me2MeNativeMessagingHostTest, StartDaemonNoConsent) {
603 base::DictionaryValue message; 598 base::DictionaryValue message;
604 message.SetString("type", "startDaemon"); 599 message.SetString("type", "startDaemon");
605 message.Set("config", base::DictionaryValue().DeepCopy()); 600 message.Set("config", base::DictionaryValue().DeepCopy());
606 TestBadRequest(message); 601 TestBadRequest(message);
607 } 602 }
608 603
609 } // namespace remoting 604 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698