| 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 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 class MockScheduler final : public TestingPlatformMockScheduler { | 15 class MockScheduler final : public WebScheduler { |
| 16 public: | 16 public: |
| 17 MockScheduler() {} | 17 MockScheduler() {} |
| 18 ~MockScheduler() override {} | 18 ~MockScheduler() override {} |
| 19 |
| 20 // WebScheduler implementation: |
| 21 WebTaskRunner* loadingTaskRunner() override { return nullptr; } |
| 22 WebTaskRunner* timerTaskRunner() override { return nullptr; } |
| 23 void shutdown() override {} |
| 19 bool shouldYieldForHighPriorityWork() override { return true; } | 24 bool shouldYieldForHighPriorityWork() override { return true; } |
| 25 bool canExceedIdleDeadlineIfRequired() override { return false; } |
| 26 void postIdleTask(const WebTraceLocation&, WebThread::IdleTask*) override {} |
| 27 void postNonNestableIdleTask(const WebTraceLocation&, |
| 28 WebThread::IdleTask*) override {} |
| 29 std::unique_ptr<WebViewScheduler> createWebViewScheduler( |
| 30 InterventionReporter*, |
| 31 WebViewScheduler::WebViewSchedulerSettings*) override { |
| 32 return nullptr; |
| 33 } |
| 34 void suspendTimerQueue() override {} |
| 35 void resumeTimerQueue() override {} |
| 36 void addPendingNavigation(WebScheduler::NavigatingFrameType) override {} |
| 37 void removePendingNavigation(WebScheduler::NavigatingFrameType) override {} |
| 20 | 38 |
| 21 private: | 39 private: |
| 22 DISALLOW_COPY_AND_ASSIGN(MockScheduler); | 40 DISALLOW_COPY_AND_ASSIGN(MockScheduler); |
| 23 }; | 41 }; |
| 24 | 42 |
| 25 class MockThread final : public WebThread { | 43 class MockThread final : public WebThread { |
| 26 public: | 44 public: |
| 27 MockThread() {} | 45 MockThread() {} |
| 28 ~MockThread() override {} | 46 ~MockThread() override {} |
| 29 bool isCurrentThread() const override { return true; } | 47 bool isCurrentThread() const override { return true; } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 94 |
| 77 TEST_F(IdleDeadlineTest, yieldForHighPriorityWork) { | 95 TEST_F(IdleDeadlineTest, yieldForHighPriorityWork) { |
| 78 ScopedTestingPlatformSupport<MockPlatform> platform; | 96 ScopedTestingPlatformSupport<MockPlatform> platform; |
| 79 | 97 |
| 80 IdleDeadline* deadline = | 98 IdleDeadline* deadline = |
| 81 IdleDeadline::create(1.25, IdleDeadline::CallbackType::CalledWhenIdle); | 99 IdleDeadline::create(1.25, IdleDeadline::CallbackType::CalledWhenIdle); |
| 82 EXPECT_FLOAT_EQ(0, deadline->timeRemaining()); | 100 EXPECT_FLOAT_EQ(0, deadline->timeRemaining()); |
| 83 } | 101 } |
| 84 | 102 |
| 85 } // namespace blink | 103 } // namespace blink |
| OLD | NEW |