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

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: Adding new file I missed previously. Created 3 years, 11 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..43100f43c8717867214c2714aebb9514cf42d6a7 100644
--- a/components/gcm_driver/gcm_client_impl_unittest.cc
+++ b/components/gcm_driver/gcm_client_impl_unittest.cc
@@ -309,8 +309,10 @@ class GCMClientImplTest : public testing::Test,
void OnSendFinished(const std::string& app_id,
const std::string& message_id,
GCMClient::Result result) override {}
- void OnMessageReceived(const std::string& registration_id,
- const IncomingMessage& message) override;
+ void OnMessageReceived(
+ const std::string& registration_id,
+ const IncomingMessage& message,
+ const GCMClient::MessageReceiptCallback& callback) override;
void OnMessagesDeleted(const std::string& app_id) override;
void OnMessageSendError(
const std::string& app_id,
@@ -616,8 +618,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 GCMClient::MessageReceiptCallback& callback) {
last_event_ = MESSAGE_RECEIVED;
last_app_id_ = registration_id;
last_message_ = message;
@@ -936,6 +940,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 +1796,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 +1875,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