OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "webkit/browser/fileapi/async_file_test_helper.h" | 15 #include "webkit/browser/fileapi/async_file_test_helper.h" |
16 #include "webkit/browser/fileapi/file_system_context.h" | 16 #include "webkit/browser/fileapi/file_system_context.h" |
17 #include "webkit/browser/fileapi/file_system_mount_point_provider.h" | 17 #include "webkit/browser/fileapi/file_system_mount_point_provider.h" |
18 #include "webkit/browser/fileapi/file_system_operation.h" | 18 #include "webkit/browser/fileapi/file_system_operation.h" |
19 #include "webkit/browser/fileapi/file_system_url.h" | 19 #include "webkit/browser/fileapi/file_system_url.h" |
20 #include "webkit/browser/fileapi/mock_file_system_context.h" | 20 #include "webkit/browser/fileapi/mock_file_system_context.h" |
21 #include "webkit/browser/fileapi/test_file_set.h" | 21 #include "webkit/browser/fileapi/test_file_set.h" |
22 #include "webkit/common/fileapi/file_system_util.h" | 22 #include "webkit/common/fileapi/file_system_util.h" |
23 #include "webkit/quota/mock_quota_manager.h" | 23 #include "webkit/quota/mock_quota_manager.h" |
24 #include "webkit/quota/quota_manager.h" | 24 #include "webkit/quota/quota_manager.h" |
25 | 25 |
26 namespace fileapi { | 26 namespace fileapi { |
27 | 27 |
28 typedef FileSystemOperation::FileEntryList FileEntryList; | 28 typedef FileSystemOperation::FileEntryList FileEntryList; |
29 | 29 |
| 30 namespace { |
| 31 |
| 32 void ExpectOk(base::PlatformFileError error) { |
| 33 ASSERT_EQ(base::PLATFORM_FILE_OK, error); |
| 34 } |
| 35 |
| 36 } // namespace |
| 37 |
30 class CrossOperationTestHelper { | 38 class CrossOperationTestHelper { |
31 public: | 39 public: |
32 CrossOperationTestHelper( | 40 CrossOperationTestHelper( |
33 const GURL& origin, | 41 const GURL& origin, |
34 FileSystemType src_type, | 42 FileSystemType src_type, |
35 FileSystemType dest_type) | 43 FileSystemType dest_type) |
36 : origin_(origin), | 44 : origin_(origin), |
37 src_type_(src_type), | 45 src_type_(src_type), |
38 dest_type_(dest_type) {} | 46 dest_type_(dest_type) {} |
39 | 47 |
(...skipping 16 matching lines...) Expand all Loading... |
56 quota_manager_proxy_ = new quota::MockQuotaManagerProxy( | 64 quota_manager_proxy_ = new quota::MockQuotaManagerProxy( |
57 quota_manager_, | 65 quota_manager_, |
58 base::MessageLoopProxy::current()); | 66 base::MessageLoopProxy::current()); |
59 file_system_context_ = CreateFileSystemContextForTesting( | 67 file_system_context_ = CreateFileSystemContextForTesting( |
60 quota_manager_proxy_, | 68 quota_manager_proxy_, |
61 base_dir); | 69 base_dir); |
62 | 70 |
63 // Prepare the origin's root directory. | 71 // Prepare the origin's root directory. |
64 FileSystemMountPointProvider* mount_point_provider = | 72 FileSystemMountPointProvider* mount_point_provider = |
65 file_system_context_->GetMountPointProvider(src_type_); | 73 file_system_context_->GetMountPointProvider(src_type_); |
66 mount_point_provider->GetFileSystemRootPathOnFileThread( | 74 mount_point_provider->ValidateFileSystemRoot( |
67 SourceURL(std::string()), true /* create */); | 75 origin_, src_type_, true /* create */, base::Bind(&ExpectOk)); |
68 mount_point_provider = | 76 mount_point_provider = |
69 file_system_context_->GetMountPointProvider(dest_type_); | 77 file_system_context_->GetMountPointProvider(dest_type_); |
70 mount_point_provider->GetFileSystemRootPathOnFileThread( | 78 mount_point_provider->ValidateFileSystemRoot( |
71 DestURL(std::string()), true /* create */); | 79 origin_, dest_type_, true /* create */, base::Bind(&ExpectOk)); |
| 80 base::MessageLoop::current()->RunUntilIdle(); |
72 | 81 |
73 // Grant relatively big quota initially. | 82 // Grant relatively big quota initially. |
74 quota_manager_->SetQuota(origin_, | 83 quota_manager_->SetQuota(origin_, |
75 FileSystemTypeToQuotaStorageType(src_type_), | 84 FileSystemTypeToQuotaStorageType(src_type_), |
76 1024 * 1024); | 85 1024 * 1024); |
77 quota_manager_->SetQuota(origin_, | 86 quota_manager_->SetQuota(origin_, |
78 FileSystemTypeToQuotaStorageType(dest_type_), | 87 FileSystemTypeToQuotaStorageType(dest_type_), |
79 1024 * 1024); | 88 1024 * 1024); |
80 } | 89 } |
81 | 90 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 test::kRegularTestCaseSize); | 416 test::kRegularTestCaseSize); |
408 | 417 |
409 int64 src_new_usage = helper.GetSourceUsage(); | 418 int64 src_new_usage = helper.GetSourceUsage(); |
410 ASSERT_EQ(src_initial_usage, src_new_usage); | 419 ASSERT_EQ(src_initial_usage, src_new_usage); |
411 | 420 |
412 int64 dest_increase = helper.GetDestUsage() - dest_initial_usage; | 421 int64 dest_increase = helper.GetDestUsage() - dest_initial_usage; |
413 ASSERT_EQ(src_increase, dest_increase); | 422 ASSERT_EQ(src_increase, dest_increase); |
414 } | 423 } |
415 | 424 |
416 } // namespace fileapi | 425 } // namespace fileapi |
OLD | NEW |