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

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: yolo: another big bag of changes 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 mock_sync_service()->active_data_types_ = syncer::ModelTypeSet();
50 EXPECT_EQ(DisabledReason::HISTORY_SYNC_DISABLED,
51 service()->GetDisabledReasonFromDeps());
52
53 // Encryption enabled.
54 mock_sync_service()->is_encrypt_everything_enabled_ = true;
55 EXPECT_EQ(DisabledReason::PASSPHRASE_ENCRYPTION_ENABLED,
56 service()->GetDisabledReasonFromDeps());
57
58 // Not done loading.
59 mock_sync_service()->configuration_done_ = false;
60 mock_sync_service()->active_data_types_ = syncer::ModelTypeSet();
61 EXPECT_EQ(DisabledReason::HISTORY_SYNC_STATE_UNKNOWN,
62 service()->GetDisabledReasonFromDeps());
63
64 // Sync disabled.
65 mock_sync_service()->can_sync_start_ = false;
66 EXPECT_EQ(DisabledReason::SYNC_DISABLED,
67 service()->GetDisabledReasonFromDeps());
68 }
69
70 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/ntp_snippets_status_service.cc ('k') | components/ntp_snippets/ntp_snippets_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698