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

Unified Diff: components/feature_engagement_tracker/internal/test/event_util.cc

Issue 2876633002: Add a PersistentStore to FeatureEngagementTracker (Closed)
Patch Set: Fix deps Created 3 years, 7 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/feature_engagement_tracker/internal/test/event_util.cc
diff --git a/components/feature_engagement_tracker/internal/test/event_util.cc b/components/feature_engagement_tracker/internal/test/event_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..af6a351408f5fbf57ae3aa89d2a784b2ed687c04
--- /dev/null
+++ b/components/feature_engagement_tracker/internal/test/event_util.cc
@@ -0,0 +1,46 @@
+// Copyright 2017 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 "components/feature_engagement_tracker/internal/test/event_util.h"
+
+#include "components/feature_engagement_tracker/internal/proto/event.pb.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace feature_engagement_tracker {
+namespace test {
+
+void SetEventCountForDay(Event* event, uint32_t day, uint32_t count) {
+ Event_Count* event_count = event->add_events();
+ event_count->set_day(day);
+ event_count->set_count(count);
+}
+
+void VerifyEventCount(const Event* event, uint32_t day, uint32_t count) {
+ bool found_day = false;
+ for (const auto& event_count : event->events()) {
+ if (event_count.day() == day) {
+ EXPECT_FALSE(found_day);
+ found_day = true;
+ EXPECT_EQ(count, event_count.count());
+ }
+ }
+ EXPECT_TRUE(found_day);
+}
+
+void VerifyEventsEqual(const Event* a, const Event* b) {
+ if (!a || !b) {
+ // If one of the events are nullptr, both should be nullptr.
+ ASSERT_EQ(a, b);
+ return;
+ }
+
+ EXPECT_EQ(a->name(), b->name());
+ EXPECT_EQ(a->events_size(), b->events_size());
+ for (int i = 0; i < a->events_size(); ++i) {
+ VerifyEventCount(b, a->events(i).day(), a->events(i).count());
+ }
+}
+
+} // namespace test
+} // namespace feature_engagement_tracker
« no previous file with comments | « components/feature_engagement_tracker/internal/test/event_util.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698