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

Unified Diff: components/ntp_snippets/breaking_news/subscription_manager_unittest.cc

Issue 2922543002: [NTP::Push] Add Content Suggestions GCM App Handler (Closed)
Patch Set: Implement unsubscribe. Created 3 years, 6 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/breaking_news/subscription_manager_unittest.cc
diff --git a/components/ntp_snippets/breaking_news/subscription_manager_unittest.cc b/components/ntp_snippets/breaking_news/subscription_manager_unittest.cc
index 1cddf00af7bb04649b2fcf188bdd01e0e437f06f..160fd5b14c8e85d513b369211614209117190ea0 100644
--- a/components/ntp_snippets/breaking_news/subscription_manager_unittest.cc
+++ b/components/ntp_snippets/breaking_news/subscription_manager_unittest.cc
@@ -64,6 +64,7 @@ class SubscriptionManagerTest : public testing::Test {
TEST_F(SubscriptionManagerTest, SubscribeSuccessfully) {
std::string token = "1234567890";
SubscriptionManager manager(GetRequestContext(), GetPrefService(),
+ GURL("http://valid-url.test"),
Peter Beverloo 2017/06/08 07:02:40 nit: usually we store repeated strings in a consta
mamir 2017/06/08 10:31:38 Done.
GURL("http://valid-url.test"));
manager.Subscribe(token);
RespondWithData("");
@@ -75,6 +76,7 @@ TEST_F(SubscriptionManagerTest, SubscribeSuccessfully) {
TEST_F(SubscriptionManagerTest, SubscribeWithErrors) {
std::string token = "1234567890";
SubscriptionManager manager(GetRequestContext(), GetPrefService(),
+ GURL("http://valid-url.test"),
GURL("http://valid-url.test"));
manager.Subscribe(token);
RespondWithError(net::ERR_TIMED_OUT);
@@ -82,4 +84,31 @@ TEST_F(SubscriptionManagerTest, SubscribeWithErrors) {
ntp_snippets::prefs::kContentSuggestionsSubscriptionDataToken));
}
+TEST_F(SubscriptionManagerTest, UnsubscribeSuccessfully) {
+ std::string token = "1234567890";
+ GetPrefService()->SetString(
+ ntp_snippets::prefs::kContentSuggestionsSubscriptionDataToken, token);
+ SubscriptionManager manager(GetRequestContext(), GetPrefService(),
+ GURL("http://valid-url.test"),
+ GURL("http://valid-url.test"));
+ manager.Unsubscribe(token);
+ RespondWithData("");
+ EXPECT_FALSE(GetPrefService()->HasPrefPath(
+ ntp_snippets::prefs::kContentSuggestionsSubscriptionDataToken));
+}
+
+TEST_F(SubscriptionManagerTest, UnsubscribeWithErrors) {
+ std::string token = "1234567890";
+ GetPrefService()->SetString(
+ ntp_snippets::prefs::kContentSuggestionsSubscriptionDataToken, token);
+ SubscriptionManager manager(GetRequestContext(), GetPrefService(),
+ GURL("http://valid-url.test"),
+ GURL("http://valid-url.test"));
+ manager.Unsubscribe(token);
+ RespondWithError(net::ERR_TIMED_OUT);
+ EXPECT_EQ(GetPrefService()->GetString(
+ ntp_snippets::prefs::kContentSuggestionsSubscriptionDataToken),
+ token);
+}
+
} // namespace ntp_snippets

Powered by Google App Engine
This is Rietveld 408576698