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

Unified Diff: components/gcm_driver/gcm_stats_recorder_impl_unittest.cc

Issue 1616113003: List message decryption failures on chrome://gcm-internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after CL 1619053003 Created 4 years, 11 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: components/gcm_driver/gcm_stats_recorder_impl_unittest.cc
diff --git a/components/gcm_driver/gcm_stats_recorder_impl_unittest.cc b/components/gcm_driver/gcm_stats_recorder_impl_unittest.cc
index 30a95dae089b5943b3cdaf6a7884cd00f4de7762..5c6fe253fc3942f32d6ff1af06fc0af5318b93c2 100644
--- a/components/gcm_driver/gcm_stats_recorder_impl_unittest.cc
+++ b/components/gcm_driver/gcm_stats_recorder_impl_unittest.cc
@@ -10,6 +10,7 @@
#include <string>
#include <vector>
+#include "components/gcm_driver/crypto/gcm_encryption_provider.h"
#include "google_apis/gcm/engine/mcs_client.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -98,6 +99,9 @@ static const char kNotifySendStatusDetails[] = "Msg size: 99 bytes, TTL: 7";
static const char kIncomingSendErrorEvent[] = "Received 'send error' msg";
static const char kIncomingSendErrorDetails[] = "";
+static const GCMEncryptionProvider::DecryptionFailure kDecryptionFailureReason =
+ GCMEncryptionProvider::DECRYPTION_FAILURE_INVALID_PAYLOAD;
+
} // namespace
class GCMStatsRecorderImplTest : public testing::Test {
@@ -126,12 +130,18 @@ class GCMStatsRecorderImplTest : public testing::Test {
EXPECT_EQ(expected_count,
static_cast<int>(recorder_.sending_activities().size()));
}
+ void VerifyRecordedDecryptionFailureCount(int expected_count) {
+ EXPECT_EQ(
+ expected_count,
+ static_cast<int>(recorder_.decryption_failure_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;
+ EXPECT_TRUE(recorder_.decryption_failure_activities().empty()) << remark;
}
void VerifyCheckinInitiated(const std::string& remark) {
@@ -287,6 +297,16 @@ class GCMStatsRecorderImplTest : public testing::Test {
remark);
}
+ void VerifyRecordedDecryptionFailure(const std::string& remark) {
+ const auto& queue = recorder_.decryption_failure_activities();
+
+ EXPECT_EQ(kAppId, queue.front().app_id) << remark;
+ EXPECT_EQ(
+ GCMEncryptionProvider::ToDecryptionFailureDetailsString(
+ kDecryptionFailureReason),
+ queue.front().details) << remark;
+ }
+
protected:
void VerifyCheckin(
const std::deque<CheckinActivity>& queue,
@@ -526,4 +546,11 @@ TEST_F(GCMStatsRecorderImplTest, RecordSendingTest) {
VerifyDataSentToWire("4th call");
}
+TEST_F(GCMStatsRecorderImplTest, RecordDecryptionFailureTest) {
+ recorder_.RecordDecryptionFailure(kAppId, kDecryptionFailureReason);
+ VerifyRecordedDecryptionFailureCount(1);
+
+ VerifyRecordedDecryptionFailure("1st call");
+}
+
} // namespace gcm
« no previous file with comments | « components/gcm_driver/gcm_stats_recorder_impl.cc ('k') | components/gcm_driver/resources/gcm_internals.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698