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

Side by Side Diff: components/ntp_snippets/remote/remote_suggestions_status_service_unittest.cc

Issue 2667623002: [Remote suggestions] Clean up variation params in the status service (Closed)
Patch Set: Rebase Created 3 years, 10 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/remote/remote_suggestions_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/remote/remote_suggestions_status_service.h" 5 #include "components/ntp_snippets/remote/remote_suggestions_status_service.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "components/ntp_snippets/features.h" 10 #include "components/ntp_snippets/features.h"
(...skipping 22 matching lines...) Expand all
33 std::unique_ptr<RemoteSuggestionsStatusService> MakeService() { 33 std::unique_ptr<RemoteSuggestionsStatusService> MakeService() {
34 return base::MakeUnique<RemoteSuggestionsStatusService>( 34 return base::MakeUnique<RemoteSuggestionsStatusService>(
35 utils_.fake_signin_manager(), utils_.pref_service()); 35 utils_.fake_signin_manager(), utils_.pref_service());
36 } 36 }
37 37
38 protected: 38 protected:
39 test::RemoteSuggestionsTestUtils utils_; 39 test::RemoteSuggestionsTestUtils utils_;
40 variations::testing::VariationParamsManager params_manager_; 40 variations::testing::VariationParamsManager params_manager_;
41 }; 41 };
42 42
43 TEST_F(RemoteSuggestionsStatusServiceTest, SigninNeededIfSpecifiedByParam) {
44 // Specify by the parameter that signin is required.
45 params_manager_.SetVariationParamsWithFeatureAssociations(
46 ntp_snippets::kStudyName, {{"fetching_requires_signin", "true"}},
47 {ntp_snippets::kArticleSuggestionsFeature.name});
48
49 auto service = MakeService();
50
51 // The default test setup is signed out.
52 EXPECT_EQ(RemoteSuggestionsStatus::SIGNED_OUT_AND_DISABLED,
53 service->GetStatusFromDeps());
54
55 // Once signed in, we should be in a compatible state.
56 utils_.fake_signin_manager()->SignIn("foo@bar.com");
57 EXPECT_EQ(RemoteSuggestionsStatus::ENABLED_AND_SIGNED_IN,
58 service->GetStatusFromDeps());
59 }
60
61 TEST_F(RemoteSuggestionsStatusServiceTest, NoSigninNeeded) { 43 TEST_F(RemoteSuggestionsStatusServiceTest, NoSigninNeeded) {
62 auto service = MakeService(); 44 auto service = MakeService();
63 45
64 // By default, no signin is required. 46 // By default, no signin is required.
65 EXPECT_EQ(RemoteSuggestionsStatus::ENABLED_AND_SIGNED_OUT, 47 EXPECT_EQ(RemoteSuggestionsStatus::ENABLED_AND_SIGNED_OUT,
66 service->GetStatusFromDeps()); 48 service->GetStatusFromDeps());
67 49
68 // One can still sign in. 50 // One can still sign in.
69 utils_.fake_signin_manager()->SignIn("foo@bar.com"); 51 utils_.fake_signin_manager()->SignIn("foo@bar.com");
70 EXPECT_EQ(RemoteSuggestionsStatus::ENABLED_AND_SIGNED_IN, 52 EXPECT_EQ(RemoteSuggestionsStatus::ENABLED_AND_SIGNED_IN,
(...skipping 12 matching lines...) Expand all
83 EXPECT_EQ(RemoteSuggestionsStatus::EXPLICITLY_DISABLED, 65 EXPECT_EQ(RemoteSuggestionsStatus::EXPLICITLY_DISABLED,
84 service->GetStatusFromDeps()); 66 service->GetStatusFromDeps());
85 67
86 // The other dependencies shouldn't matter anymore. 68 // The other dependencies shouldn't matter anymore.
87 utils_.fake_signin_manager()->SignIn("foo@bar.com"); 69 utils_.fake_signin_manager()->SignIn("foo@bar.com");
88 EXPECT_EQ(RemoteSuggestionsStatus::EXPLICITLY_DISABLED, 70 EXPECT_EQ(RemoteSuggestionsStatus::EXPLICITLY_DISABLED,
89 service->GetStatusFromDeps()); 71 service->GetStatusFromDeps());
90 } 72 }
91 73
92 } // namespace ntp_snippets 74 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/remote/remote_suggestions_status_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698