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

Side by Side Diff: components/ntp_snippets/ntp_snippets_status_service_unittest.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, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/ntp_snippets/ntp_snippets_status_service.h"
6
7 #include <memory>
8
9 #include "components/ntp_snippets/ntp_snippets_test_utils.h"
10 #include "components/prefs/pref_registry_simple.h"
11 #include "components/prefs/testing_pref_service.h"
12 #include "components/signin/core/browser/account_tracker_service.h"
13 #include "components/signin/core/browser/fake_signin_manager.h"
14 #include "components/signin/core/browser/test_signin_client.h"
15 #include "components/signin/core/common/signin_pref_names.h"
16 #include "components/sync_driver/fake_sync_service.h"
17 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h"
19
20 using testing::Return;
21
22 namespace ntp_snippets {
23
24 class NTPSnippetsStatusServiceTest : public test::NTPSnippetsTestBase {
25 public:
26 void SetUp() override {
27 test::NTPSnippetsTestBase::SetUp();
28
29 service_.reset(new NTPSnippetsStatusService(fake_signin_manager(),
30 mock_sync_service()));
31 }
32
33 protected:
34 NTPSnippetsStatusService* service() { return service_.get(); }
35
36 private:
37 std::unique_ptr<NTPSnippetsStatusService> service_;
38 };
39
40 TEST_F(NTPSnippetsStatusServiceTest, SyncStateCompatibility) {
41 // The default test setup is signed out.
42 EXPECT_EQ(DisabledReason::SIGNED_OUT, service()->GetDisabledReasonFromDeps());
43
44 // Once signed in, we should be in a compatible sync state.
45 fake_signin_manager()->SignIn("foo@bar.com");
46 EXPECT_EQ(DisabledReason::NONE, service()->GetDisabledReasonFromDeps());
47
48 // History sync disabled.
49 ON_CALL(*mock_sync_service(), GetActiveDataTypes())
50 .WillByDefault(Return(syncer::ModelTypeSet()));
51 EXPECT_EQ(DisabledReason::HISTORY_SYNC_DISABLED,
52 service()->GetDisabledReasonFromDeps());
53
54 // Encryption enabled.
55 ON_CALL(*mock_sync_service(), IsEncryptEverythingEnabled())
56 .WillByDefault(Return(true));
57 EXPECT_EQ(DisabledReason::PASSPHRASE_ENCRYPTION_ENABLED,
58 service()->GetDisabledReasonFromDeps());
59
60 // Not done loading.
61 ON_CALL(*mock_sync_service(), ConfigurationDone())
62 .WillByDefault(Return(false));
63 ON_CALL(*mock_sync_service(), GetActiveDataTypes())
64 .WillByDefault(Return(syncer::ModelTypeSet()));
65 EXPECT_EQ(DisabledReason::HISTORY_SYNC_STATE_UNKNOWN,
66 service()->GetDisabledReasonFromDeps());
67
68 // Sync disabled.
69 ON_CALL(*mock_sync_service(), CanSyncStart()).WillByDefault(Return(false));
70 EXPECT_EQ(DisabledReason::SYNC_DISABLED,
71 service()->GetDisabledReasonFromDeps());
72 }
73
74 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698