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

Side by Side Diff: Source/platform/scheduler/SchedulerTest.cpp

Issue 554693004: Adds a didReceiveInputEvent api to the blink scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed an error Created 6 years, 3 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
« no previous file with comments | « Source/platform/scheduler/Scheduler.cpp ('k') | public/platform/WebSchedulerProxy.h » ('j') | 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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 m_scheduler->setSharedTimerFiredFunction(nullptr); 460 m_scheduler->setSharedTimerFiredFunction(nullptr);
461 } 461 }
462 462
463 TEST_F(SchedulerTest, TestInputEventDoesNotTriggerShouldYield_InNormalMode) 463 TEST_F(SchedulerTest, TestInputEventDoesNotTriggerShouldYield_InNormalMode)
464 { 464 {
465 m_scheduler->postInputTask(FROM_HERE, WTF::bind(&dummyTask)); 465 m_scheduler->postInputTask(FROM_HERE, WTF::bind(&dummyTask));
466 466
467 EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork()); 467 EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
468 } 468 }
469 469
470 TEST_F(SchedulerTest, TestDidReceiveInputEventDoesNotTriggerShouldYield)
471 {
472 m_scheduler->didReceiveInputEvent();
473
474 EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
475 }
476
470 TEST_F(SchedulerTest, TestCompositorEventDoesNotTriggerShouldYield_InNormalMode) 477 TEST_F(SchedulerTest, TestCompositorEventDoesNotTriggerShouldYield_InNormalMode)
471 { 478 {
472 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask)); 479 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask));
473 480
474 EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork()); 481 EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
475 } 482 }
476 483
477 TEST_F(SchedulerTest, TestInputEventDoesTriggerShouldYield_InLowSchedulerPolicy) 484 TEST_F(SchedulerTest, TestCompositorEventDoesTriggerShouldYieldAfterDidReceiveIn putEvent)
485 {
486 m_scheduler->didReceiveInputEvent();
487
488 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
489 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask));
Sami 2014/09/11 15:12:05 This problem was here already before, but should b
alexclarke 2014/09/11 15:21:12 Done.
490
491 EXPECT_TRUE(m_scheduler->shouldYieldForHighPriorityWork());
492 }
493
494 TEST_F(SchedulerTest, TestInputEventDoesTriggerShouldYield_InCompositorPriorityM ode)
478 { 495 {
479 m_scheduler->enterSchedulerPolicy(SchedulerForTest::CompositorPriority); 496 m_scheduler->enterSchedulerPolicy(SchedulerForTest::CompositorPriority);
480 m_scheduler->postInputTask(FROM_HERE, WTF::bind(&dummyTask)); 497 m_scheduler->postInputTask(FROM_HERE, WTF::bind(&dummyTask));
481 498
482 EXPECT_TRUE(m_scheduler->shouldYieldForHighPriorityWork()); 499 EXPECT_TRUE(m_scheduler->shouldYieldForHighPriorityWork());
483 } 500 }
484 501
485 TEST_F(SchedulerTest, TestCompositorEventDoesTriggerShouldYield_InLowSchedulerPo licy) 502 TEST_F(SchedulerTest, TestCompositorEventDoesTriggerShouldYield_InCompositorPrio rityMode)
486 { 503 {
487 m_scheduler->enterSchedulerPolicy(SchedulerForTest::CompositorPriority); 504 m_scheduler->enterSchedulerPolicy(SchedulerForTest::CompositorPriority);
488 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask)); 505 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask));
489 506
490 EXPECT_TRUE(m_scheduler->shouldYieldForHighPriorityWork()); 507 EXPECT_TRUE(m_scheduler->shouldYieldForHighPriorityWork());
491 } 508 }
492 509
493 TEST_F(SchedulerTest, TestCompositorEvent_LowSchedulerPolicyDoesntLastLong) 510 TEST_F(SchedulerTest, TestCompositorEvent_LowSchedulerPolicyDoesntLastLong)
494 { 511 {
495 m_platformSupport.setMonotonicTimeForTest(1000.0); 512 m_platformSupport.setMonotonicTimeForTest(1000.0);
496 513
497 m_scheduler->enterSchedulerPolicy(SchedulerForTest::CompositorPriority); 514 m_scheduler->enterSchedulerPolicy(SchedulerForTest::CompositorPriority);
498 m_scheduler->postInputTask(FROM_HERE, WTF::bind(&dummyTask)); 515 m_scheduler->postInputTask(FROM_HERE, WTF::bind(&dummyTask));
499 m_platformSupport.setMonotonicTimeForTest(1000.5); 516 m_platformSupport.setMonotonicTimeForTest(1000.5);
500 runPendingTasks(); 517 runPendingTasks();
501 518
502 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork()); 519 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
503 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask)); 520 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask));
504 521
505 EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork()); 522 EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
506 } 523 }
507 524
525 TEST_F(SchedulerTest, testDidReceiveInputEvent_DoesntTriggerLowLatencyModeForLon g)
526 {
527 m_platformSupport.setMonotonicTimeForTest(1000.0);
528
529 // Note the latency mode gets reset by executeHighPriorityTasks, so we need a dummy task here
530 // to make sure runPendingTasks triggers executeHighPriorityTasks.
531 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask));
532 m_scheduler->didReceiveInputEvent();
533 m_platformSupport.setMonotonicTimeForTest(1000.5);
534 runPendingTasks();
535
536 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
537 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask));
538
539 EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
540 }
541
508 } // namespace 542 } // namespace
OLDNEW
« no previous file with comments | « Source/platform/scheduler/Scheduler.cpp ('k') | public/platform/WebSchedulerProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698