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/file_stream.h" | 5 #include "net/base/file_stream.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 FileStream stream(base::MessageLoopProxy::current()); | 165 FileStream stream(base::MessageLoopProxy::current()); |
166 | 166 |
167 EXPECT_FALSE(stream.IsOpen()); | 167 EXPECT_FALSE(stream.IsOpen()); |
168 | 168 |
169 // Try seeking... | 169 // Try seeking... |
170 rv = stream.Seek(base::File::FROM_BEGIN, 5, callback64.callback()); | 170 rv = stream.Seek(base::File::FROM_BEGIN, 5, callback64.callback()); |
171 EXPECT_EQ(ERR_UNEXPECTED, callback64.GetResult(rv)); | 171 EXPECT_EQ(ERR_UNEXPECTED, callback64.GetResult(rv)); |
172 | 172 |
173 // Try reading... | 173 // Try reading... |
174 scoped_refptr<IOBufferWithSize> buf = new IOBufferWithSize(10); | 174 scoped_refptr<IOBufferWithSize> buf = new IOBufferWithSize(10); |
175 rv = stream.Read(buf, buf->size(), callback.callback()); | 175 rv = stream.Read(buf.get(), buf->size(), callback.callback()); |
176 EXPECT_EQ(ERR_UNEXPECTED, callback.GetResult(rv)); | 176 EXPECT_EQ(ERR_UNEXPECTED, callback.GetResult(rv)); |
177 } | 177 } |
178 | 178 |
179 TEST_F(FileStreamTest, Read) { | 179 TEST_F(FileStreamTest, Read) { |
180 int64 file_size; | 180 int64 file_size; |
181 EXPECT_TRUE(base::GetFileSize(temp_file_path(), &file_size)); | 181 EXPECT_TRUE(base::GetFileSize(temp_file_path(), &file_size)); |
182 | 182 |
183 FileStream stream(base::MessageLoopProxy::current()); | 183 FileStream stream(base::MessageLoopProxy::current()); |
184 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | | 184 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | |
185 base::File::FLAG_ASYNC; | 185 base::File::FLAG_ASYNC; |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 total_bytes_read += rv; | 874 total_bytes_read += rv; |
875 data_read.append(buf->data(), rv); | 875 data_read.append(buf->data(), rv); |
876 } | 876 } |
877 EXPECT_EQ(file_size, total_bytes_read); | 877 EXPECT_EQ(file_size, total_bytes_read); |
878 } | 878 } |
879 #endif | 879 #endif |
880 | 880 |
881 } // namespace | 881 } // namespace |
882 | 882 |
883 } // namespace net | 883 } // namespace net |
OLD | NEW |