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 class ModelImplTest : public ::testing::Test { | 96 class ModelImplTest : public ::testing::Test { |
132 public: | 97 public: |
133 ModelImplTest() | 98 ModelImplTest() |
134 : got_initialize_callback_(false), initialize_callback_result_(false) {} | 99 : got_initialize_callback_(false), initialize_callback_result_(false) {} |
135 | 100 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 base::RunLoop().RunUntilIdle(); | 153 base::RunLoop().RunUntilIdle(); |
189 EXPECT_TRUE(model_->IsReady()); | 154 EXPECT_TRUE(model_->IsReady()); |
190 EXPECT_TRUE(got_initialize_callback_); | 155 EXPECT_TRUE(got_initialize_callback_); |
191 EXPECT_TRUE(initialize_callback_result_); | 156 EXPECT_TRUE(initialize_callback_result_); |
192 | 157 |
193 // Verify that all the data matches what was put into the store in | 158 // Verify that all the data matches what was put into the store in |
194 // CreateStore(). | 159 // CreateStore(). |
195 const Event* foo_event = model_->GetEvent("foo"); | 160 const Event* foo_event = model_->GetEvent("foo"); |
196 EXPECT_EQ("foo", foo_event->name()); | 161 EXPECT_EQ("foo", foo_event->name()); |
197 EXPECT_EQ(1, foo_event->events_size()); | 162 EXPECT_EQ(1, foo_event->events_size()); |
198 VerifyEventCount(foo_event, 1u, 1u); | 163 test::VerifyEventCount(foo_event, 1u, 1u); |
199 | 164 |
200 const Event* bar_event = model_->GetEvent("bar"); | 165 const Event* bar_event = model_->GetEvent("bar"); |
201 EXPECT_EQ("bar", bar_event->name()); | 166 EXPECT_EQ("bar", bar_event->name()); |
202 EXPECT_EQ(3, bar_event->events_size()); | 167 EXPECT_EQ(3, bar_event->events_size()); |
203 VerifyEventCount(bar_event, 1u, 3u); | 168 test::VerifyEventCount(bar_event, 1u, 3u); |
204 VerifyEventCount(bar_event, 2u, 3u); | 169 test::VerifyEventCount(bar_event, 2u, 3u); |
205 VerifyEventCount(bar_event, 5u, 5u); | 170 test::VerifyEventCount(bar_event, 5u, 5u); |
206 | 171 |
207 const Event* qux_event = model_->GetEvent("qux"); | 172 const Event* qux_event = model_->GetEvent("qux"); |
208 EXPECT_EQ("qux", qux_event->name()); | 173 EXPECT_EQ("qux", qux_event->name()); |
209 EXPECT_EQ(3, qux_event->events_size()); | 174 EXPECT_EQ(3, qux_event->events_size()); |
210 VerifyEventCount(qux_event, 1u, 5u); | 175 test::VerifyEventCount(qux_event, 1u, 5u); |
211 VerifyEventCount(qux_event, 2u, 1u); | 176 test::VerifyEventCount(qux_event, 2u, 1u); |
212 VerifyEventCount(qux_event, 3u, 2u); | 177 test::VerifyEventCount(qux_event, 3u, 2u); |
213 } | 178 } |
214 | 179 |
215 TEST_F(ModelImplTest, RetrievingNewEventsShouldYieldNullptr) { | 180 TEST_F(ModelImplTest, RetrievingNewEventsShouldYieldNullptr) { |
216 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 181 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
217 base::Unretained(this))); | 182 base::Unretained(this))); |
218 base::RunLoop().RunUntilIdle(); | 183 base::RunLoop().RunUntilIdle(); |
219 EXPECT_TRUE(model_->IsReady()); | 184 EXPECT_TRUE(model_->IsReady()); |
220 | 185 |
221 const Event* no_event = model_->GetEvent("no"); | 186 const Event* no_event = model_->GetEvent("no"); |
222 EXPECT_EQ(nullptr, no_event); | 187 EXPECT_EQ(nullptr, no_event); |
223 VerifyEqual(nullptr, store_->GetLastWrittenEvent()); | 188 test::VerifyEventsEqual(nullptr, store_->GetLastWrittenEvent()); |
224 } | 189 } |
225 | 190 |
226 TEST_F(ModelImplTest, IncrementingNonExistingEvent) { | 191 TEST_F(ModelImplTest, IncrementingNonExistingEvent) { |
227 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 192 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
228 base::Unretained(this))); | 193 base::Unretained(this))); |
229 base::RunLoop().RunUntilIdle(); | 194 base::RunLoop().RunUntilIdle(); |
230 EXPECT_TRUE(model_->IsReady()); | 195 EXPECT_TRUE(model_->IsReady()); |
231 | 196 |
232 // Incrementing the event should work even if it does not exist. | 197 // Incrementing the event should work even if it does not exist. |
233 model_->IncrementEvent("nonexisting", 1u); | 198 model_->IncrementEvent("nonexisting", 1u); |
234 const Event* event1 = model_->GetEvent("nonexisting"); | 199 const Event* event1 = model_->GetEvent("nonexisting"); |
235 EXPECT_EQ("nonexisting", event1->name()); | 200 EXPECT_EQ("nonexisting", event1->name()); |
236 EXPECT_EQ(1, event1->events_size()); | 201 EXPECT_EQ(1, event1->events_size()); |
237 VerifyEventCount(event1, 1u, 1u); | 202 test::VerifyEventCount(event1, 1u, 1u); |
238 VerifyEqual(event1, store_->GetLastWrittenEvent()); | 203 test::VerifyEventsEqual(event1, store_->GetLastWrittenEvent()); |
239 | 204 |
240 // Incrementing the event after it has been initialized to 1, it should now | 205 // Incrementing the event after it has been initialized to 1, it should now |
241 // have a count of 2 for the given day. | 206 // have a count of 2 for the given day. |
242 model_->IncrementEvent("nonexisting", 1u); | 207 model_->IncrementEvent("nonexisting", 1u); |
243 const Event* event2 = model_->GetEvent("nonexisting"); | 208 const Event* event2 = model_->GetEvent("nonexisting"); |
244 Event_Count event2_count = event2->events(0); | 209 Event_Count event2_count = event2->events(0); |
245 EXPECT_EQ(1, event2->events_size()); | 210 EXPECT_EQ(1, event2->events_size()); |
246 VerifyEventCount(event2, 1u, 2u); | 211 test::VerifyEventCount(event2, 1u, 2u); |
247 VerifyEqual(event2, store_->GetLastWrittenEvent()); | 212 test::VerifyEventsEqual(event2, store_->GetLastWrittenEvent()); |
248 } | 213 } |
249 | 214 |
250 TEST_F(ModelImplTest, IncrementingNonExistingEventMultipleDays) { | 215 TEST_F(ModelImplTest, IncrementingNonExistingEventMultipleDays) { |
251 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 216 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
252 base::Unretained(this))); | 217 base::Unretained(this))); |
253 base::RunLoop().RunUntilIdle(); | 218 base::RunLoop().RunUntilIdle(); |
254 EXPECT_TRUE(model_->IsReady()); | 219 EXPECT_TRUE(model_->IsReady()); |
255 | 220 |
256 model_->IncrementEvent("nonexisting", 1u); | 221 model_->IncrementEvent("nonexisting", 1u); |
257 model_->IncrementEvent("nonexisting", 2u); | 222 model_->IncrementEvent("nonexisting", 2u); |
258 model_->IncrementEvent("nonexisting", 2u); | 223 model_->IncrementEvent("nonexisting", 2u); |
259 model_->IncrementEvent("nonexisting", 3u); | 224 model_->IncrementEvent("nonexisting", 3u); |
260 const Event* event = model_->GetEvent("nonexisting"); | 225 const Event* event = model_->GetEvent("nonexisting"); |
261 EXPECT_EQ(3, event->events_size()); | 226 EXPECT_EQ(3, event->events_size()); |
262 VerifyEventCount(event, 1u, 1u); | 227 test::VerifyEventCount(event, 1u, 1u); |
263 VerifyEventCount(event, 2u, 2u); | 228 test::VerifyEventCount(event, 2u, 2u); |
264 VerifyEventCount(event, 3u, 1u); | 229 test::VerifyEventCount(event, 3u, 1u); |
265 VerifyEqual(event, store_->GetLastWrittenEvent()); | 230 test::VerifyEventsEqual(event, store_->GetLastWrittenEvent()); |
266 } | 231 } |
267 | 232 |
268 TEST_F(ModelImplTest, IncrementingSingleDayExistingEvent) { | 233 TEST_F(ModelImplTest, IncrementingSingleDayExistingEvent) { |
269 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 234 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
270 base::Unretained(this))); | 235 base::Unretained(this))); |
271 base::RunLoop().RunUntilIdle(); | 236 base::RunLoop().RunUntilIdle(); |
272 EXPECT_TRUE(model_->IsReady()); | 237 EXPECT_TRUE(model_->IsReady()); |
273 | 238 |
274 // |foo| is inserted into the store with a count of 1 at day 1. | 239 // |foo| is inserted into the store with a count of 1 at day 1. |
275 const Event* foo_event = model_->GetEvent("foo"); | 240 const Event* foo_event = model_->GetEvent("foo"); |
276 EXPECT_EQ("foo", foo_event->name()); | 241 EXPECT_EQ("foo", foo_event->name()); |
277 EXPECT_EQ(1, foo_event->events_size()); | 242 EXPECT_EQ(1, foo_event->events_size()); |
278 VerifyEventCount(foo_event, 1u, 1u); | 243 test::VerifyEventCount(foo_event, 1u, 1u); |
279 | 244 |
280 // Incrementing |foo| should change count to 2. | 245 // Incrementing |foo| should change count to 2. |
281 model_->IncrementEvent("foo", 1u); | 246 model_->IncrementEvent("foo", 1u); |
282 const Event* foo_event2 = model_->GetEvent("foo"); | 247 const Event* foo_event2 = model_->GetEvent("foo"); |
283 EXPECT_EQ(1, foo_event2->events_size()); | 248 EXPECT_EQ(1, foo_event2->events_size()); |
284 VerifyEventCount(foo_event2, 1u, 2u); | 249 test::VerifyEventCount(foo_event2, 1u, 2u); |
285 VerifyEqual(foo_event2, store_->GetLastWrittenEvent()); | 250 test::VerifyEventsEqual(foo_event2, store_->GetLastWrittenEvent()); |
286 } | 251 } |
287 | 252 |
288 TEST_F(ModelImplTest, IncrementingSingleDayExistingEventTwice) { | 253 TEST_F(ModelImplTest, IncrementingSingleDayExistingEventTwice) { |
289 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 254 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
290 base::Unretained(this))); | 255 base::Unretained(this))); |
291 base::RunLoop().RunUntilIdle(); | 256 base::RunLoop().RunUntilIdle(); |
292 EXPECT_TRUE(model_->IsReady()); | 257 EXPECT_TRUE(model_->IsReady()); |
293 | 258 |
294 // |foo| is inserted into the store with a count of 1 at day 1, so | 259 // |foo| is inserted into the store with a count of 1 at day 1, so |
295 // incrementing twice should lead to 3. | 260 // incrementing twice should lead to 3. |
296 model_->IncrementEvent("foo", 1u); | 261 model_->IncrementEvent("foo", 1u); |
297 model_->IncrementEvent("foo", 1u); | 262 model_->IncrementEvent("foo", 1u); |
298 const Event* foo_event = model_->GetEvent("foo"); | 263 const Event* foo_event = model_->GetEvent("foo"); |
299 EXPECT_EQ(1, foo_event->events_size()); | 264 EXPECT_EQ(1, foo_event->events_size()); |
300 VerifyEventCount(foo_event, 1u, 3u); | 265 test::VerifyEventCount(foo_event, 1u, 3u); |
301 VerifyEqual(foo_event, store_->GetLastWrittenEvent()); | 266 test::VerifyEventsEqual(foo_event, store_->GetLastWrittenEvent()); |
302 } | 267 } |
303 | 268 |
304 TEST_F(ModelImplTest, IncrementingExistingMultiDayEvent) { | 269 TEST_F(ModelImplTest, IncrementingExistingMultiDayEvent) { |
305 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 270 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
306 base::Unretained(this))); | 271 base::Unretained(this))); |
307 base::RunLoop().RunUntilIdle(); | 272 base::RunLoop().RunUntilIdle(); |
308 EXPECT_TRUE(model_->IsReady()); | 273 EXPECT_TRUE(model_->IsReady()); |
309 | 274 |
310 // |bar| is inserted into the store with a count of 3 at day 2. Incrementing | 275 // |bar| is inserted into the store with a count of 3 at day 2. Incrementing |
311 // that day should lead to a count of 4. | 276 // that day should lead to a count of 4. |
312 const Event* bar_event = model_->GetEvent("bar"); | 277 const Event* bar_event = model_->GetEvent("bar"); |
313 VerifyEventCount(bar_event, 2u, 3u); | 278 test::VerifyEventCount(bar_event, 2u, 3u); |
314 model_->IncrementEvent("bar", 2u); | 279 model_->IncrementEvent("bar", 2u); |
315 const Event* bar_event2 = model_->GetEvent("bar"); | 280 const Event* bar_event2 = model_->GetEvent("bar"); |
316 VerifyEventCount(bar_event2, 2u, 4u); | 281 test::VerifyEventCount(bar_event2, 2u, 4u); |
317 VerifyEqual(bar_event2, store_->GetLastWrittenEvent()); | 282 test::VerifyEventsEqual(bar_event2, store_->GetLastWrittenEvent()); |
318 } | 283 } |
319 | 284 |
320 TEST_F(ModelImplTest, IncrementingExistingMultiDayEventNewDay) { | 285 TEST_F(ModelImplTest, IncrementingExistingMultiDayEventNewDay) { |
321 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 286 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
322 base::Unretained(this))); | 287 base::Unretained(this))); |
323 base::RunLoop().RunUntilIdle(); | 288 base::RunLoop().RunUntilIdle(); |
324 EXPECT_TRUE(model_->IsReady()); | 289 EXPECT_TRUE(model_->IsReady()); |
325 | 290 |
326 // |bar| does not contain entries for day 10, so incrementing should create | 291 // |bar| does not contain entries for day 10, so incrementing should create |
327 // the day. | 292 // the day. |
328 model_->IncrementEvent("bar", 10u); | 293 model_->IncrementEvent("bar", 10u); |
329 const Event* bar_event = model_->GetEvent("bar"); | 294 const Event* bar_event = model_->GetEvent("bar"); |
330 VerifyEventCount(bar_event, 10u, 1u); | 295 test::VerifyEventCount(bar_event, 10u, 1u); |
331 VerifyEqual(bar_event, store_->GetLastWrittenEvent()); | 296 test::VerifyEventsEqual(bar_event, store_->GetLastWrittenEvent()); |
332 model_->IncrementEvent("bar", 10u); | 297 model_->IncrementEvent("bar", 10u); |
333 const Event* bar_event2 = model_->GetEvent("bar"); | 298 const Event* bar_event2 = model_->GetEvent("bar"); |
334 VerifyEventCount(bar_event2, 10u, 2u); | 299 test::VerifyEventCount(bar_event2, 10u, 2u); |
335 VerifyEqual(bar_event2, store_->GetLastWrittenEvent()); | 300 test::VerifyEventsEqual(bar_event2, store_->GetLastWrittenEvent()); |
336 } | 301 } |
337 | 302 |
338 TEST_F(ModelImplTest, ShowState) { | 303 TEST_F(ModelImplTest, ShowState) { |
339 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 304 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
340 base::Unretained(this))); | 305 base::Unretained(this))); |
341 base::RunLoop().RunUntilIdle(); | 306 base::RunLoop().RunUntilIdle(); |
342 EXPECT_TRUE(model_->IsReady()); | 307 EXPECT_TRUE(model_->IsReady()); |
343 | 308 |
344 EXPECT_FALSE(model_->IsCurrentlyShowing()); | 309 EXPECT_FALSE(model_->IsCurrentlyShowing()); |
345 | 310 |
(...skipping 10 matching lines...) Expand all Loading... |
356 TEST_F(LoadFailingModelImplTest, FailedInitializeInformsCaller) { | 321 TEST_F(LoadFailingModelImplTest, FailedInitializeInformsCaller) { |
357 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, | 322 model_->Initialize(base::Bind(&ModelImplTest::OnModelInitializationFinished, |
358 base::Unretained(this))); | 323 base::Unretained(this))); |
359 base::RunLoop().RunUntilIdle(); | 324 base::RunLoop().RunUntilIdle(); |
360 EXPECT_FALSE(model_->IsReady()); | 325 EXPECT_FALSE(model_->IsReady()); |
361 EXPECT_TRUE(got_initialize_callback_); | 326 EXPECT_TRUE(got_initialize_callback_); |
362 EXPECT_FALSE(initialize_callback_result_); | 327 EXPECT_FALSE(initialize_callback_result_); |
363 } | 328 } |
364 | 329 |
365 } // namespace feature_engagement_tracker | 330 } // namespace feature_engagement_tracker |
OLD | NEW |