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

Side by Side Diff: remoting/protocol/message_reader_unittest.cc

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 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
« no previous file with comments | « remoting/protocol/message_reader.cc ('k') | remoting/protocol/message_serialization.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 std::string result(buffer->total_bytes(), ' '); 70 std::string result(buffer->total_bytes(), ' ');
71 buffer->CopyTo(const_cast<char*>(result.data()), result.size()); 71 buffer->CopyTo(const_cast<char*>(result.data()), result.size());
72 return result == expected; 72 return result == expected;
73 } 73 }
74 74
75 void OnReadError(int error) { 75 void OnReadError(int error) {
76 read_error_ = error; 76 read_error_ = error;
77 reader_.reset(); 77 reader_.reset();
78 } 78 }
79 79
80 void OnMessage(scoped_ptr<CompoundBuffer> buffer) { 80 void OnMessage(std::unique_ptr<CompoundBuffer> buffer) {
81 messages_.push_back(buffer.release()); 81 messages_.push_back(buffer.release());
82 callback_.OnMessage(); 82 callback_.OnMessage();
83 } 83 }
84 84
85 base::MessageLoop message_loop_; 85 base::MessageLoop message_loop_;
86 scoped_ptr<MessageReader> reader_; 86 std::unique_ptr<MessageReader> reader_;
87 FakeStreamSocket socket_; 87 FakeStreamSocket socket_;
88 MockMessageReceivedCallback callback_; 88 MockMessageReceivedCallback callback_;
89 int read_error_ = 0; 89 int read_error_ = 0;
90 std::vector<CompoundBuffer*> messages_; 90 std::vector<CompoundBuffer*> messages_;
91 }; 91 };
92 92
93 // Receive one message. 93 // Receive one message.
94 TEST_F(MessageReaderTest, OneMessage) { 94 TEST_F(MessageReaderTest, OneMessage) {
95 AddMessage(kTestMessage1); 95 AddMessage(kTestMessage1);
96 96
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 EXPECT_CALL(callback_, OnMessage()) 185 EXPECT_CALL(callback_, OnMessage())
186 .Times(1) 186 .Times(1)
187 .WillOnce(Invoke(this, &MessageReaderTest::DeleteReader)); 187 .WillOnce(Invoke(this, &MessageReaderTest::DeleteReader));
188 188
189 InitReader(); 189 InitReader();
190 base::RunLoop().RunUntilIdle(); 190 base::RunLoop().RunUntilIdle();
191 } 191 }
192 192
193 } // namespace protocol 193 } // namespace protocol
194 } // namespace remoting 194 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/message_reader.cc ('k') | remoting/protocol/message_serialization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698