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

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

Issue 2922543002: [NTP::Push] Add Content Suggestions GCM App Handler (Closed)
Patch Set: peter@ comments. 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..7faf9d2dd7cf0c1f5d9f4a92d113d87f832c082a 100644
--- a/components/ntp_snippets/breaking_news/subscription_manager_unittest.cc
+++ b/components/ntp_snippets/breaking_news/subscription_manager_unittest.cc
@@ -54,6 +54,8 @@ class SubscriptionManagerTest : public testing::Test {
url_fetcher->delegate()->OnURLFetchComplete(url_fetcher);
}
+ const std::string url{"http://valid-url.test"};
+
private:
base::MessageLoop message_loop_;
scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_;
@@ -63,8 +65,8 @@ class SubscriptionManagerTest : public testing::Test {
TEST_F(SubscriptionManagerTest, SubscribeSuccessfully) {
std::string token = "1234567890";
- SubscriptionManager manager(GetRequestContext(), GetPrefService(),
- GURL("http://valid-url.test"));
+ SubscriptionManager manager(GetRequestContext(), GetPrefService(), GURL(url),
+ GURL(url));
manager.Subscribe(token);
RespondWithData("");
EXPECT_EQ(GetPrefService()->GetString(
@@ -74,12 +76,37 @@ TEST_F(SubscriptionManagerTest, SubscribeSuccessfully) {
TEST_F(SubscriptionManagerTest, SubscribeWithErrors) {
std::string token = "1234567890";
- SubscriptionManager manager(GetRequestContext(), GetPrefService(),
- GURL("http://valid-url.test"));
+ SubscriptionManager manager(GetRequestContext(), GetPrefService(), GURL(url),
+ GURL(url));
manager.Subscribe(token);
RespondWithError(net::ERR_TIMED_OUT);
EXPECT_FALSE(GetPrefService()->HasPrefPath(
ntp_snippets::prefs::kContentSuggestionsSubscriptionDataToken));
}
+TEST_F(SubscriptionManagerTest, UnsubscribeSuccessfully) {
+ std::string token = "1234567890";
+ GetPrefService()->SetString(
+ ntp_snippets::prefs::kContentSuggestionsSubscriptionDataToken, token);
+ SubscriptionManager manager(GetRequestContext(), GetPrefService(), GURL(url),
+ GURL(url));
+ 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(url),
+ GURL(url));
+ 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