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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: Source/platform/scheduler/SchedulerTest.cpp
diff --git a/Source/platform/scheduler/SchedulerTest.cpp b/Source/platform/scheduler/SchedulerTest.cpp
index 4a3d9dfa07dc24b8f890c3bca349bce39b9d2b2d..d1243b069c50cd6f325ca07787175938be5109d4 100644
--- a/Source/platform/scheduler/SchedulerTest.cpp
+++ b/Source/platform/scheduler/SchedulerTest.cpp
@@ -432,6 +432,14 @@ TEST_F(SchedulerTest, TestInputEventTriggersShouldYield)
EXPECT_TRUE(m_scheduler->shouldYieldForHighPriorityWork());
}
+TEST_F(SchedulerTest, TestDidReceiveInputEventDoesNotTriggerShouldYield)
+{
+ ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
+ m_scheduler->didReceiveInputEvent();
+
+ ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
+}
+
TEST_F(SchedulerTest, TestCompositorEventDoesNotTriggerShouldYield_InNormalMode)
{
ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
@@ -440,6 +448,16 @@ TEST_F(SchedulerTest, TestCompositorEventDoesNotTriggerShouldYield_InNormalMode)
EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
}
+TEST_F(SchedulerTest, TestCompositorEventDoesTriggerShouldYield_InLowLatencyMode)
+{
+ m_scheduler->didReceiveInputEvent();
+
+ ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
+ m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask));
+
+ EXPECT_TRUE(m_scheduler->shouldYieldForHighPriorityWork());
+}
+
TEST_F(SchedulerTest, TestInputEventTriggersLowLatencyMode)
{
m_scheduler->postInputTask(FROM_HERE, WTF::bind(&dummyTask));
@@ -466,4 +484,21 @@ TEST_F(SchedulerTest, TestCompositorEvent_LowLatencyModeDoesntLastLongWithoutInp
EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
}
+TEST_F(SchedulerTest, testDidReceiveInputEvent_DoesntTriggerLowLatencyModeForLong)
+{
+ SchedulerTestingPlatformSupport::setDebugTime(1000.0);
+
+ // Note the latency mode gets reset by executeHighPriorityTasks, so we need a dummy task here
+ // to make sure runPendingTasks triggers executeHighPriorityTasks.
+ m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask));
+ m_scheduler->didReceiveInputEvent();
+ SchedulerTestingPlatformSupport::setDebugTime(1000.5);
+ runPendingTasks();
+
+ ASSERT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
+ m_scheduler->postCompositorTask(FROM_HERE, WTF::bind(&dummyTask));
+
+ EXPECT_FALSE(m_scheduler->shouldYieldForHighPriorityWork());
+}
+
} // namespace

Powered by Google App Engine
This is Rietveld 408576698