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

Unified Diff: components/gcm_driver/gcm_client_impl_unittest.cc

Issue 2578583002: Provide a mechanism for the GCM driver to send message receipts to GCM.
Patch Set: Added a callback entry point to GCMDriver, moved MessageReceiptCallback to gcm_message_status. Created 3 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 side-by-side diff with in-line comments
Download patch
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 827a6056d468ff5ed8c453cc1b578ccfa889cf69..6e4de30e185cf1c0a1872260664e101766f98dd4 100644
--- a/components/gcm_driver/gcm_client_impl_unittest.cc
+++ b/components/gcm_driver/gcm_client_impl_unittest.cc
@@ -310,7 +310,8 @@ class GCMClientImplTest : public testing::Test,
const std::string& message_id,
GCMClient::Result result) override {}
void OnMessageReceived(const std::string& registration_id,
- const IncomingMessage& message) override;
+ const IncomingMessage& message,
+ const MessageReceiptCallback& callback) override;
void OnMessagesDeleted(const std::string& app_id) override;
void OnMessageSendError(
const std::string& app_id,
@@ -616,8 +617,10 @@ void GCMClientImplTest::OnGCMReady(
last_token_fetch_time_ = last_token_fetch_time;
}
-void GCMClientImplTest::OnMessageReceived(const std::string& registration_id,
- const IncomingMessage& message) {
+void GCMClientImplTest::OnMessageReceived(
+ const std::string& registration_id,
+ const IncomingMessage& message,
+ const MessageReceiptCallback& callback) {
last_event_ = MESSAGE_RECEIVED;
last_app_id_ = registration_id;
last_message_ = message;
@@ -936,6 +939,9 @@ TEST_F(GCMClientImplTest, DispatchDownstreamMessage) {
EXPECT_TRUE(message3.IsValid());
ReceiveMessageFromMCS(message3);
+ // TODO(harkness): Add a check for invalid app handler once the
+ // DefaultAppHandler is removed.
+
EXPECT_NE(MESSAGE_RECEIVED, last_event());
EXPECT_NE(kExtensionAppId, last_app_id());
}
@@ -1789,6 +1795,24 @@ TEST_F(GCMClientInstanceIDTest, DispatchDownstreamMessageWithoutSubtype) {
EXPECT_NE(MESSAGE_RECEIVED, last_event());
+ // Check that the last message sent was a message receipt for a failed message
+ // and that it had the values expected.
+ mcs_proto::DataMessageStanza stanza =
+ mcs_client()->last_data_message_stanza();
+ EXPECT_EQ(kExtensionAppId, stanza.category());
+ const auto& app_data = stanza.app_data();
+ ASSERT_EQ(3, app_data.size());
+ for (const auto& pair : app_data) {
+ if (pair.key() == "message_id")
+ EXPECT_EQ("", pair.value());
+ else if (pair.key() == "status")
+ EXPECT_EQ("2", pair.value());
+ else if (pair.key() == "type")
+ EXPECT_EQ("message_receipt", pair.value());
+ else
+ EXPECT_TRUE(0);
+ }
+
reset_last_event();
// Message for kSender will be received.
@@ -1850,6 +1874,24 @@ TEST_F(GCMClientInstanceIDTest, DispatchDownstreamMessageWithSubtype) {
EXPECT_NE(MESSAGE_RECEIVED, last_event());
+ // Check that the last message sent was a message receipt for a failed message
+ // and that it had the values expected.
+ mcs_proto::DataMessageStanza stanza =
+ mcs_client()->last_data_message_stanza();
+ EXPECT_EQ(kSubtypeAppId, stanza.category());
+ const auto& app_data = stanza.app_data();
+ ASSERT_EQ(3, app_data.size());
+ for (const auto& pair : app_data) {
+ if (pair.key() == "message_id")
+ EXPECT_EQ("", pair.value());
+ else if (pair.key() == "status")
+ EXPECT_EQ("2", pair.value());
+ else if (pair.key() == "type")
+ EXPECT_EQ("message_receipt", pair.value());
+ else
+ EXPECT_TRUE(0);
+ }
+
reset_last_event();
// Message for kSender will be received.

Powered by Google App Engine
This is Rietveld 408576698