Chromium Code Reviews| Index: net/spdy/spdy_network_transaction_unittest.cc |
| diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc |
| index 46cebe3f59384038ca741b61f6e87bd0b004ad1a..af82e3727e4ba9b9a348b3746bf3c47b382d3263 100644 |
| --- a/net/spdy/spdy_network_transaction_unittest.cc |
| +++ b/net/spdy/spdy_network_transaction_unittest.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/memory/scoped_vector.h" |
| #include "base/run_loop.h" |
| #include "base/stl_util.h" |
| +#include "base/test/test_file_util.h" |
| #include "net/base/auth.h" |
| #include "net/base/net_log_unittest.h" |
| #include "net/base/request_priority.h" |
| @@ -459,6 +460,33 @@ class SpdyNetworkTransactionTest |
| return google_post_request_; |
| } |
| + const HttpRequestInfo& CreateUnreadableFilePostRequest() { |
| + if (google_post_request_initialized_) |
| + return google_post_request_; |
| + |
| + base::FilePath file_path; |
| + CHECK(file_util::CreateTemporaryFileInDir(temp_dir_.path(), &file_path)); |
| + CHECK_EQ(static_cast<int>(kUploadDataSize), |
| + file_util::WriteFile(file_path, kUploadData, kUploadDataSize)); |
| + CHECK(file_util::MakeFileUnreadable(file_path)); |
| + |
| + ScopedVector<UploadElementReader> element_readers; |
| + element_readers.push_back( |
| + new UploadFileElementReader(base::MessageLoopProxy::current().get(), |
| + file_path, |
| + 0, |
| + kUploadDataSize, |
| + base::Time())); |
| + upload_data_stream_.reset( |
| + new UploadDataStream(element_readers.Pass(), 0)); |
| + |
| + google_post_request_.method = "POST"; |
| + google_post_request_.url = GURL(kDefaultURL); |
| + google_post_request_.upload_data_stream = upload_data_stream_.get(); |
| + google_post_request_initialized_ = true; |
| + return google_post_request_; |
| + } |
| + |
| const HttpRequestInfo& CreateComplexPostRequest() { |
| if (!google_post_request_initialized_) { |
| const int kFileRangeOffset = 1; |
| @@ -1785,6 +1813,35 @@ TEST_P(SpdyNetworkTransactionTest, FilePost) { |
| EXPECT_EQ("hello!", out.response_data); |
| } |
| +// Test that a POST with a unreadable file fails. |
| +TEST_P(SpdyNetworkTransactionTest, UnreadableFilePost) { |
| + scoped_ptr<SpdyFrame> req( |
| + spdy_util_.ConstructSpdyPost( |
| + kRequestUrl, 1, kUploadDataSize, LOWEST, NULL, 0)); |
| + scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); |
| + MockWrite writes[] = { |
| + CreateMockWrite(*req), |
| + }; |
| + MockRead reads[] = { |
| + CreateMockRead(*resp), |
| + }; |
| + |
| + DelayedSocketData data(2, reads, arraysize(reads), writes, arraysize(writes)); |
| + NormalSpdyTransactionHelper helper(CreateUnreadableFilePostRequest(), |
| + DEFAULT_PRIORITY, |
| + BoundNetLog(), GetParam(), NULL); |
| + helper.RunPreTestSetup(); |
| + helper.AddData(&data); |
| + TestCompletionCallback callback; |
|
hashimoto
2013/10/29 06:55:26
I'm not familiar with the code in this file, but i
tzik
2013/11/07 04:42:55
Ah, I though it expects the transaction complete s
|
| + int rv = helper.trans()->Start(&CreatePostRequest(), |
| + callback.callback(), |
| + BoundNetLog()); |
| + EXPECT_EQ(ERR_IO_PENDING, rv); |
| + |
| + base::RunLoop().RunUntilIdle(); |
| + helper.VerifyDataNotConsumed(); |
|
hashimoto
2013/10/29 06:55:26
How about doing some verification against helper.o
tzik
2013/10/31 12:19:28
Done.
|
| +} |
| + |
| // Test that a complex POST works. |
| TEST_P(SpdyNetworkTransactionTest, ComplexPost) { |
| scoped_ptr<SpdyFrame> req( |