OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "base/command_line.h" | 33 #include "base/command_line.h" |
34 #include "base/memory/discardable_memory_allocator.h" | 34 #include "base/memory/discardable_memory_allocator.h" |
35 #include "base/memory/ptr_util.h" | 35 #include "base/memory/ptr_util.h" |
36 #include "base/metrics/statistics_recorder.h" | 36 #include "base/metrics/statistics_recorder.h" |
37 #include "base/test/icu_test_util.h" | 37 #include "base/test/icu_test_util.h" |
38 #include "base/test/test_discardable_memory_allocator.h" | 38 #include "base/test/test_discardable_memory_allocator.h" |
39 #include "cc/blink/web_compositor_support_impl.h" | 39 #include "cc/blink/web_compositor_support_impl.h" |
40 #include "cc/test/ordered_simple_task_runner.h" | 40 #include "cc/test/ordered_simple_task_runner.h" |
41 #include "platform/HTTPNames.h" | 41 #include "platform/HTTPNames.h" |
42 #include "platform/heap/Heap.h" | 42 #include "platform/heap/Heap.h" |
| 43 #include "platform/scheduler/base/real_time_domain.h" |
| 44 #include "platform/scheduler/base/task_queue_manager.h" |
43 #include "platform/scheduler/base/test_time_source.h" | 45 #include "platform/scheduler/base/test_time_source.h" |
44 #include "platform/scheduler/child/scheduler_tqm_delegate_for_test.h" | 46 #include "platform/scheduler/child/scheduler_tqm_delegate_for_test.h" |
45 #include "platform/scheduler/renderer/renderer_scheduler_impl.h" | 47 #include "platform/scheduler/renderer/renderer_scheduler_impl.h" |
46 #include "public/platform/WebContentLayer.h" | 48 #include "public/platform/WebContentLayer.h" |
47 #include "public/platform/WebExternalTextureLayer.h" | 49 #include "public/platform/WebExternalTextureLayer.h" |
48 #include "public/platform/WebImageLayer.h" | 50 #include "public/platform/WebImageLayer.h" |
49 #include "public/platform/WebScrollbarLayer.h" | 51 #include "public/platform/WebScrollbarLayer.h" |
50 #include "wtf/CryptographicallyRandomNumber.h" | 52 #include "wtf/CryptographicallyRandomNumber.h" |
51 #include "wtf/CurrentTime.h" | 53 #include "wtf/CurrentTime.h" |
52 #include "wtf/PtrUtil.h" | 54 #include "wtf/PtrUtil.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 m_mockTaskRunner->RunPendingTasks(); | 215 m_mockTaskRunner->RunPendingTasks(); |
214 m_mockTaskRunner->ClearRunTaskLimit(); | 216 m_mockTaskRunner->ClearRunTaskLimit(); |
215 } | 217 } |
216 | 218 |
217 void TestingPlatformSupportWithMockScheduler::runUntilIdle() { | 219 void TestingPlatformSupportWithMockScheduler::runUntilIdle() { |
218 m_mockTaskRunner->RunUntilIdle(); | 220 m_mockTaskRunner->RunUntilIdle(); |
219 } | 221 } |
220 | 222 |
221 void TestingPlatformSupportWithMockScheduler::runForPeriodSeconds( | 223 void TestingPlatformSupportWithMockScheduler::runForPeriodSeconds( |
222 double seconds) { | 224 double seconds) { |
223 m_mockTaskRunner->RunForPeriod(base::TimeDelta::FromSecondsD(seconds)); | 225 const base::TimeTicks deadline = |
| 226 m_clock->NowTicks() + base::TimeDelta::FromSecondsD(seconds); |
| 227 |
| 228 scheduler::TaskQueueManager* taskQueueManager = |
| 229 m_scheduler->GetSchedulerHelperForTesting() |
| 230 ->GetTaskQueueManagerForTesting(); |
| 231 |
| 232 for (;;) { |
| 233 // If we've run out of immediate work then fast forward to the next delayed |
| 234 // task, but don't pass |deadline|. |
| 235 if (!taskQueueManager->HasImmediateWorkForTesting()) { |
| 236 base::TimeTicks nextDelayedTask; |
| 237 if (!taskQueueManager->real_time_domain()->NextScheduledRunTime( |
| 238 &nextDelayedTask) || |
| 239 nextDelayedTask > deadline) { |
| 240 break; |
| 241 } |
| 242 |
| 243 m_clock->SetNowTicks(nextDelayedTask); |
| 244 } |
| 245 |
| 246 if (m_clock->NowTicks() > deadline) |
| 247 break; |
| 248 |
| 249 m_mockTaskRunner->RunPendingTasks(); |
| 250 } |
| 251 |
| 252 m_clock->SetNowTicks(deadline); |
224 } | 253 } |
225 | 254 |
226 void TestingPlatformSupportWithMockScheduler::advanceClockSeconds( | 255 void TestingPlatformSupportWithMockScheduler::advanceClockSeconds( |
227 double seconds) { | 256 double seconds) { |
228 m_clock->Advance(base::TimeDelta::FromSecondsD(seconds)); | 257 m_clock->Advance(base::TimeDelta::FromSecondsD(seconds)); |
229 } | 258 } |
230 | 259 |
231 void TestingPlatformSupportWithMockScheduler::setAutoAdvanceNowToPendingTasks( | 260 void TestingPlatformSupportWithMockScheduler::setAutoAdvanceNowToPendingTasks( |
232 bool autoAdvance) { | 261 bool autoAdvance) { |
233 m_mockTaskRunner->SetAutoAdvanceNowToPendingTasks(autoAdvance); | 262 m_mockTaskRunner->SetAutoAdvanceNowToPendingTasks(autoAdvance); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 ProcessHeap::init(); | 313 ProcessHeap::init(); |
285 ThreadState::attachMainThread(); | 314 ThreadState::attachMainThread(); |
286 ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr, nullptr, | 315 ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr, nullptr, |
287 nullptr); | 316 nullptr); |
288 HTTPNames::init(); | 317 HTTPNames::init(); |
289 } | 318 } |
290 | 319 |
291 ScopedUnittestsEnvironmentSetup::~ScopedUnittestsEnvironmentSetup() {} | 320 ScopedUnittestsEnvironmentSetup::~ScopedUnittestsEnvironmentSetup() {} |
292 | 321 |
293 } // namespace blink | 322 } // namespace blink |
OLD | NEW |