diff options
author | peter <peter@chromium.org> | 2016-01-22 15:44:32 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-22 23:45:28 +0000 |
commit | 3b13f04b739480acc7d449ef5c4ba0157bb538b5 (patch) | |
tree | 65c165f901129b0b85244a9a48f94262ee51b0df /components/gcm_driver/gcm_stats_recorder_impl_unittest.cc | |
parent | 618039679323b6fc09e2146768f121661b0cdd41 (diff) | |
download | chromium_src-3b13f04b739480acc7d449ef5c4ba0157bb538b5.zip chromium_src-3b13f04b739480acc7d449ef5c4ba0157bb538b5.tar.gz chromium_src-3b13f04b739480acc7d449ef5c4ba0157bb538b5.tar.bz2 |
List message decryption failures on chrome://gcm-internals
This CL is basically just plumbing of a result code to an internal
diagnosis page. Decryption is done at the level of the GCM Driver,
while, for desktop, the GCMStatsRecorder is owned by the GCMClient
several layers down, on another thread.
BUG=569127
Review URL: https://codereview.chromium.org/1616113003
Cr-Commit-Position: refs/heads/master@{#371084}
Diffstat (limited to 'components/gcm_driver/gcm_stats_recorder_impl_unittest.cc')
-rw-r--r-- | components/gcm_driver/gcm_stats_recorder_impl_unittest.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/components/gcm_driver/gcm_stats_recorder_impl_unittest.cc b/components/gcm_driver/gcm_stats_recorder_impl_unittest.cc index 30a95da..5c6fe25 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 |