OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "storage/browser/fileapi/file_system_file_stream_reader.h" | 5 #include "storage/browser/fileapi/file_system_file_stream_reader.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 | 61 |
62 void NeverCalled(int unused) { ADD_FAILURE(); } | 62 void NeverCalled(int unused) { ADD_FAILURE(); } |
63 | 63 |
64 } // namespace | 64 } // namespace |
65 | 65 |
66 class FileSystemFileStreamReaderTest : public testing::Test { | 66 class FileSystemFileStreamReaderTest : public testing::Test { |
67 public: | 67 public: |
68 FileSystemFileStreamReaderTest() {} | 68 FileSystemFileStreamReaderTest() {} |
69 | 69 |
70 virtual void SetUp() OVERRIDE { | 70 virtual void SetUp() override { |
71 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 71 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
72 | 72 |
73 file_system_context_ = CreateFileSystemContextForTesting( | 73 file_system_context_ = CreateFileSystemContextForTesting( |
74 NULL, temp_dir_.path()); | 74 NULL, temp_dir_.path()); |
75 | 75 |
76 file_system_context_->OpenFileSystem( | 76 file_system_context_->OpenFileSystem( |
77 GURL(kURLOrigin), | 77 GURL(kURLOrigin), |
78 storage::kFileSystemTypeTemporary, | 78 storage::kFileSystemTypeTemporary, |
79 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, | 79 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, |
80 base::Bind(&OnOpenFileSystem)); | 80 base::Bind(&OnOpenFileSystem)); |
81 base::RunLoop().RunUntilIdle(); | 81 base::RunLoop().RunUntilIdle(); |
82 | 82 |
83 WriteFile(kTestFileName, kTestData, kTestDataSize, | 83 WriteFile(kTestFileName, kTestData, kTestDataSize, |
84 &test_file_modification_time_); | 84 &test_file_modification_time_); |
85 } | 85 } |
86 | 86 |
87 virtual void TearDown() OVERRIDE { | 87 virtual void TearDown() override { |
88 base::RunLoop().RunUntilIdle(); | 88 base::RunLoop().RunUntilIdle(); |
89 } | 89 } |
90 | 90 |
91 protected: | 91 protected: |
92 storage::FileSystemFileStreamReader* CreateFileReader( | 92 storage::FileSystemFileStreamReader* CreateFileReader( |
93 const std::string& file_name, | 93 const std::string& file_name, |
94 int64 initial_offset, | 94 int64 initial_offset, |
95 const base::Time& expected_modification_time) { | 95 const base::Time& expected_modification_time) { |
96 return new FileSystemFileStreamReader(file_system_context_.get(), | 96 return new FileSystemFileStreamReader(file_system_context_.get(), |
97 GetFileSystemURL(file_name), | 97 GetFileSystemURL(file_name), |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 new net::IOBufferWithSize(kTestDataSize)); | 263 new net::IOBufferWithSize(kTestDataSize)); |
264 int rv = reader->Read(buf.get(), buf->size(), base::Bind(&NeverCalled)); | 264 int rv = reader->Read(buf.get(), buf->size(), base::Bind(&NeverCalled)); |
265 ASSERT_TRUE(rv == net::ERR_IO_PENDING || rv >= 0); | 265 ASSERT_TRUE(rv == net::ERR_IO_PENDING || rv >= 0); |
266 | 266 |
267 // Delete immediately. | 267 // Delete immediately. |
268 // Should not crash; nor should NeverCalled be callback. | 268 // Should not crash; nor should NeverCalled be callback. |
269 reader.reset(); | 269 reader.reset(); |
270 } | 270 } |
271 | 271 |
272 } // namespace content | 272 } // namespace content |
OLD | NEW |