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

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

Issue 1899433002: Update flags used by offline pages and bookmarks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test Created 4 years, 8 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 12 matching lines...) Expand all
23 #include "components/bookmarks/browser/bookmark_client.h" 23 #include "components/bookmarks/browser/bookmark_client.h"
24 #include "components/bookmarks/browser/bookmark_model.h" 24 #include "components/bookmarks/browser/bookmark_model.h"
25 #include "components/bookmarks/browser/bookmark_node.h" 25 #include "components/bookmarks/browser/bookmark_node.h"
26 #include "components/bookmarks/browser/bookmark_storage.h" 26 #include "components/bookmarks/browser/bookmark_storage.h"
27 #include "components/bookmarks/browser/bookmark_undo_delegate.h" 27 #include "components/bookmarks/browser/bookmark_undo_delegate.h"
28 #include "components/bookmarks/browser/bookmark_undo_provider.h" 28 #include "components/bookmarks/browser/bookmark_undo_provider.h"
29 #include "components/bookmarks/test/test_bookmark_client.h" 29 #include "components/bookmarks/test/test_bookmark_client.h"
30 #include "components/offline_pages/offline_page_bookmark_bridge.h" 30 #include "components/offline_pages/offline_page_bookmark_bridge.h"
31 #include "components/offline_pages/offline_page_feature.h" 31 #include "components/offline_pages/offline_page_feature.h"
32 #include "components/offline_pages/offline_page_item.h" 32 #include "components/offline_pages/offline_page_item.h"
33 #include "components/offline_pages/offline_page_switches.h"
34 #include "components/offline_pages/offline_page_test_archiver.h" 33 #include "components/offline_pages/offline_page_test_archiver.h"
35 #include "components/offline_pages/offline_page_test_store.h" 34 #include "components/offline_pages/offline_page_test_store.h"
36 #include "testing/gtest/include/gtest/gtest.h" 35 #include "testing/gtest/include/gtest/gtest.h"
37 #include "url/gurl.h" 36 #include "url/gurl.h"
38 37
39 using SavePageResult = offline_pages::OfflinePageModel::SavePageResult; 38 using SavePageResult = offline_pages::OfflinePageModel::SavePageResult;
40 using DeletePageResult = offline_pages::OfflinePageModel::DeletePageResult; 39 using DeletePageResult = offline_pages::OfflinePageModel::DeletePageResult;
41 using GetAllPagesResult = offline_pages::OfflinePageModel::GetAllPagesResult; 40 using GetAllPagesResult = offline_pages::OfflinePageModel::GetAllPagesResult;
42 41
43 namespace offline_pages { 42 namespace offline_pages {
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 1126
1128 std::set<int64_t> id_set; 1127 std::set<int64_t> id_set;
1129 for (size_t i = 0; i < ids.size(); i++) { 1128 for (size_t i = 0; i < ids.size(); i++) {
1130 id_set.insert(ids[i]); 1129 id_set.insert(ids[i]);
1131 } 1130 }
1132 1131
1133 EXPECT_TRUE(id_set.find(offline1) != id_set.end()); 1132 EXPECT_TRUE(id_set.find(offline1) != id_set.end());
1134 EXPECT_TRUE(id_set.find(offline2) != id_set.end()); 1133 EXPECT_TRUE(id_set.find(offline2) != id_set.end());
1135 } 1134 }
1136 1135
1137 TEST(CommandLineFlagsTest, OffliningRecentPages) { 1136 TEST(CommandLineFlagsTest, OfflineBookmarks) {
1138 // TODO(dimich): once offline pages are enabled by default, remove this.
1139 base::CommandLine::ForCurrentProcess()->AppendSwitch(
1140 switches::kEnableOfflinePages);
1141 // Disabled by default. 1137 // Disabled by default.
1142 EXPECT_FALSE(offline_pages::IsOffliningRecentPagesEnabled()); 1138 EXPECT_FALSE(offline_pages::IsOfflineBookmarksEnabled());
1143 1139
1144 // Check if feature is correctly enabled by command-line flag. 1140 // Check if feature is correctly enabled by command-line flag.
1145 base::FeatureList::ClearInstanceForTesting(); 1141 base::FeatureList::ClearInstanceForTesting();
1146 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList); 1142 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
1147 feature_list->InitializeFromCommandLine( 1143 feature_list->InitializeFromCommandLine(
1148 offline_pages::kOffliningRecentPagesFeature.name, ""); 1144 offline_pages::kOfflineBookmarksFeature.name, "");
1149 base::FeatureList::SetInstance(std::move(feature_list)); 1145 base::FeatureList::SetInstance(std::move(feature_list));
1146 EXPECT_TRUE(offline_pages::IsOfflineBookmarksEnabled());
1147 }
1148
1149 TEST(CommandLineFlagsTest, OffliningRecentPages) {
1150 // Enable offline bookmarks feature first.
1151 // TODO(dimich): once offline pages are enabled by default, remove this.
1152 base::FeatureList::ClearInstanceForTesting();
1153 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
1154 feature_list->InitializeFromCommandLine(
1155 offline_pages::kOfflineBookmarksFeature.name, "");
1156 base::FeatureList::SetInstance(std::move(feature_list));
1157
1158 // This feature is still disabled by default.
1159 EXPECT_FALSE(offline_pages::IsOffliningRecentPagesEnabled());
1160
1161 // Check if feature is correctly enabled by command-line flag.
1162 base::FeatureList::ClearInstanceForTesting();
1163 scoped_ptr<base::FeatureList> feature_list2(new base::FeatureList);
1164 feature_list2->InitializeFromCommandLine(
1165 std::string(offline_pages::kOfflineBookmarksFeature.name) + "," +
1166 offline_pages::kOffliningRecentPagesFeature.name,
1167 "");
1168 base::FeatureList::SetInstance(std::move(feature_list2));
1150 EXPECT_TRUE(offline_pages::IsOffliningRecentPagesEnabled()); 1169 EXPECT_TRUE(offline_pages::IsOffliningRecentPagesEnabled());
1151 } 1170 }
1152 1171
1153 TEST(CommandLineFlagsTest, OfflinePagesBackgroundLoading) { 1172 TEST(CommandLineFlagsTest, OfflinePagesBackgroundLoading) {
1173 // Enable offline bookmarks feature first.
1154 // TODO(dimich): once offline pages are enabled by default, remove this. 1174 // TODO(dimich): once offline pages are enabled by default, remove this.
1155 base::CommandLine::ForCurrentProcess()->AppendSwitch( 1175 base::FeatureList::ClearInstanceForTesting();
1156 switches::kEnableOfflinePages); 1176 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
1157 // Disabled by default. 1177 feature_list->InitializeFromCommandLine(
1178 offline_pages::kOfflineBookmarksFeature.name, "");
1179 base::FeatureList::SetInstance(std::move(feature_list));
1180
1181 // This feature is still disabled by default.
1158 EXPECT_FALSE(offline_pages::IsOfflinePagesBackgroundLoadingEnabled()); 1182 EXPECT_FALSE(offline_pages::IsOfflinePagesBackgroundLoadingEnabled());
1159 1183
1160 // Check if feature is correctly enabled by command-line flag. 1184 // Check if feature is correctly enabled by command-line flag.
1161 base::FeatureList::ClearInstanceForTesting(); 1185 base::FeatureList::ClearInstanceForTesting();
1162 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList); 1186 scoped_ptr<base::FeatureList> feature_list2(new base::FeatureList);
1163 feature_list->InitializeFromCommandLine( 1187 feature_list2->InitializeFromCommandLine(
1164 offline_pages::kOfflinePagesBackgroundLoadingFeature.name, ""); 1188 std::string(offline_pages::kOfflineBookmarksFeature.name) + "," +
1165 base::FeatureList::SetInstance(std::move(feature_list)); 1189 offline_pages::kOfflinePagesBackgroundLoadingFeature.name,
1190 "");
1191 base::FeatureList::SetInstance(std::move(feature_list2));
1166 EXPECT_TRUE(offline_pages::IsOfflinePagesBackgroundLoadingEnabled()); 1192 EXPECT_TRUE(offline_pages::IsOfflinePagesBackgroundLoadingEnabled());
1167 } 1193 }
1168 1194
1169 } // namespace offline_pages 1195 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_feature.cc ('k') | components/offline_pages/offline_page_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698