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

Unified Diff: components/ntp_snippets/remote/remote_suggestions_status_service_unittest.cc

Issue 2556543003: Add another unittest for configuring sign-in dependency. (Closed)
Patch Set: Marc's comments Created 4 years 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
« no previous file with comments | « components/ntp_snippets/remote/remote_suggestions_status_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/remote/remote_suggestions_status_service_unittest.cc
diff --git a/components/ntp_snippets/remote/remote_suggestions_status_service_unittest.cc b/components/ntp_snippets/remote/remote_suggestions_status_service_unittest.cc
index a8c6baaf8f44587c09de836e92fbd5b93a019b7c..30511f81fb8631f21562fb3bcef1c595a3920a8c 100644
--- a/components/ntp_snippets/remote/remote_suggestions_status_service_unittest.cc
+++ b/components/ntp_snippets/remote/remote_suggestions_status_service_unittest.cc
@@ -6,6 +6,8 @@
#include <memory>
+#include "components/ntp_snippets/features.h"
+#include "components/ntp_snippets/ntp_snippets_constants.h"
#include "components/ntp_snippets/pref_names.h"
#include "components/ntp_snippets/remote/test_utils.h"
#include "components/prefs/pref_registry_simple.h"
@@ -14,6 +16,7 @@
#include "components/signin/core/browser/fake_signin_manager.h"
#include "components/signin/core/browser/test_signin_client.h"
#include "components/signin/core/common/signin_pref_names.h"
+#include "components/variations/variations_params_manager.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -33,11 +36,40 @@ class RemoteSuggestionsStatusServiceTest : public ::testing::Test {
protected:
test::RemoteSuggestionsTestUtils utils_;
+ variations::testing::VariationParamsManager params_manager_;
};
-// TODO(jkrcal): Extend the ways to override variation parameters in unit-test
-// (bug 645447), and recover the SigninStateCompatibility test that sign-in is
-// required when the parameter is overriden.
+TEST_F(RemoteSuggestionsStatusServiceTest, SigninNeededIfSpecifiedByParam) {
+ // Specify by the parameter that signin is required.
+ params_manager_.SetVariationParamsWithFeatureAssociations(
+ ntp_snippets::kStudyName, {{"fetching_requires_signin", "true"}},
+ {ntp_snippets::kArticleSuggestionsFeature.name});
+
+ auto service = MakeService();
+
+ // The default test setup is signed out.
+ EXPECT_EQ(RemoteSuggestionsStatus::SIGNED_OUT_AND_DISABLED,
+ service->GetStatusFromDeps());
+
+ // Once signed in, we should be in a compatible state.
+ utils_.fake_signin_manager()->SignIn("foo@bar.com");
+ EXPECT_EQ(RemoteSuggestionsStatus::ENABLED_AND_SIGNED_IN,
+ service->GetStatusFromDeps());
+}
+
+TEST_F(RemoteSuggestionsStatusServiceTest, NoSigninNeeded) {
+ auto service = MakeService();
+
+ // By default, no signin is required.
+ EXPECT_EQ(RemoteSuggestionsStatus::ENABLED_AND_SIGNED_OUT,
+ service->GetStatusFromDeps());
+
+ // One can still sign in.
+ utils_.fake_signin_manager()->SignIn("foo@bar.com");
+ EXPECT_EQ(RemoteSuggestionsStatus::ENABLED_AND_SIGNED_IN,
+ service->GetStatusFromDeps());
+}
+
TEST_F(RemoteSuggestionsStatusServiceTest, DisabledViaPref) {
auto service = MakeService();
@@ -50,7 +82,7 @@ TEST_F(RemoteSuggestionsStatusServiceTest, DisabledViaPref) {
EXPECT_EQ(RemoteSuggestionsStatus::EXPLICITLY_DISABLED,
service->GetStatusFromDeps());
- // Signing-in shouldn't matter anymore.
+ // The other dependencies shouldn't matter anymore.
utils_.fake_signin_manager()->SignIn("foo@bar.com");
EXPECT_EQ(RemoteSuggestionsStatus::EXPLICITLY_DISABLED,
service->GetStatusFromDeps());
« no previous file with comments | « components/ntp_snippets/remote/remote_suggestions_status_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698