| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 14 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 15 #include "base/platform_file.h" | 16 #include "base/platform_file.h" |
| 16 #include "base/scoped_temp_dir.h" | |
| 17 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "webkit/fileapi/file_system_usage_cache.h" | 19 #include "webkit/fileapi/file_system_usage_cache.h" |
| 20 #include "webkit/fileapi/file_system_util.h" | 20 #include "webkit/fileapi/file_system_util.h" |
| 21 #include "webkit/fileapi/file_util_helper.h" | 21 #include "webkit/fileapi/file_util_helper.h" |
| 22 #include "webkit/fileapi/local_file_system_operation.h" | 22 #include "webkit/fileapi/local_file_system_operation.h" |
| 23 #include "webkit/fileapi/local_file_system_test_helper.h" | 23 #include "webkit/fileapi/local_file_system_test_helper.h" |
| 24 #include "webkit/quota/quota_manager.h" | 24 #include "webkit/quota/quota_manager.h" |
| 25 | 25 |
| 26 namespace fileapi { | 26 namespace fileapi { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 FileSystemOperation::StatusCallback RecordStatusCallback() { | 155 FileSystemOperation::StatusCallback RecordStatusCallback() { |
| 156 return base::Bind(&LocalFileSystemQuotaTest::DidFinish, AsWeakPtr()); | 156 return base::Bind(&LocalFileSystemQuotaTest::DidFinish, AsWeakPtr()); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void DidFinish(base::PlatformFileError status) { | 159 void DidFinish(base::PlatformFileError status) { |
| 160 status_ = status; | 160 status_ = status; |
| 161 } | 161 } |
| 162 | 162 |
| 163 LocalFileSystemTestOriginHelper test_helper_; | 163 LocalFileSystemTestOriginHelper test_helper_; |
| 164 | 164 |
| 165 ScopedTempDir work_dir_; | 165 base::ScopedTempDir work_dir_; |
| 166 MessageLoop message_loop_; | 166 MessageLoop message_loop_; |
| 167 scoped_refptr<quota::QuotaManager> quota_manager_; | 167 scoped_refptr<quota::QuotaManager> quota_manager_; |
| 168 | 168 |
| 169 base::WeakPtrFactory<LocalFileSystemQuotaTest> weak_factory_; | 169 base::WeakPtrFactory<LocalFileSystemQuotaTest> weak_factory_; |
| 170 | 170 |
| 171 int next_unique_path_suffix_; | 171 int next_unique_path_suffix_; |
| 172 | 172 |
| 173 // For post-operation status. | 173 // For post-operation status. |
| 174 int status_; | 174 int status_; |
| 175 quota::QuotaStatusCode quota_status_; | 175 quota::QuotaStatusCode quota_status_; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 340 |
| 341 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size, ActualFileSize()); | 341 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size, ActualFileSize()); |
| 342 EXPECT_EQ(expected_usage, SizeByQuotaUtil()); | 342 EXPECT_EQ(expected_usage, SizeByQuotaUtil()); |
| 343 GetUsageAndQuotaFromQuotaManager(); | 343 GetUsageAndQuotaFromQuotaManager(); |
| 344 EXPECT_EQ(quota::kQuotaStatusOk, quota_status()); | 344 EXPECT_EQ(quota::kQuotaStatusOk, quota_status()); |
| 345 EXPECT_EQ(expected_usage, usage()); | 345 EXPECT_EQ(expected_usage, usage()); |
| 346 ASSERT_LT(expected_usage, quota()); | 346 ASSERT_LT(expected_usage, quota()); |
| 347 } | 347 } |
| 348 | 348 |
| 349 } // namespace fileapi | 349 } // namespace fileapi |
| OLD | NEW |