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

Side by Side Diff: chrome/browser/android/offline_pages/offline_page_utils_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: 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 "chrome/browser/android/offline_pages/offline_page_utils.h" 5 #include "chrome/browser/android/offline_pages/offline_page_utils.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/feature_list.h"
12 #include "base/files/file.h" 13 #include "base/files/file.h"
13 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
14 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
15 #include "base/test/test_simple_task_runner.h" 16 #include "base/test/test_simple_task_runner.h"
16 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
17 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 18 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
18 #include "chrome/browser/android/offline_pages/test_offline_page_model_builder.h " 19 #include "chrome/browser/android/offline_pages/test_offline_page_model_builder.h "
19 #include "chrome/common/chrome_constants.h" 20 #include "chrome/common/chrome_constants.h"
20 #include "chrome/test/base/testing_profile.h" 21 #include "chrome/test/base/testing_profile.h"
22 #include "components/offline_pages/offline_page_feature.h"
21 #include "components/offline_pages/offline_page_model.h" 23 #include "components/offline_pages/offline_page_model.h"
22 #include "components/offline_pages/offline_page_switches.h"
23 #include "components/offline_pages/offline_page_test_archiver.h" 24 #include "components/offline_pages/offline_page_test_archiver.h"
24 #include "components/offline_pages/offline_page_test_store.h" 25 #include "components/offline_pages/offline_page_test_store.h"
25 #include "components/offline_pages/proto/offline_pages.pb.h" 26 #include "components/offline_pages/proto/offline_pages.pb.h"
26 #include "net/base/filename_util.h" 27 #include "net/base/filename_util.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
28 #include "url/gurl.h" 29 #include "url/gurl.h"
29 30
30 namespace offline_pages { 31 namespace offline_pages {
31 namespace { 32 namespace {
32 33
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 91
91 OfflinePageUtilsTest::OfflinePageUtilsTest() 92 OfflinePageUtilsTest::OfflinePageUtilsTest()
92 : task_runner_(new base::TestSimpleTaskRunner), 93 : task_runner_(new base::TestSimpleTaskRunner),
93 task_runner_handle_(task_runner_) {} 94 task_runner_handle_(task_runner_) {}
94 95
95 OfflinePageUtilsTest::~OfflinePageUtilsTest() {} 96 OfflinePageUtilsTest::~OfflinePageUtilsTest() {}
96 97
97 void OfflinePageUtilsTest::SetUp() { 98 void OfflinePageUtilsTest::SetUp() {
98 // Enables offline pages feature. 99 // Enables offline pages feature.
99 // TODO(jianli): Remove this once the feature is completely enabled. 100 // TODO(jianli): Remove this once the feature is completely enabled.
100 base::CommandLine::ForCurrentProcess()->AppendSwitch( 101 base::FeatureList::ClearInstanceForTesting();
101 switches::kEnableOfflinePages); 102 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList);
103 feature_list->InitializeFromCommandLine(
104 offline_pages::kOfflineBookmarksFeature.name, "");
105 base::FeatureList::SetInstance(std::move(feature_list));
102 106
103 // Set up the factory for testing. 107 // Set up the factory for testing.
104 OfflinePageModelFactory::GetInstance()->SetTestingFactoryAndUse( 108 OfflinePageModelFactory::GetInstance()->SetTestingFactoryAndUse(
105 &profile_, BuildTestOfflinePageModel); 109 &profile_, BuildTestOfflinePageModel);
106 RunUntilIdle(); 110 RunUntilIdle();
107 111
108 // Make sure the store contains the right offline pages before the load 112 // Make sure the store contains the right offline pages before the load
109 // happens. 113 // happens.
110 CreateOfflinePages(); 114 CreateOfflinePages();
111 } 115 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 TEST_F(OfflinePageUtilsTest, HasOfflinePageForOnlineURL) { 239 TEST_F(OfflinePageUtilsTest, HasOfflinePageForOnlineURL) {
236 EXPECT_TRUE( 240 EXPECT_TRUE(
237 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage1Url)); 241 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage1Url));
238 EXPECT_TRUE( 242 EXPECT_TRUE(
239 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage2Url)); 243 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage2Url));
240 EXPECT_FALSE( 244 EXPECT_FALSE(
241 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage3Url)); 245 OfflinePageUtils::HasOfflinePageForOnlineURL(profile(), kTestPage3Url));
242 } 246 }
243 247
244 } // namespace offline_pages 248 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698