OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/dom/IdleDeadline.h" | 5 #include "core/dom/IdleDeadline.h" |
6 | 6 |
7 #include "platform/testing/TestingPlatformSupport.h" | 7 #include "platform/testing/TestingPlatformSupport.h" |
8 #include "public/platform/Platform.h" | 8 #include "public/platform/Platform.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "wtf/CurrentTime.h" | 10 #include "wtf/CurrentTime.h" |
| 11 #include "wtf/PtrUtil.h" |
11 | 12 |
12 namespace blink { | 13 namespace blink { |
13 namespace { | 14 namespace { |
14 | 15 |
15 class MockScheduler final : public TestingPlatformMockScheduler { | 16 class MockScheduler final : public TestingPlatformMockScheduler { |
16 public: | 17 public: |
17 MockScheduler() {} | 18 MockScheduler() {} |
18 ~MockScheduler() override {} | 19 ~MockScheduler() override {} |
19 bool shouldYieldForHighPriorityWork() override { return true; } | 20 bool shouldYieldForHighPriorityWork() override { return true; } |
20 | 21 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 EXPECT_FLOAT_EQ(249.995, deadline->timeRemaining()); | 69 EXPECT_FLOAT_EQ(249.995, deadline->timeRemaining()); |
69 } | 70 } |
70 | 71 |
71 TEST_F(IdleDeadlineTest, deadlineInPast) { | 72 TEST_F(IdleDeadlineTest, deadlineInPast) { |
72 IdleDeadline* deadline = | 73 IdleDeadline* deadline = |
73 IdleDeadline::create(0.75, IdleDeadline::CallbackType::CalledWhenIdle); | 74 IdleDeadline::create(0.75, IdleDeadline::CallbackType::CalledWhenIdle); |
74 EXPECT_FLOAT_EQ(0, deadline->timeRemaining()); | 75 EXPECT_FLOAT_EQ(0, deadline->timeRemaining()); |
75 } | 76 } |
76 | 77 |
77 TEST_F(IdleDeadlineTest, yieldForHighPriorityWork) { | 78 TEST_F(IdleDeadlineTest, yieldForHighPriorityWork) { |
78 MockPlatform platform; | 79 ScopedTestingPlatformSupport<MockPlatform> platform( |
| 80 WTF::makeUnique<MockPlatform>()); |
79 | 81 |
80 IdleDeadline* deadline = | 82 IdleDeadline* deadline = |
81 IdleDeadline::create(1.25, IdleDeadline::CallbackType::CalledWhenIdle); | 83 IdleDeadline::create(1.25, IdleDeadline::CallbackType::CalledWhenIdle); |
82 EXPECT_FLOAT_EQ(0, deadline->timeRemaining()); | 84 EXPECT_FLOAT_EQ(0, deadline->timeRemaining()); |
83 } | 85 } |
84 | 86 |
85 } // namespace blink | 87 } // namespace blink |
OLD | NEW |