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

Side by Side Diff: google_apis/gcm/engine/mcs_client_unittest.cc

Issue 160703002: [GCM] Track connection failures properly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « google_apis/gcm/engine/mcs_client.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "google_apis/gcm/engine/mcs_client.h" 5 #include "google_apis/gcm/engine/mcs_client.h"
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 TEST_F(MCSClientTest, LoginSuccess) { 263 TEST_F(MCSClientTest, LoginSuccess) {
264 BuildMCSClient(); 264 BuildMCSClient();
265 InitializeClient(); 265 InitializeClient();
266 LoginClient(std::vector<std::string>()); 266 LoginClient(std::vector<std::string>());
267 EXPECT_TRUE(connection_factory()->IsEndpointReachable()); 267 EXPECT_TRUE(connection_factory()->IsEndpointReachable());
268 EXPECT_TRUE(init_success()); 268 EXPECT_TRUE(init_success());
269 ASSERT_TRUE(received_message()); 269 ASSERT_TRUE(received_message());
270 EXPECT_EQ(kLoginResponseTag, received_message()->tag()); 270 EXPECT_EQ(kLoginResponseTag, received_message()->tag());
271 } 271 }
272 272
273 // Encounter a server error during the login attempt. 273 // Encounter a server error during the login attempt. Should trigger a
274 // reconnect.
274 TEST_F(MCSClientTest, FailLogin) { 275 TEST_F(MCSClientTest, FailLogin) {
275 BuildMCSClient(); 276 BuildMCSClient();
276 InitializeClient(); 277 InitializeClient();
277 GetFakeHandler()->set_fail_login(true); 278 GetFakeHandler()->set_fail_login(true);
279 connection_factory()->set_delay_reconnect(true);
278 LoginClient(std::vector<std::string>()); 280 LoginClient(std::vector<std::string>());
279 EXPECT_FALSE(connection_factory()->IsEndpointReachable()); 281 EXPECT_FALSE(connection_factory()->IsEndpointReachable());
280 EXPECT_FALSE(init_success()); 282 EXPECT_FALSE(init_success());
281 EXPECT_FALSE(received_message()); 283 EXPECT_FALSE(received_message());
284 EXPECT_TRUE(connection_factory()->reconnect_pending());
282 } 285 }
283 286
284 // Send a message without RMQ support. 287 // Send a message without RMQ support.
285 TEST_F(MCSClientTest, SendMessageNoRMQ) { 288 TEST_F(MCSClientTest, SendMessageNoRMQ) {
286 BuildMCSClient(); 289 BuildMCSClient();
287 InitializeClient(); 290 InitializeClient();
288 LoginClient(std::vector<std::string>()); 291 LoginClient(std::vector<std::string>());
289 MCSMessage message(BuildDataMessage("from", "category", "X", 1, "", 0, 1, 0)); 292 MCSMessage message(BuildDataMessage("from", "category", "X", 1, "", 0, 1, 0));
290 GetFakeHandler()->ExpectOutgoingMessage(message); 293 GetFakeHandler()->ExpectOutgoingMessage(message);
291 mcs_client()->SendMessage(message); 294 mcs_client()->SendMessage(message);
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 LoginClient(std::vector<std::string>()); 714 LoginClient(std::vector<std::string>());
712 PumpLoop(); 715 PumpLoop();
713 EXPECT_EQ("X", sent_message_id()); 716 EXPECT_EQ("X", sent_message_id());
714 EXPECT_EQ(MCSClient::TTL_EXCEEDED, message_send_status()); 717 EXPECT_EQ(MCSClient::TTL_EXCEEDED, message_send_status());
715 EXPECT_TRUE(GetFakeHandler()->AllOutgoingMessagesReceived()); 718 EXPECT_TRUE(GetFakeHandler()->AllOutgoingMessagesReceived());
716 } 719 }
717 720
718 } // namespace 721 } // namespace
719 722
720 } // namespace gcm 723 } // namespace gcm
OLDNEW
« no previous file with comments | « google_apis/gcm/engine/mcs_client.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698