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 |