diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-10 22:01:23 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-10 22:01:23 +0000 |
commit | bc389d78c9ec3c5f5f1cb416c3b83aefcf969a98 (patch) | |
tree | b64ea71e6a41a00765ac2b4cf4034267c7b3ad83 /net | |
parent | 50c7eb8a256dfbff20f5434f78a3f4f537c4239b (diff) | |
download | chromium_src-bc389d78c9ec3c5f5f1cb416c3b83aefcf969a98.zip chromium_src-bc389d78c9ec3c5f5f1cb416c3b83aefcf969a98.tar.gz chromium_src-bc389d78c9ec3c5f5f1cb416c3b83aefcf969a98.tar.bz2 |
Add a couple of methods to the StaticMockSocket for verifying
that all data has been consumed from the Mock socket. Tests
can optionally use this by including a zero-length read at the
end of their data and then verifying that it is at the end.
Example:
MockWrite writes[] = {
MockWrite( ... <data> ...),
MockWrite( ... <data> ...),
MockWrite( ... <data> ...),
MockWrite(true, 0, 0), // Marks EOF
}
<run tests>
EXPECT_EQ(mock_socket.at_write_eof());
TEST=this is the test
BUG=none
Review URL: http://codereview.chromium.org/385011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31605 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/socket/socket_test_util.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h index cfbdda8..b4a260c 100644 --- a/net/socket/socket_test_util.h +++ b/net/socket/socket_test_util.h @@ -104,6 +104,13 @@ class StaticMockSocket : public MockSocket { virtual MockWriteResult OnWrite(const std::string& data); virtual void Reset(); + // If the test wishes to verify that all data is consumed, it can include + // a EOF MockRead or MockWrite, which is a zero-length Read or Write. + // The test can then call at_read_eof() or at_write_eof() to verify that + // all data has been consumed. + bool at_read_eof() const { return reads_[read_index_].data_len == 0; } + bool at_write_eof() const { return writes_[write_index_].data_len == 0; } + private: MockRead* reads_; int read_index_; |