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.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, |
20 const base::Closure& closure, | 20 const base::Closure& closure, |
21 const base::TimeDelta& delay) | 21 const base::TimeDelta& delay) |
22 : DelayedUniqueNotifier(task_runner, closure, delay) {} | 22 : DelayedUniqueNotifier(task_runner, closure, delay) {} |
23 virtual ~TestNotifier() {} | 23 ~TestNotifier() override {} |
24 | 24 |
25 // Overridden from DelayedUniqueNotifier: | 25 // Overridden from DelayedUniqueNotifier: |
26 virtual base::TimeTicks Now() const override { return now_; } | 26 base::TimeTicks Now() const override { return now_; } |
27 | 27 |
28 void SetNow(base::TimeTicks now) { now_ = now; } | 28 void SetNow(base::TimeTicks now) { now_ = now; } |
29 | 29 |
30 private: | 30 private: |
31 base::TimeTicks now_; | 31 base::TimeTicks now_; |
32 }; | 32 }; |
33 | 33 |
34 class DelayedUniqueNotifierTest : public testing::Test { | 34 class DelayedUniqueNotifierTest : public testing::Test { |
35 public: | 35 public: |
36 DelayedUniqueNotifierTest() : notification_count_(0) {} | 36 DelayedUniqueNotifierTest() : notification_count_(0) {} |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 tasks[0].task.Run(); | 257 tasks[0].task.Run(); |
258 EXPECT_EQ(1, NotificationCount()); | 258 EXPECT_EQ(1, NotificationCount()); |
259 | 259 |
260 tasks = TakePendingTasks(); | 260 tasks = TakePendingTasks(); |
261 EXPECT_EQ(0u, tasks.size()); | 261 EXPECT_EQ(0u, tasks.size()); |
262 EXPECT_FALSE(notifier.HasPendingNotification()); | 262 EXPECT_FALSE(notifier.HasPendingNotification()); |
263 } | 263 } |
264 | 264 |
265 } // namespace | 265 } // namespace |
266 } // namespace cc | 266 } // namespace cc |
OLD | NEW |