Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Side by Side Diff: components/offline_pages/offline_page_model_unittest.cc

Issue 2006923005: [Offline Pages] Two-step expiration in storage manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_model.h" 5 #include "components/offline_pages/offline_page_model.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 std::get<0>(save_result)); 968 std::get<0>(save_result));
969 } 969 }
970 970
971 // First two pages will be expired. 971 // First two pages will be expired.
972 std::vector<int64_t> pages_to_expire = {std::get<1>(saved_pages[0]), 972 std::vector<int64_t> pages_to_expire = {std::get<1>(saved_pages[0]),
973 std::get<1>(saved_pages[1])}; 973 std::get<1>(saved_pages[1])};
974 // Pages are marked as expired if they have an expiration_time set. 974 // Pages are marked as expired if they have an expiration_time set.
975 base::Time expiration_time = 975 base::Time expiration_time =
976 base::Time::Now() + base::TimeDelta::FromMinutes(5); 976 base::Time::Now() + base::TimeDelta::FromMinutes(5);
977 977
978 model()->ExpirePages(pages_to_expire, expiration_time); 978 model()->ExpirePages(
979 pages_to_expire, expiration_time,
980 base::Bind(&OfflinePageModelTest::OnDeletePageDone, AsWeakPtr()));
979 PumpLoop(); 981 PumpLoop();
980 982
981 const std::vector<OfflinePageItem>& offline_pages = GetAllPages(); 983 const std::vector<OfflinePageItem>& offline_pages = GetAllPages();
982 for (const auto& offline_page : offline_pages) { 984 for (const auto& offline_page : offline_pages) {
983 if (std::find(pages_to_expire.begin(), pages_to_expire.end(), 985 if (std::find(pages_to_expire.begin(), pages_to_expire.end(),
984 offline_page.offline_id) != pages_to_expire.end()) { 986 offline_page.offline_id) != pages_to_expire.end()) {
985 EXPECT_EQ(expiration_time, offline_page.expiration_time); 987 EXPECT_EQ(expiration_time, offline_page.expiration_time);
986 EXPECT_TRUE(offline_page.IsExpired()); 988 EXPECT_TRUE(offline_page.IsExpired());
987 } else { 989 } else {
988 EXPECT_EQ(base::Time(), offline_page.expiration_time); 990 EXPECT_EQ(base::Time(), offline_page.expiration_time);
989 EXPECT_FALSE(offline_page.IsExpired()); 991 EXPECT_FALSE(offline_page.IsExpired());
990 } 992 }
991 } 993 }
994 EXPECT_EQ(DeletePageResult::SUCCESS, last_delete_result());
992 } 995 }
993 996
994 TEST(CommandLineFlagsTest, OfflineBookmarks) { 997 TEST(CommandLineFlagsTest, OfflineBookmarks) {
995 // Disabled by default. 998 // Disabled by default.
996 EXPECT_FALSE(offline_pages::IsOfflineBookmarksEnabled()); 999 EXPECT_FALSE(offline_pages::IsOfflineBookmarksEnabled());
997 1000
998 // Check if feature is correctly enabled by command-line flag. 1001 // Check if feature is correctly enabled by command-line flag.
999 base::FeatureList::ClearInstanceForTesting(); 1002 base::FeatureList::ClearInstanceForTesting();
1000 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); 1003 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
1001 feature_list->InitializeFromCommandLine( 1004 feature_list->InitializeFromCommandLine(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 std::unique_ptr<base::FeatureList> feature_list2(new base::FeatureList); 1047 std::unique_ptr<base::FeatureList> feature_list2(new base::FeatureList);
1045 feature_list2->InitializeFromCommandLine( 1048 feature_list2->InitializeFromCommandLine(
1046 std::string(offline_pages::kOfflineBookmarksFeature.name) + "," + 1049 std::string(offline_pages::kOfflineBookmarksFeature.name) + "," +
1047 offline_pages::kOfflinePagesBackgroundLoadingFeature.name, 1050 offline_pages::kOfflinePagesBackgroundLoadingFeature.name,
1048 ""); 1051 "");
1049 base::FeatureList::SetInstance(std::move(feature_list2)); 1052 base::FeatureList::SetInstance(std::move(feature_list2));
1050 EXPECT_TRUE(offline_pages::IsOfflinePagesBackgroundLoadingEnabled()); 1053 EXPECT_TRUE(offline_pages::IsOfflinePagesBackgroundLoadingEnabled());
1051 } 1054 }
1052 1055
1053 } // namespace offline_pages 1056 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698