OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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/feature_engagement_tracker/internal/model_impl.h" | 5 #include "components/feature_engagement_tracker/internal/model_impl.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/feature_list.h" | 11 #include "base/feature_list.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "base/test/scoped_feature_list.h" | 16 #include "base/test/scoped_feature_list.h" |
17 #include "components/feature_engagement_tracker/internal/editable_configuration.
h" | 17 #include "components/feature_engagement_tracker/internal/editable_configuration.
h" |
18 #include "components/feature_engagement_tracker/internal/in_memory_store.h" | 18 #include "components/feature_engagement_tracker/internal/in_memory_store.h" |
19 #include "components/feature_engagement_tracker/internal/never_storage_validator
.h" | 19 #include "components/feature_engagement_tracker/internal/never_storage_validator
.h" |
20 #include "components/feature_engagement_tracker/internal/proto/event.pb.h" | 20 #include "components/feature_engagement_tracker/internal/proto/event.pb.h" |
| 21 #include "components/feature_engagement_tracker/internal/test/event_util.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 | 23 |
23 namespace feature_engagement_tracker { | 24 namespace feature_engagement_tracker { |
24 | 25 |
25 namespace { | 26 namespace { |
26 const base::Feature kTestFeatureFoo{"test_foo", | 27 const base::Feature kTestFeatureFoo{"test_foo", |
27 base::FEATURE_DISABLED_BY_DEFAULT}; | 28 base::FEATURE_DISABLED_BY_DEFAULT}; |
28 const base::Feature kTestFeatureBar{"test_bar", | 29 const base::Feature kTestFeatureBar{"test_bar", |
29 base::FEATURE_DISABLED_BY_DEFAULT}; | 30 base::FEATURE_DISABLED_BY_DEFAULT}; |
30 | 31 |
31 void RegisterFeatureConfig(EditableConfiguration* configuration, | 32 void RegisterFeatureConfig(EditableConfiguration* configuration, |
32 const base::Feature& feature, | 33 const base::Feature& feature, |
33 bool valid) { | 34 bool valid) { |
34 FeatureConfig config; | 35 FeatureConfig config; |
35 config.valid = valid; | 36 config.valid = valid; |
36 config.used.name = feature.name; | 37 config.used.name = feature.name; |
37 configuration->SetConfiguration(&feature, config); | 38 configuration->SetConfiguration(&feature, config); |
38 } | 39 } |
39 | 40 |
40 void SetEventCountForDay(Event* event, uint32_t day, uint32_t count) { | |
41 Event_Count* event_count = event->add_events(); | |
42 event_count->set_day(day); | |
43 event_count->set_count(count); | |
44 } | |
45 | |
46 // Verifies that the given |event| contains a |day| with the correct |count|, | |
47 // and that the day only exists a single time. | |
48 void VerifyEventCount(const Event* event, uint32_t day, uint32_t count) { | |
49 bool found_day = false; | |
50 for (int i = 0; i < event->events_size(); ++i) { | |
51 Event_Count event_count = event->events(i); | |
52 if (event_count.day() == day) { | |
53 EXPECT_FALSE(found_day); | |
54 found_day = true; | |
55 EXPECT_EQ(count, event_count.count()); | |
56 } | |
57 } | |
58 EXPECT_TRUE(found_day); | |
59 } | |
60 | |
61 // Verifies that the event |a| and |b| contain the exact same data. | |
62 void VerifyEqual(const Event* a, const Event* b) { | |
63 if (!a || !b) { | |
64 // If one of the events are nullptr, both should be nullptr. | |
65 ASSERT_EQ(a, b); | |
66 return; | |
67 } | |
68 | |
69 EXPECT_EQ(a->name(), b->name()); | |
70 EXPECT_EQ(a->events_size(), b->events_size()); | |
71 for (int i = 0; i < a->events_size(); ++i) { | |
72 VerifyEventCount(b, a->events(i).day(), a->events(i).count()); | |
73 } | |
74 } | |
75 | |
76 // A test-only implementation of InMemoryStore that tracks calls to | 41 // A test-only implementation of InMemoryStore that tracks calls to |
77 // WriteEvent(...). | 42 // WriteEvent(...). |
78 class TestInMemoryStore : public InMemoryStore { | 43 class TestInMemoryStore : public InMemoryStore { |
79 public: | 44 public: |
80 explicit TestInMemoryStore(std::unique_ptr<std::vector<Event>> events, | 45 explicit TestInMemoryStore(std::unique_ptr<std::vector<Event>> events, |
81 bool load_should_succeed) | 46 bool load_should_succeed) |
82 : InMemoryStore(std::move(events)), | 47 : InMemoryStore(std::move(events)), |
83 load_should_succeed_(load_should_succeed) {} | 48 load_should_succeed_(load_should_succeed) {} |
84 | 49 |
85 void Load(const OnLoadedCallback& callback) override { | 50 void Load(const OnLoadedCallback& callback) override { |
(...skipping 15 matching lines...) Expand all Loading... |
101 bool load_should_succeed_; | 66 bool load_should_succeed_; |
102 }; | 67 }; |
103 | 68 |
104 // Creates a TestInMemoryStore containing three hard coded events. | 69 // Creates a TestInMemoryStore containing three hard coded events. |
105 std::unique_ptr<TestInMemoryStore> CreatePrefilledStore() { | 70 std::unique_ptr<TestInMemoryStore> CreatePrefilledStore() { |
106 std::unique_ptr<std::vector<Event>> events = | 71 std::unique_ptr<std::vector<Event>> events = |
107 base::MakeUnique<std::vector<Event>>(); | 72 base::MakeUnique<std::vector<Event>>(); |
108 | 73 |
109 Event foo; | 74 Event foo; |
110 foo.set_name("foo"); | 75 foo.set_name("foo"); |
111 SetEventCountForDay(&foo, 1, 1); | 76 test::SetEventCountForDay(&foo, 1, 1); |
112 events->push_back(foo); | 77 events->push_back(foo); |
113 | 78 |
114 Event bar; | 79 Event bar; |
115 bar.set_name("bar"); | 80 bar.set_name("bar"); |
116 SetEventCountForDay(&bar, 1, 3); | 81 test::SetEventCountForDay(&bar, 1, 3); |
117 SetEventCountForDay(&bar, 2, 3); | 82 test::SetEventCountForDay(&bar, 2, 3); |
118 SetEventCountForDay(&bar, 5, 5); | 83 test::SetEventCountForDay(&bar, 5, 5); |
119 events->push_back(bar); | 84 events->push_back(bar); |
120 | 85 |
121 Event qux; | 86 Event qux; |
122 qux.set_name("qux"); | 87 qux.set_name("qux"); |
123 SetEventCountForDay(&qux, 1, 5); | 88 test::SetEventCountForDay(&qux, 1, 5); |
124 SetEventCountForDay(&qux, 2, 1); | 89 test::SetEventCountForDay(&qux, 2, 1); |
125 SetEventCountForDay(&qux, 3, 2); | 90 test::SetEventCountForDay(&qux, 3, 2); |
126 events->push_back(qux); | 91 events->push_back(qux); |
127 | 92 |
128 return base::MakeUnique<TestInMemoryStore>(std::move(events), true); | 93 return base::MakeUnique<TestInMemoryStore>(std::move(events), true); |
129 } | 94 } |
130 | 95 |
131 // A test-only implementation of ModelImpl to be able to change the current | 96 // A test-only implementation of ModelImpl to be able to change the current |
132 // day while a test is running. | 97 // day while a test is running. |
133 class TestModelImpl : public ModelImpl { | 98 class TestModelImpl : public ModelImpl { |
134 public: | 99 public: |
135 TestModelImpl(std::unique_ptr<Store> store, | 100 TestModelImpl(std::unique_ptr<Store> store, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 base::RunLoop().RunUntilIdle(); | 174 base::RunLoop().RunUntilIdle(); |
210 EXPECT_TRUE(model_->IsReady()); | 175 EXPECT_TRUE(model_->IsReady()); |
211 EXPECT_TRUE(got_initialize_callback_); | 176 EXPECT_TRUE(got_initialize_callback_); |
212 EXPECT_TRUE(initialize_callback_result_); | 177 EXPECT_TRUE(initialize_callback_result_); |
213 | 178 |
214 // Verify that all the data matches what was put into the store in | 179 // Verify that all the data matches what was put into the store in |
215 // CreateStore(). | 180 // CreateStore(). |
216 const Event* foo_event = model_->GetEvent("foo"); | 181 const Event* foo_event = model_->GetEvent("foo"); |
217 EXPECT_EQ("foo", foo_event->name()); | 182 EXPECT_EQ("foo", foo_event->name()); |
218 EXPECT_EQ(1, foo_event->events_size()); | 183 EXPECT_EQ(1, foo_event->events_size()); |
219 VerifyEventCount(foo_event, 1u, 1u); | 184 test::VerifyEventCount(foo_event, 1u, 1u); |
220 | 185 |
221 const Event* bar_event = model_->GetEvent("bar"); | 186 const Event* bar_event = model_->GetEvent("bar"); |
222 EXPECT_EQ("bar", bar_event->name()); | 187 EXPECT_EQ("bar", bar_event->name()); |
223 EXPECT_EQ(3, bar_event->events_size()); | 188 EXPECT_EQ(3, bar_event->events_size()); |
224 VerifyEventCount(bar_event, 1u, 3u); | 189 test::VerifyEventCount(bar_event, 1u, 3u); |
225 VerifyEventCount(bar_event, 2u, 3u); | 190 test::VerifyEventCount(bar_event, 2u, 3u); |
226 VerifyEventCount(bar_event, 5u, 5u); | 191 test::VerifyEventCount(bar_event, 5u, 5u); |
227 | 192 |
228 const Event* qux_event = model_->GetEvent("qux"); | 193 const Event* qux_event = model_->GetEvent("qux"); |
229 EXPECT_EQ("qux", qux_event->name()); | 194 EXPECT_EQ("qux", qux_event->name()); |
230 EXPECT_EQ(3, qux_event->events_size()); | 195 EXPECT_EQ(3, qux_event->events_size()); |
231 VerifyEventCount(qux_event, 1u, 5u); | 196 test::VerifyEventCount(qux_event, 1u, 5u); |
232 VerifyEventCount(qux_event, 2u, 1u); | 197 test::VerifyEventCount(qux_event, 2u, 1u); |
233 VerifyEventCount(qux_event, 3u, 2u); | 198 test::VerifyEventCount(qux_event, 3u, 2u); |
234 } | 199 } |
235 | 200 |
236 TEST_F(ModelImplTest, RetrievingNewEventsShouldYieldNullptr) { | 201 TEST_F(ModelImplTest, RetrievingNewEventsShouldYieldNullptr) { |
237 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 202 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
238 base::Unretained(this))); | 203 base::Unretained(this))); |
239 base::RunLoop().RunUntilIdle(); | 204 base::RunLoop().RunUntilIdle(); |
240 EXPECT_TRUE(model_->IsReady()); | 205 EXPECT_TRUE(model_->IsReady()); |
241 | 206 |
242 const Event* no_event = model_->GetEvent("no"); | 207 const Event* no_event = model_->GetEvent("no"); |
243 EXPECT_EQ(nullptr, no_event); | 208 EXPECT_EQ(nullptr, no_event); |
244 VerifyEqual(nullptr, store_->GetLastWrittenEvent()); | 209 test::VerifyEventsEqual(nullptr, store_->GetLastWrittenEvent()); |
245 } | 210 } |
246 | 211 |
247 TEST_F(ModelImplTest, IncrementingNonExistingEvent) { | 212 TEST_F(ModelImplTest, IncrementingNonExistingEvent) { |
248 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 213 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
249 base::Unretained(this))); | 214 base::Unretained(this))); |
250 base::RunLoop().RunUntilIdle(); | 215 base::RunLoop().RunUntilIdle(); |
251 EXPECT_TRUE(model_->IsReady()); | 216 EXPECT_TRUE(model_->IsReady()); |
252 | 217 |
253 model_->SetCurrentDay(1u); | 218 model_->SetCurrentDay(1u); |
254 | 219 |
255 // Incrementing the event should work even if it does not exist. | 220 // Incrementing the event should work even if it does not exist. |
256 model_->IncrementEvent("nonexisting"); | 221 model_->IncrementEvent("nonexisting"); |
257 const Event* event1 = model_->GetEvent("nonexisting"); | 222 const Event* event1 = model_->GetEvent("nonexisting"); |
258 EXPECT_EQ("nonexisting", event1->name()); | 223 EXPECT_EQ("nonexisting", event1->name()); |
259 EXPECT_EQ(1, event1->events_size()); | 224 EXPECT_EQ(1, event1->events_size()); |
260 VerifyEventCount(event1, 1u, 1u); | 225 test::VerifyEventCount(event1, 1u, 1u); |
261 VerifyEqual(event1, store_->GetLastWrittenEvent()); | 226 test::VerifyEventsEqual(event1, store_->GetLastWrittenEvent()); |
262 | 227 |
263 // Incrementing the event after it has been initialized to 1, it should now | 228 // Incrementing the event after it has been initialized to 1, it should now |
264 // have a count of 2 for the given day. | 229 // have a count of 2 for the given day. |
265 model_->IncrementEvent("nonexisting"); | 230 model_->IncrementEvent("nonexisting"); |
266 const Event* event2 = model_->GetEvent("nonexisting"); | 231 const Event* event2 = model_->GetEvent("nonexisting"); |
267 Event_Count event2_count = event2->events(0); | 232 Event_Count event2_count = event2->events(0); |
268 EXPECT_EQ(1, event2->events_size()); | 233 EXPECT_EQ(1, event2->events_size()); |
269 VerifyEventCount(event2, 1u, 2u); | 234 test::VerifyEventCount(event2, 1u, 2u); |
270 VerifyEqual(event2, store_->GetLastWrittenEvent()); | 235 test::VerifyEventsEqual(event2, store_->GetLastWrittenEvent()); |
271 } | 236 } |
272 | 237 |
273 TEST_F(ModelImplTest, IncrementingNonExistingEventMultipleDays) { | 238 TEST_F(ModelImplTest, IncrementingNonExistingEventMultipleDays) { |
274 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 239 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
275 base::Unretained(this))); | 240 base::Unretained(this))); |
276 base::RunLoop().RunUntilIdle(); | 241 base::RunLoop().RunUntilIdle(); |
277 EXPECT_TRUE(model_->IsReady()); | 242 EXPECT_TRUE(model_->IsReady()); |
278 | 243 |
279 model_->SetCurrentDay(1u); | 244 model_->SetCurrentDay(1u); |
280 model_->IncrementEvent("nonexisting"); | 245 model_->IncrementEvent("nonexisting"); |
281 model_->SetCurrentDay(2u); | 246 model_->SetCurrentDay(2u); |
282 model_->IncrementEvent("nonexisting"); | 247 model_->IncrementEvent("nonexisting"); |
283 model_->IncrementEvent("nonexisting"); | 248 model_->IncrementEvent("nonexisting"); |
284 model_->SetCurrentDay(3u); | 249 model_->SetCurrentDay(3u); |
285 model_->IncrementEvent("nonexisting"); | 250 model_->IncrementEvent("nonexisting"); |
286 const Event* event = model_->GetEvent("nonexisting"); | 251 const Event* event = model_->GetEvent("nonexisting"); |
287 EXPECT_EQ(3, event->events_size()); | 252 EXPECT_EQ(3, event->events_size()); |
288 VerifyEventCount(event, 1u, 1u); | 253 test::VerifyEventCount(event, 1u, 1u); |
289 VerifyEventCount(event, 2u, 2u); | 254 test::VerifyEventCount(event, 2u, 2u); |
290 VerifyEventCount(event, 3u, 1u); | 255 test::VerifyEventCount(event, 3u, 1u); |
291 VerifyEqual(event, store_->GetLastWrittenEvent()); | 256 test::VerifyEventsEqual(event, store_->GetLastWrittenEvent()); |
292 } | 257 } |
293 | 258 |
294 TEST_F(ModelImplTest, IncrementingSingleDayExistingEvent) { | 259 TEST_F(ModelImplTest, IncrementingSingleDayExistingEvent) { |
295 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 260 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
296 base::Unretained(this))); | 261 base::Unretained(this))); |
297 base::RunLoop().RunUntilIdle(); | 262 base::RunLoop().RunUntilIdle(); |
298 EXPECT_TRUE(model_->IsReady()); | 263 EXPECT_TRUE(model_->IsReady()); |
299 | 264 |
300 model_->SetCurrentDay(1u); | 265 model_->SetCurrentDay(1u); |
301 | 266 |
302 // |foo| is inserted into the store with a count of 1 at day 1. | 267 // |foo| is inserted into the store with a count of 1 at day 1. |
303 const Event* foo_event = model_->GetEvent("foo"); | 268 const Event* foo_event = model_->GetEvent("foo"); |
304 EXPECT_EQ("foo", foo_event->name()); | 269 EXPECT_EQ("foo", foo_event->name()); |
305 EXPECT_EQ(1, foo_event->events_size()); | 270 EXPECT_EQ(1, foo_event->events_size()); |
306 VerifyEventCount(foo_event, 1u, 1u); | 271 test::VerifyEventCount(foo_event, 1u, 1u); |
307 | 272 |
308 // Incrementing |foo| should change count to 2. | 273 // Incrementing |foo| should change count to 2. |
309 model_->IncrementEvent("foo"); | 274 model_->IncrementEvent("foo"); |
310 const Event* foo_event2 = model_->GetEvent("foo"); | 275 const Event* foo_event2 = model_->GetEvent("foo"); |
311 EXPECT_EQ(1, foo_event2->events_size()); | 276 EXPECT_EQ(1, foo_event2->events_size()); |
312 VerifyEventCount(foo_event2, 1u, 2u); | 277 test::VerifyEventCount(foo_event2, 1u, 2u); |
313 VerifyEqual(foo_event2, store_->GetLastWrittenEvent()); | 278 test::VerifyEventsEqual(foo_event2, store_->GetLastWrittenEvent()); |
314 } | 279 } |
315 | 280 |
316 TEST_F(ModelImplTest, IncrementingSingleDayExistingEventTwice) { | 281 TEST_F(ModelImplTest, IncrementingSingleDayExistingEventTwice) { |
317 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 282 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
318 base::Unretained(this))); | 283 base::Unretained(this))); |
319 base::RunLoop().RunUntilIdle(); | 284 base::RunLoop().RunUntilIdle(); |
320 EXPECT_TRUE(model_->IsReady()); | 285 EXPECT_TRUE(model_->IsReady()); |
321 | 286 |
322 model_->SetCurrentDay(1u); | 287 model_->SetCurrentDay(1u); |
323 | 288 |
324 // |foo| is inserted into the store with a count of 1 at day 1, so | 289 // |foo| is inserted into the store with a count of 1 at day 1, so |
325 // incrementing twice should lead to 3. | 290 // incrementing twice should lead to 3. |
326 model_->IncrementEvent("foo"); | 291 model_->IncrementEvent("foo"); |
327 model_->IncrementEvent("foo"); | 292 model_->IncrementEvent("foo"); |
328 const Event* foo_event = model_->GetEvent("foo"); | 293 const Event* foo_event = model_->GetEvent("foo"); |
329 EXPECT_EQ(1, foo_event->events_size()); | 294 EXPECT_EQ(1, foo_event->events_size()); |
330 VerifyEventCount(foo_event, 1u, 3u); | 295 test::VerifyEventCount(foo_event, 1u, 3u); |
331 VerifyEqual(foo_event, store_->GetLastWrittenEvent()); | 296 test::VerifyEventsEqual(foo_event, store_->GetLastWrittenEvent()); |
332 } | 297 } |
333 | 298 |
334 TEST_F(ModelImplTest, IncrementingExistingMultiDayEvent) { | 299 TEST_F(ModelImplTest, IncrementingExistingMultiDayEvent) { |
335 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 300 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
336 base::Unretained(this))); | 301 base::Unretained(this))); |
337 base::RunLoop().RunUntilIdle(); | 302 base::RunLoop().RunUntilIdle(); |
338 EXPECT_TRUE(model_->IsReady()); | 303 EXPECT_TRUE(model_->IsReady()); |
339 | 304 |
340 // |bar| is inserted into the store with a count of 3 at day 2. Incrementing | 305 // |bar| is inserted into the store with a count of 3 at day 2. Incrementing |
341 // that day should lead to a count of 4. | 306 // that day should lead to a count of 4. |
342 model_->SetCurrentDay(2u); | 307 model_->SetCurrentDay(2u); |
343 const Event* bar_event = model_->GetEvent("bar"); | 308 const Event* bar_event = model_->GetEvent("bar"); |
344 VerifyEventCount(bar_event, 2u, 3u); | 309 test::VerifyEventCount(bar_event, 2u, 3u); |
345 model_->IncrementEvent("bar"); | 310 model_->IncrementEvent("bar"); |
346 const Event* bar_event2 = model_->GetEvent("bar"); | 311 const Event* bar_event2 = model_->GetEvent("bar"); |
347 VerifyEventCount(bar_event2, 2u, 4u); | 312 test::VerifyEventCount(bar_event2, 2u, 4u); |
348 VerifyEqual(bar_event2, store_->GetLastWrittenEvent()); | 313 test::VerifyEventsEqual(bar_event2, store_->GetLastWrittenEvent()); |
349 } | 314 } |
350 | 315 |
351 TEST_F(ModelImplTest, IncrementingExistingMultiDayEventNewDay) { | 316 TEST_F(ModelImplTest, IncrementingExistingMultiDayEventNewDay) { |
352 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 317 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
353 base::Unretained(this))); | 318 base::Unretained(this))); |
354 base::RunLoop().RunUntilIdle(); | 319 base::RunLoop().RunUntilIdle(); |
355 EXPECT_TRUE(model_->IsReady()); | 320 EXPECT_TRUE(model_->IsReady()); |
356 | 321 |
357 // |bar| does not contain entries for day 10, so incrementing should create | 322 // |bar| does not contain entries for day 10, so incrementing should create |
358 // the day. | 323 // the day. |
359 model_->SetCurrentDay(10u); | 324 model_->SetCurrentDay(10u); |
360 model_->IncrementEvent("bar"); | 325 model_->IncrementEvent("bar"); |
361 const Event* bar_event = model_->GetEvent("bar"); | 326 const Event* bar_event = model_->GetEvent("bar"); |
362 VerifyEventCount(bar_event, 10u, 1u); | 327 test::VerifyEventCount(bar_event, 10u, 1u); |
363 VerifyEqual(bar_event, store_->GetLastWrittenEvent()); | 328 test::VerifyEventsEqual(bar_event, store_->GetLastWrittenEvent()); |
364 model_->IncrementEvent("bar"); | 329 model_->IncrementEvent("bar"); |
365 const Event* bar_event2 = model_->GetEvent("bar"); | 330 const Event* bar_event2 = model_->GetEvent("bar"); |
366 VerifyEventCount(bar_event2, 10u, 2u); | 331 test::VerifyEventCount(bar_event2, 10u, 2u); |
367 VerifyEqual(bar_event2, store_->GetLastWrittenEvent()); | 332 test::VerifyEventsEqual(bar_event2, store_->GetLastWrittenEvent()); |
368 } | 333 } |
369 | 334 |
370 TEST_F(ModelImplTest, ShowState) { | 335 TEST_F(ModelImplTest, ShowState) { |
371 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 336 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
372 base::Unretained(this))); | 337 base::Unretained(this))); |
373 base::RunLoop().RunUntilIdle(); | 338 base::RunLoop().RunUntilIdle(); |
374 EXPECT_TRUE(model_->IsReady()); | 339 EXPECT_TRUE(model_->IsReady()); |
375 | 340 |
376 EXPECT_FALSE(model_->IsCurrentlyShowing()); | 341 EXPECT_FALSE(model_->IsCurrentlyShowing()); |
377 | 342 |
(...skipping 10 matching lines...) Expand all Loading... |
388 TEST_F(LoadFailingModelImplTest, FailedInitializeInformsCaller) { | 353 TEST_F(LoadFailingModelImplTest, FailedInitializeInformsCaller) { |
389 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 354 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
390 base::Unretained(this))); | 355 base::Unretained(this))); |
391 base::RunLoop().RunUntilIdle(); | 356 base::RunLoop().RunUntilIdle(); |
392 EXPECT_FALSE(model_->IsReady()); | 357 EXPECT_FALSE(model_->IsReady()); |
393 EXPECT_TRUE(got_initialize_callback_); | 358 EXPECT_TRUE(got_initialize_callback_); |
394 EXPECT_FALSE(initialize_callback_result_); | 359 EXPECT_FALSE(initialize_callback_result_); |
395 } | 360 } |
396 | 361 |
397 } // namespace feature_engagement_tracker | 362 } // namespace feature_engagement_tracker |
OLD | NEW |