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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "content/browser/fileapi/mock_file_change_observer.h" | 12 #include "content/browser/fileapi/mock_file_change_observer.h" |
| 13 #include "content/browser/quota/mock_quota_manager.h" |
13 #include "content/public/test/mock_blob_url_request_context.h" | 14 #include "content/public/test/mock_blob_url_request_context.h" |
14 #include "content/public/test/test_file_system_backend.h" | 15 #include "content/public/test/test_file_system_backend.h" |
15 #include "content/public/test/test_file_system_context.h" | 16 #include "content/public/test/test_file_system_context.h" |
16 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
17 #include "net/url_request/url_request_context.h" | 18 #include "net/url_request/url_request_context.h" |
18 #include "net/url_request/url_request_job.h" | 19 #include "net/url_request/url_request_job.h" |
19 #include "net/url_request/url_request_job_factory_impl.h" | 20 #include "net/url_request/url_request_job_factory_impl.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "url/gurl.h" | 22 #include "url/gurl.h" |
22 #include "webkit/browser/blob/blob_storage_context.h" | 23 #include "webkit/browser/blob/blob_storage_context.h" |
23 #include "webkit/browser/blob/blob_url_request_job.h" | 24 #include "webkit/browser/blob/blob_url_request_job.h" |
24 #include "webkit/browser/fileapi/file_system_context.h" | 25 #include "webkit/browser/fileapi/file_system_context.h" |
25 #include "webkit/browser/fileapi/file_system_file_util.h" | 26 #include "webkit/browser/fileapi/file_system_file_util.h" |
26 #include "webkit/browser/fileapi/file_system_operation_context.h" | 27 #include "webkit/browser/fileapi/file_system_operation_context.h" |
27 #include "webkit/browser/fileapi/file_system_operation_runner.h" | 28 #include "webkit/browser/fileapi/file_system_operation_runner.h" |
28 #include "webkit/browser/fileapi/local_file_util.h" | 29 #include "webkit/browser/fileapi/local_file_util.h" |
29 #include "webkit/browser/quota/mock_quota_manager.h" | |
30 #include "webkit/common/blob/blob_data.h" | 30 #include "webkit/common/blob/blob_data.h" |
31 #include "webkit/common/fileapi/file_system_util.h" | 31 #include "webkit/common/fileapi/file_system_util.h" |
32 | 32 |
33 using fileapi::FileSystemOperation; | 33 using fileapi::FileSystemOperation; |
34 using fileapi::FileSystemOperationRunner; | 34 using fileapi::FileSystemOperationRunner; |
35 using fileapi::FileSystemURL; | 35 using fileapi::FileSystemURL; |
36 using content::MockBlobURLRequestContext; | 36 using content::MockBlobURLRequestContext; |
37 using content::ScopedTextBlob; | 37 using content::ScopedTextBlob; |
38 | 38 |
39 namespace content { | 39 namespace content { |
(...skipping 20 matching lines...) Expand all Loading... |
60 complete_(false), | 60 complete_(false), |
61 weak_factory_(this) { | 61 weak_factory_(this) { |
62 change_observers_ = fileapi::MockFileChangeObserver::CreateList( | 62 change_observers_ = fileapi::MockFileChangeObserver::CreateList( |
63 &change_observer_); | 63 &change_observer_); |
64 } | 64 } |
65 | 65 |
66 virtual void SetUp() { | 66 virtual void SetUp() { |
67 ASSERT_TRUE(dir_.CreateUniqueTempDir()); | 67 ASSERT_TRUE(dir_.CreateUniqueTempDir()); |
68 | 68 |
69 quota_manager_ = | 69 quota_manager_ = |
70 new quota::MockQuotaManager(false /* is_incognito */, | 70 new MockQuotaManager(false /* is_incognito */, |
71 dir_.path(), | 71 dir_.path(), |
72 base::MessageLoopProxy::current().get(), | 72 base::MessageLoopProxy::current().get(), |
73 base::MessageLoopProxy::current().get(), | 73 base::MessageLoopProxy::current().get(), |
74 NULL /* special storage policy */); | 74 NULL /* special storage policy */); |
75 virtual_path_ = base::FilePath(FILE_PATH_LITERAL("temporary file")); | 75 virtual_path_ = base::FilePath(FILE_PATH_LITERAL("temporary file")); |
76 | 76 |
77 file_system_context_ = CreateFileSystemContextForTesting( | 77 file_system_context_ = CreateFileSystemContextForTesting( |
78 quota_manager_->proxy(), dir_.path()); | 78 quota_manager_->proxy(), dir_.path()); |
79 url_request_context_.reset( | 79 url_request_context_.reset( |
80 new MockBlobURLRequestContext(file_system_context_.get())); | 80 new MockBlobURLRequestContext(file_system_context_.get())); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 void DidCancel(base::File::Error status) { | 147 void DidCancel(base::File::Error status) { |
148 cancel_status_ = status; | 148 cancel_status_ = status; |
149 } | 149 } |
150 | 150 |
151 const MockBlobURLRequestContext& url_request_context() const { | 151 const MockBlobURLRequestContext& url_request_context() const { |
152 return *url_request_context_; | 152 return *url_request_context_; |
153 } | 153 } |
154 | 154 |
155 scoped_refptr<fileapi::FileSystemContext> file_system_context_; | 155 scoped_refptr<fileapi::FileSystemContext> file_system_context_; |
156 scoped_refptr<quota::MockQuotaManager> quota_manager_; | 156 scoped_refptr<MockQuotaManager> quota_manager_; |
157 | 157 |
158 base::MessageLoopForIO loop_; | 158 base::MessageLoopForIO loop_; |
159 | 159 |
160 base::ScopedTempDir dir_; | 160 base::ScopedTempDir dir_; |
161 base::FilePath virtual_path_; | 161 base::FilePath virtual_path_; |
162 | 162 |
163 // For post-operation status. | 163 // For post-operation status. |
164 base::File::Error status_; | 164 base::File::Error status_; |
165 base::File::Error cancel_status_; | 165 base::File::Error cancel_status_; |
166 int64 bytes_written_; | 166 int64 bytes_written_; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 EXPECT_EQ(base::File::FILE_ERROR_ABORT, status()); | 323 EXPECT_EQ(base::File::FILE_ERROR_ABORT, status()); |
324 EXPECT_EQ(base::File::FILE_OK, cancel_status()); | 324 EXPECT_EQ(base::File::FILE_OK, cancel_status()); |
325 EXPECT_TRUE(complete()); | 325 EXPECT_TRUE(complete()); |
326 | 326 |
327 EXPECT_EQ(0, change_observer()->get_and_reset_modify_file_count()); | 327 EXPECT_EQ(0, change_observer()->get_and_reset_modify_file_count()); |
328 } | 328 } |
329 | 329 |
330 // TODO(ericu,dmikurube,kinuko): Add more tests for cancel cases. | 330 // TODO(ericu,dmikurube,kinuko): Add more tests for cancel cases. |
331 | 331 |
332 } // namespace content | 332 } // namespace content |
OLD | NEW |