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

Side by Side Diff: net/base/upload_data_stream_unittest.cc

Issue 1250002: Report unreadable files as size zero when uploading. (Closed)
Patch Set: Address comments Created 10 years, 9 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 unified diff | Download patch
« no previous file with comments | « net/base/upload_data_stream.cc ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/upload_data_stream.h" 5 #include "net/base/upload_data_stream.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 scoped_ptr<UploadDataStream> stream( 72 scoped_ptr<UploadDataStream> stream(
73 UploadDataStream::Create(upload_data_, NULL)); 73 UploadDataStream::Create(upload_data_, NULL));
74 ASSERT_TRUE(stream.get()); 74 ASSERT_TRUE(stream.get());
75 EXPECT_FALSE(stream->eof()); 75 EXPECT_FALSE(stream->eof());
76 uint64 read_counter = 0; 76 uint64 read_counter = 0;
77 while (!stream->eof()) { 77 while (!stream->eof()) {
78 read_counter += stream->buf_len(); 78 read_counter += stream->buf_len();
79 stream->DidConsume(stream->buf_len()); 79 stream->DidConsume(stream->buf_len());
80 } 80 }
81 EXPECT_LT(read_counter, stream->size()); 81 // UpdateDataStream will pad out the file with 0 bytes so that the HTTP
82 // transaction doesn't hang. Therefore we expected the full size.
83 EXPECT_EQ(read_counter, stream->size());
82 84
83 file_util::Delete(temp_file_path, false); 85 file_util::Delete(temp_file_path, false);
84 } 86 }
85 87
86 void UploadDataStreamTest::FileChangedHelper(const FilePath& file_path, 88 void UploadDataStreamTest::FileChangedHelper(const FilePath& file_path,
87 const base::Time& time, 89 const base::Time& time,
88 bool error_expected) { 90 bool error_expected) {
89 std::vector<UploadData::Element> elements; 91 std::vector<UploadData::Element> elements;
90 UploadData::Element element; 92 UploadData::Element element;
91 element.SetToFilePathRange(file_path, 1, 2, time); 93 element.SetToFilePathRange(file_path, 1, 2, time);
(...skipping 24 matching lines...) Expand all
116 // Test file changed. 118 // Test file changed.
117 FileChangedHelper(temp_file_path, 119 FileChangedHelper(temp_file_path,
118 file_info.last_modified - base::TimeDelta::FromSeconds(1), 120 file_info.last_modified - base::TimeDelta::FromSeconds(1),
119 true); 121 true);
120 122
121 file_util::Delete(temp_file_path, false); 123 file_util::Delete(temp_file_path, false);
122 } 124 }
123 125
124 } // namespace net 126 } // namespace net
125 127
OLDNEW
« no previous file with comments | « net/base/upload_data_stream.cc ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698