| 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_operation.h" | 19 #include "webkit/fileapi/file_system_operation.h" |
| 20 #include "webkit/fileapi/file_system_test_helper.h" | 20 #include "webkit/fileapi/file_system_test_helper.h" |
| 21 #include "webkit/fileapi/file_system_usage_cache.h" | 21 #include "webkit/fileapi/file_system_usage_cache.h" |
| 22 #include "webkit/fileapi/file_system_util.h" | 22 #include "webkit/fileapi/file_system_util.h" |
| 23 #include "webkit/fileapi/local_file_system_file_util.h" | 23 #include "webkit/fileapi/local_file_util.h" |
| 24 #include "webkit/fileapi/quota_file_util.h" | 24 #include "webkit/fileapi/quota_file_util.h" |
| 25 #include "webkit/quota/quota_manager.h" | 25 #include "webkit/quota/quota_manager.h" |
| 26 | 26 |
| 27 namespace fileapi { | 27 namespace fileapi { |
| 28 | 28 |
| 29 const int kFileOperationStatusNotSet = 1; | 29 const int kFileOperationStatusNotSet = 1; |
| 30 | 30 |
| 31 class FileSystemQuotaTest : public testing::Test { | 31 class FileSystemQuotaTest : public testing::Test { |
| 32 public: | 32 public: |
| 33 FileSystemQuotaTest() | 33 FileSystemQuotaTest() |
| 34 : local_file_util_( | 34 : local_file_util_(new LocalFileUtil(QuotaFileUtil::CreateDefault())), |
| 35 new LocalFileSystemFileUtil(QuotaFileUtil::CreateDefault())), | |
| 36 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 35 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 37 status_(kFileOperationStatusNotSet), | 36 status_(kFileOperationStatusNotSet), |
| 38 quota_status_(quota::kQuotaStatusUnknown), | 37 quota_status_(quota::kQuotaStatusUnknown), |
| 39 usage_(-1), | 38 usage_(-1), |
| 40 quota_(-1) {} | 39 quota_(-1) {} |
| 41 | 40 |
| 42 FileSystemOperation* operation(); | 41 FileSystemOperation* operation(); |
| 43 | 42 |
| 44 void set_status(int status) { status_ = status; } | 43 void set_status(int status) { status_ = status; } |
| 45 int status() const { return status_; } | 44 int status() const { return status_; } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 FilePath child_file1_path_; | 113 FilePath child_file1_path_; |
| 115 FilePath child_file2_path_; | 114 FilePath child_file2_path_; |
| 116 FilePath grandchild_file1_path_; | 115 FilePath grandchild_file1_path_; |
| 117 FilePath grandchild_file2_path_; | 116 FilePath grandchild_file2_path_; |
| 118 | 117 |
| 119 protected: | 118 protected: |
| 120 FileSystemTestOriginHelper test_helper_; | 119 FileSystemTestOriginHelper test_helper_; |
| 121 | 120 |
| 122 ScopedTempDir work_dir_; | 121 ScopedTempDir work_dir_; |
| 123 scoped_refptr<quota::QuotaManager> quota_manager_; | 122 scoped_refptr<quota::QuotaManager> quota_manager_; |
| 124 scoped_ptr<LocalFileSystemFileUtil> local_file_util_; | 123 scoped_ptr<LocalFileUtil> local_file_util_; |
| 125 | 124 |
| 126 base::ScopedCallbackFactory<FileSystemQuotaTest> callback_factory_; | 125 base::ScopedCallbackFactory<FileSystemQuotaTest> callback_factory_; |
| 127 | 126 |
| 128 // For post-operation status. | 127 // For post-operation status. |
| 129 int status_; | 128 int status_; |
| 130 quota::QuotaStatusCode quota_status_; | 129 quota::QuotaStatusCode quota_status_; |
| 131 int64 usage_; | 130 int64 usage_; |
| 132 int64 quota_; | 131 int64 quota_; |
| 133 | 132 |
| 134 DISALLOW_COPY_AND_ASSIGN(FileSystemQuotaTest); | 133 DISALLOW_COPY_AND_ASSIGN(FileSystemQuotaTest); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 | 328 |
| 330 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size, ActualSize()); | 329 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size, ActualSize()); |
| 331 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size, SizeInUsageFile()); | 330 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size, SizeInUsageFile()); |
| 332 GetUsageAndQuotaFromQuotaManager(); | 331 GetUsageAndQuotaFromQuotaManager(); |
| 333 EXPECT_EQ(quota::kQuotaStatusOk, quota_status()); | 332 EXPECT_EQ(quota::kQuotaStatusOk, quota_status()); |
| 334 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size, usage()); | 333 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size, usage()); |
| 335 ASSERT_LT(2 * child_file_size + 3 * grandchild_file_size, quota()); | 334 ASSERT_LT(2 * child_file_size + 3 * grandchild_file_size, quota()); |
| 336 } | 335 } |
| 337 | 336 |
| 338 } // namespace fileapi | 337 } // namespace fileapi |
| OLD | NEW |