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

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: Added some more tests 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
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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } 425 }
426 426
427 TEST_F(SchedulerTest, TestInputEventTriggersShouldYield) 427 TEST_F(SchedulerTest, TestInputEventTriggersShouldYield)
428 { 428 {
429 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork()); 429 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
430 m_scheduler->postInputTask(FROM_HERE, WTF::bind(&dummyTask)); 430 m_scheduler->postInputTask(FROM_HERE, WTF::bind(&dummyTask));
431 431
432 EXPECT_TRUE(m_scheduler->shouldYieldForHighPriorityWork()); 432 EXPECT_TRUE(m_scheduler->shouldYieldForHighPriorityWork());
433 } 433 }
434 434
435 TEST_F(SchedulerTest, TestDidReceiveInputEventDoesNotTriggerShouldYield)
436 {
437 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
438 m_scheduler->didReceiveInputEvent();
439
440 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
441 }
442
435 TEST_F(SchedulerTest, TestCompositorEventDoesNotTriggerShouldYield_InNormalMode) 443 TEST_F(SchedulerTest, TestCompositorEventDoesNotTriggerShouldYield_InNormalMode)
436 { 444 {
437 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork()); 445 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
438 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask)); 446 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask));
439 447
440 EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork()); 448 EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
441 } 449 }
442 450
451 TEST_F(SchedulerTest, TestCompositorEventDoesTriggerShouldYield_InLowLatencyMode )
452 {
453 m_scheduler->didReceiveInputEvent();
454
455 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
456 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask));
457
458 EXPECT_TRUE(m_scheduler->shouldYieldForHighPriorityWork());
459 }
460
443 TEST_F(SchedulerTest, TestInputEventTriggersLowLatencyMode) 461 TEST_F(SchedulerTest, TestInputEventTriggersLowLatencyMode)
444 { 462 {
445 m_scheduler->postInputTask(FROM_HERE, WTF::bind(&dummyTask)); 463 m_scheduler->postInputTask(FROM_HERE, WTF::bind(&dummyTask));
446 runPendingTasks(); 464 runPendingTasks();
447 465
448 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork()); 466 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
449 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask)); 467 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask));
450 468
451 EXPECT_TRUE(m_scheduler->shouldYieldForHighPriorityWork()); 469 EXPECT_TRUE(m_scheduler->shouldYieldForHighPriorityWork());
452 } 470 }
453 471
454 TEST_F(SchedulerTest, TestCompositorEvent_LowLatencyModeDoesntLastLongWithoutInp utEvents) 472 TEST_F(SchedulerTest, TestCompositorEvent_LowLatencyModeDoesntLastLongWithoutInp utEvents)
455 { 473 {
456 SchedulerTestingPlatformSupport::setDebugTime(1000.0); 474 SchedulerTestingPlatformSupport::setDebugTime(1000.0);
457 475
458 // Fire off an input task to put us in low latency mode. 476 // Fire off an input task to put us in low latency mode.
459 m_scheduler->postInputTask(FROM_HERE, WTF::bind(&dummyTask)); 477 m_scheduler->postInputTask(FROM_HERE, WTF::bind(&dummyTask));
460 SchedulerTestingPlatformSupport::setDebugTime(1000.5); 478 SchedulerTestingPlatformSupport::setDebugTime(1000.5);
461 runPendingTasks(); 479 runPendingTasks();
462 480
463 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork()); 481 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
464 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask)); 482 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask));
465 483
466 EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork()); 484 EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
467 } 485 }
468 486
487 TEST_F(SchedulerTest, testDidReceiveInputEvent_DoesntTriggerLowLatencyModeForLon g)
488 {
489 SchedulerTestingPlatformSupport::setDebugTime(1000.0);
490
491 // Note the latency mode gets reset by executeHighPriorityTasks, so we need a dummy task here
492 // to make sure runPendingTasks triggers executeHighPriorityTasks.
493 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask));
494 m_scheduler->didReceiveInputEvent();
495 SchedulerTestingPlatformSupport::setDebugTime(1000.5);
496 runPendingTasks();
497
498 ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
499 m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask));
500
501 EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
502 }
503
469 } // namespace 504 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698