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

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

Issue 2757723002: Update ICE protocol to handle closed channel (Closed)
Patch Set: . Created 3 years, 9 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/stream_message_pipe_adapter.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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 AddMessage(kTestMessage2); 142 AddMessage(kTestMessage2);
143 base::RunLoop().RunUntilIdle(); 143 base::RunLoop().RunUntilIdle();
144 144
145 EXPECT_TRUE(CompareResult(messages_[1].get(), kTestMessage2)); 145 EXPECT_TRUE(CompareResult(messages_[1].get(), kTestMessage2));
146 146
147 EXPECT_TRUE(socket_.read_pending()); 147 EXPECT_TRUE(socket_.read_pending());
148 } 148 }
149 149
150 // Read() returns error. 150 // Read() returns error.
151 TEST_F(MessageReaderTest, ReadError) { 151 TEST_F(MessageReaderTest, ReadError) {
152 socket_.AppendReadError(net::ERR_FAILED); 152 socket_.SetReadError(net::ERR_FAILED);
153 153
154 EXPECT_CALL(callback_, OnMessage()).Times(0); 154 EXPECT_CALL(callback_, OnMessage()).Times(0);
155 155
156 InitReader(); 156 InitReader();
157 157
158 EXPECT_EQ(net::ERR_FAILED, read_error_); 158 EXPECT_EQ(net::ERR_FAILED, read_error_);
159 EXPECT_FALSE(reader_); 159 EXPECT_FALSE(reader_);
160 } 160 }
161 161
162 // Read() returns 0 (end of stream).
163 TEST_F(MessageReaderTest, EndOfStream) {
164 socket_.SetReadError(0);
165
166 EXPECT_CALL(callback_, OnMessage()).Times(0);
167
168 InitReader();
169
170 EXPECT_EQ(0, read_error_);
171 EXPECT_FALSE(reader_);
172 }
173
162 // Verify that we the OnMessage callback is not reentered. 174 // Verify that we the OnMessage callback is not reentered.
163 TEST_F(MessageReaderTest, ReadFromCallback) { 175 TEST_F(MessageReaderTest, ReadFromCallback) {
164 AddMessage(kTestMessage1); 176 AddMessage(kTestMessage1);
165 177
166 EXPECT_CALL(callback_, OnMessage()) 178 EXPECT_CALL(callback_, OnMessage())
167 .Times(2) 179 .Times(2)
168 .WillOnce(Invoke(this, &MessageReaderTest::AddSecondMessage)); 180 .WillOnce(Invoke(this, &MessageReaderTest::AddSecondMessage));
169 181
170 InitReader(); 182 InitReader();
171 base::RunLoop().RunUntilIdle(); 183 base::RunLoop().RunUntilIdle();
(...skipping 10 matching lines...) Expand all
182 EXPECT_CALL(callback_, OnMessage()) 194 EXPECT_CALL(callback_, OnMessage())
183 .Times(1) 195 .Times(1)
184 .WillOnce(Invoke(this, &MessageReaderTest::DeleteReader)); 196 .WillOnce(Invoke(this, &MessageReaderTest::DeleteReader));
185 197
186 InitReader(); 198 InitReader();
187 base::RunLoop().RunUntilIdle(); 199 base::RunLoop().RunUntilIdle();
188 } 200 }
189 201
190 } // namespace protocol 202 } // namespace protocol
191 } // namespace remoting 203 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/message_reader.cc ('k') | remoting/protocol/stream_message_pipe_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698