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

Unified Diff: components/invalidation/gcm_network_channel_unittest.cc

Issue 334253006: Notify SyncNetworkChannel about GCM connection state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed typo Created 6 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
« no previous file with comments | « components/invalidation/gcm_network_channel_delegate.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/invalidation/gcm_network_channel_unittest.cc
diff --git a/components/invalidation/gcm_network_channel_unittest.cc b/components/invalidation/gcm_network_channel_unittest.cc
index 29cab076baa89398623b6e79ca364c7a39c7c619..be61ba98a1ef4d322d55c408acd0e30f7c360bdd 100644
--- a/components/invalidation/gcm_network_channel_unittest.cc
+++ b/components/invalidation/gcm_network_channel_unittest.cc
@@ -17,7 +17,10 @@ class TestGCMNetworkChannelDelegate : public GCMNetworkChannelDelegate {
TestGCMNetworkChannelDelegate()
: register_call_count_(0) {}
- virtual void Initialize() OVERRIDE {}
+ virtual void Initialize(
+ GCMNetworkChannelDelegate::ConnectionStateCallback callback) OVERRIDE {
+ connection_state_callback = callback;
+ }
virtual void RequestToken(RequestTokenCallback callback) OVERRIDE {
request_token_callback = callback;
@@ -41,6 +44,7 @@ class TestGCMNetworkChannelDelegate : public GCMNetworkChannelDelegate {
RegisterCallback register_callback;
int register_call_count_;
MessageCallback message_callback;
+ ConnectionStateCallback connection_state_callback;
};
// Backoff policy for test. Run first 5 retries without delay.
@@ -406,7 +410,7 @@ TEST_F(GCMNetworkChannelTest, Base64EncodeDecode) {
EXPECT_EQ(input, plain);
}
-TEST_F(GCMNetworkChannelTest, TransientError) {
+TEST_F(GCMNetworkChannelTest, HttpTransientError) {
EXPECT_FALSE(delegate()->message_callback.is_null());
// POST will fail.
url_fetcher_factory()->SetFakeResponse(GURL("http://test.url.com"),
@@ -437,6 +441,15 @@ TEST_F(GCMNetworkChannelTest, TransientError) {
EXPECT_EQ(INVALIDATIONS_ENABLED, get_last_invalidator_state());
}
+TEST_F(GCMNetworkChannelTest, GcmConnectionState) {
+ delegate()->connection_state_callback.Run(
+ GCMNetworkChannelDelegate::CONNECTION_STATE_OFFLINE);
+ EXPECT_EQ(TRANSIENT_INVALIDATION_ERROR, get_last_invalidator_state());
+ delegate()->connection_state_callback.Run(
+ GCMNetworkChannelDelegate::CONNECTION_STATE_ONLINE);
+ EXPECT_EQ(INVALIDATIONS_ENABLED, get_last_invalidator_state());
+}
+
#if !defined(OS_ANDROID)
TEST_F(GCMNetworkChannelTest, BuildUrl) {
GURL url = BuildUrl("registration.id");
« no previous file with comments | « components/invalidation/gcm_network_channel_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698