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) { |