Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp

Issue 2433323003: Fix TestingPlatformSupportWithMockScheduler::runForPeriodSeconds (Closed)
Patch Set: Fix compile Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/testing/TestingPlatformSupport.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp
diff --git a/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp b/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp
index 8e44543b40ce1e55bdd0f659ecf116f73225e64b..0497600ee4c8e2c347f4b2f58c961af59027c670 100644
--- a/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp
+++ b/third_party/WebKit/Source/platform/testing/TestingPlatformSupport.cpp
@@ -40,6 +40,8 @@
#include "cc/test/ordered_simple_task_runner.h"
#include "platform/HTTPNames.h"
#include "platform/heap/Heap.h"
+#include "platform/scheduler/base/real_time_domain.h"
+#include "platform/scheduler/base/task_queue_manager.h"
#include "platform/scheduler/base/test_time_source.h"
#include "platform/scheduler/child/scheduler_tqm_delegate_for_test.h"
#include "platform/scheduler/renderer/renderer_scheduler_impl.h"
@@ -220,7 +222,34 @@ void TestingPlatformSupportWithMockScheduler::runUntilIdle() {
void TestingPlatformSupportWithMockScheduler::runForPeriodSeconds(
double seconds) {
- m_mockTaskRunner->RunForPeriod(base::TimeDelta::FromSecondsD(seconds));
+ const base::TimeTicks deadline =
+ m_clock->NowTicks() + base::TimeDelta::FromSecondsD(seconds);
+
+ scheduler::TaskQueueManager* taskQueueManager =
+ m_scheduler->GetSchedulerHelperForTesting()
+ ->GetTaskQueueManagerForTesting();
+
+ for (;;) {
+ // If we've run out of immediate work then fast forward to the next delayed
+ // task, but don't pass |deadline|.
+ if (!taskQueueManager->HasImmediateWorkForTesting()) {
+ base::TimeTicks nextDelayedTask;
+ if (!taskQueueManager->real_time_domain()->NextScheduledRunTime(
+ &nextDelayedTask) ||
+ nextDelayedTask > deadline) {
+ break;
+ }
+
+ m_clock->SetNowTicks(nextDelayedTask);
+ }
+
+ if (m_clock->NowTicks() > deadline)
+ break;
+
+ m_mockTaskRunner->RunPendingTasks();
+ }
+
+ m_clock->SetNowTicks(deadline);
}
void TestingPlatformSupportWithMockScheduler::advanceClockSeconds(
« no previous file with comments | « third_party/WebKit/Source/platform/testing/TestingPlatformSupport.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698