OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This test checks the entire behavior of FileSystem usage and quota, such as: | 5 // This test checks the entire behavior of FileSystem usage and quota, such as: |
6 // 1) the actual size of files on disk, | 6 // 1) the actual size of files on disk, |
7 // 2) the described size in .usage, and | 7 // 2) the described size in .usage, and |
8 // 3) the result of QuotaManager::GetUsageAndQuota. | 8 // 3) the result of QuotaManager::GetUsageAndQuota. |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_callback_factory.h" | 12 #include "base/memory/scoped_callback_factory.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/platform_file.h" | 15 #include "base/platform_file.h" |
16 #include "base/scoped_temp_dir.h" | 16 #include "base/scoped_temp_dir.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 18 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
19 #include "webkit/fileapi/file_system_context.h" | 19 #include "webkit/fileapi/file_system_context.h" |
20 #include "webkit/fileapi/file_system_operation.h" | 20 #include "webkit/fileapi/file_system_operation.h" |
21 #include "webkit/fileapi/file_system_test_helper.h" | 21 #include "webkit/fileapi/file_system_test_helper.h" |
22 #include "webkit/fileapi/file_system_usage_cache.h" | 22 #include "webkit/fileapi/file_system_usage_cache.h" |
23 #include "webkit/fileapi/file_system_util.h" | 23 #include "webkit/fileapi/file_system_util.h" |
24 #include "webkit/fileapi/local_file_system_file_util.h" | 24 #include "webkit/fileapi/local_file_util.h" |
25 #include "webkit/fileapi/quota_file_util.h" | 25 #include "webkit/fileapi/quota_file_util.h" |
26 #include "webkit/quota/mock_special_storage_policy.h" | 26 #include "webkit/quota/mock_special_storage_policy.h" |
27 #include "webkit/quota/quota_manager.h" | 27 #include "webkit/quota/quota_manager.h" |
28 | 28 |
29 namespace fileapi { | 29 namespace fileapi { |
30 | 30 |
31 const int kFileOperationStatusNotSet = 1; | 31 const int kFileOperationStatusNotSet = 1; |
32 | 32 |
33 class FileSystemQuotaTest : public testing::Test { | 33 class FileSystemQuotaTest : public testing::Test { |
34 public: | 34 public: |
35 FileSystemQuotaTest() | 35 FileSystemQuotaTest() |
36 : quota_file_util_(QuotaFileUtil::CreateDefault()), | 36 : quota_file_util_(QuotaFileUtil::CreateDefault()), |
37 local_file_util_(new LocalFileSystemFileUtil(quota_file_util_)), | 37 local_file_util_(new LocalFileUtil(quota_file_util_)), |
38 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 38 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
39 file_path_cost_(0), | 39 file_path_cost_(0), |
40 status_(kFileOperationStatusNotSet), | 40 status_(kFileOperationStatusNotSet), |
41 quota_status_(quota::kQuotaStatusUnknown), | 41 quota_status_(quota::kQuotaStatusUnknown), |
42 usage_(-1), | 42 usage_(-1), |
43 quota_(-1) {} | 43 quota_(-1) {} |
44 | 44 |
45 FileSystemOperation* operation(); | 45 FileSystemOperation* operation(); |
46 | 46 |
47 void set_status(int status) { status_ = status; } | 47 void set_status(int status) { status_ = status; } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 FilePath child_file2_path_; | 125 FilePath child_file2_path_; |
126 FilePath grandchild_file1_path_; | 126 FilePath grandchild_file1_path_; |
127 FilePath grandchild_file2_path_; | 127 FilePath grandchild_file2_path_; |
128 | 128 |
129 protected: | 129 protected: |
130 FileSystemTestOriginHelper test_helper_; | 130 FileSystemTestOriginHelper test_helper_; |
131 | 131 |
132 ScopedTempDir work_dir_; | 132 ScopedTempDir work_dir_; |
133 scoped_refptr<quota::QuotaManager> quota_manager_; | 133 scoped_refptr<quota::QuotaManager> quota_manager_; |
134 QuotaFileUtil* quota_file_util_; | 134 QuotaFileUtil* quota_file_util_; |
135 scoped_ptr<LocalFileSystemFileUtil> local_file_util_; | 135 scoped_ptr<LocalFileUtil> local_file_util_; |
136 | 136 |
137 base::ScopedCallbackFactory<FileSystemQuotaTest> callback_factory_; | 137 base::ScopedCallbackFactory<FileSystemQuotaTest> callback_factory_; |
138 | 138 |
139 int64 file_path_cost_; | 139 int64 file_path_cost_; |
140 | 140 |
141 // For post-operation status. | 141 // For post-operation status. |
142 int status_; | 142 int status_; |
143 quota::QuotaStatusCode quota_status_; | 143 quota::QuotaStatusCode quota_status_; |
144 int64 usage_; | 144 int64 usage_; |
145 int64 quota_; | 145 int64 quota_; |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 EXPECT_EQ(-1, SizeInUsageFile()); | 426 EXPECT_EQ(-1, SizeInUsageFile()); |
427 | 427 |
428 GetUsageAndQuotaFromQuotaManager(); | 428 GetUsageAndQuotaFromQuotaManager(); |
429 EXPECT_EQ(quota::kQuotaStatusOk, quota_status()); | 429 EXPECT_EQ(quota::kQuotaStatusOk, quota_status()); |
430 EXPECT_EQ(all_file_size + file_path_cost(), SizeInUsageFile()); | 430 EXPECT_EQ(all_file_size + file_path_cost(), SizeInUsageFile()); |
431 EXPECT_EQ(all_file_size + file_path_cost(), usage()); | 431 EXPECT_EQ(all_file_size + file_path_cost(), usage()); |
432 ASSERT_LT(all_file_size, quota()); | 432 ASSERT_LT(all_file_size, quota()); |
433 } | 433 } |
434 | 434 |
435 } // namespace fileapi | 435 } // namespace fileapi |
OLD | NEW |