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

Unified Diff: Source/platform/scheduler/SchedulerTest.cpp

Issue 640053003: Modify the scheduler to queue idle work between idle periods. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Drop extra {} Created 6 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 | « Source/platform/scheduler/Scheduler.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/scheduler/SchedulerTest.cpp
diff --git a/Source/platform/scheduler/SchedulerTest.cpp b/Source/platform/scheduler/SchedulerTest.cpp
index aa708556f5ee3b221c503c5a912dbde5a83681fc..548146e2ce99cf91a3aafc533c660a8f39c217d6 100644
--- a/Source/platform/scheduler/SchedulerTest.cpp
+++ b/Source/platform/scheduler/SchedulerTest.cpp
@@ -257,6 +257,13 @@ void idleTestTask(bool* taskRun, double expectedDeadline, double deadlineSeconds
*taskRun = true;
}
+void repostingIdleTestTask(Scheduler* scheduler, int* runCount, double deadlineSeconds)
+{
+ if (*runCount == 0)
+ scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(&repostingIdleTestTask, scheduler, runCount));
+ (*runCount)++;
+}
+
TEST_F(SchedulerTest, TestPostTask)
{
int result = 0;
@@ -332,6 +339,24 @@ TEST_F(SchedulerTest, TestIdleTask)
EXPECT_TRUE(taskRun);
}
+TEST_F(SchedulerTest, TestRepostingIdleTask)
+{
+ int runCount = 0;
+
+ m_scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(&repostingIdleTestTask, m_scheduler, &runCount));
+
+ enableIdleTasks();
+ runPendingTasks();
+ EXPECT_EQ(1, runCount);
+
+ runPendingTasks();
+ EXPECT_EQ(1, runCount); // Reposted tasks shouldn't run until next idle period.
+
+ enableIdleTasks();
+ runPendingTasks();
+ EXPECT_EQ(2, runCount);
+}
+
TEST_F(SchedulerTest, TestTaskPrioritization_normalPolicy)
{
m_scheduler->postTask(FROM_HERE, WTF::bind(&SchedulerTest::appendToVector, this, std::string("L1")));
« no previous file with comments | « Source/platform/scheduler/Scheduler.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698