| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/offline_pages/offline_page_storage_manager.h" | 5 #include "components/offline_pages/offline_page_storage_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/test/simple_test_clock.h" | 13 #include "base/test/simple_test_clock.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "components/offline_pages/archive_manager.h" | 15 #include "components/offline_pages/archive_manager.h" |
| 16 #include "components/offline_pages/client_namespace_constants.h" | |
| 17 #include "components/offline_pages/client_policy_controller.h" | 16 #include "components/offline_pages/client_policy_controller.h" |
| 18 #include "components/offline_pages/offline_page_item.h" | 17 #include "components/offline_pages/offline_page_item.h" |
| 19 #include "components/offline_pages/offline_page_storage_manager.h" | 18 #include "components/offline_pages/offline_page_storage_manager.h" |
| 20 #include "components/offline_pages/offline_page_types.h" | 19 #include "components/offline_pages/offline_page_types.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 21 |
| 23 using LifetimePolicy = offline_pages::LifetimePolicy; | 22 using LifetimePolicy = offline_pages::LifetimePolicy; |
| 24 using ClearStorageResult = | 23 using ClearStorageResult = |
| 25 offline_pages::OfflinePageStorageManager::ClearStorageResult; | 24 offline_pages::OfflinePageStorageManager::ClearStorageResult; |
| 26 using StorageStats = offline_pages::ArchiveManager::StorageStats; | 25 using StorageStats = offline_pages::ArchiveManager::StorageStats; |
| 27 | 26 |
| 28 namespace offline_pages { | 27 namespace offline_pages { |
| 29 | 28 |
| 30 namespace { | 29 namespace { |
| 30 const char kBookmarkNamespace[] = "bookmark"; |
| 31 const char kLastNNamespace[] = "last_n"; |
| 31 const GURL kTestUrl("http://example.com"); | 32 const GURL kTestUrl("http://example.com"); |
| 32 const base::FilePath::CharType kFilePath[] = FILE_PATH_LITERAL("/data"); | 33 const base::FilePath::CharType kFilePath[] = FILE_PATH_LITERAL("/data"); |
| 33 const int64_t kTestFileSize = 500 * (1 << 10); | 34 const int64_t kTestFileSize = 500 * (1 << 10); |
| 34 const int64_t kFreeSpaceNormal = 100 * (1 << 20); | 35 const int64_t kFreeSpaceNormal = 100 * (1 << 20); |
| 35 | 36 |
| 36 enum TestOptions { | 37 enum TestOptions { |
| 37 DEFAULT = 1 << 0, | 38 DEFAULT = 1 << 0, |
| 38 EXPIRE_FAILURE = 1 << 1, | 39 EXPIRE_FAILURE = 1 << 1, |
| 39 DELETE_FAILURE = 1 << 2, | 40 DELETE_FAILURE = 1 << 2, |
| 40 EXPIRE_AND_DELETE_FAILURES = EXPIRE_FAILURE | DELETE_FAILURE, | 41 EXPIRE_AND_DELETE_FAILURES = EXPIRE_FAILURE | DELETE_FAILURE, |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 EXPECT_EQ(0, client()->GetTotalSize()); | 433 EXPECT_EQ(0, client()->GetTotalSize()); |
| 433 EXPECT_EQ(5, total_cleared_times()); | 434 EXPECT_EQ(5, total_cleared_times()); |
| 434 EXPECT_EQ(ClearStorageResult::SUCCESS, last_clear_storage_result()); | 435 EXPECT_EQ(ClearStorageResult::SUCCESS, last_clear_storage_result()); |
| 435 // Number of removed pages should be the ones expired above and all the pages | 436 // Number of removed pages should be the ones expired above and all the pages |
| 436 // initially created for last_n namespace. | 437 // initially created for last_n namespace. |
| 437 EXPECT_EQ(expired_page_count + 101, | 438 EXPECT_EQ(expired_page_count + 101, |
| 438 static_cast<int>(client()->GetRemovedPages().size())); | 439 static_cast<int>(client()->GetRemovedPages().size())); |
| 439 } | 440 } |
| 440 | 441 |
| 441 } // namespace offline_pages | 442 } // namespace offline_pages |
| OLD | NEW |