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

Unified Diff: google_apis/gcm/gcm_stats_recorder_unittest.cc

Issue 202083005: Add activity recording capability to gcm internals page. User can refresh, start/stop recording, an… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address all code reviews. Created 6 years, 9 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: google_apis/gcm/gcm_stats_recorder_unittest.cc
diff --git a/google_apis/gcm/gcm_stats_recorder_unittest.cc b/google_apis/gcm/gcm_stats_recorder_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7b33b43207efadd00b6fc398bed6de5ab9e354af
--- /dev/null
+++ b/google_apis/gcm/gcm_stats_recorder_unittest.cc
@@ -0,0 +1,92 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "google_apis/gcm/gcm_stats_recorder.h"
+
+#include <deque>
+#include <string>
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace gcm {
+
+namespace {
+
+const std::string kAppId[] = { "app id 1", "app id 2" };
+const std::string kReceiverId[] = { "receiver 1", "receiver 2" };
+const std::string kMessageId[] = { "message id 1", "message id 2" };
+const std::string kEvent[] = { "event 1", "event 2" };
+const std::string kDetails[] = { "details 1", "details 2" };
+
+class TestGCMStatsRecorder : public GCMStatsRecorder {
+ public:
+ TestGCMStatsRecorder() {};
+ virtual ~TestGCMStatsRecorder() {};
+
+ std::deque<gcm::GCMStatsRecorder::SendingActivity>* sending_activities() {
+ return &sending_activities_;
+ }
+};
+
+} // namespace
+
+class GCMStatsRecorderTest : public testing::Test {
+ public:
+ GCMStatsRecorderTest();
+ virtual ~GCMStatsRecorderTest();
+ virtual void SetUp() OVERRIDE;
+
+ void VerifyRecordedSending(int count);
+
+ protected:
+ TestGCMStatsRecorder recorder_;
+};
+
+GCMStatsRecorderTest::GCMStatsRecorderTest(){
+}
+
+GCMStatsRecorderTest::~GCMStatsRecorderTest() {}
+
+void GCMStatsRecorderTest::SetUp(){
+ recorder_.SetRecording(true);
+}
+
+void GCMStatsRecorderTest::VerifyRecordedSending(int count){
+ EXPECT_EQ(count, static_cast<int>(recorder_.sending_activities()->size()));
+ if (count == 0)
+ return;
+ for (int i = 0; i < count; ++i) {
+ EXPECT_EQ(recorder_.sending_activities()->at(count - i - 1).app_id,
+ kAppId[i]);
+ EXPECT_EQ(recorder_.sending_activities()->at(count - i - 1).receiver_id,
+ kReceiverId[i]);
+ EXPECT_EQ(recorder_.sending_activities()->at(count - i - 1).message_id,
+ kMessageId[i]);
+ EXPECT_EQ(recorder_.sending_activities()->at(count - i - 1).event,
+ kEvent[i]);
+ EXPECT_EQ(recorder_.sending_activities()->at(count - i - 1).details,
+ kDetails[i]);
+ }
+}
+
+
+TEST_F(GCMStatsRecorderTest, RecordSendingTest) {
+ recorder_.RecordSending(kAppId[0], kReceiverId[0], kMessageId[0], kEvent[0],
+ kDetails[0]);
+ recorder_.RecordSending(kAppId[1], kReceiverId[1], kMessageId[1], kEvent[1],
+ kDetails[1]);
+ EXPECT_TRUE(recorder_.is_recording());
+ VerifyRecordedSending(2);
+
+ recorder_.Clear();
+ VerifyRecordedSending(0);
+
+ recorder_.SetRecording(false);
+ EXPECT_FALSE(recorder_.is_recording());
+ recorder_.RecordSending(kAppId[0], kReceiverId[0], kMessageId[0], kEvent[0],
+ kDetails[0]);
+ VerifyRecordedSending(0);
+}
+
+} // namespace gcm
« google_apis/gcm/gcm_stats_recorder.cc ('K') | « google_apis/gcm/gcm_stats_recorder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698