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

Side by Side Diff: components/ntp_snippets/ntp_snippets_status_service_unittest.cc

Issue 2343583002: Change the default value of the fetching_requires_signin parameter (Closed)
Patch Set: Reverting the unittest experiment Created 4 years, 3 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
« no previous file with comments | « components/ntp_snippets/ntp_snippets_status_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 19 matching lines...) Expand all
30 30
31 std::unique_ptr<NTPSnippetsStatusService> MakeService() { 31 std::unique_ptr<NTPSnippetsStatusService> MakeService() {
32 return base::MakeUnique<NTPSnippetsStatusService>( 32 return base::MakeUnique<NTPSnippetsStatusService>(
33 utils_.fake_signin_manager(), utils_.pref_service()); 33 utils_.fake_signin_manager(), utils_.pref_service());
34 } 34 }
35 35
36 protected: 36 protected:
37 test::NTPSnippetsTestUtils utils_; 37 test::NTPSnippetsTestUtils utils_;
38 }; 38 };
39 39
40 TEST_F(NTPSnippetsStatusServiceTest, SigninStateCompatibility) { 40 // TODO(jkrcal): Extend the ways to override variation parameters in unit-test
41 auto service = MakeService(); 41 // (bug 645447), and recover the SigninStateCompatibility test that sign-in is
42 42 // required when the parameter is overriden.
43 // The default test setup is signed out.
44 EXPECT_EQ(DisabledReason::SIGNED_OUT, service->GetDisabledReasonFromDeps());
45
46 // Once signed in, we should be in a compatible state.
47 utils_.fake_signin_manager()->SignIn("foo@bar.com");
48 EXPECT_EQ(DisabledReason::NONE, service->GetDisabledReasonFromDeps());
49 }
50
51 TEST_F(NTPSnippetsStatusServiceTest, DisabledViaPref) { 43 TEST_F(NTPSnippetsStatusServiceTest, DisabledViaPref) {
52 auto service = MakeService(); 44 auto service = MakeService();
53 45
54 // The default test setup is signed out. 46 // The default test setup is signed out. The service is enabled.
55 ASSERT_EQ(DisabledReason::SIGNED_OUT, service->GetDisabledReasonFromDeps()); 47 ASSERT_EQ(DisabledReason::NONE, service->GetDisabledReasonFromDeps());
56 48
57 // Once the enabled pref is set to false, we should be disabled. 49 // Once the enabled pref is set to false, we should be disabled.
58 utils_.pref_service()->SetBoolean(prefs::kEnableSnippets, false); 50 utils_.pref_service()->SetBoolean(prefs::kEnableSnippets, false);
59 EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED, 51 EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED,
60 service->GetDisabledReasonFromDeps()); 52 service->GetDisabledReasonFromDeps());
61 53
62 // The other dependencies shouldn't matter anymore. 54 // Signing-in shouldn't matter anymore.
63 utils_.fake_signin_manager()->SignIn("foo@bar.com"); 55 utils_.fake_signin_manager()->SignIn("foo@bar.com");
64 EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED, 56 EXPECT_EQ(DisabledReason::EXPLICITLY_DISABLED,
65 service->GetDisabledReasonFromDeps()); 57 service->GetDisabledReasonFromDeps());
66 } 58 }
67 59
68 } // namespace ntp_snippets 60 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/ntp_snippets_status_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698