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

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

Issue 439923006: Prioritizing input and compositor tasks in the blink scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: made runPendingTasks private Created 6 years, 4 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 0b35485e9232fb0518f3c5ef9e964dca34c5de72..9e2d54846c3ecd775eb71c1bc7f41924bc7ba16b 100644
--- a/Source/platform/scheduler/SchedulerTest.cpp
+++ b/Source/platform/scheduler/SchedulerTest.cpp
@@ -10,9 +10,13 @@
#include "public/platform/Platform.h"
#include "public/platform/WebThread.h"
+#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <string>
+#include <vector>
using blink::Scheduler;
+using namespace std;
namespace {
@@ -131,9 +135,24 @@ public:
m_platformSupport.runPendingTasks();
}
+ void appendToVector(string value)
+ {
+ m_order.push_back(value);
+ }
+
+ void appendToVectorReentrant(int count)
+ {
+ m_reentrantOrder.push_back(count);
+
+ if (count < 4)
+ m_scheduler->postTask(FROM_HERE, bind(&SchedulerTest::appendToVectorReentrant, this, count + 1));
+ }
+
protected:
SchedulerTestingPlatformSupport m_platformSupport;
Scheduler* m_scheduler;
+ std::vector<string> m_order;
+ std::vector<int> m_reentrantOrder;
};
void orderedTestTask(int value, int* result)
@@ -173,6 +192,17 @@ TEST_F(SchedulerTest, TestPostMixedTaskTypes)
EXPECT_EQ(15, result);
}
+TEST_F(SchedulerTest, TestTasksExecutedOnShutdown)
+{
+ int result = 0;
+ m_scheduler->postTask(FROM_HERE, bind(&unorderedTestTask, 1, &result));
+ m_scheduler->postInputTask(FROM_HERE, bind(&unorderedTestTask, 2, &result));
+ m_scheduler->postCompositorTask(FROM_HERE, bind(&unorderedTestTask, 4, &result));
+ m_scheduler->postTask(FROM_HERE, bind(&unorderedTestTask, 8, &result));
+ Scheduler::shutdown();
Sami 2014/08/07 15:51:27 Thanks for adding this test. Can you add a re-entr
alexclarke 2014/08/07 16:01:30 Done.
+ EXPECT_EQ(15, result);
+}
+
int s_sharedTimerTickCount;
void sharedTimerFunction()
{
@@ -209,4 +239,27 @@ TEST_F(SchedulerTest, TestIdleTask)
EXPECT_EQ(4, result);
}
+TEST_F(SchedulerTest, TestTaskPrioritization)
+{
+ m_scheduler->postTask(FROM_HERE, bind(&SchedulerTest::appendToVector, this, string("L1")));
+ m_scheduler->postTask(FROM_HERE, bind(&SchedulerTest::appendToVector, this, string("L2")));
+ m_scheduler->postInputTask(FROM_HERE, bind(&SchedulerTest::appendToVector, this, string("I1")));
+ m_scheduler->postInputTask(FROM_HERE, bind(&SchedulerTest::appendToVector, this, string("I2")));
+ m_scheduler->postCompositorTask(FROM_HERE, bind(&SchedulerTest::appendToVector, this, string("C1")));
+ m_scheduler->postCompositorTask(FROM_HERE, bind(&SchedulerTest::appendToVector, this, string("C2")));
+
+ runPendingTasks();
+ EXPECT_THAT(m_order, testing::ElementsAre(
+ string("I1"), string("I2"), string("C1"), string("C2"), string("L1"), string("L2")));
+}
+
+TEST_F(SchedulerTest, TestRentrantTask)
+{
+ m_scheduler->postTask(FROM_HERE, bind(&SchedulerTest::appendToVectorReentrant, this, 0));
+ runPendingTasks();
+
+ EXPECT_THAT(m_reentrantOrder, testing::ElementsAre(0, 1, 2, 3, 4));
+}
+
+
} // namespace
« Source/platform/scheduler/Scheduler.cpp ('K') | « Source/platform/scheduler/Scheduler.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698