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 <map> | 5 #include <map> |
6 #include <queue> | 6 #include <queue> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "webkit/browser/fileapi/file_system_context.h" | 27 #include "webkit/browser/fileapi/file_system_context.h" |
28 #include "webkit/browser/fileapi/file_system_operation.h" | 28 #include "webkit/browser/fileapi/file_system_operation.h" |
29 #include "webkit/browser/fileapi/file_system_url.h" | 29 #include "webkit/browser/fileapi/file_system_url.h" |
30 #include "webkit/browser/quota/quota_manager.h" | 30 #include "webkit/browser/quota/quota_manager.h" |
31 #include "webkit/common/fileapi/file_system_util.h" | 31 #include "webkit/common/fileapi/file_system_util.h" |
32 | 32 |
33 using content::AsyncFileTestHelper; | 33 using content::AsyncFileTestHelper; |
34 using fileapi::CopyOrMoveOperationDelegate; | 34 using fileapi::CopyOrMoveOperationDelegate; |
35 using fileapi::FileStreamWriter; | 35 using fileapi::FileStreamWriter; |
36 using fileapi::FileSystemOperation; | 36 using fileapi::FileSystemOperation; |
37 using fileapi::FileSystemType; | |
38 using fileapi::FileSystemURL; | 37 using fileapi::FileSystemURL; |
39 | 38 |
40 namespace content { | 39 namespace content { |
41 | 40 |
42 typedef fileapi::FileSystemOperation::FileEntryList FileEntryList; | 41 typedef fileapi::FileSystemOperation::FileEntryList FileEntryList; |
43 | 42 |
44 namespace { | 43 namespace { |
45 | 44 |
46 void ExpectOk(const GURL& origin_url, | 45 void ExpectOk(const GURL& origin_url, |
47 const std::string& name, | 46 const std::string& name, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 157 |
159 private: | 158 private: |
160 base::Thread* thread_; | 159 base::Thread* thread_; |
161 DISALLOW_COPY_AND_ASSIGN(ScopedThreadStopper); | 160 DISALLOW_COPY_AND_ASSIGN(ScopedThreadStopper); |
162 }; | 161 }; |
163 | 162 |
164 } // namespace | 163 } // namespace |
165 | 164 |
166 class CopyOrMoveOperationTestHelper { | 165 class CopyOrMoveOperationTestHelper { |
167 public: | 166 public: |
168 CopyOrMoveOperationTestHelper( | 167 CopyOrMoveOperationTestHelper(const GURL& origin, |
169 const GURL& origin, | 168 fileapi::FileSystemType src_type, |
170 FileSystemType src_type, | 169 fileapi::FileSystemType dest_type) |
171 FileSystemType dest_type) | 170 : origin_(origin), src_type_(src_type), dest_type_(dest_type) {} |
172 : origin_(origin), | |
173 src_type_(src_type), | |
174 dest_type_(dest_type) {} | |
175 | 171 |
176 ~CopyOrMoveOperationTestHelper() { | 172 ~CopyOrMoveOperationTestHelper() { |
177 file_system_context_ = NULL; | 173 file_system_context_ = NULL; |
178 quota_manager_proxy_->SimulateQuotaManagerDestroyed(); | 174 quota_manager_proxy_->SimulateQuotaManagerDestroyed(); |
179 quota_manager_ = NULL; | 175 quota_manager_ = NULL; |
180 quota_manager_proxy_ = NULL; | 176 quota_manager_proxy_ = NULL; |
181 base::RunLoop().RunUntilIdle(); | 177 base::RunLoop().RunUntilIdle(); |
182 } | 178 } |
183 | 179 |
184 void SetUp() { | 180 void SetUp() { |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 return AsyncFileTestHelper::FileExists( | 366 return AsyncFileTestHelper::FileExists( |
371 file_system_context_.get(), url, expected_size); | 367 file_system_context_.get(), url, expected_size); |
372 } | 368 } |
373 | 369 |
374 bool DirectoryExists(const FileSystemURL& url) { | 370 bool DirectoryExists(const FileSystemURL& url) { |
375 return AsyncFileTestHelper::DirectoryExists(file_system_context_.get(), | 371 return AsyncFileTestHelper::DirectoryExists(file_system_context_.get(), |
376 url); | 372 url); |
377 } | 373 } |
378 | 374 |
379 private: | 375 private: |
380 void GetUsageAndQuota(FileSystemType type, int64* usage, int64* quota) { | 376 void GetUsageAndQuota(fileapi::FileSystemType type, |
| 377 int64* usage, |
| 378 int64* quota) { |
381 quota::QuotaStatusCode status = AsyncFileTestHelper::GetUsageAndQuota( | 379 quota::QuotaStatusCode status = AsyncFileTestHelper::GetUsageAndQuota( |
382 quota_manager_.get(), origin_, type, usage, quota); | 380 quota_manager_.get(), origin_, type, usage, quota); |
383 ASSERT_EQ(quota::kQuotaStatusOk, status); | 381 ASSERT_EQ(quota::kQuotaStatusOk, status); |
384 } | 382 } |
385 | 383 |
386 private: | 384 private: |
387 base::ScopedTempDir base_; | 385 base::ScopedTempDir base_; |
388 | 386 |
389 const GURL origin_; | 387 const GURL origin_; |
390 const FileSystemType src_type_; | 388 const fileapi::FileSystemType src_type_; |
391 const FileSystemType dest_type_; | 389 const fileapi::FileSystemType dest_type_; |
392 | 390 |
393 base::MessageLoopForIO message_loop_; | 391 base::MessageLoopForIO message_loop_; |
394 scoped_refptr<fileapi::FileSystemContext> file_system_context_; | 392 scoped_refptr<fileapi::FileSystemContext> file_system_context_; |
395 scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_; | 393 scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_; |
396 scoped_refptr<MockQuotaManager> quota_manager_; | 394 scoped_refptr<MockQuotaManager> quota_manager_; |
397 | 395 |
398 DISALLOW_COPY_AND_ASSIGN(CopyOrMoveOperationTestHelper); | 396 DISALLOW_COPY_AND_ASSIGN(CopyOrMoveOperationTestHelper); |
399 }; | 397 }; |
400 | 398 |
401 TEST(LocalFileSystemCopyOrMoveOperationTest, CopySingleFile) { | 399 TEST(LocalFileSystemCopyOrMoveOperationTest, CopySingleFile) { |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 | 860 |
863 base::File::Error error = base::File::FILE_ERROR_FAILED; | 861 base::File::Error error = base::File::FILE_ERROR_FAILED; |
864 base::RunLoop run_loop; | 862 base::RunLoop run_loop; |
865 helper.Run(base::Bind(&AssignAndQuit, &run_loop, &error)); | 863 helper.Run(base::Bind(&AssignAndQuit, &run_loop, &error)); |
866 run_loop.Run(); | 864 run_loop.Run(); |
867 | 865 |
868 EXPECT_EQ(base::File::FILE_ERROR_ABORT, error); | 866 EXPECT_EQ(base::File::FILE_ERROR_ABORT, error); |
869 } | 867 } |
870 | 868 |
871 } // namespace content | 869 } // namespace content |
OLD | NEW |