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

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: Created 4 years 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..ddf9db0454f3b8ca8c3e2b7390bbc9e75cf5ecf8 100644
--- a/components/gcm_driver/gcm_client_impl_unittest.cc
+++ b/components/gcm_driver/gcm_client_impl_unittest.cc
@@ -311,6 +311,9 @@ class GCMClientImplTest : public testing::Test,
GCMClient::Result result) override {}
void OnMessageReceived(const std::string& registration_id,
const IncomingMessage& message) override;
+ void OnMessageReceivedError(const std::string& app_id,
+ const std::string& message_id,
+ int status) override;
void OnMessagesDeleted(const std::string& app_id) override;
void OnMessageSendError(
const std::string& app_id,
@@ -347,6 +350,9 @@ class GCMClientImplTest : public testing::Test,
last_result_ = GCMClient::UNKNOWN_ERROR;
last_account_mappings_.clear();
last_token_fetch_time_ = base::Time();
+ last_receipt_app_id_.clear();
+ last_receipt_message_id_.clear();
+ last_receipt_status_ = 0;
}
LastEvent last_event() const { return last_event_; }
@@ -356,6 +362,13 @@ class GCMClientImplTest : public testing::Test,
}
const std::string& last_message_id() const { return last_message_id_; }
GCMClient::Result last_result() const { return last_result_; }
+ const std::string& last_receipt_app_id() const {
+ return last_receipt_app_id_;
+ }
+ const std::string& last_receipt_message_id() const {
+ return last_receipt_message_id_;
+ }
+ int last_receipt_status() const { return last_receipt_status_; }
const IncomingMessage& last_message() const { return last_message_; }
const GCMClient::SendErrorDetails& last_error_details() const {
return last_error_details_;
@@ -412,6 +425,9 @@ class GCMClientImplTest : public testing::Test,
GCMClient::SendErrorDetails last_error_details_;
base::Time last_token_fetch_time_;
std::vector<AccountMapping> last_account_mappings_;
+ std::string last_receipt_app_id_;
+ std::string last_receipt_message_id_;
+ int last_receipt_status_;
std::unique_ptr<GCMClientImpl> gcm_client_;
@@ -623,6 +639,14 @@ void GCMClientImplTest::OnMessageReceived(const std::string& registration_id,
last_message_ = message;
}
+void GCMClientImplTest::OnMessageReceivedError(const std::string& app_id,
+ const std::string& message_id,
+ int status) {
+ last_receipt_app_id_ = app_id;
+ last_receipt_message_id_ = message_id;
+ last_receipt_status_ = status;
+}
+
void GCMClientImplTest::OnRegisterFinished(
const linked_ptr<RegistrationInfo>& registration_info,
const std::string& registration_id,
@@ -936,6 +960,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());
}
@@ -1788,6 +1815,8 @@ TEST_F(GCMClientInstanceIDTest, DispatchDownstreamMessageWithoutSubtype) {
ReceiveMessageFromMCS(message0);
EXPECT_NE(MESSAGE_RECEIVED, last_event());
+ EXPECT_EQ(kExtensionAppId, last_receipt_app_id());
+ EXPECT_EQ(GCMClient::GCM_INVALID_SUBTYPE, last_receipt_status());
reset_last_event();
@@ -1849,6 +1878,8 @@ TEST_F(GCMClientInstanceIDTest, DispatchDownstreamMessageWithSubtype) {
ReceiveMessageFromMCS(message0);
EXPECT_NE(MESSAGE_RECEIVED, last_event());
+ EXPECT_EQ(kSubtypeAppId, last_receipt_app_id());
+ EXPECT_EQ(GCMClient::GCM_INVALID_SUBTYPE, last_receipt_status());
reset_last_event();

Powered by Google App Engine
This is Rietveld 408576698