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 <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "base/run_loop.h" | |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "net/base/io_buffer.h" | 19 #include "net/base/io_buffer.h" |
19 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
20 #include "net/base/test_completion_callback.h" | 21 #include "net/base/test_completion_callback.h" |
21 #include "net/base/upload_bytes_element_reader.h" | 22 #include "net/base/upload_bytes_element_reader.h" |
22 #include "net/base/upload_file_element_reader.h" | 23 #include "net/base/upload_file_element_reader.h" |
23 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "testing/platform_test.h" | 26 #include "testing/platform_test.h" |
26 | 27 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 int init_result_; | 117 int init_result_; |
117 | 118 |
118 // Result value returned from Read(). | 119 // Result value returned from Read(). |
119 int read_result_; | 120 int read_result_; |
120 }; | 121 }; |
121 | 122 |
122 } // namespace | 123 } // namespace |
123 | 124 |
124 class UploadDataStreamTest : public PlatformTest { | 125 class UploadDataStreamTest : public PlatformTest { |
125 public: | 126 public: |
126 virtual void SetUp() OVERRIDE { | 127 UploadDataStreamTest() { |
127 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 128 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
128 } | 129 } |
130 ~UploadDataStreamTest() { | |
Ryan Sleevi
2013/09/13 21:57:27
style nit: virtual
| |
131 element_readers_.clear(); | |
132 base::RunLoop().RunUntilIdle(); | |
133 } | |
129 | 134 |
130 void FileChangedHelper(const base::FilePath& file_path, | 135 void FileChangedHelper(const base::FilePath& file_path, |
131 const base::Time& time, | 136 const base::Time& time, |
132 bool error_expected); | 137 bool error_expected); |
133 | 138 |
134 base::ScopedTempDir temp_dir_; | 139 base::ScopedTempDir temp_dir_; |
135 ScopedVector<UploadElementReader> element_readers_; | 140 ScopedVector<UploadElementReader> element_readers_; |
136 }; | 141 }; |
137 | 142 |
138 TEST_F(UploadDataStreamTest, EmptyUploadData) { | 143 TEST_F(UploadDataStreamTest, EmptyUploadData) { |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
805 wrapped_buffer2.get(), buf2.size(), read_callback2.callback())); | 810 wrapped_buffer2.get(), buf2.size(), read_callback2.callback())); |
806 EXPECT_EQ(static_cast<int>(buf2.size()), read_callback2.WaitForResult()); | 811 EXPECT_EQ(static_cast<int>(buf2.size()), read_callback2.WaitForResult()); |
807 EXPECT_EQ(expected_data, buf2); | 812 EXPECT_EQ(expected_data, buf2); |
808 EXPECT_TRUE(stream.IsEOF()); | 813 EXPECT_TRUE(stream.IsEOF()); |
809 | 814 |
810 // Make sure callbacks are not called for cancelled operations. | 815 // Make sure callbacks are not called for cancelled operations. |
811 EXPECT_FALSE(read_callback1.have_result()); | 816 EXPECT_FALSE(read_callback1.have_result()); |
812 } | 817 } |
813 | 818 |
814 } // namespace net | 819 } // namespace net |
OLD | NEW |