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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/feature_engagement_tracker/internal/test/event_util.h"
6
7 #include "components/feature_engagement_tracker/internal/proto/event.pb.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace feature_engagement_tracker {
11 namespace test {
12
13 void SetEventCountForDay(Event* event, uint32_t day, uint32_t count) {
14 Event_Count* event_count = event->add_events();
15 event_count->set_day(day);
16 event_count->set_count(count);
17 }
18
19 void VerifyEventCount(const Event* event, uint32_t day, uint32_t count) {
20 bool found_day = false;
21 for (const auto& event_count : event->events()) {
22 if (event_count.day() == day) {
23 EXPECT_FALSE(found_day);
24 found_day = true;
25 EXPECT_EQ(count, event_count.count());
26 }
27 }
28 EXPECT_TRUE(found_day);
29 }
30
31 void VerifyEventsEqual(const Event* a, const Event* b) {
32 if (!a || !b) {
33 // If one of the events are nullptr, both should be nullptr.
34 ASSERT_EQ(a, b);
35 return;
36 }
37
38 EXPECT_EQ(a->name(), b->name());
39 EXPECT_EQ(a->events_size(), b->events_size());
40 for (int i = 0; i < a->events_size(); ++i) {
41 VerifyEventCount(b, a->events(i).day(), a->events(i).count());
42 }
43 }
44
45 } // namespace test
46 } // namespace feature_engagement_tracker
OLDNEW
« 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