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

Unified Diff: components/ntp_snippets/ntp_snippets_test_utils.cc

Issue 2061803002: 📰 The Status card reports disabled sync states (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simplifyBridge
Patch Set: Refactor out status detection, update tests. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: components/ntp_snippets/ntp_snippets_test_utils.cc
diff --git a/components/ntp_snippets/ntp_snippets_test_utils.cc b/components/ntp_snippets/ntp_snippets_test_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bde8c4f0c5bffe749db9b8ee2df1449e0027d8ed
--- /dev/null
+++ b/components/ntp_snippets/ntp_snippets_test_utils.cc
@@ -0,0 +1,67 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/ntp_snippets/ntp_snippets_test_utils.h"
+
+#include <memory>
+
+#include "components/prefs/pref_registry_simple.h"
+#include "components/prefs/testing_pref_service.h"
+#include "components/signin/core/browser/account_tracker_service.h"
+#include "components/signin/core/browser/fake_signin_manager.h"
+#include "components/signin/core/browser/test_signin_client.h"
+#include "components/signin/core/common/signin_pref_names.h"
+#include "components/sync_driver/fake_sync_service.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using testing::Return;
+
+namespace ntp_snippets {
+namespace test {
+
+MockSyncService::MockSyncService() {}
+
+MockSyncService::~MockSyncService() {}
+
+NTPSnippetsTestBase::NTPSnippetsTestBase()
+ : pref_service_(new TestingPrefServiceSimple()) {
+ pref_service_->registry()->RegisterStringPref(prefs::kGoogleServicesAccountId,
+ std::string());
+ pref_service_->registry()->RegisterStringPref(
+ prefs::kGoogleServicesLastAccountId, std::string());
+ pref_service_->registry()->RegisterStringPref(
+ prefs::kGoogleServicesLastUsername, std::string());
+}
+
+NTPSnippetsTestBase::~NTPSnippetsTestBase() {}
+
+void NTPSnippetsTestBase::SetUp() {
+ signin_client_.reset(new TestSigninClient(pref_service_.get()));
+ account_tracker_.reset(new AccountTrackerService());
+ ResetSyncServiceMock();
+ ResetSigninManager();
+}
+
+void NTPSnippetsTestBase::ResetSigninManager() {
+ fake_signin_manager_.reset(
+ new FakeSigninManagerBase(signin_client_.get(), account_tracker_.get()));
+}
+
+void NTPSnippetsTestBase::ResetSyncServiceMock() {
+ // Use a NiceMock to avoid the "uninteresting call" warnings.
+ mock_sync_service_.reset(new testing::NiceMock<MockSyncService>);
Bernhard Bauer 2016/06/28 13:47:39 This mock doesn't really seem to verify its intera
dgn 2016/06/28 16:38:57 Probably more staightforward, yes. Done.
+
+ ON_CALL(*mock_sync_service_, CanSyncStart()).WillByDefault(Return(true));
+ ON_CALL(*mock_sync_service_, IsSyncActive()).WillByDefault(Return(true));
+ ON_CALL(*mock_sync_service_, IsEncryptEverythingEnabled())
+ .WillByDefault(Return(false));
+ ON_CALL(*mock_sync_service_, ConfigurationDone()).WillByDefault(Return(true));
+ ON_CALL(*mock_sync_service_, GetActiveDataTypes())
+ .WillByDefault(
+ Return(syncer::ModelTypeSet(syncer::HISTORY_DELETE_DIRECTIVES)));
+}
+
+} // namespace test
+} // namespace ntp_snippets

Powered by Google App Engine
This is Rietveld 408576698