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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/platform/scheduler/Scheduler.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "platform/scheduler/Scheduler.h" 6 #include "platform/scheduler/Scheduler.h"
7 7
8 #include "platform/TestingPlatformSupport.h" 8 #include "platform/TestingPlatformSupport.h"
9 #include "platform/TraceLocation.h" 9 #include "platform/TraceLocation.h"
10 #include "public/platform/Platform.h" 10 #include "public/platform/Platform.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 *result += value; 250 *result += value;
251 } 251 }
252 252
253 void idleTestTask(bool* taskRun, double expectedDeadline, double deadlineSeconds ) 253 void idleTestTask(bool* taskRun, double expectedDeadline, double deadlineSeconds )
254 { 254 {
255 EXPECT_FALSE(*taskRun); 255 EXPECT_FALSE(*taskRun);
256 EXPECT_EQ(expectedDeadline, deadlineSeconds); 256 EXPECT_EQ(expectedDeadline, deadlineSeconds);
257 *taskRun = true; 257 *taskRun = true;
258 } 258 }
259 259
260 void repostingIdleTestTask(Scheduler* scheduler, int* runCount, double deadlineS econds)
261 {
262 if (*runCount == 0)
263 scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(&repostingIdleTestT ask, scheduler, runCount));
264 (*runCount)++;
265 }
266
260 TEST_F(SchedulerTest, TestPostTask) 267 TEST_F(SchedulerTest, TestPostTask)
261 { 268 {
262 int result = 0; 269 int result = 0;
263 m_scheduler->postTask(FROM_HERE, WTF::bind(&orderedTestTask, 1, &result)); 270 m_scheduler->postTask(FROM_HERE, WTF::bind(&orderedTestTask, 1, &result));
264 m_scheduler->postTask(FROM_HERE, WTF::bind(&orderedTestTask, 2, &result)); 271 m_scheduler->postTask(FROM_HERE, WTF::bind(&orderedTestTask, 2, &result));
265 m_scheduler->postTask(FROM_HERE, WTF::bind(&orderedTestTask, 3, &result)); 272 m_scheduler->postTask(FROM_HERE, WTF::bind(&orderedTestTask, 3, &result));
266 m_scheduler->postTask(FROM_HERE, WTF::bind(&orderedTestTask, 4, &result)); 273 m_scheduler->postTask(FROM_HERE, WTF::bind(&orderedTestTask, 4, &result));
267 runPendingTasks(); 274 runPendingTasks();
268 EXPECT_EQ(0x1234, result); 275 EXPECT_EQ(0x1234, result);
269 } 276 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 runPendingTasks(); 332 runPendingTasks();
326 EXPECT_FALSE(taskRun); // We missed the deadline. 333 EXPECT_FALSE(taskRun); // We missed the deadline.
327 334
328 m_scheduler->willBeginFrame(secondDeadline); 335 m_scheduler->willBeginFrame(secondDeadline);
329 m_platformSupport.setMonotonicTimeForTest(secondDeadline - 0.1); 336 m_platformSupport.setMonotonicTimeForTest(secondDeadline - 0.1);
330 m_scheduler->didCommitFrameToCompositor(); 337 m_scheduler->didCommitFrameToCompositor();
331 runPendingTasks(); 338 runPendingTasks();
332 EXPECT_TRUE(taskRun); 339 EXPECT_TRUE(taskRun);
333 } 340 }
334 341
342 TEST_F(SchedulerTest, TestRepostingIdleTask)
343 {
344 int runCount = 0;
345
346 m_scheduler->postIdleTask(FROM_HERE, WTF::bind<double>(&repostingIdleTestTas k, m_scheduler, &runCount));
347
348 enableIdleTasks();
349 runPendingTasks();
350 EXPECT_EQ(1, runCount);
351
352 runPendingTasks();
353 EXPECT_EQ(1, runCount); // Reposted tasks shouldn't run until next idle peri od.
354
355 enableIdleTasks();
356 runPendingTasks();
357 EXPECT_EQ(2, runCount);
358 }
359
335 TEST_F(SchedulerTest, TestTaskPrioritization_normalPolicy) 360 TEST_F(SchedulerTest, TestTaskPrioritization_normalPolicy)
336 { 361 {
337 m_scheduler->postTask(FROM_HERE, WTF::bind(&SchedulerTest::appendToVector, t his, std::string("L1"))); 362 m_scheduler->postTask(FROM_HERE, WTF::bind(&SchedulerTest::appendToVector, t his, std::string("L1")));
338 m_scheduler->postTask(FROM_HERE, WTF::bind(&SchedulerTest::appendToVector, t his, std::string("L2"))); 363 m_scheduler->postTask(FROM_HERE, WTF::bind(&SchedulerTest::appendToVector, t his, std::string("L2")));
339 m_scheduler->postInputTask(FROM_HERE, WTF::bind(&SchedulerTest::appendToVect or, this, std::string("I1"))); 364 m_scheduler->postInputTask(FROM_HERE, WTF::bind(&SchedulerTest::appendToVect or, this, std::string("I1")));
340 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&SchedulerTest::appendT oVector, this, std::string("C1"))); 365 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&SchedulerTest::appendT oVector, this, std::string("C1")));
341 m_scheduler->postInputTask(FROM_HERE, WTF::bind(&SchedulerTest::appendToVect or, this, std::string("I2"))); 366 m_scheduler->postInputTask(FROM_HERE, WTF::bind(&SchedulerTest::appendToVect or, this, std::string("I2")));
342 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&SchedulerTest::appendT oVector, this, std::string("C2"))); 367 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&SchedulerTest::appendT oVector, this, std::string("C2")));
343 m_scheduler->postIpcTask(FROM_HERE, WTF::bind(&SchedulerTest::appendToVector , this, std::string("IPC"))); 368 m_scheduler->postIpcTask(FROM_HERE, WTF::bind(&SchedulerTest::appendToVector , this, std::string("IPC")));
344 369
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 m_platformSupport.setMonotonicTimeForTest(1000.5); 555 m_platformSupport.setMonotonicTimeForTest(1000.5);
531 runPendingTasks(); 556 runPendingTasks();
532 557
533 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork()); 558 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
534 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask)); 559 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask));
535 560
536 EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork()); 561 EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
537 } 562 }
538 563
539 } // namespace 564 } // namespace
OLDNEW
« 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