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

Unified Diff: components/ntp_snippets/ntp_snippets_test_utils.h

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.h
diff --git a/components/ntp_snippets/ntp_snippets_test_utils.h b/components/ntp_snippets/ntp_snippets_test_utils.h
new file mode 100644
index 0000000000000000000000000000000000000000..f282da7f9c55a006e9b9d7e48581b8e4c2620203
--- /dev/null
+++ b/components/ntp_snippets/ntp_snippets_test_utils.h
@@ -0,0 +1,65 @@
+// 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.
+
+#ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_TEST_UTILS_H_
+#define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_TEST_UTILS_H_
+
+#include <memory>
+
+#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;
+
+class FakeSigninManagerBase;
+class MockSyncService;
+class TestingPrefServiceSimple;
+class TestSigninClient;
+class AccountTrackerService;
Bernhard Bauer 2016/06/28 13:47:39 Nit: Sort alphabetically
dgn 2016/06/28 16:38:57 Done.
+
+namespace ntp_snippets {
+namespace test {
+
+class MockSyncService : public sync_driver::FakeSyncService {
+ public:
+ MockSyncService();
+ virtual ~MockSyncService();
+ MOCK_CONST_METHOD0(CanSyncStart, bool());
+ MOCK_CONST_METHOD0(IsSyncActive, bool());
+ MOCK_CONST_METHOD0(ConfigurationDone, bool());
+ MOCK_CONST_METHOD0(IsEncryptEverythingEnabled, bool());
+ MOCK_CONST_METHOD0(GetActiveDataTypes, syncer::ModelTypeSet());
+};
+
+// Common base for snippet tests, handles initializing mocks for sync and
+// signin. |SetUp()| should be called if a subclass overrides it.
+class NTPSnippetsTestBase : public testing::Test {
+ public:
+ void SetUp() override;
+
+ protected:
+ NTPSnippetsTestBase();
+ ~NTPSnippetsTestBase() override;
+ void ResetSigninManager();
+
+ MockSyncService* mock_sync_service() { return mock_sync_service_.get(); }
+ FakeSigninManagerBase* fake_signin_manager() {
+ return fake_signin_manager_.get();
+ }
+ TestingPrefServiceSimple* pref_service() { return pref_service_.get(); }
+
+ private:
+ void ResetSyncServiceMock();
+ std::unique_ptr<FakeSigninManagerBase> fake_signin_manager_;
+ std::unique_ptr<MockSyncService> mock_sync_service_;
+ std::unique_ptr<TestingPrefServiceSimple> pref_service_;
+ std::unique_ptr<TestSigninClient> signin_client_;
+ std::unique_ptr<AccountTrackerService> account_tracker_;
+};
+
+} // namespace test
+} // namespace ntp_snippets
+
+#endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_TEST_UTILS_H_

Powered by Google App Engine
This is Rietveld 408576698