| 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 #include "webkit/fileapi/quota_file_util.h" | 5 #include "webkit/fileapi/quota_file_util.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
| 9 #include "base/platform_file.h" | 9 #include "base/platform_file.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "webkit/fileapi/file_system_context.h" | 12 #include "webkit/fileapi/file_system_context.h" |
| 13 #include "webkit/fileapi/file_system_operation_context.h" | 13 #include "webkit/fileapi/file_system_operation_context.h" |
| 14 #include "webkit/fileapi/file_system_test_helper.h" | 14 #include "webkit/fileapi/file_system_test_helper.h" |
| 15 #include "webkit/fileapi/file_system_types.h" | 15 #include "webkit/fileapi/file_system_types.h" |
| 16 #include "webkit/fileapi/file_system_usage_cache.h" | 16 #include "webkit/fileapi/file_system_usage_cache.h" |
| 17 #include "webkit/fileapi/file_util_delete_helper.h" |
| 17 #include "webkit/fileapi/quota_file_util.h" | 18 #include "webkit/fileapi/quota_file_util.h" |
| 18 | 19 |
| 19 namespace fileapi { | 20 namespace fileapi { |
| 20 | 21 |
| 21 class QuotaFileUtilTest : public testing::Test { | 22 class QuotaFileUtilTest : public testing::Test { |
| 22 public: | 23 public: |
| 23 QuotaFileUtilTest() {} | 24 QuotaFileUtilTest() {} |
| 24 | 25 |
| 25 void SetUp() { | 26 void SetUp() { |
| 26 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 27 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 quota_file_util()->Truncate(context.get(), | 504 quota_file_util()->Truncate(context.get(), |
| 504 Path(dfile2), | 505 Path(dfile2), |
| 505 120)); | 506 120)); |
| 506 ASSERT_EQ(1480, quota_test_helper().GetCachedOriginUsage()); | 507 ASSERT_EQ(1480, quota_test_helper().GetCachedOriginUsage()); |
| 507 ASSERT_EQ(quota_test_helper().ComputeCurrentOriginUsage(), | 508 ASSERT_EQ(quota_test_helper().ComputeCurrentOriginUsage(), |
| 508 quota_test_helper().GetCachedOriginUsage()); | 509 quota_test_helper().GetCachedOriginUsage()); |
| 509 | 510 |
| 510 context.reset(NewContext()); | 511 context.reset(NewContext()); |
| 511 context->set_allowed_bytes_growth(QuotaFileUtil::kNoLimit); | 512 context->set_allowed_bytes_growth(QuotaFileUtil::kNoLimit); |
| 512 ASSERT_EQ(base::PLATFORM_FILE_OK, | 513 ASSERT_EQ(base::PLATFORM_FILE_OK, |
| 513 quota_file_util()->Delete(context.get(), | 514 DeletePath(context.get(), quota_file_util(), |
| 514 Path(file), | 515 Path(file), false)); |
| 515 false)); | |
| 516 ASSERT_EQ(1140, quota_test_helper().GetCachedOriginUsage()); | 516 ASSERT_EQ(1140, quota_test_helper().GetCachedOriginUsage()); |
| 517 ASSERT_EQ(quota_test_helper().ComputeCurrentOriginUsage(), | 517 ASSERT_EQ(quota_test_helper().ComputeCurrentOriginUsage(), |
| 518 quota_test_helper().GetCachedOriginUsage()); | 518 quota_test_helper().GetCachedOriginUsage()); |
| 519 | 519 |
| 520 context.reset(NewContext()); | 520 context.reset(NewContext()); |
| 521 context->set_allowed_bytes_growth(QuotaFileUtil::kNoLimit); | 521 context->set_allowed_bytes_growth(QuotaFileUtil::kNoLimit); |
| 522 ASSERT_EQ(base::PLATFORM_FILE_OK, | 522 ASSERT_EQ(base::PLATFORM_FILE_OK, |
| 523 quota_file_util()->Delete(context.get(), | 523 DeletePath(context.get(), quota_file_util(), |
| 524 Path(dir), | 524 Path(dir), true)); |
| 525 true)); | |
| 526 ASSERT_EQ(0, quota_test_helper().GetCachedOriginUsage()); | 525 ASSERT_EQ(0, quota_test_helper().GetCachedOriginUsage()); |
| 527 ASSERT_EQ(quota_test_helper().ComputeCurrentOriginUsage(), | 526 ASSERT_EQ(quota_test_helper().ComputeCurrentOriginUsage(), |
| 528 quota_test_helper().GetCachedOriginUsage()); | 527 quota_test_helper().GetCachedOriginUsage()); |
| 529 } | 528 } |
| 530 | 529 |
| 531 } // namespace fileapi | 530 } // namespace fileapi |
| OLD | NEW |