| OLD | NEW |
| 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_status_service.h" | 5 #include "components/ntp_snippets/ntp_snippets_status_service.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "components/ntp_snippets/ntp_snippets_test_utils.h" | 9 #include "components/ntp_snippets/ntp_snippets_test_utils.h" |
| 10 #include "components/ntp_snippets/pref_names.h" | 10 #include "components/ntp_snippets/pref_names.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // Sync disabled. | 69 // Sync disabled. |
| 70 mock_sync_service()->can_sync_start_ = false; | 70 mock_sync_service()->can_sync_start_ = false; |
| 71 EXPECT_EQ(DisabledReason::SYNC_DISABLED, | 71 EXPECT_EQ(DisabledReason::SYNC_DISABLED, |
| 72 service()->GetDisabledReasonFromDeps()); | 72 service()->GetDisabledReasonFromDeps()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 TEST_F(NTPSnippetsStatusServiceTest, DisabledViaPref) { | 75 TEST_F(NTPSnippetsStatusServiceTest, DisabledViaPref) { |
| 76 // The default test setup is signed out. | 76 // The default test setup is signed out. |
| 77 ASSERT_EQ(DisabledReason::SIGNED_OUT, service()->GetDisabledReasonFromDeps()); | 77 ASSERT_EQ(DisabledReason::SIGNED_OUT, service()->GetDisabledReasonFromDeps()); |
| 78 | 78 |
| 79 // Once the disabled pref is set, we should be disabled. | 79 // Once the enabled pref is set to false, we should be disabled. |
| 80 pref_service()->SetBoolean(prefs::kDisableSnippets, true); | 80 pref_service()->SetBoolean(prefs::kEnableSnippets, false); |
| 81 EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED, | 81 EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED, |
| 82 service()->GetDisabledReasonFromDeps()); | 82 service()->GetDisabledReasonFromDeps()); |
| 83 | 83 |
| 84 // The other dependencies shouldn't matter anymore. | 84 // The other dependencies shouldn't matter anymore. |
| 85 fake_signin_manager()->SignIn("foo@bar.com"); | 85 fake_signin_manager()->SignIn("foo@bar.com"); |
| 86 EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED, | 86 EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED, |
| 87 service()->GetDisabledReasonFromDeps()); | 87 service()->GetDisabledReasonFromDeps()); |
| 88 | 88 |
| 89 mock_sync_service()->active_data_types_ = syncer::ModelTypeSet(); | 89 mock_sync_service()->active_data_types_ = syncer::ModelTypeSet(); |
| 90 EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED, | 90 EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED, |
| 91 service()->GetDisabledReasonFromDeps()); | 91 service()->GetDisabledReasonFromDeps()); |
| 92 | 92 |
| 93 mock_sync_service()->is_encrypt_everything_enabled_ = true; | 93 mock_sync_service()->is_encrypt_everything_enabled_ = true; |
| 94 EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED, | 94 EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED, |
| 95 service()->GetDisabledReasonFromDeps()); | 95 service()->GetDisabledReasonFromDeps()); |
| 96 | 96 |
| 97 mock_sync_service()->configuration_done_ = false; | 97 mock_sync_service()->configuration_done_ = false; |
| 98 EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED, | 98 EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED, |
| 99 service()->GetDisabledReasonFromDeps()); | 99 service()->GetDisabledReasonFromDeps()); |
| 100 | 100 |
| 101 mock_sync_service()->can_sync_start_ = false; | 101 mock_sync_service()->can_sync_start_ = false; |
| 102 EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED, | 102 EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED, |
| 103 service()->GetDisabledReasonFromDeps()); | 103 service()->GetDisabledReasonFromDeps()); |
| 104 } | 104 } |
| 105 | 105 |
| 106 } // namespace ntp_snippets | 106 } // namespace ntp_snippets |
| OLD | NEW |