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

Side by Side Diff: net/socket/deterministic_socket_data_unittest.cc

Issue 10795012: Modify DeterministicSocketData to verify that the sequence number of reads and writes start at zero… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix rebase problem. Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_stream_parser_unittest.cc ('k') | net/socket/socket_test_util.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 "net/socket/socket_test_util.h" 5 #include "net/socket/socket_test_util.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "testing/platform_test.h" 10 #include "testing/platform_test.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 data_->SetStopped(true); 179 data_->SetStopped(true);
180 AssertReadReturns(kMsg1, kLen1, ERR_UNEXPECTED); 180 AssertReadReturns(kMsg1, kLen1, ERR_UNEXPECTED);
181 } 181 }
182 182
183 TEST_F(DeterministicSocketDataTest, SingleSyncReadTooEarly) { 183 TEST_F(DeterministicSocketDataTest, SingleSyncReadTooEarly) {
184 MockRead reads[] = { 184 MockRead reads[] = {
185 MockRead(SYNCHRONOUS, kMsg1, kLen1, 1), // Sync Read 185 MockRead(SYNCHRONOUS, kMsg1, kLen1, 1), // Sync Read
186 MockRead(SYNCHRONOUS, 0, 2), // EOF 186 MockRead(SYNCHRONOUS, 0, 2), // EOF
187 }; 187 };
188 188
189 Initialize(reads, arraysize(reads), NULL, 0); 189 MockWrite writes[] = {
190 MockWrite(SYNCHRONOUS, 0, 0)
191 };
192
193 Initialize(reads, arraysize(reads), writes, arraysize(writes));
190 194
191 data_->StopAfter(2); 195 data_->StopAfter(2);
192 ASSERT_FALSE(data_->stopped()); 196 ASSERT_FALSE(data_->stopped());
193 AssertReadReturns(kMsg1, kLen1, ERR_UNEXPECTED); 197 AssertReadReturns(kMsg1, kLen1, ERR_UNEXPECTED);
194 } 198 }
195 199
196 TEST_F(DeterministicSocketDataTest, SingleSyncRead) { 200 TEST_F(DeterministicSocketDataTest, SingleSyncRead) {
197 MockRead reads[] = { 201 MockRead reads[] = {
198 MockRead(SYNCHRONOUS, kMsg1, kLen1, 0), // Sync Read 202 MockRead(SYNCHRONOUS, kMsg1, kLen1, 0), // Sync Read
199 MockRead(SYNCHRONOUS, 0, 1), // EOF 203 MockRead(SYNCHRONOUS, 0, 1), // EOF
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 306
303 data_->SetStopped(true); 307 data_->SetStopped(true);
304 AssertWriteReturns(kMsg1, kLen1, ERR_UNEXPECTED); 308 AssertWriteReturns(kMsg1, kLen1, ERR_UNEXPECTED);
305 } 309 }
306 310
307 TEST_F(DeterministicSocketDataTest, SingleSyncWriteTooEarly) { 311 TEST_F(DeterministicSocketDataTest, SingleSyncWriteTooEarly) {
308 MockWrite writes[] = { 312 MockWrite writes[] = {
309 MockWrite(SYNCHRONOUS, kMsg1, kLen1, 1), // Sync Write 313 MockWrite(SYNCHRONOUS, kMsg1, kLen1, 1), // Sync Write
310 }; 314 };
311 315
312 Initialize(NULL, 0, writes, arraysize(writes)); 316 MockRead reads[] = {
317 MockRead(SYNCHRONOUS, 0, 0)
318 };
319
320 Initialize(reads, arraysize(reads), writes, arraysize(writes));
313 321
314 data_->StopAfter(2); 322 data_->StopAfter(2);
315 ASSERT_FALSE(data_->stopped()); 323 ASSERT_FALSE(data_->stopped());
316 AssertWriteReturns(kMsg1, kLen1, ERR_UNEXPECTED); 324 AssertWriteReturns(kMsg1, kLen1, ERR_UNEXPECTED);
317 } 325 }
318 326
319 TEST_F(DeterministicSocketDataTest, SingleSyncWrite) { 327 TEST_F(DeterministicSocketDataTest, SingleSyncWrite) {
320 MockWrite writes[] = { 328 MockWrite writes[] = {
321 MockWrite(SYNCHRONOUS, kMsg1, kLen1, 0), // Sync Write 329 MockWrite(SYNCHRONOUS, kMsg1, kLen1, 0), // Sync Write
322 }; 330 };
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 // Issue the writes which will complete immediately 536 // Issue the writes which will complete immediately
529 data_->StopAfter(1); 537 data_->StopAfter(1);
530 AssertSyncWriteEquals(kMsg3, kLen3); 538 AssertSyncWriteEquals(kMsg3, kLen3);
531 539
532 data_->RunFor(1); 540 data_->RunFor(1);
533 ASSERT_EQ(kLen2, read_callback_.WaitForResult()); 541 ASSERT_EQ(kLen2, read_callback_.WaitForResult());
534 AssertReadBufferEquals(kMsg2, kLen2); 542 AssertReadBufferEquals(kMsg2, kLen2);
535 } 543 }
536 544
537 } // namespace net 545 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_parser_unittest.cc ('k') | net/socket/socket_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698