OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/gcm_driver/gcm_stats_recorder_impl.h" | 5 #include "components/gcm_driver/gcm_stats_recorder_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <string> | 10 #include <string> |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 static const char kDataDeletedMessageDetails[] = | 92 static const char kDataDeletedMessageDetails[] = |
93 "Message has been deleted on server"; | 93 "Message has been deleted on server"; |
94 | 94 |
95 static const char kDataSentToWireEvent[] = "Data msg sent to wire"; | 95 static const char kDataSentToWireEvent[] = "Data msg sent to wire"; |
96 static const char kSentToWireDetails[] = "Msg queued for 5 seconds"; | 96 static const char kSentToWireDetails[] = "Msg queued for 5 seconds"; |
97 static const char kNotifySendStatusEvent[] = "SEND status: QUEUED"; | 97 static const char kNotifySendStatusEvent[] = "SEND status: QUEUED"; |
98 static const char kNotifySendStatusDetails[] = "Msg size: 99 bytes, TTL: 7"; | 98 static const char kNotifySendStatusDetails[] = "Msg size: 99 bytes, TTL: 7"; |
99 static const char kIncomingSendErrorEvent[] = "Received 'send error' msg"; | 99 static const char kIncomingSendErrorEvent[] = "Received 'send error' msg"; |
100 static const char kIncomingSendErrorDetails[] = ""; | 100 static const char kIncomingSendErrorDetails[] = ""; |
101 | 101 |
102 static const GCMEncryptionProvider::DecryptionFailure kDecryptionFailureReason = | 102 static const GCMEncryptionProvider::DecryptionResult kDecryptionResultFailure = |
103 GCMEncryptionProvider::DECRYPTION_FAILURE_INVALID_PAYLOAD; | 103 GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_PAYLOAD; |
104 | 104 |
105 } // namespace | 105 } // namespace |
106 | 106 |
107 class GCMStatsRecorderImplTest : public testing::Test { | 107 class GCMStatsRecorderImplTest : public testing::Test { |
108 public: | 108 public: |
109 GCMStatsRecorderImplTest(); | 109 GCMStatsRecorderImplTest(); |
110 ~GCMStatsRecorderImplTest() override; | 110 ~GCMStatsRecorderImplTest() override; |
111 void SetUp() override; | 111 void SetUp() override; |
112 | 112 |
113 void VerifyRecordedCheckinCount(int expected_count) { | 113 void VerifyRecordedCheckinCount(int expected_count) { |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 kIncomingSendErrorEvent, | 295 kIncomingSendErrorEvent, |
296 kIncomingSendErrorDetails, | 296 kIncomingSendErrorDetails, |
297 remark); | 297 remark); |
298 } | 298 } |
299 | 299 |
300 void VerifyRecordedDecryptionFailure(const std::string& remark) { | 300 void VerifyRecordedDecryptionFailure(const std::string& remark) { |
301 const auto& queue = recorder_.decryption_failure_activities(); | 301 const auto& queue = recorder_.decryption_failure_activities(); |
302 | 302 |
303 EXPECT_EQ(kAppId, queue.front().app_id) << remark; | 303 EXPECT_EQ(kAppId, queue.front().app_id) << remark; |
304 EXPECT_EQ( | 304 EXPECT_EQ( |
305 GCMEncryptionProvider::ToDecryptionFailureDetailsString( | 305 GCMEncryptionProvider::ToDecryptionResultDetailsString( |
306 kDecryptionFailureReason), | 306 kDecryptionResultFailure), |
307 queue.front().details) << remark; | 307 queue.front().details) << remark; |
308 } | 308 } |
309 | 309 |
310 protected: | 310 protected: |
311 void VerifyCheckin( | 311 void VerifyCheckin( |
312 const std::deque<CheckinActivity>& queue, | 312 const std::deque<CheckinActivity>& queue, |
313 const std::string& event, | 313 const std::string& event, |
314 const std::string& details, | 314 const std::string& details, |
315 const std::string& remark) { | 315 const std::string& remark) { |
316 EXPECT_EQ(event, queue.front().event) << remark; | 316 EXPECT_EQ(event, queue.front().event) << remark; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 recorder_.RecordIncomingSendError(kAppId, kReceiverId, kMessageId); | 540 recorder_.RecordIncomingSendError(kAppId, kReceiverId, kMessageId); |
541 VerifyRecordedSendingCount(3); | 541 VerifyRecordedSendingCount(3); |
542 VerifyIncomingSendError("3rd call"); | 542 VerifyIncomingSendError("3rd call"); |
543 | 543 |
544 recorder_.RecordDataSentToWire(kAppId, kReceiverId, kMessageId, kQueuedSec); | 544 recorder_.RecordDataSentToWire(kAppId, kReceiverId, kMessageId, kQueuedSec); |
545 VerifyRecordedSendingCount(4); | 545 VerifyRecordedSendingCount(4); |
546 VerifyDataSentToWire("4th call"); | 546 VerifyDataSentToWire("4th call"); |
547 } | 547 } |
548 | 548 |
549 TEST_F(GCMStatsRecorderImplTest, RecordDecryptionFailureTest) { | 549 TEST_F(GCMStatsRecorderImplTest, RecordDecryptionFailureTest) { |
550 recorder_.RecordDecryptionFailure(kAppId, kDecryptionFailureReason); | 550 recorder_.RecordDecryptionFailure(kAppId, kDecryptionResultFailure); |
551 VerifyRecordedDecryptionFailureCount(1); | 551 VerifyRecordedDecryptionFailureCount(1); |
552 | 552 |
553 VerifyRecordedDecryptionFailure("1st call"); | 553 VerifyRecordedDecryptionFailure("1st call"); |
554 } | 554 } |
555 | 555 |
556 } // namespace gcm | 556 } // namespace gcm |
OLD | NEW |