| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "public/platform/scheduler/child/webthread_impl_for_worker_scheduler.h" | 5 #include "public/platform/scheduler/child/webthread_impl_for_worker_scheduler.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
| 9 #include "platform/WebTaskRunner.h" | 9 #include "platform/WebTaskRunner.h" |
| 10 #include "platform/scheduler/child/web_scheduler_impl.h" | 10 #include "platform/scheduler/child/web_scheduler_impl.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 thread_.reset(); | 138 thread_.reset(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 TEST_F(WebThreadImplForWorkerSchedulerTest, TestIdleTask) { | 141 TEST_F(WebThreadImplForWorkerSchedulerTest, TestIdleTask) { |
| 142 std::unique_ptr<MockIdleTask> task(new MockIdleTask()); | 142 std::unique_ptr<MockIdleTask> task(new MockIdleTask()); |
| 143 base::WaitableEvent completion( | 143 base::WaitableEvent completion( |
| 144 base::WaitableEvent::ResetPolicy::AUTOMATIC, | 144 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 145 base::WaitableEvent::InitialState::NOT_SIGNALED); | 145 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 146 | 146 |
| 147 EXPECT_CALL(*task, run(_)); | 147 EXPECT_CALL(*task, run(_)); |
| 148 ON_CALL(*task, run(_)) | 148 ON_CALL(*task, run(_)).WillByDefault(Invoke([&completion](double) { |
| 149 .WillByDefault(Invoke([&completion](double) { completion.Signal(); })); | 149 completion.Signal(); |
| 150 })); |
| 150 | 151 |
| 151 thread_->postIdleTask(BLINK_FROM_HERE, task.release()); | 152 thread_->postIdleTask(BLINK_FROM_HERE, task.release()); |
| 152 // We need to post a wakeup task or idle work will never happen. | 153 // We need to post a wakeup task or idle work will never happen. |
| 153 thread_->getWebTaskRunner()->postDelayedTask(BLINK_FROM_HERE, | 154 thread_->getWebTaskRunner()->postDelayedTask(BLINK_FROM_HERE, |
| 154 WTF::bind([] {}), 50ll); | 155 WTF::bind([] {}), 50ll); |
| 155 | 156 |
| 156 completion.Wait(); | 157 completion.Wait(); |
| 157 } | 158 } |
| 158 | 159 |
| 159 TEST_F(WebThreadImplForWorkerSchedulerTest, TestTaskObserver) { | 160 TEST_F(WebThreadImplForWorkerSchedulerTest, TestTaskObserver) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 186 thread_->getWebTaskRunner()->postTask( | 187 thread_->getWebTaskRunner()->postTask( |
| 187 BLINK_FROM_HERE, WTF::bind(&MockTask::run, WTF::unretained(&task))); | 188 BLINK_FROM_HERE, WTF::bind(&MockTask::run, WTF::unretained(&task))); |
| 188 thread_->getWebTaskRunner()->postDelayedTask( | 189 thread_->getWebTaskRunner()->postDelayedTask( |
| 189 BLINK_FROM_HERE, | 190 BLINK_FROM_HERE, |
| 190 WTF::bind(&MockTask::run, WTF::unretained(&delayed_task)), 50ll); | 191 WTF::bind(&MockTask::run, WTF::unretained(&delayed_task)), 50ll); |
| 191 thread_.reset(); | 192 thread_.reset(); |
| 192 } | 193 } |
| 193 | 194 |
| 194 } // namespace scheduler | 195 } // namespace scheduler |
| 195 } // namespace blink | 196 } // namespace blink |
| OLD | NEW |