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

Side by Side Diff: components/ntp_snippets/ntp_snippets_test_utils.cc

Issue 2285133004: Overhaul ntp_snippets_service_unittest.cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: No brackets. Created 4 years, 3 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/ntp_snippets/ntp_snippets_test_utils.h ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ntp_snippets/ntp_snippets_test_utils.h" 5 #include "components/ntp_snippets/ntp_snippets_test_utils.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "components/prefs/pref_registry_simple.h" 9 #include "components/prefs/pref_registry_simple.h"
10 #include "components/prefs/testing_pref_service.h" 10 #include "components/prefs/testing_pref_service.h"
11 #include "components/signin/core/browser/account_tracker_service.h" 11 #include "components/signin/core/browser/account_tracker_service.h"
12 #include "components/signin/core/browser/fake_signin_manager.h" 12 #include "components/signin/core/browser/fake_signin_manager.h"
13 #include "components/signin/core/browser/test_signin_client.h" 13 #include "components/signin/core/browser/test_signin_client.h"
14 #include "components/signin/core/common/signin_pref_names.h" 14 #include "components/signin/core/common/signin_pref_names.h"
15 #include "components/sync/driver/fake_sync_service.h" 15 #include "components/sync/driver/fake_sync_service.h"
16 16
17 namespace ntp_snippets { 17 namespace ntp_snippets {
18 namespace test { 18 namespace test {
19 19
20 MockSyncService::MockSyncService() 20 FakeSyncService::FakeSyncService()
21 : can_sync_start_(true), 21 : can_sync_start_(true),
22 is_sync_active_(true), 22 is_sync_active_(true),
23 configuration_done_(true), 23 configuration_done_(true),
24 is_encrypt_everything_enabled_(false), 24 is_encrypt_everything_enabled_(false),
25 active_data_types_(syncer::HISTORY_DELETE_DIRECTIVES) {} 25 active_data_types_(syncer::HISTORY_DELETE_DIRECTIVES) {}
26 26
27 MockSyncService::~MockSyncService() {} 27 FakeSyncService::~FakeSyncService() {}
28 28
29 bool MockSyncService::CanSyncStart() const { 29 bool FakeSyncService::CanSyncStart() const {
30 return can_sync_start_; 30 return can_sync_start_;
31 } 31 }
32 32
33 bool MockSyncService::IsSyncActive() const { 33 bool FakeSyncService::IsSyncActive() const {
34 return is_sync_active_; 34 return is_sync_active_;
35 } 35 }
36 36
37 bool MockSyncService::ConfigurationDone() const { 37 bool FakeSyncService::ConfigurationDone() const {
38 return configuration_done_; 38 return configuration_done_;
39 } 39 }
40 40
41 bool MockSyncService::IsEncryptEverythingEnabled() const { 41 bool FakeSyncService::IsEncryptEverythingEnabled() const {
42 return is_encrypt_everything_enabled_; 42 return is_encrypt_everything_enabled_;
43 } 43 }
44 44
45 syncer::ModelTypeSet MockSyncService::GetActiveDataTypes() const { 45 syncer::ModelTypeSet FakeSyncService::GetActiveDataTypes() const {
46 return active_data_types_; 46 return active_data_types_;
47 } 47 }
48 48
49 NTPSnippetsTestBase::NTPSnippetsTestBase() 49 NTPSnippetsTestUtils::NTPSnippetsTestUtils()
50 : pref_service_(new TestingPrefServiceSimple()) { 50 : pref_service_(new TestingPrefServiceSimple()) {
51 pref_service_->registry()->RegisterStringPref(prefs::kGoogleServicesAccountId, 51 pref_service_->registry()->RegisterStringPref(prefs::kGoogleServicesAccountId,
52 std::string()); 52 std::string());
53 pref_service_->registry()->RegisterStringPref( 53 pref_service_->registry()->RegisterStringPref(
54 prefs::kGoogleServicesLastAccountId, std::string()); 54 prefs::kGoogleServicesLastAccountId, std::string());
55 pref_service_->registry()->RegisterStringPref( 55 pref_service_->registry()->RegisterStringPref(
56 prefs::kGoogleServicesLastUsername, std::string()); 56 prefs::kGoogleServicesLastUsername, std::string());
57 }
58
59 NTPSnippetsTestBase::~NTPSnippetsTestBase() {}
60
61 void NTPSnippetsTestBase::SetUp() {
62 signin_client_.reset(new TestSigninClient(pref_service_.get())); 57 signin_client_.reset(new TestSigninClient(pref_service_.get()));
63 account_tracker_.reset(new AccountTrackerService()); 58 account_tracker_.reset(new AccountTrackerService());
64 mock_sync_service_.reset(new MockSyncService()); 59 fake_sync_service_.reset(new FakeSyncService());
65 ResetSigninManager(); 60 ResetSigninManager();
66 } 61 }
67 62
68 void NTPSnippetsTestBase::ResetSigninManager() { 63 NTPSnippetsTestUtils::~NTPSnippetsTestUtils() = default;
64
65 void NTPSnippetsTestUtils::ResetSigninManager() {
69 fake_signin_manager_.reset( 66 fake_signin_manager_.reset(
70 new FakeSigninManagerBase(signin_client_.get(), account_tracker_.get())); 67 new FakeSigninManagerBase(signin_client_.get(), account_tracker_.get()));
71 } 68 }
72 69
73 } // namespace test 70 } // namespace test
74 } // namespace ntp_snippets 71 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/ntp_snippets_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698