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

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

Issue 442123003: [GCM] Adding the OnSendAcknowledgement event (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing code review comments. Created 6 years, 4 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 | « components/invalidation/gcm_invalidation_bridge.cc ('k') | no next file » | 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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 kLoginRequestTag, 356 kLoginRequestTag,
357 BuildLoginRequest(kAndroidId, kSecurityToken, ""). 357 BuildLoginRequest(kAndroidId, kSecurityToken, "").
358 PassAs<const google::protobuf::MessageLite>())); 358 PassAs<const google::protobuf::MessageLite>()));
359 // The second (re)send. 359 // The second (re)send.
360 MCSMessage message2(BuildDataMessage( 360 MCSMessage message2(BuildDataMessage(
361 "from", "category", "X", 1, "1", kTTLValue, 1, kTTLValue - 1, "", 0)); 361 "from", "category", "X", 1, "1", kTTLValue, 1, kTTLValue - 1, "", 0));
362 GetFakeHandler()->ExpectOutgoingMessage(message2); 362 GetFakeHandler()->ExpectOutgoingMessage(message2);
363 mcs_client()->SendMessage(message); 363 mcs_client()->SendMessage(message);
364 PumpLoop(); // Wait for the queuing to happen. 364 PumpLoop(); // Wait for the queuing to happen.
365 EXPECT_EQ(MCSClient::QUEUED, message_send_status()); 365 EXPECT_EQ(MCSClient::QUEUED, message_send_status());
366 EXPECT_EQ("X", sent_message_id());
366 EXPECT_FALSE(GetFakeHandler()->AllOutgoingMessagesReceived()); 367 EXPECT_FALSE(GetFakeHandler()->AllOutgoingMessagesReceived());
367 GetFakeHandler()->set_fail_send(false); 368 GetFakeHandler()->set_fail_send(false);
368 clock()->Advance(base::TimeDelta::FromSeconds(kTTLValue - 1)); 369 clock()->Advance(base::TimeDelta::FromSeconds(kTTLValue - 1));
369 connection_factory()->Connect(); 370 connection_factory()->Connect();
370 WaitForMCSEvent(); // Wait for the login to finish. 371 WaitForMCSEvent(); // Wait for the login to finish.
371 PumpLoop(); // Wait for the send to happen. 372 PumpLoop(); // Wait for the send to happen.
373
374 // Receive the ack.
375 scoped_ptr<mcs_proto::IqStanza> ack = BuildStreamAck();
376 ack->set_last_stream_id_received(2);
377 GetFakeHandler()->ReceiveMessage(
378 MCSMessage(kIqStanzaTag,
379 ack.PassAs<const google::protobuf::MessageLite>()));
380 WaitForMCSEvent();
381
382 EXPECT_EQ(MCSClient::SENT, message_send_status());
383 EXPECT_EQ("X", sent_message_id());
372 EXPECT_TRUE(GetFakeHandler()->AllOutgoingMessagesReceived()); 384 EXPECT_TRUE(GetFakeHandler()->AllOutgoingMessagesReceived());
373 } 385 }
374 386
375 // Send a message with RMQ support without receiving an acknowledgement. On 387 // Send a message with RMQ support without receiving an acknowledgement. On
376 // restart the message should be resent. 388 // restart the message should be resent.
377 TEST_F(MCSClientTest, SendMessageRMQOnRestart) { 389 TEST_F(MCSClientTest, SendMessageRMQOnRestart) {
378 BuildMCSClient(); 390 BuildMCSClient();
379 InitializeClient(); 391 InitializeClient();
380 LoginClient(std::vector<std::string>()); 392 LoginClient(std::vector<std::string>());
381 GetFakeHandler()->set_fail_send(true); 393 GetFakeHandler()->set_fail_send(true);
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 879
868 LoginClient(std::vector<std::string>()); 880 LoginClient(std::vector<std::string>());
869 GetFakeHandler()->ExpectOutgoingMessage(message); 881 GetFakeHandler()->ExpectOutgoingMessage(message);
870 GetFakeHandler()->ExpectOutgoingMessage(message2); 882 GetFakeHandler()->ExpectOutgoingMessage(message2);
871 PumpLoop(); 883 PumpLoop();
872 } 884 }
873 885
874 } // namespace 886 } // namespace
875 887
876 } // namespace gcm 888 } // namespace gcm
OLDNEW
« no previous file with comments | « components/invalidation/gcm_invalidation_bridge.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698