OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <deque> | 5 #include <deque> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/test/test_pending_task.h" | 9 #include "base/test/test_pending_task_info.h" |
10 #include "base/test/test_simple_task_runner.h" | 10 #include "base/test/test_simple_task_runner.h" |
11 #include "cc/base/delayed_unique_notifier.h" | 11 #include "cc/base/delayed_unique_notifier.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 namespace { | 15 namespace { |
16 | 16 |
17 class TestNotifier : public DelayedUniqueNotifier { | 17 class TestNotifier : public DelayedUniqueNotifier { |
18 public: | 18 public: |
19 TestNotifier(base::SequencedTaskRunner* task_runner, | 19 TestNotifier(base::SequencedTaskRunner* task_runner, |
(...skipping 17 matching lines...) Expand all Loading... |
37 | 37 |
38 void SetUp() override { | 38 void SetUp() override { |
39 notification_count_ = 0; | 39 notification_count_ = 0; |
40 task_runner_ = make_scoped_refptr(new base::TestSimpleTaskRunner); | 40 task_runner_ = make_scoped_refptr(new base::TestSimpleTaskRunner); |
41 } | 41 } |
42 | 42 |
43 void Notify() { ++notification_count_; } | 43 void Notify() { ++notification_count_; } |
44 | 44 |
45 int NotificationCount() const { return notification_count_; } | 45 int NotificationCount() const { return notification_count_; } |
46 | 46 |
47 std::deque<base::TestPendingTask> TakePendingTasks() { | 47 base::TestPendingTaskQueue TakePendingTasks() { |
48 return task_runner_->TakePendingTasks(); | 48 return task_runner_->TakePendingTasks(); |
49 } | 49 } |
50 | 50 |
51 protected: | 51 protected: |
52 int notification_count_; | 52 int notification_count_; |
53 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; | 53 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; |
54 }; | 54 }; |
55 | 55 |
56 TEST_F(DelayedUniqueNotifierTest, ZeroDelay) { | 56 TEST_F(DelayedUniqueNotifierTest, ZeroDelay) { |
57 base::TimeDelta delay = base::TimeDelta::FromInternalValue(0); | 57 base::TimeDelta delay = base::TimeDelta::FromInternalValue(0); |
58 TestNotifier notifier( | 58 TestNotifier notifier( |
59 task_runner_.get(), | 59 task_runner_.get(), |
60 base::Bind(&DelayedUniqueNotifierTest::Notify, base::Unretained(this)), | 60 base::Bind(&DelayedUniqueNotifierTest::Notify, base::Unretained(this)), |
61 delay); | 61 delay); |
62 | 62 |
63 EXPECT_EQ(0, NotificationCount()); | 63 EXPECT_EQ(0, NotificationCount()); |
64 | 64 |
65 // Basic schedule for |delay| from now. | 65 // Basic schedule for |delay| from now. |
66 base::TimeTicks schedule_time = | 66 base::TimeTicks schedule_time = |
67 base::TimeTicks() + base::TimeDelta::FromInternalValue(10); | 67 base::TimeTicks() + base::TimeDelta::FromInternalValue(10); |
68 | 68 |
69 notifier.SetNow(schedule_time); | 69 notifier.SetNow(schedule_time); |
70 notifier.Schedule(); | 70 notifier.Schedule(); |
71 | 71 |
72 std::deque<base::TestPendingTask> tasks = TakePendingTasks(); | 72 base::TestPendingTaskQueue tasks = TakePendingTasks(); |
73 ASSERT_EQ(1u, tasks.size()); | 73 ASSERT_EQ(1u, tasks.size()); |
74 EXPECT_EQ(base::TimeTicks() + delay, tasks[0].GetTimeToRun()); | 74 base::TestPendingTaskInfo task_info = tasks[0].first; |
| 75 base::OnceClosure task = std::move(tasks[0].second); |
75 | 76 |
76 tasks[0].task.Run(); | 77 EXPECT_EQ(base::TimeTicks() + delay, task_info.GetTimeToRun()); |
| 78 |
| 79 std::move(task).Run(); |
77 EXPECT_EQ(1, NotificationCount()); | 80 EXPECT_EQ(1, NotificationCount()); |
78 | 81 |
79 // 5 schedules should result in only one run. | 82 // 5 schedules should result in only one run. |
80 for (int i = 0; i < 5; ++i) | 83 for (int i = 0; i < 5; ++i) |
81 notifier.Schedule(); | 84 notifier.Schedule(); |
82 | 85 |
83 tasks = TakePendingTasks(); | 86 tasks = TakePendingTasks(); |
84 ASSERT_EQ(1u, tasks.size()); | 87 ASSERT_EQ(1u, tasks.size()); |
85 EXPECT_EQ(base::TimeTicks() + delay, tasks[0].GetTimeToRun()); | 88 task_info = tasks[0].first; |
| 89 task = std::move(tasks[0].second); |
| 90 EXPECT_EQ(base::TimeTicks() + delay, task_info.GetTimeToRun()); |
86 | 91 |
87 tasks[0].task.Run(); | 92 std::move(task).Run(); |
88 EXPECT_EQ(2, NotificationCount()); | 93 EXPECT_EQ(2, NotificationCount()); |
89 } | 94 } |
90 | 95 |
91 TEST_F(DelayedUniqueNotifierTest, SmallDelay) { | 96 TEST_F(DelayedUniqueNotifierTest, SmallDelay) { |
92 base::TimeDelta delay = base::TimeDelta::FromInternalValue(20); | 97 base::TimeDelta delay = base::TimeDelta::FromInternalValue(20); |
93 TestNotifier notifier( | 98 TestNotifier notifier( |
94 task_runner_.get(), | 99 task_runner_.get(), |
95 base::Bind(&DelayedUniqueNotifierTest::Notify, base::Unretained(this)), | 100 base::Bind(&DelayedUniqueNotifierTest::Notify, base::Unretained(this)), |
96 delay); | 101 delay); |
97 | 102 |
98 EXPECT_EQ(0, NotificationCount()); | 103 EXPECT_EQ(0, NotificationCount()); |
99 | 104 |
100 // Basic schedule for |delay| from now (now: 30, run time: 50). | 105 // Basic schedule for |delay| from now (now: 30, run time: 50). |
101 base::TimeTicks schedule_time = | 106 base::TimeTicks schedule_time = |
102 base::TimeTicks() + base::TimeDelta::FromInternalValue(30); | 107 base::TimeTicks() + base::TimeDelta::FromInternalValue(30); |
103 | 108 |
104 notifier.SetNow(schedule_time); | 109 notifier.SetNow(schedule_time); |
105 notifier.Schedule(); | 110 notifier.Schedule(); |
106 | 111 |
107 std::deque<base::TestPendingTask> tasks = TakePendingTasks(); | 112 base::TestPendingTaskQueue tasks = TakePendingTasks(); |
108 | 113 |
109 ASSERT_EQ(1u, tasks.size()); | 114 ASSERT_EQ(1u, tasks.size()); |
110 EXPECT_EQ(base::TimeTicks() + delay, tasks[0].GetTimeToRun()); | 115 base::TestPendingTaskInfo task_info = tasks[0].first; |
| 116 base::OnceClosure task = std::move(tasks[0].second); |
| 117 EXPECT_EQ(base::TimeTicks() + delay, task_info.GetTimeToRun()); |
111 | 118 |
112 // It's not yet time to run, so we expect no notifications. | 119 // It's not yet time to run, so we expect no notifications. |
113 tasks[0].task.Run(); | 120 std::move(task).Run(); |
114 EXPECT_EQ(0, NotificationCount()); | 121 EXPECT_EQ(0, NotificationCount()); |
115 | 122 |
116 tasks = TakePendingTasks(); | 123 tasks = TakePendingTasks(); |
| 124 ASSERT_EQ(1u, tasks.size()); |
| 125 task_info = tasks[0].first; |
| 126 task = std::move(tasks[0].second); |
117 | 127 |
118 ASSERT_EQ(1u, tasks.size()); | |
119 // Now the time should be delay minus whatever the value of now happens to be | 128 // Now the time should be delay minus whatever the value of now happens to be |
120 // (now: 30, run time: 50). | 129 // (now: 30, run time: 50). |
121 base::TimeTicks scheduled_run_time = notifier.Now() + delay; | 130 base::TimeTicks scheduled_run_time = notifier.Now() + delay; |
122 base::TimeTicks scheduled_delay = | 131 base::TimeTicks scheduled_delay = |
123 base::TimeTicks() + (scheduled_run_time - notifier.Now()); | 132 base::TimeTicks() + (scheduled_run_time - notifier.Now()); |
124 EXPECT_EQ(scheduled_delay, tasks[0].GetTimeToRun()); | 133 EXPECT_EQ(scheduled_delay, task_info.GetTimeToRun()); |
125 | 134 |
126 // Move closer to the run time (time: 49, run time: 50). | 135 // Move closer to the run time (time: 49, run time: 50). |
127 notifier.SetNow(notifier.Now() + base::TimeDelta::FromInternalValue(19)); | 136 notifier.SetNow(notifier.Now() + base::TimeDelta::FromInternalValue(19)); |
128 | 137 |
129 // It's not yet time to run, so we expect no notifications. | 138 // It's not yet time to run, so we expect no notifications. |
130 tasks[0].task.Run(); | 139 std::move(task).Run(); |
131 EXPECT_EQ(0, NotificationCount()); | 140 EXPECT_EQ(0, NotificationCount()); |
132 | 141 |
133 tasks = TakePendingTasks(); | 142 tasks = TakePendingTasks(); |
134 ASSERT_EQ(1u, tasks.size()); | 143 ASSERT_EQ(1u, tasks.size()); |
| 144 task_info = tasks[0].first; |
| 145 task = std::move(tasks[0].second); |
135 | 146 |
136 // Now the time should be delay minus whatever the value of now happens to be. | 147 // Now the time should be delay minus whatever the value of now happens to be. |
137 scheduled_delay = base::TimeTicks() + (scheduled_run_time - notifier.Now()); | 148 scheduled_delay = base::TimeTicks() + (scheduled_run_time - notifier.Now()); |
138 EXPECT_EQ(scheduled_delay, tasks[0].GetTimeToRun()); | 149 EXPECT_EQ(scheduled_delay, task_info.GetTimeToRun()); |
139 | 150 |
140 // Move to exactly the run time (time: 50, run time: 50). | 151 // Move to exactly the run time (time: 50, run time: 50). |
141 notifier.SetNow(notifier.Now() + base::TimeDelta::FromInternalValue(1)); | 152 notifier.SetNow(notifier.Now() + base::TimeDelta::FromInternalValue(1)); |
142 | 153 |
143 // It's time to run! | 154 // It's time to run! |
144 tasks[0].task.Run(); | 155 std::move(task).Run(); |
145 EXPECT_EQ(1, NotificationCount()); | 156 EXPECT_EQ(1, NotificationCount()); |
146 | 157 |
147 tasks = TakePendingTasks(); | 158 tasks = TakePendingTasks(); |
148 EXPECT_EQ(0u, tasks.size()); | 159 EXPECT_EQ(0u, tasks.size()); |
149 } | 160 } |
150 | 161 |
151 TEST_F(DelayedUniqueNotifierTest, RescheduleDelay) { | 162 TEST_F(DelayedUniqueNotifierTest, RescheduleDelay) { |
152 base::TimeDelta delay = base::TimeDelta::FromInternalValue(20); | 163 base::TimeDelta delay = base::TimeDelta::FromInternalValue(20); |
153 TestNotifier notifier( | 164 TestNotifier notifier( |
154 task_runner_.get(), | 165 task_runner_.get(), |
155 base::Bind(&DelayedUniqueNotifierTest::Notify, base::Unretained(this)), | 166 base::Bind(&DelayedUniqueNotifierTest::Notify, base::Unretained(this)), |
156 delay); | 167 delay); |
157 | 168 |
158 base::TimeTicks schedule_time; | 169 base::TimeTicks schedule_time; |
159 // Move time 19 units forward and reschedule, expecting that we still need to | 170 // Move time 19 units forward and reschedule, expecting that we still need to |
160 // run in |delay| time and we don't get a notification. | 171 // run in |delay| time and we don't get a notification. |
161 for (int i = 0; i < 10; ++i) { | 172 for (int i = 0; i < 10; ++i) { |
162 EXPECT_EQ(0, NotificationCount()); | 173 EXPECT_EQ(0, NotificationCount()); |
163 | 174 |
164 // Move time forward 19 units. | 175 // Move time forward 19 units. |
165 schedule_time = notifier.Now() + base::TimeDelta::FromInternalValue(19); | 176 schedule_time = notifier.Now() + base::TimeDelta::FromInternalValue(19); |
166 notifier.SetNow(schedule_time); | 177 notifier.SetNow(schedule_time); |
167 notifier.Schedule(); | 178 notifier.Schedule(); |
168 | 179 |
169 std::deque<base::TestPendingTask> tasks = TakePendingTasks(); | 180 base::TestPendingTaskQueue tasks = TakePendingTasks(); |
170 | |
171 ASSERT_EQ(1u, tasks.size()); | 181 ASSERT_EQ(1u, tasks.size()); |
172 EXPECT_EQ(base::TimeTicks() + delay, tasks[0].GetTimeToRun()); | 182 base::TestPendingTaskInfo task_info = tasks[0].first; |
| 183 base::OnceClosure task = std::move(tasks[0].second); |
| 184 EXPECT_EQ(base::TimeTicks() + delay, task_info.GetTimeToRun()); |
173 | 185 |
174 // It's not yet time to run, so we expect no notifications. | 186 // It's not yet time to run, so we expect no notifications. |
175 tasks[0].task.Run(); | 187 std::move(task).Run(); |
176 EXPECT_EQ(0, NotificationCount()); | 188 EXPECT_EQ(0, NotificationCount()); |
177 } | 189 } |
178 | 190 |
179 // Move time forward 20 units, expecting a notification. | 191 // Move time forward 20 units, expecting a notification. |
180 schedule_time = notifier.Now() + base::TimeDelta::FromInternalValue(20); | 192 schedule_time = notifier.Now() + base::TimeDelta::FromInternalValue(20); |
181 notifier.SetNow(schedule_time); | 193 notifier.SetNow(schedule_time); |
182 | 194 |
183 std::deque<base::TestPendingTask> tasks = TakePendingTasks(); | 195 base::TestPendingTaskQueue tasks = TakePendingTasks(); |
184 | |
185 ASSERT_EQ(1u, tasks.size()); | 196 ASSERT_EQ(1u, tasks.size()); |
186 EXPECT_EQ(base::TimeTicks() + delay, tasks[0].GetTimeToRun()); | 197 base::TestPendingTaskInfo task_info = tasks[0].first; |
| 198 base::OnceClosure task = std::move(tasks[0].second); |
| 199 EXPECT_EQ(base::TimeTicks() + delay, task_info.GetTimeToRun()); |
187 | 200 |
188 // Time to run! | 201 // Time to run! |
189 tasks[0].task.Run(); | 202 std::move(task).Run(); |
190 EXPECT_EQ(1, NotificationCount()); | 203 EXPECT_EQ(1, NotificationCount()); |
191 } | 204 } |
192 | 205 |
193 TEST_F(DelayedUniqueNotifierTest, CancelAndHasPendingNotification) { | 206 TEST_F(DelayedUniqueNotifierTest, CancelAndHasPendingNotification) { |
194 base::TimeDelta delay = base::TimeDelta::FromInternalValue(20); | 207 base::TimeDelta delay = base::TimeDelta::FromInternalValue(20); |
195 TestNotifier notifier( | 208 TestNotifier notifier( |
196 task_runner_.get(), | 209 task_runner_.get(), |
197 base::Bind(&DelayedUniqueNotifierTest::Notify, base::Unretained(this)), | 210 base::Bind(&DelayedUniqueNotifierTest::Notify, base::Unretained(this)), |
198 delay); | 211 delay); |
199 | 212 |
200 EXPECT_EQ(0, NotificationCount()); | 213 EXPECT_EQ(0, NotificationCount()); |
201 | 214 |
202 // Schedule for |delay| seconds from now. | 215 // Schedule for |delay| seconds from now. |
203 base::TimeTicks schedule_time = | 216 base::TimeTicks schedule_time = |
204 notifier.Now() + base::TimeDelta::FromInternalValue(10); | 217 notifier.Now() + base::TimeDelta::FromInternalValue(10); |
205 notifier.SetNow(schedule_time); | 218 notifier.SetNow(schedule_time); |
206 notifier.Schedule(); | 219 notifier.Schedule(); |
207 EXPECT_TRUE(notifier.HasPendingNotification()); | 220 EXPECT_TRUE(notifier.HasPendingNotification()); |
208 | 221 |
209 // Cancel the run. | 222 // Cancel the run. |
210 notifier.Cancel(); | 223 notifier.Cancel(); |
211 EXPECT_FALSE(notifier.HasPendingNotification()); | 224 EXPECT_FALSE(notifier.HasPendingNotification()); |
212 | 225 |
213 std::deque<base::TestPendingTask> tasks = TakePendingTasks(); | 226 base::TestPendingTaskQueue tasks = TakePendingTasks(); |
214 | |
215 ASSERT_EQ(1u, tasks.size()); | 227 ASSERT_EQ(1u, tasks.size()); |
216 EXPECT_EQ(base::TimeTicks() + delay, tasks[0].GetTimeToRun()); | 228 base::TestPendingTaskInfo task_info = tasks[0].first; |
| 229 base::OnceClosure task = std::move(tasks[0].second); |
| 230 EXPECT_EQ(base::TimeTicks() + delay, task_info.GetTimeToRun()); |
217 | 231 |
218 // Time to run, but a canceled task! | 232 // Time to run, but a canceled task! |
219 tasks[0].task.Run(); | 233 std::move(task).Run(); |
220 EXPECT_EQ(0, NotificationCount()); | 234 EXPECT_EQ(0, NotificationCount()); |
221 EXPECT_FALSE(notifier.HasPendingNotification()); | 235 EXPECT_FALSE(notifier.HasPendingNotification()); |
222 | 236 |
223 tasks = TakePendingTasks(); | 237 tasks = TakePendingTasks(); |
224 EXPECT_EQ(0u, tasks.size()); | 238 EXPECT_EQ(0u, tasks.size()); |
225 | 239 |
226 notifier.Schedule(); | 240 notifier.Schedule(); |
227 EXPECT_TRUE(notifier.HasPendingNotification()); | 241 EXPECT_TRUE(notifier.HasPendingNotification()); |
228 tasks = TakePendingTasks(); | 242 tasks = TakePendingTasks(); |
229 | 243 |
230 ASSERT_EQ(1u, tasks.size()); | 244 ASSERT_EQ(1u, tasks.size()); |
231 EXPECT_EQ(base::TimeTicks() + delay, tasks[0].GetTimeToRun()); | 245 task_info = tasks[0].first; |
| 246 task = std::move(tasks[0].second); |
| 247 EXPECT_EQ(base::TimeTicks() + delay, task_info.GetTimeToRun()); |
232 | 248 |
233 // Advance the time. | 249 // Advance the time. |
234 notifier.SetNow(notifier.Now() + delay); | 250 notifier.SetNow(notifier.Now() + delay); |
235 | 251 |
236 // This should run since it wasn't canceled. | 252 // This should run since it wasn't canceled. |
237 tasks[0].task.Run(); | 253 std::move(task).Run(); |
238 EXPECT_EQ(1, NotificationCount()); | 254 EXPECT_EQ(1, NotificationCount()); |
239 EXPECT_FALSE(notifier.HasPendingNotification()); | 255 EXPECT_FALSE(notifier.HasPendingNotification()); |
240 | 256 |
241 for (int i = 0; i < 10; ++i) { | 257 for (int i = 0; i < 10; ++i) { |
242 notifier.Schedule(); | 258 notifier.Schedule(); |
243 EXPECT_TRUE(notifier.HasPendingNotification()); | 259 EXPECT_TRUE(notifier.HasPendingNotification()); |
244 notifier.Cancel(); | 260 notifier.Cancel(); |
245 EXPECT_FALSE(notifier.HasPendingNotification()); | 261 EXPECT_FALSE(notifier.HasPendingNotification()); |
246 } | 262 } |
247 | 263 |
248 tasks = TakePendingTasks(); | 264 tasks = TakePendingTasks(); |
249 | |
250 ASSERT_EQ(1u, tasks.size()); | 265 ASSERT_EQ(1u, tasks.size()); |
251 EXPECT_EQ(base::TimeTicks() + delay, tasks[0].GetTimeToRun()); | 266 task_info = tasks[0].first; |
| 267 task = std::move(tasks[0].second); |
| 268 EXPECT_EQ(base::TimeTicks() + delay, task_info.GetTimeToRun()); |
252 | 269 |
253 // Time to run, but a canceled task! | 270 // Time to run, but a canceled task! |
254 notifier.SetNow(notifier.Now() + delay); | 271 notifier.SetNow(notifier.Now() + delay); |
255 tasks[0].task.Run(); | 272 std::move(task).Run(); |
256 EXPECT_EQ(1, NotificationCount()); | 273 EXPECT_EQ(1, NotificationCount()); |
257 | 274 |
258 tasks = TakePendingTasks(); | 275 tasks = TakePendingTasks(); |
259 EXPECT_EQ(0u, tasks.size()); | 276 EXPECT_EQ(0u, tasks.size()); |
260 EXPECT_FALSE(notifier.HasPendingNotification()); | 277 EXPECT_FALSE(notifier.HasPendingNotification()); |
261 } | 278 } |
262 | 279 |
263 TEST_F(DelayedUniqueNotifierTest, ShutdownWithScheduledTask) { | 280 TEST_F(DelayedUniqueNotifierTest, ShutdownWithScheduledTask) { |
264 base::TimeDelta delay = base::TimeDelta::FromInternalValue(20); | 281 base::TimeDelta delay = base::TimeDelta::FromInternalValue(20); |
265 TestNotifier notifier( | 282 TestNotifier notifier( |
266 task_runner_.get(), | 283 task_runner_.get(), |
267 base::Bind(&DelayedUniqueNotifierTest::Notify, base::Unretained(this)), | 284 base::Bind(&DelayedUniqueNotifierTest::Notify, base::Unretained(this)), |
268 delay); | 285 delay); |
269 | 286 |
270 EXPECT_EQ(0, NotificationCount()); | 287 EXPECT_EQ(0, NotificationCount()); |
271 | 288 |
272 // Schedule for |delay| seconds from now. | 289 // Schedule for |delay| seconds from now. |
273 base::TimeTicks schedule_time = | 290 base::TimeTicks schedule_time = |
274 notifier.Now() + base::TimeDelta::FromInternalValue(10); | 291 notifier.Now() + base::TimeDelta::FromInternalValue(10); |
275 notifier.SetNow(schedule_time); | 292 notifier.SetNow(schedule_time); |
276 notifier.Schedule(); | 293 notifier.Schedule(); |
277 EXPECT_TRUE(notifier.HasPendingNotification()); | 294 EXPECT_TRUE(notifier.HasPendingNotification()); |
278 | 295 |
279 // Shutdown the notifier. | 296 // Shutdown the notifier. |
280 notifier.Shutdown(); | 297 notifier.Shutdown(); |
281 | 298 |
282 // The task is still there, but... | 299 // The task is still there, but... |
283 std::deque<base::TestPendingTask> tasks = TakePendingTasks(); | 300 base::TestPendingTaskQueue tasks = TakePendingTasks(); |
284 ASSERT_EQ(1u, tasks.size()); | 301 ASSERT_EQ(1u, tasks.size()); |
285 | 302 |
286 // Running the task after shutdown does nothing since it's cancelled. | 303 // Running the task after shutdown does nothing since it's cancelled. |
287 tasks[0].task.Run(); | 304 std::move(tasks[0].second).Run(); |
288 EXPECT_EQ(0, NotificationCount()); | 305 EXPECT_EQ(0, NotificationCount()); |
289 | 306 |
290 tasks = TakePendingTasks(); | 307 tasks = TakePendingTasks(); |
291 EXPECT_EQ(0u, tasks.size()); | 308 EXPECT_EQ(0u, tasks.size()); |
292 | 309 |
293 // We are no longer able to schedule tasks. | 310 // We are no longer able to schedule tasks. |
294 notifier.Schedule(); | 311 notifier.Schedule(); |
295 tasks = TakePendingTasks(); | 312 tasks = TakePendingTasks(); |
296 ASSERT_EQ(0u, tasks.size()); | 313 ASSERT_EQ(0u, tasks.size()); |
297 | 314 |
(...skipping 15 matching lines...) Expand all Loading... |
313 // Schedule for |delay| seconds from now. | 330 // Schedule for |delay| seconds from now. |
314 base::TimeTicks schedule_time = | 331 base::TimeTicks schedule_time = |
315 notifier.Now() + base::TimeDelta::FromInternalValue(10); | 332 notifier.Now() + base::TimeDelta::FromInternalValue(10); |
316 notifier.SetNow(schedule_time); | 333 notifier.SetNow(schedule_time); |
317 | 334 |
318 // Shutdown the notifier. | 335 // Shutdown the notifier. |
319 notifier.Shutdown(); | 336 notifier.Shutdown(); |
320 | 337 |
321 // Scheduling a task no longer does anything. | 338 // Scheduling a task no longer does anything. |
322 notifier.Schedule(); | 339 notifier.Schedule(); |
323 std::deque<base::TestPendingTask> tasks = TakePendingTasks(); | 340 base::TestPendingTaskQueue tasks = TakePendingTasks(); |
324 ASSERT_EQ(0u, tasks.size()); | 341 ASSERT_EQ(0u, tasks.size()); |
325 | 342 |
326 // Verify after the scheduled time happens there is still no task. | 343 // Verify after the scheduled time happens there is still no task. |
327 notifier.SetNow(notifier.Now() + delay); | 344 notifier.SetNow(notifier.Now() + delay); |
328 tasks = TakePendingTasks(); | 345 tasks = TakePendingTasks(); |
329 ASSERT_EQ(0u, tasks.size()); | 346 ASSERT_EQ(0u, tasks.size()); |
330 } | 347 } |
331 | 348 |
332 } // namespace | 349 } // namespace |
333 } // namespace cc | 350 } // namespace cc |
OLD | NEW |