Chromium Code Reviews| 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 |