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

Unified Diff: google_apis/gcm/monitoring/gcm_stats_recorder_unittest.cc

Issue 277743002: Enable auto-refreshing of the gcm-internals page whenever a GCM activity is recorded, and fix a bug… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing Jian's comment. Created 6 years, 7 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 | « google_apis/gcm/monitoring/gcm_stats_recorder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/gcm/monitoring/gcm_stats_recorder_unittest.cc
diff --git a/google_apis/gcm/monitoring/gcm_stats_recorder_unittest.cc b/google_apis/gcm/monitoring/gcm_stats_recorder_unittest.cc
index d33fc247fd1797086d99803cb30091dad2af7712..c9256c7da089e4885e08e8a7f29f7e1b84859d59 100644
--- a/google_apis/gcm/monitoring/gcm_stats_recorder_unittest.cc
+++ b/google_apis/gcm/monitoring/gcm_stats_recorder_unittest.cc
@@ -123,6 +123,13 @@ class GCMStatsRecorderTest : public testing::Test {
EXPECT_EQ(expected_count,
static_cast<int>(recorder_.sending_activities().size()));
}
+ void VerifyAllActivityQueueEmpty(const std::string& remark) {
+ EXPECT_TRUE(recorder_.checkin_activities().empty()) << remark;
+ EXPECT_TRUE(recorder_.connection_activities().empty()) << remark;
+ EXPECT_TRUE(recorder_.registration_activities().empty()) << remark;
+ EXPECT_TRUE(recorder_.receiving_activities().empty()) << remark;
+ EXPECT_TRUE(recorder_.sending_activities().empty()) << remark;
+ }
void VerifyCheckinInitiated(const std::string& remark) {
VerifyCheckin(recorder_.checkin_activities(),
@@ -354,9 +361,46 @@ TEST_F(GCMStatsRecorderTest, StartStopRecordingTest) {
recorder_.SetRecording(false);
EXPECT_FALSE(recorder_.is_recording());
+ recorder_.Clear();
+ VerifyAllActivityQueueEmpty("all cleared");
+
+ // Exercise every recording method below and verify that nothing is recorded.
+ recorder_.RecordCheckinInitiated(kAndroidId);
+ recorder_.RecordCheckinDelayedDueToBackoff(kDelay);
+ recorder_.RecordCheckinSuccess();
+ recorder_.RecordCheckinFailure(kCheckinStatus, true);
+ VerifyAllActivityQueueEmpty("no checkin");
+
+ recorder_.RecordConnectionInitiated(kHost);
+ recorder_.RecordConnectionDelayedDueToBackoff(kDelay);
+ recorder_.RecordConnectionSuccess();
+ recorder_.RecordConnectionFailure(kNetworkError);
+ recorder_.RecordConnectionResetSignaled(kReason);
+ VerifyAllActivityQueueEmpty("no registration");
+
+ recorder_.RecordRegistrationSent(kAppId, kSenderIds);
+ recorder_.RecordRegistrationResponse(kAppId, sender_ids_,
+ kRegistrationStatus);
+ recorder_.RecordRegistrationRetryRequested(kAppId, sender_ids_, kRetries);
+ recorder_.RecordUnregistrationSent(kAppId);
+ recorder_.RecordUnregistrationResponse(kAppId, kUnregistrationStatus);
+ recorder_.RecordUnregistrationRetryDelayed(kAppId, kDelay);
+ VerifyAllActivityQueueEmpty("no unregistration");
+
+ recorder_.RecordDataMessageReceived(kAppId, kFrom, kByteSize, true,
+ GCMStatsRecorder::DATA_MESSAGE);
+ recorder_.RecordDataMessageReceived(kAppId, kFrom, kByteSize, true,
+ GCMStatsRecorder::DELETED_MESSAGES);
+ recorder_.RecordDataMessageReceived(kAppId, kFrom, kByteSize, false,
+ GCMStatsRecorder::DATA_MESSAGE);
+ VerifyAllActivityQueueEmpty("no receiving");
+
recorder_.RecordDataSentToWire(kAppId, kReceiverId, kMessageId, kQueuedSec);
- VerifyRecordedSendingCount(1);
- VerifyDataSentToWire("2nd call");
+ recorder_.RecordNotifySendStatus(kAppId, kReceiverId, kMessageId,
+ kMessageSendStatus, kByteSize, kTTL);
+ recorder_.RecordIncomingSendError(kAppId, kReceiverId, kMessageId);
+ recorder_.RecordDataSentToWire(kAppId, kReceiverId, kMessageId, kQueuedSec);
+ VerifyAllActivityQueueEmpty("no sending");
}
TEST_F(GCMStatsRecorderTest, ClearLogTest) {
« no previous file with comments | « google_apis/gcm/monitoring/gcm_stats_recorder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698