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

Unified Diff: components/gcm_driver/gcm_client_impl_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/gcm_driver/gcm_client_impl.cc ('k') | components/gcm_driver/gcm_driver_desktop.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/gcm_driver/gcm_client_impl_unittest.cc
diff --git a/components/gcm_driver/gcm_client_impl_unittest.cc b/components/gcm_driver/gcm_client_impl_unittest.cc
index b477918152974ec16724a6c1ea87e3a30d105800..e4f2b0997e9ff48560447edd295fd4b9c8a8e562 100644
--- a/components/gcm_driver/gcm_client_impl_unittest.cc
+++ b/components/gcm_driver/gcm_client_impl_unittest.cc
@@ -35,6 +35,7 @@ enum LastEvent {
REGISTRATION_COMPLETED,
UNREGISTRATION_COMPLETED,
MESSAGE_SEND_ERROR,
+ MESSAGE_SEND_ACK,
MESSAGE_RECEIVED,
MESSAGES_DELETED,
};
@@ -223,6 +224,10 @@ class GCMClientImplTest : public testing::Test,
void InitializeGCMClient();
void StartGCMClient();
void ReceiveMessageFromMCS(const MCSMessage& message);
+ void ReceiveOnMessageSentToMCS(
+ const std::string& app_id,
+ const std::string& message_id,
+ const MCSClient::MessageSendStatus status);
void CompleteCheckin(uint64 android_id,
uint64 security_token,
const std::string& digest,
@@ -251,6 +256,8 @@ class GCMClientImplTest : public testing::Test,
virtual void OnMessageSendError(
const std::string& app_id,
const gcm::GCMClient::SendErrorDetails& send_error_details) OVERRIDE;
+ virtual void OnSendAcknowledged(const std::string& app_id,
+ const std::string& message_id) OVERRIDE;
virtual void OnGCMReady() OVERRIDE;
virtual void OnActivityRecorded() OVERRIDE {}
virtual void OnConnected(const net::IPEndPoint& ip_endpoint) OVERRIDE {}
@@ -474,6 +481,13 @@ void GCMClientImplTest::ReceiveMessageFromMCS(const MCSMessage& message) {
gcm_client_->OnMessageReceivedFromMCS(message);
}
+void GCMClientImplTest::ReceiveOnMessageSentToMCS(
+ const std::string& app_id,
+ const std::string& message_id,
+ const MCSClient::MessageSendStatus status) {
+ gcm_client_->OnMessageSentToMCS(0LL, app_id, message_id, status);
+}
+
void GCMClientImplTest::OnGCMReady() {
last_event_ = LOADING_COMPLETED;
QuitLoop();
@@ -517,6 +531,13 @@ void GCMClientImplTest::OnMessageSendError(
last_error_details_ = send_error_details;
}
+void GCMClientImplTest::OnSendAcknowledged(const std::string& app_id,
+ const std::string& message_id) {
+ last_event_ = MESSAGE_SEND_ACK;
+ last_app_id_ = app_id;
+ last_message_id_ = message_id;
+}
+
int64 GCMClientImplTest::CurrentTime() {
return clock()->Now().ToInternalValue() / base::Time::kMicrosecondsPerSecond;
}
@@ -678,9 +699,6 @@ TEST_F(GCMClientImplTest, DispatchDownstreamMessgaesDeleted) {
}
TEST_F(GCMClientImplTest, SendMessage) {
- mcs_proto::DataMessageStanza stanza;
- stanza.set_ttl(500);
-
GCMClient::OutgoingMessage message;
message.id = "007";
message.time_to_live = 500;
@@ -700,6 +718,13 @@ TEST_F(GCMClientImplTest, SendMessage) {
mcs_client()->last_data_message_stanza().app_data(0).value());
}
+TEST_F(GCMClientImplTest, SendMessageAcknowledged) {
+ ReceiveOnMessageSentToMCS(kAppId, "007", MCSClient::SENT);
+ EXPECT_EQ(MESSAGE_SEND_ACK, last_event());
+ EXPECT_EQ(kAppId, last_app_id());
+ EXPECT_EQ("007", last_message_id());
+}
+
class GCMClientImplCheckinTest : public GCMClientImplTest {
public:
GCMClientImplCheckinTest();
« no previous file with comments | « components/gcm_driver/gcm_client_impl.cc ('k') | components/gcm_driver/gcm_driver_desktop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698