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

Side by Side Diff: components/feature_engagement_tracker/internal/test/event_util.cc

Issue 2876633002: Add a PersistentStore to FeatureEngagementTracker (Closed)
Patch Set: Rebased and fleshed out test 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 <map>
nyquist 2017/05/11 17:08:03 Nit: Did you end up using this include? Maybe I'm
David Trainor- moved to gerrit 2017/05/11 19:30:28 Done.
8
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace feature_engagement_tracker {
12 namespace test {
13
14 void SetEventCountForDay(Event* event, uint32_t day, uint32_t count) {
15 Event_Count* event_count = event->add_events();
16 event_count->set_day(day);
17 event_count->set_count(count);
18 }
19
20 void VerifyEventCount(const Event* event, uint32_t day, uint32_t count) {
21 bool found_day = false;
22 for (int i = 0; i < event->events_size(); ++i) {
nyquist 2017/05/11 17:08:03 Nit: I know you just moved this around, but should
David Trainor- moved to gerrit 2017/05/11 19:30:28 Done.
23 Event_Count event_count = event->events(i);
24 if (event_count.day() == day) {
25 EXPECT_FALSE(found_day);
26 found_day = true;
27 EXPECT_EQ(count, event_count.count());
28 }
29 }
30 EXPECT_TRUE(found_day);
31 }
32
33 void VerifyEventsEqual(const Event* a, const Event* b) {
34 if (!a || !b) {
35 // If one of the events are nullptr, both should be nullptr.
36 ASSERT_EQ(a, b);
37 return;
38 }
39
40 EXPECT_EQ(a->name(), b->name());
41 EXPECT_EQ(a->events_size(), b->events_size());
42 for (int i = 0; i < a->events_size(); ++i) {
43 VerifyEventCount(b, a->events(i).day(), a->events(i).count());
44 }
45 }
46
47 } // namespace test
48 } // namespace feature_engagement_tracker
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698