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

Unified Diff: net/socket/socket_test_util.cc

Issue 149211: Correctly handle multiple control response lines in new FTP transaction (Closed)
Patch Set: fixes Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/socket/socket_test_util.h ('k') | 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
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index fc5ddf334a002321f61fd6aad3885ed9e4a4e8ca..25de9d33e7b0c1ad98670aec994b0f692ff80e71 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -248,33 +248,33 @@ void StaticMockSocket::Reset() {
}
DynamicMockSocket::DynamicMockSocket()
- : read_(false, ERR_UNEXPECTED),
- has_read_(false),
- short_read_limit_(0) {
+ : short_read_limit_(0),
+ allow_unconsumed_reads_(false) {
}
MockRead DynamicMockSocket::GetNextRead() {
- if (!has_read_)
+ if (reads_.empty())
return MockRead(true, ERR_UNEXPECTED);
- MockRead result = read_;
+ MockRead result = reads_.front();
if (short_read_limit_ == 0 || result.data_len <= short_read_limit_) {
- has_read_ = false;
+ reads_.pop_front();
} else {
result.data_len = short_read_limit_;
- read_.data += result.data_len;
- read_.data_len -= result.data_len;
+ reads_.front().data += result.data_len;
+ reads_.front().data_len -= result.data_len;
}
return result;
}
void DynamicMockSocket::Reset() {
- has_read_ = false;
+ reads_.clear();
}
void DynamicMockSocket::SimulateRead(const char* data) {
- EXPECT_FALSE(has_read_) << "Unconsumed read: " << read_.data;
- read_ = MockRead(data);
- has_read_ = true;
+ if (!allow_unconsumed_reads_) {
+ EXPECT_TRUE(reads_.empty()) << "Unconsumed read: " << reads_.front().data;
+ }
+ reads_.push_back(MockRead(data));
}
void MockClientSocketFactory::AddMockSocket(MockSocket* socket) {
« no previous file with comments | « net/socket/socket_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698