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..9edbdcc92869d5afa7dff602c71fe28ed4b77152 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,18 @@ 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> body(spdy_util_.ConstructSpdyBodyFrame(1, true)); |
|
hashimoto
2013/10/29 04:08:59
Do we need |req| and |body|?
tzik
2013/10/29 05:48:02
Hmm? Let me reconsider... This test doesn't look m
tzik
2013/10/29 06:06:19
OK, I updated the test.
|
| + NormalSpdyTransactionHelper helper(CreateUnreadableFilePostRequest(), |
| + DEFAULT_PRIORITY, |
| + BoundNetLog(), GetParam(), NULL); |
| + helper.VerifyDataNotConsumed(); |
| +} |
| + |
| // Test that a complex POST works. |
| TEST_P(SpdyNetworkTransactionTest, ComplexPost) { |
| scoped_ptr<SpdyFrame> req( |