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

Side by Side Diff: remoting/host/native_messaging/native_messaging_reader_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 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/native_messaging/native_messaging_reader.h" 5 #include "remoting/host/native_messaging/native_messaging_reader.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 base::RunLoop run_loop_; 48 base::RunLoop run_loop_;
49 }; 49 };
50 50
51 NativeMessagingReaderTest::NativeMessagingReaderTest() { 51 NativeMessagingReaderTest::NativeMessagingReaderTest() {
52 } 52 }
53 53
54 NativeMessagingReaderTest::~NativeMessagingReaderTest() {} 54 NativeMessagingReaderTest::~NativeMessagingReaderTest() {}
55 55
56 void NativeMessagingReaderTest::SetUp() { 56 void NativeMessagingReaderTest::SetUp() {
57 ASSERT_TRUE(MakePipe(&read_file_, &write_file_)); 57 ASSERT_TRUE(MakePipe(&read_file_, &write_file_));
58 reader_.reset(new NativeMessagingReader(read_file_.Pass())); 58 reader_.reset(new NativeMessagingReader(std::move(read_file_)));
59 } 59 }
60 60
61 void NativeMessagingReaderTest::Run() { 61 void NativeMessagingReaderTest::Run() {
62 // Close the write-end, so the reader doesn't block waiting for more data. 62 // Close the write-end, so the reader doesn't block waiting for more data.
63 write_file_.Close(); 63 write_file_.Close();
64 64
65 // base::Unretained is safe since no further tasks can run after 65 // base::Unretained is safe since no further tasks can run after
66 // RunLoop::Run() returns. 66 // RunLoop::Run() returns.
67 reader_->Start( 67 reader_->Start(
68 base::Bind(&NativeMessagingReaderTest::OnMessage, base::Unretained(this)), 68 base::Bind(&NativeMessagingReaderTest::OnMessage, base::Unretained(this)),
69 run_loop_.QuitClosure()); 69 run_loop_.QuitClosure());
70 run_loop_.Run(); 70 run_loop_.Run();
71 } 71 }
72 72
73 void NativeMessagingReaderTest::OnMessage(scoped_ptr<base::Value> message) { 73 void NativeMessagingReaderTest::OnMessage(scoped_ptr<base::Value> message) {
74 message_ = message.Pass(); 74 message_ = std::move(message);
75 } 75 }
76 76
77 void NativeMessagingReaderTest::WriteMessage(const std::string& message) { 77 void NativeMessagingReaderTest::WriteMessage(const std::string& message) {
78 uint32 length = message.length(); 78 uint32 length = message.length();
79 WriteData(reinterpret_cast<char*>(&length), 4); 79 WriteData(reinterpret_cast<char*>(&length), 4);
80 WriteData(message.data(), length); 80 WriteData(message.data(), length);
81 } 81 }
82 82
83 void NativeMessagingReaderTest::WriteData(const char* data, int length) { 83 void NativeMessagingReaderTest::WriteData(const char* data, int length) {
84 int written = write_file_.WriteAtCurrentPos(data, length); 84 int written = write_file_.WriteAtCurrentPos(data, length);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 Run(); 145 Run();
146 EXPECT_TRUE(message_); 146 EXPECT_TRUE(message_);
147 base::DictionaryValue* message_dict; 147 base::DictionaryValue* message_dict;
148 EXPECT_TRUE(message_->GetAsDictionary(&message_dict)); 148 EXPECT_TRUE(message_->GetAsDictionary(&message_dict));
149 int result; 149 int result;
150 EXPECT_TRUE(message_dict->GetInteger("foo", &result)); 150 EXPECT_TRUE(message_dict->GetInteger("foo", &result));
151 EXPECT_EQ(42, result); 151 EXPECT_EQ(42, result);
152 } 152 }
153 153
154 } // namespace remoting 154 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698