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

Unified Diff: components/ntp_snippets/ntp_snippets_status_service_unittest.cc

Issue 2285133004: Overhaul ntp_snippets_service_unittest.cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: merge Created 4 years, 4 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 6b3c8cfa7605ff6ee8904f413f0278a2facc5cce..f3bf30b1fb0bdfd4f73b2203561fd2cc9ba0f0c6 100644
--- a/components/ntp_snippets/ntp_snippets_status_service_unittest.cc
+++ b/components/ntp_snippets/ntp_snippets_status_service_unittest.cc
@@ -21,48 +21,48 @@ using testing::Return;
namespace ntp_snippets {
-class NTPSnippetsStatusServiceTest : public test::NTPSnippetsTestBase {
+class NTPSnippetsStatusServiceTest : public ::testing::Test {
public:
NTPSnippetsStatusServiceTest() {
- NTPSnippetsStatusService::RegisterProfilePrefs(pref_service()->registry());
+ NTPSnippetsStatusService::RegisterProfilePrefs(
+ utils_.pref_service()->registry());
}
- void SetUp() override {
- test::NTPSnippetsTestBase::SetUp();
-
- service_.reset(
- new NTPSnippetsStatusService(fake_signin_manager(), pref_service()));
+ std::unique_ptr<NTPSnippetsStatusService> MakeService() {
+ return base::MakeUnique<NTPSnippetsStatusService>(
+ utils_.fake_signin_manager(), utils_.pref_service());
}
protected:
- NTPSnippetsStatusService* service() { return service_.get(); }
-
- private:
- std::unique_ptr<NTPSnippetsStatusService> service_;
+ test::NTPSnippetsTestUtils utils_;
};
TEST_F(NTPSnippetsStatusServiceTest, SigninStateCompatibility) {
+ auto service = MakeService();
+
// The default test setup is signed out.
- EXPECT_EQ(DisabledReason::SIGNED_OUT, service()->GetDisabledReasonFromDeps());
+ EXPECT_EQ(DisabledReason::SIGNED_OUT, service->GetDisabledReasonFromDeps());
// Once signed in, we should be in a compatible state.
- fake_signin_manager()->SignIn("foo@bar.com");
- EXPECT_EQ(DisabledReason::NONE, service()->GetDisabledReasonFromDeps());
+ utils_.fake_signin_manager()->SignIn("foo@bar.com");
+ EXPECT_EQ(DisabledReason::NONE, service->GetDisabledReasonFromDeps());
}
TEST_F(NTPSnippetsStatusServiceTest, DisabledViaPref) {
+ auto service = MakeService();
+
// The default test setup is signed out.
- ASSERT_EQ(DisabledReason::SIGNED_OUT, service()->GetDisabledReasonFromDeps());
+ ASSERT_EQ(DisabledReason::SIGNED_OUT, service->GetDisabledReasonFromDeps());
// Once the enabled pref is set to false, we should be disabled.
- pref_service()->SetBoolean(prefs::kEnableSnippets, false);
+ utils_.pref_service()->SetBoolean(prefs::kEnableSnippets, false);
EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED,
- service()->GetDisabledReasonFromDeps());
+ service->GetDisabledReasonFromDeps());
// The other dependencies shouldn't matter anymore.
- fake_signin_manager()->SignIn("foo@bar.com");
+ utils_.fake_signin_manager()->SignIn("foo@bar.com");
EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED,
- service()->GetDisabledReasonFromDeps());
+ service->GetDisabledReasonFromDeps());
}
} // namespace ntp_snippets

Powered by Google App Engine
This is Rietveld 408576698