OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" |
10 #include "base/file_path.h" | 11 #include "base/file_path.h" |
11 #include "base/file_util.h" | 12 #include "base/file_util.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/message_loop.h" |
13 #include "base/time.h" | 15 #include "base/time.h" |
14 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
15 #include "net/base/upload_data.h" | 17 #include "net/base/upload_data.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "testing/platform_test.h" | 19 #include "testing/platform_test.h" |
18 | 20 |
19 namespace net { | 21 namespace net { |
20 | 22 |
21 namespace { | 23 namespace { |
22 | 24 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 ASSERT_EQ(static_cast<int>(kTestDataSize), | 68 ASSERT_EQ(static_cast<int>(kTestDataSize), |
67 file_util::WriteFile(temp_file_path, kTestData, kTestDataSize)); | 69 file_util::WriteFile(temp_file_path, kTestData, kTestDataSize)); |
68 const uint64 kFakeSize = kTestDataSize*2; | 70 const uint64 kFakeSize = kTestDataSize*2; |
69 | 71 |
70 std::vector<UploadData::Element> elements; | 72 std::vector<UploadData::Element> elements; |
71 UploadData::Element element; | 73 UploadData::Element element; |
72 element.SetToFilePath(temp_file_path); | 74 element.SetToFilePath(temp_file_path); |
73 element.SetContentLength(kFakeSize); | 75 element.SetContentLength(kFakeSize); |
74 elements.push_back(element); | 76 elements.push_back(element); |
75 upload_data_->SetElements(elements); | 77 upload_data_->SetElements(elements); |
76 EXPECT_EQ(kFakeSize, upload_data_->GetContentLength()); | 78 EXPECT_EQ(kFakeSize, upload_data_->GetContentLengthSyncForTesting()); |
77 | 79 |
78 scoped_ptr<UploadDataStream> stream(new UploadDataStream(upload_data_)); | 80 scoped_ptr<UploadDataStream> stream(new UploadDataStream(upload_data_)); |
79 ASSERT_EQ(OK, stream->Init()); | 81 ASSERT_EQ(OK, stream->Init()); |
80 ASSERT_TRUE(stream.get()); | 82 ASSERT_TRUE(stream.get()); |
81 EXPECT_EQ(kFakeSize, stream->size()); | 83 EXPECT_EQ(kFakeSize, stream->size()); |
82 EXPECT_EQ(0U, stream->position()); | 84 EXPECT_EQ(0U, stream->position()); |
83 EXPECT_FALSE(stream->eof()); | 85 EXPECT_FALSE(stream->eof()); |
84 uint64 read_counter = 0; | 86 uint64 read_counter = 0; |
85 while (!stream->eof()) { | 87 while (!stream->eof()) { |
86 read_counter += stream->buf_len(); | 88 read_counter += stream->buf_len(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 128 |
127 // Test file changed. | 129 // Test file changed. |
128 FileChangedHelper(temp_file_path, | 130 FileChangedHelper(temp_file_path, |
129 file_info.last_modified - base::TimeDelta::FromSeconds(1), | 131 file_info.last_modified - base::TimeDelta::FromSeconds(1), |
130 true); | 132 true); |
131 | 133 |
132 file_util::Delete(temp_file_path, false); | 134 file_util::Delete(temp_file_path, false); |
133 } | 135 } |
134 | 136 |
135 } // namespace net | 137 } // namespace net |
OLD | NEW |