OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_android.h" | 5 #include "components/gcm_driver/gcm_stats_recorder_android.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "components/gcm_driver/crypto/gcm_encryption_provider.h" | 9 #include "components/gcm_driver/crypto/gcm_encryption_provider.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 namespace gcm { | 12 namespace gcm { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 const char kTestAppId[] = "test_app_id"; | 16 const char kTestAppId[] = "test_app_id"; |
| 17 const char kTestSenderId[] = "test_sender_id"; |
17 | 18 |
18 class GCMStatsRecorderAndroidTest : public ::testing::Test, | 19 class GCMStatsRecorderAndroidTest : public ::testing::Test, |
19 public GCMStatsRecorderAndroid::Delegate { | 20 public GCMStatsRecorderAndroid::Delegate { |
20 public: | 21 public: |
21 GCMStatsRecorderAndroidTest() | 22 GCMStatsRecorderAndroidTest() |
22 : activity_recorded_calls_(0) {} | 23 : activity_recorded_calls_(0) {} |
23 ~GCMStatsRecorderAndroidTest() override {} | 24 ~GCMStatsRecorderAndroidTest() override {} |
24 | 25 |
25 // GCMStatsRecorderAndroid::Delegate implementation. | 26 // GCMStatsRecorderAndroid::Delegate implementation. |
26 void OnActivityRecorded() override { | 27 void OnActivityRecorded() override { |
(...skipping 19 matching lines...) Expand all Loading... |
46 | 47 |
47 recorder.RecordRegistrationResponse(kTestAppId, true /* success */); | 48 recorder.RecordRegistrationResponse(kTestAppId, true /* success */); |
48 EXPECT_EQ(2u, activity_recorded_calls()); | 49 EXPECT_EQ(2u, activity_recorded_calls()); |
49 | 50 |
50 recorder.RecordUnregistrationSent(kTestAppId); | 51 recorder.RecordUnregistrationSent(kTestAppId); |
51 EXPECT_EQ(3u, activity_recorded_calls()); | 52 EXPECT_EQ(3u, activity_recorded_calls()); |
52 | 53 |
53 recorder.RecordUnregistrationResponse(kTestAppId, true /* success */); | 54 recorder.RecordUnregistrationResponse(kTestAppId, true /* success */); |
54 EXPECT_EQ(4u, activity_recorded_calls()); | 55 EXPECT_EQ(4u, activity_recorded_calls()); |
55 | 56 |
56 recorder.RecordDataMessageReceived(kTestAppId, 42 /* message_byte_size */); | 57 recorder.RecordDataMessageReceived(kTestAppId, kTestSenderId, |
| 58 42 /* message_byte_size */); |
57 EXPECT_EQ(5u, activity_recorded_calls()); | 59 EXPECT_EQ(5u, activity_recorded_calls()); |
58 | 60 |
59 recorder.RecordDecryptionFailure( | 61 recorder.RecordDecryptionFailure( |
60 kTestAppId, GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_PAYLOAD); | 62 kTestAppId, GCMEncryptionProvider::DECRYPTION_RESULT_INVALID_PAYLOAD); |
61 EXPECT_EQ(6u, activity_recorded_calls()); | 63 EXPECT_EQ(6u, activity_recorded_calls()); |
62 | 64 |
63 RecordedActivities activities; | 65 RecordedActivities activities; |
64 recorder.CollectActivities(&activities); | 66 recorder.CollectActivities(&activities); |
65 | 67 |
66 EXPECT_EQ(4u, activities.registration_activities.size()); | 68 EXPECT_EQ(4u, activities.registration_activities.size()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 107 |
106 RecordedActivities activities; | 108 RecordedActivities activities; |
107 recorder.CollectActivities(&activities); | 109 recorder.CollectActivities(&activities); |
108 | 110 |
109 EXPECT_EQ(0u, activities.registration_activities.size()); | 111 EXPECT_EQ(0u, activities.registration_activities.size()); |
110 } | 112 } |
111 | 113 |
112 } // namespace | 114 } // namespace |
113 | 115 |
114 } // namespace gcm | 116 } // namespace gcm |
OLD | NEW |