summaryrefslogtreecommitdiffstats
path: root/net/socket
diff options
context:
space:
mode:
authorrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-21 00:35:39 +0000
committerrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-21 00:35:39 +0000
commitd55b30acf681116affd8ce2cc8deec9cae2e124f (patch)
tree936ef6f0cfce9e02f5bf33d8c6e3fdc2cd2bfaf0 /net/socket
parentf98502f4243d2329256f20352148d9cadf38fbdf (diff)
downloadchromium_src-d55b30acf681116affd8ce2cc8deec9cae2e124f.zip
chromium_src-d55b30acf681116affd8ce2cc8deec9cae2e124f.tar.gz
chromium_src-d55b30acf681116affd8ce2cc8deec9cae2e124f.tar.bz2
Modify DeterministicSocketData to verify that the sequence number of reads and writes start at zero and are continuous.
Review URL: https://chromiumcodereview.appspot.com/10795012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147749 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket')
-rw-r--r--net/socket/deterministic_socket_data_unittest.cc12
-rw-r--r--net/socket/socket_test_util.cc27
-rw-r--r--net/socket/socket_test_util.h4
3 files changed, 40 insertions, 3 deletions
diff --git a/net/socket/deterministic_socket_data_unittest.cc b/net/socket/deterministic_socket_data_unittest.cc
index e3fa4af..e1f42f4 100644
--- a/net/socket/deterministic_socket_data_unittest.cc
+++ b/net/socket/deterministic_socket_data_unittest.cc
@@ -186,7 +186,11 @@ TEST_F(DeterministicSocketDataTest, SingleSyncReadTooEarly) {
MockRead(SYNCHRONOUS, 0, 2), // EOF
};
- Initialize(reads, arraysize(reads), NULL, 0);
+ MockWrite writes[] = {
+ MockWrite(SYNCHRONOUS, 0, 0)
+ };
+
+ Initialize(reads, arraysize(reads), writes, arraysize(writes));
data_->StopAfter(2);
ASSERT_FALSE(data_->stopped());
@@ -309,7 +313,11 @@ TEST_F(DeterministicSocketDataTest, SingleSyncWriteTooEarly) {
MockWrite(SYNCHRONOUS, kMsg1, kLen1, 1), // Sync Write
};
- Initialize(NULL, 0, writes, arraysize(writes));
+ MockRead reads[] = {
+ MockRead(SYNCHRONOUS, 0, 0)
+ };
+
+ Initialize(reads, arraysize(reads), writes, arraysize(writes));
data_->StopAfter(2);
ASSERT_FALSE(data_->stopped());
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index ff66830..34af370 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -450,6 +450,7 @@ DeterministicSocketData::DeterministicSocketData(MockRead* reads,
stopping_sequence_number_(0),
stopped_(false),
print_debug_(false) {
+ VerifyCorrectSequenceNumbers(reads, reads_count, writes, writes_count);
}
DeterministicSocketData::~DeterministicSocketData() {}
@@ -603,6 +604,32 @@ void DeterministicSocketData::NextStep() {
SetStopped(true);
}
+void DeterministicSocketData::VerifyCorrectSequenceNumbers(
+ MockRead* reads, size_t reads_count,
+ MockWrite* writes, size_t writes_count) {
+ size_t read = 0;
+ size_t write = 0;
+ int expected = 0;
+ while (read < reads_count || write < writes_count) {
+ // Check to see that we have a read or write at the expected
+ // state.
+ if (read < reads_count && reads[read].sequence_number == expected) {
+ ++read;
+ ++expected;
+ continue;
+ }
+ if (write < writes_count && writes[write].sequence_number == expected) {
+ ++write;
+ ++expected;
+ continue;
+ }
+ NOTREACHED() << "Missing sequence number: " << expected;
+ return;
+ }
+ DCHECK_EQ(read, reads_count);
+ DCHECK_EQ(write, writes_count);
+}
+
MockClientSocketFactory::MockClientSocketFactory() {}
MockClientSocketFactory::~MockClientSocketFactory() {}
diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h
index 0c7e4cf..171e3c3 100644
--- a/net/socket/socket_test_util.h
+++ b/net/socket/socket_test_util.h
@@ -486,6 +486,9 @@ class DeterministicSocketData
void NextStep();
+ void VerifyCorrectSequenceNumbers(MockRead* reads, size_t reads_count,
+ MockWrite* writes, size_t writes_count);
+
int sequence_number_;
MockRead current_read_;
MockWrite current_write_;
@@ -759,7 +762,6 @@ class MockSSLClientSocket : public MockClientSocket, public AsyncSocket {
SSLCertRequestInfo* cert_request_info) OVERRIDE;
virtual NextProtoStatus GetNextProto(std::string* proto,
std::string* server_protos) OVERRIDE;
- //virtual bool was_npn_negotiated() const OVERRIDE;
virtual bool set_was_npn_negotiated(bool negotiated) OVERRIDE;
virtual void set_protocol_negotiated(
NextProto protocol_negotiated) OVERRIDE;