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

Unified Diff: google_apis/gcm/engine/registration_request_unittest.cc

Issue 2434243002: GCM Engine: Split up reg/unreg UNKNOWN_ERROR to improve metrics (Closed)
Patch Set: Created 4 years, 2 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: google_apis/gcm/engine/registration_request_unittest.cc
diff --git a/google_apis/gcm/engine/registration_request_unittest.cc b/google_apis/gcm/engine/registration_request_unittest.cc
index aeb58321d740f87e3060dca43149b00670c4782c..42378d83c687c8c8c798300222140565de110977 100644
--- a/google_apis/gcm/engine/registration_request_unittest.cc
+++ b/google_apis/gcm/engine/registration_request_unittest.cc
@@ -193,6 +193,24 @@ TEST_F(GCMRegistrationRequestTest, ResponseParsing) {
EXPECT_EQ("2501", registration_id_);
}
+TEST_F(GCMRegistrationRequestTest, ResponseParsingFailed) {
+ CreateRequest("sender1,sender2");
+ request_->Start();
+
+ SetResponse(net::HTTP_OK, "tok"); // Simulate truncated message.
+ CompleteFetch();
+
+ EXPECT_FALSE(callback_called_);
+
+ // Ensuring a retry happened and succeeds.
+ SetResponse(net::HTTP_OK, "token=2501");
+ CompleteFetch();
+
+ EXPECT_TRUE(callback_called_);
+ EXPECT_EQ(RegistrationRequest::SUCCESS, status_);
+ EXPECT_EQ("2501", registration_id_);
+}
+
TEST_F(GCMRegistrationRequestTest, ResponseHttpStatusNotOK) {
CreateRequest("sender1,sender2");
request_->Start();
@@ -270,6 +288,24 @@ TEST_F(GCMRegistrationRequestTest, ResponseAuthenticationError) {
EXPECT_EQ("2501", registration_id_);
}
+TEST_F(GCMRegistrationRequestTest, ResponseInternalServerError) {
+ CreateRequest("sender1,sender2");
+ request_->Start();
+
+ SetResponse(net::HTTP_INTERNAL_SERVER_ERROR, "Error=InternalServerError");
+ CompleteFetch();
+
+ EXPECT_FALSE(callback_called_);
+
+ // Ensuring a retry happened and succeeds.
+ SetResponse(net::HTTP_OK, "token=2501");
+ CompleteFetch();
+
+ EXPECT_TRUE(callback_called_);
+ EXPECT_EQ(RegistrationRequest::SUCCESS, status_);
+ EXPECT_EQ("2501", registration_id_);
+}
+
TEST_F(GCMRegistrationRequestTest, ResponseInvalidParameters) {
CreateRequest("sender1,sender2");
request_->Start();
@@ -306,6 +342,30 @@ TEST_F(GCMRegistrationRequestTest, ResponseInvalidSenderBadRequest) {
EXPECT_EQ(std::string(), registration_id_);
}
+TEST_F(GCMRegistrationRequestTest, ResponseQuotaExceeded) {
+ CreateRequest("sender1");
+ request_->Start();
+
+ SetResponse(net::HTTP_SERVICE_UNAVAILABLE, "Error=QUOTA_EXCEEDED");
+ CompleteFetch();
+
+ EXPECT_TRUE(callback_called_);
+ EXPECT_EQ(RegistrationRequest::QUOTA_EXCEEDED, status_);
+ EXPECT_EQ(std::string(), registration_id_);
+}
+
+TEST_F(GCMRegistrationRequestTest, ResponseTooManyRegistrations) {
+ CreateRequest("sender1");
+ request_->Start();
+
+ SetResponse(net::HTTP_OK, "Error=TOO_MANY_REGISTRATIONS");
+ CompleteFetch();
+
+ EXPECT_TRUE(callback_called_);
+ EXPECT_EQ(RegistrationRequest::TOO_MANY_REGISTRATIONS, status_);
+ EXPECT_EQ(std::string(), registration_id_);
+}
+
TEST_F(GCMRegistrationRequestTest, RequestNotSuccessful) {
CreateRequest("sender1,sender2");
request_->Start();

Powered by Google App Engine
This is Rietveld 408576698