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

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

Issue 1976163004: [Offline Pages] Adds Rappor metrics measuring what domains are saved & viewed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no-store
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
« no previous file with comments | « components/offline_pages/offline_page_model.cc ('k') | tools/metrics/rappor/rappor.xml » ('j') | 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" 12 #include "base/command_line.h"
13 #include "base/feature_list.h" 13 #include "base/feature_list.h"
14 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
15 #include "base/files/scoped_temp_dir.h" 15 #include "base/files/scoped_temp_dir.h"
16 #include "base/memory/weak_ptr.h"
16 #include "base/optional.h" 17 #include "base/optional.h"
17 #include "base/run_loop.h" 18 #include "base/run_loop.h"
18 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
19 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
21 #include "base/test/test_mock_time_task_runner.h" 22 #include "base/test/test_mock_time_task_runner.h"
22 #include "base/threading/thread_task_runner_handle.h" 23 #include "base/threading/thread_task_runner_handle.h"
23 #include "base/time/time.h" 24 #include "base/time/time.h"
24 #include "components/offline_pages/client_policy_controller.h" 25 #include "components/offline_pages/client_policy_controller.h"
25 #include "components/offline_pages/offline_page_client_policy.h" 26 #include "components/offline_pages/offline_page_client_policy.h"
26 #include "components/offline_pages/offline_page_feature.h" 27 #include "components/offline_pages/offline_page_feature.h"
27 #include "components/offline_pages/offline_page_item.h" 28 #include "components/offline_pages/offline_page_item.h"
28 #include "components/offline_pages/offline_page_storage_manager.h" 29 #include "components/offline_pages/offline_page_storage_manager.h"
29 #include "components/offline_pages/offline_page_test_archiver.h" 30 #include "components/offline_pages/offline_page_test_archiver.h"
30 #include "components/offline_pages/offline_page_test_store.h" 31 #include "components/offline_pages/offline_page_test_store.h"
31 #include "components/offline_pages/offline_page_types.h" 32 #include "components/offline_pages/offline_page_types.h"
32 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
33 #include "url/gurl.h" 34 #include "url/gurl.h"
34 35
36 namespace rappor {
37 class RapporService;
38 }
39
35 namespace offline_pages { 40 namespace offline_pages {
36 41
37 namespace { 42 namespace {
38 const char kTestClientNamespace[] = "CLIENT_NAMESPACE"; 43 const char kTestClientNamespace[] = "CLIENT_NAMESPACE";
39 const GURL kTestUrl("http://example.com"); 44 const GURL kTestUrl("http://example.com");
40 const GURL kTestUrl2("http://other.page.com"); 45 const GURL kTestUrl2("http://other.page.com");
41 const GURL kTestUrl3("http://test.xyz"); 46 const GURL kTestUrl3("http://test.xyz");
42 const GURL kFileUrl("file:///foo"); 47 const GURL kFileUrl("file:///foo");
43 const ClientId kTestClientId1(kTestClientNamespace, "1234"); 48 const ClientId kTestClientId1(kTestClientNamespace, "1234");
44 const ClientId kTestClientId2(kTestClientNamespace, "5678"); 49 const ClientId kTestClientId2(kTestClientNamespace, "5678");
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 this, url, result, kTestFileSize, base::ThreadTaskRunnerHandle::Get())); 263 this, url, result, kTestFileSize, base::ThreadTaskRunnerHandle::Get()));
259 } 264 }
260 265
261 std::unique_ptr<OfflinePageMetadataStore> OfflinePageModelTest::BuildStore() { 266 std::unique_ptr<OfflinePageMetadataStore> OfflinePageModelTest::BuildStore() {
262 return std::unique_ptr<OfflinePageMetadataStore>( 267 return std::unique_ptr<OfflinePageMetadataStore>(
263 new OfflinePageTestStore(base::ThreadTaskRunnerHandle::Get())); 268 new OfflinePageTestStore(base::ThreadTaskRunnerHandle::Get()));
264 } 269 }
265 270
266 std::unique_ptr<OfflinePageModel> OfflinePageModelTest::BuildModel( 271 std::unique_ptr<OfflinePageModel> OfflinePageModelTest::BuildModel(
267 std::unique_ptr<OfflinePageMetadataStore> store) { 272 std::unique_ptr<OfflinePageMetadataStore> store) {
268 return std::unique_ptr<OfflinePageModel>(new OfflinePageModel( 273 return std::unique_ptr<OfflinePageModel>(
269 std::move(store), temp_dir_.path(), base::ThreadTaskRunnerHandle::Get())); 274 new OfflinePageModel(std::move(store), temp_dir_.path(),
275 base::WeakPtr<rappor::RapporService>(),
276 base::ThreadTaskRunnerHandle::Get()));
270 } 277 }
271 278
272 void OfflinePageModelTest::ResetModel() { 279 void OfflinePageModelTest::ResetModel() {
273 model_->RemoveObserver(this); 280 model_->RemoveObserver(this);
274 OfflinePageTestStore* old_store = GetStore(); 281 OfflinePageTestStore* old_store = GetStore();
275 std::unique_ptr<OfflinePageMetadataStore> new_store( 282 std::unique_ptr<OfflinePageMetadataStore> new_store(
276 new OfflinePageTestStore(*old_store)); 283 new OfflinePageTestStore(*old_store));
277 model_ = BuildModel(std::move(new_store)); 284 model_ = BuildModel(std::move(new_store));
278 model_->AddObserver(this); 285 model_->AddObserver(this);
279 PumpLoop(); 286 PumpLoop();
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 std::unique_ptr<base::FeatureList> feature_list2(new base::FeatureList); 1058 std::unique_ptr<base::FeatureList> feature_list2(new base::FeatureList);
1052 feature_list2->InitializeFromCommandLine( 1059 feature_list2->InitializeFromCommandLine(
1053 std::string(offline_pages::kOfflineBookmarksFeature.name) + "," + 1060 std::string(offline_pages::kOfflineBookmarksFeature.name) + "," +
1054 offline_pages::kOfflinePagesBackgroundLoadingFeature.name, 1061 offline_pages::kOfflinePagesBackgroundLoadingFeature.name,
1055 ""); 1062 "");
1056 base::FeatureList::SetInstance(std::move(feature_list2)); 1063 base::FeatureList::SetInstance(std::move(feature_list2));
1057 EXPECT_TRUE(offline_pages::IsOfflinePagesBackgroundLoadingEnabled()); 1064 EXPECT_TRUE(offline_pages::IsOfflinePagesBackgroundLoadingEnabled());
1058 } 1065 }
1059 1066
1060 } // namespace offline_pages 1067 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_model.cc ('k') | tools/metrics/rappor/rappor.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698