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

Unified Diff: components/ntp_snippets/ntp_snippets_status_service_unittest.cc

Issue 2158373002: [NTP Snippets] Add a pref to disable the NTPSnippetsService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
Index: components/ntp_snippets/ntp_snippets_status_service_unittest.cc
diff --git a/components/ntp_snippets/ntp_snippets_status_service_unittest.cc b/components/ntp_snippets/ntp_snippets_status_service_unittest.cc
index 5568d805349bf38f29645e3792cf785d5b779946..6fce53e49bd6de4dbc31200c55bb3e5e7383f672 100644
--- a/components/ntp_snippets/ntp_snippets_status_service_unittest.cc
+++ b/components/ntp_snippets/ntp_snippets_status_service_unittest.cc
@@ -7,6 +7,7 @@
#include <memory>
#include "components/ntp_snippets/ntp_snippets_test_utils.h"
+#include "components/ntp_snippets/pref_names.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h"
#include "components/signin/core/browser/account_tracker_service.h"
@@ -23,11 +24,15 @@ namespace ntp_snippets {
class NTPSnippetsStatusServiceTest : public test::NTPSnippetsTestBase {
public:
+ NTPSnippetsStatusServiceTest() {
+ NTPSnippetsStatusService::RegisterProfilePrefs(pref_service()->registry());
+ }
+
void SetUp() override {
test::NTPSnippetsTestBase::SetUp();
- service_.reset(new NTPSnippetsStatusService(fake_signin_manager(),
- mock_sync_service()));
+ service_.reset(new NTPSnippetsStatusService(
+ fake_signin_manager(), mock_sync_service(), pref_service()));
}
protected:
@@ -67,4 +72,35 @@ TEST_F(NTPSnippetsStatusServiceTest, SyncStateCompatibility) {
service()->GetDisabledReasonFromDeps());
}
+TEST_F(NTPSnippetsStatusServiceTest, DisabledViaPref) {
+ // The default test setup is signed out.
+ ASSERT_EQ(DisabledReason::SIGNED_OUT, service()->GetDisabledReasonFromDeps());
+
+ // Once the disabled pref is set, we should be disabled.
+ pref_service()->SetBoolean(prefs::kDisableSnippets, true);
+ EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED,
+ service()->GetDisabledReasonFromDeps());
+
+ // The other dependencies shouldn't matter anymore.
+ fake_signin_manager()->SignIn("foo@bar.com");
+ EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED,
+ service()->GetDisabledReasonFromDeps());
+
+ mock_sync_service()->active_data_types_ = syncer::ModelTypeSet();
+ EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED,
+ service()->GetDisabledReasonFromDeps());
+
+ mock_sync_service()->is_encrypt_everything_enabled_ = true;
+ EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED,
+ service()->GetDisabledReasonFromDeps());
+
+ mock_sync_service()->configuration_done_ = false;
+ EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED,
+ service()->GetDisabledReasonFromDeps());
+
+ mock_sync_service()->can_sync_start_ = false;
+ EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED,
+ service()->GetDisabledReasonFromDeps());
+}
+
} // namespace ntp_snippets

Powered by Google App Engine
This is Rietveld 408576698