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

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

Issue 1750883002: Add enable-offlining-recent-pages feature switch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resolve Created 4 years, 9 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
« no previous file with comments | « components/offline_pages/offline_page_feature.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h"
13 #include "base/feature_list.h"
12 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
13 #include "base/files/scoped_temp_dir.h" 15 #include "base/files/scoped_temp_dir.h"
14 #include "base/run_loop.h" 16 #include "base/run_loop.h"
15 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
16 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
18 #include "base/test/test_mock_time_task_runner.h" 20 #include "base/test/test_mock_time_task_runner.h"
19 #include "base/thread_task_runner_handle.h" 21 #include "base/thread_task_runner_handle.h"
20 #include "base/time/time.h" 22 #include "base/time/time.h"
21 #include "components/bookmarks/browser/bookmark_client.h" 23 #include "components/bookmarks/browser/bookmark_client.h"
22 #include "components/bookmarks/browser/bookmark_model.h" 24 #include "components/bookmarks/browser/bookmark_model.h"
23 #include "components/bookmarks/browser/bookmark_node.h" 25 #include "components/bookmarks/browser/bookmark_node.h"
24 #include "components/bookmarks/browser/bookmark_storage.h" 26 #include "components/bookmarks/browser/bookmark_storage.h"
25 #include "components/bookmarks/browser/bookmark_undo_delegate.h" 27 #include "components/bookmarks/browser/bookmark_undo_delegate.h"
26 #include "components/bookmarks/browser/bookmark_undo_provider.h" 28 #include "components/bookmarks/browser/bookmark_undo_provider.h"
27 #include "components/bookmarks/test/test_bookmark_client.h" 29 #include "components/bookmarks/test/test_bookmark_client.h"
30 #include "components/offline_pages/offline_page_feature.h"
28 #include "components/offline_pages/offline_page_item.h" 31 #include "components/offline_pages/offline_page_item.h"
32 #include "components/offline_pages/offline_page_switches.h"
29 #include "components/offline_pages/offline_page_test_archiver.h" 33 #include "components/offline_pages/offline_page_test_archiver.h"
30 #include "components/offline_pages/offline_page_test_store.h" 34 #include "components/offline_pages/offline_page_test_store.h"
31 #include "testing/gtest/include/gtest/gtest.h" 35 #include "testing/gtest/include/gtest/gtest.h"
32 #include "url/gurl.h" 36 #include "url/gurl.h"
33 37
34 using SavePageResult = offline_pages::OfflinePageModel::SavePageResult; 38 using SavePageResult = offline_pages::OfflinePageModel::SavePageResult;
35 using DeletePageResult = offline_pages::OfflinePageModel::DeletePageResult; 39 using DeletePageResult = offline_pages::OfflinePageModel::DeletePageResult;
36 40
37 namespace offline_pages { 41 namespace offline_pages {
38 42
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 986
983 std::set<int64_t> id_set; 987 std::set<int64_t> id_set;
984 for (size_t i = 0; i < ids.size(); i++) { 988 for (size_t i = 0; i < ids.size(); i++) {
985 id_set.insert(ids[i]); 989 id_set.insert(ids[i]);
986 } 990 }
987 991
988 EXPECT_TRUE(id_set.find(offline1) != id_set.end()); 992 EXPECT_TRUE(id_set.find(offline1) != id_set.end());
989 EXPECT_TRUE(id_set.find(offline2) != id_set.end()); 993 EXPECT_TRUE(id_set.find(offline2) != id_set.end());
990 } 994 }
991 995
996 TEST(CommandLineFlagsTest, OffliningRecentPages) {
997 // TODO(dimich): once offline pages are enabled by default, remove this.
998 base::CommandLine::ForCurrentProcess()->AppendSwitch(
999 switches::kEnableOfflinePages);
1000 // Disabled by default.
1001 EXPECT_FALSE(offline_pages::IsOffliningRecentPagesEnabled());
1002
1003 // Check if feature is correctly enabled by command-line flag.
1004 base::FeatureList::ClearInstanceForTesting();
1005 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
1006 feature_list->InitializeFromCommandLine(
1007 offline_pages::kOffliningRecentPagesFeature.name, "");
1008 base::FeatureList::SetInstance(std::move(feature_list));
1009 EXPECT_TRUE(offline_pages::IsOffliningRecentPagesEnabled());
1010 }
1011
992 } // namespace offline_pages 1012 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_feature.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698