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

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

Issue 1654513003: Simplify message parsing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no_done
Patch Set: Created 4 years, 10 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 void DeleteReader() { reader_.reset(); } 46 void DeleteReader() { reader_.reset(); }
47 47
48 protected: 48 protected:
49 void SetUp() override { 49 void SetUp() override {
50 reader_.reset(new MessageReader()); 50 reader_.reset(new MessageReader());
51 } 51 }
52 52
53 void TearDown() override { STLDeleteElements(&messages_); } 53 void TearDown() override { STLDeleteElements(&messages_); }
54 54
55 void InitReader() { 55 void InitReader() {
56 reader_->SetMessageReceivedCallback( 56 reader_->StartReading(
57 base::Bind(&MessageReaderTest::OnMessage, base::Unretained(this))); 57 &socket_,
58 reader_->StartReading(&socket_, base::Bind(&MessageReaderTest::OnReadError, 58 base::Bind(&MessageReaderTest::OnMessage, base::Unretained(this)),
59 base::Unretained(this))); 59 base::Bind(&MessageReaderTest::OnReadError, base::Unretained(this)));
60 } 60 }
61 61
62 void AddMessage(const std::string& message) { 62 void AddMessage(const std::string& message) {
63 std::string data = std::string(4, ' ') + message; 63 std::string data = std::string(4, ' ') + message;
64 rtc::SetBE32(const_cast<char*>(data.data()), message.size()); 64 rtc::SetBE32(const_cast<char*>(data.data()), message.size());
65 65
66 socket_.AppendInputData(data); 66 socket_.AppendInputData(data);
67 } 67 }
68 68
69 bool CompareResult(CompoundBuffer* buffer, const std::string& expected) { 69 bool CompareResult(CompoundBuffer* buffer, const std::string& expected) {
(...skipping 115 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