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

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: Un deleted something I didn't intend to delete 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..d5e24d15502bad62925ed745110441f4734421e6 100644
--- a/Source/platform/scheduler/SchedulerTest.cpp
+++ b/Source/platform/scheduler/SchedulerTest.cpp
@@ -9,8 +9,11 @@
#include "platform/TraceLocation.h"
#include "public/platform/Platform.h"
#include "public/platform/WebThread.h"
+#include "wtf/text/WTFString.h"
+#include <gmock/gmock.h>
#include <gtest/gtest.h>
+#include <vector>
using blink::Scheduler;
@@ -131,9 +134,24 @@ public:
m_platformSupport.runPendingTasks();
}
+ void appendToVector(String value)
Sami 2014/08/07 14:24:45 nit: looks like this could be a normal std::string
alexclarke 2014/08/07 15:15:29 Done.
+ {
+ m_order.push_back(value);
+ }
+
+ void appendToVectorReentrant(int count)
+ {
+ m_intOrder.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_intOrder;
Sami 2014/08/07 14:24:45 bikeshed: m_reentrantOrder?
alexclarke 2014/08/07 15:15:29 Done.
};
void orderedTestTask(int value, int* result)
@@ -209,4 +227,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_intOrder, testing::ElementsAre(0, 1, 2, 3, 4));
+}
+
+
Sami 2014/08/07 14:24:45 Would you mind adding a test that checks all pendi
alexclarke 2014/08/07 15:15:29 Done.
} // 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