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

Unified Diff: net/base/file_stream_unittest.cc

Issue 887863002: The ReadFile API on Windows invoked by the FileStream::Context class which is used by URLRequestFil… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass the result of ReadFile on failure only Created 5 years, 11 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
« net/base/file_stream_context_win.cc ('K') | « net/base/file_stream_context_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/file_stream_unittest.cc
diff --git a/net/base/file_stream_unittest.cc b/net/base/file_stream_unittest.cc
index fc9257e5d1c0af8d6f541191f02415862cc57da3..8b47eccf4144185da0a990c7f60a85fa848b7080 100644
--- a/net/base/file_stream_unittest.cc
+++ b/net/base/file_stream_unittest.cc
@@ -546,6 +546,25 @@ class TestWriteReadCompletionCallback {
const CompletionCallback& callback() const { return callback_; }
+ void ValidateWrittenData() {
+ TestCompletionCallback callback;
+ int rv = 0;
+ for (;;) {
+ scoped_refptr<IOBufferWithSize> buf = new IOBufferWithSize(4);
+ rv = stream_->Read(buf.get(), buf->size(), callback.callback());
+ if (rv == ERR_IO_PENDING) {
+ base::MessageLoop::ScopedNestableTaskAllower allow(
+ base::MessageLoop::current());
+ rv = callback.WaitForResult();
+ }
+ EXPECT_LE(0, rv);
+ if (rv <= 0)
+ break;
+ *total_bytes_read_ += rv;
+ data_read_->append(buf->data(), rv);
+ }
+ }
+
private:
void OnComplete(int result) {
DCHECK_LT(0, result);
@@ -577,22 +596,6 @@ class TestWriteReadCompletionCallback {
base::MessageLoop::current());
EXPECT_LE(0, callback64.WaitForResult());
}
-
- TestCompletionCallback callback;
- for (;;) {
- scoped_refptr<IOBufferWithSize> buf = new IOBufferWithSize(4);
- rv = stream_->Read(buf.get(), buf->size(), callback.callback());
- if (rv == ERR_IO_PENDING) {
- base::MessageLoop::ScopedNestableTaskAllower allow(
- base::MessageLoop::current());
- rv = callback.WaitForResult();
- }
- EXPECT_LE(0, rv);
- if (rv <= 0)
- break;
- *total_bytes_read_ += rv;
- data_read_->append(buf->data(), rv);
- }
}
result_ = *total_bytes_written_;
@@ -646,6 +649,8 @@ TEST_F(FileStreamTest, WriteRead) {
EXPECT_LT(0, rv);
EXPECT_EQ(kTestDataSize, total_bytes_written);
+ callback.ValidateWrittenData();
+
stream.reset();
EXPECT_TRUE(base::GetFileSize(temp_file_path(), &file_size));
« net/base/file_stream_context_win.cc ('K') | « net/base/file_stream_context_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698