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

Unified Diff: net/socket/socket_test_util.cc

Issue 437031: Add a feature to the MockSocket so that it can support simulation... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/socket_test_util.cc
===================================================================
--- net/socket/socket_test_util.cc (revision 32886)
+++ net/socket/socket_test_util.cc (working copy)
@@ -298,9 +298,17 @@
net::MockWrite* w = &writes_[write_index_++];
int result = w->result;
if (w->data) {
+ // Note - we can simulate a partial write here. If the expected data
+ // is a match, but shorter than the write actually written, that is legal.
+ // Example:
+ // Application writes "foobarbaz" (9 bytes)
+ // Expected write was "foo" (3 bytes)
+ // This is a success, and we return 3 to the application.
std::string expected_data(w->data, w->data_len);
- EXPECT_EQ(expected_data, data);
- if (expected_data != data)
+ EXPECT_GE(data.length(), expected_data.length());
+ std::string actual_data(data.substr(0, w->data_len));
+ EXPECT_EQ(expected_data, actual_data);
+ if (expected_data != actual_data)
return MockWriteResult(false, net::ERR_UNEXPECTED);
if (result == net::OK)
result = w->data_len;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698