Index: third_party/WebKit/Source/core/dom/ScriptRunnerTest.cpp |
diff --git a/third_party/WebKit/Source/core/dom/ScriptRunnerTest.cpp b/third_party/WebKit/Source/core/dom/ScriptRunnerTest.cpp |
index fe174e6cfb452b117281c0f51a396748e1cb7f34..3a84b6a78266bea4d8a1f7abfc6200625a724e64 100644 |
--- a/third_party/WebKit/Source/core/dom/ScriptRunnerTest.cpp |
+++ b/third_party/WebKit/Source/core/dom/ScriptRunnerTest.cpp |
@@ -44,6 +44,7 @@ class ScriptRunnerTest : public testing::Test { |
m_element(m_document->createElement("foo")) {} |
void SetUp() override { |
+ m_platform.reset(new TestingPlatformSupportWithMockScheduler); |
// We have to create ScriptRunner after initializing platform, because we |
// need Platform::current()->currentThread()->scheduler()-> |
// loadingTaskRunner() to be initialized before creating ScriptRunner to |
@@ -55,7 +56,8 @@ class ScriptRunnerTest : public testing::Test { |
Persistent<Document> m_document; |
Persistent<Element> m_element; |
- TestingPlatformSupportWithMockScheduler m_platform; |
+ ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler> |
+ m_platform; |
Persistent<ScriptRunner> m_scriptRunner; |
WTF::Vector<int> m_order; |
}; |
@@ -66,7 +68,7 @@ TEST_F(ScriptRunnerTest, QueueSingleScript_Async) { |
m_scriptRunner->notifyScriptReady(scriptLoader, ScriptRunner::Async); |
EXPECT_CALL(*scriptLoader, execute()); |
- m_platform.runUntilIdle(); |
+ m_platform->runUntilIdle(); |
} |
TEST_F(ScriptRunnerTest, QueueSingleScript_InOrder) { |
@@ -78,7 +80,7 @@ TEST_F(ScriptRunnerTest, QueueSingleScript_InOrder) { |
m_scriptRunner->notifyScriptReady(scriptLoader, ScriptRunner::InOrder); |
- m_platform.runUntilIdle(); |
+ m_platform->runUntilIdle(); |
} |
TEST_F(ScriptRunnerTest, QueueMultipleScripts_InOrder) { |
@@ -113,7 +115,7 @@ TEST_F(ScriptRunnerTest, QueueMultipleScripts_InOrder) { |
for (int i = 2; i >= 0; i--) { |
isReady[i] = true; |
m_scriptRunner->notifyScriptReady(scriptLoaders[i], ScriptRunner::InOrder); |
- m_platform.runUntilIdle(); |
+ m_platform->runUntilIdle(); |
} |
// But ensure the scripts were run in the expected order. |
@@ -163,7 +165,7 @@ TEST_F(ScriptRunnerTest, QueueMixedScripts) { |
m_order.push_back(5); |
})); |
- m_platform.runUntilIdle(); |
+ m_platform->runUntilIdle(); |
// Async tasks are expected to run first. |
EXPECT_THAT(m_order, ElementsAre(4, 5, 1, 2, 3)); |
@@ -197,13 +199,13 @@ TEST_F(ScriptRunnerTest, QueueReentrantScript_Async) { |
// Make sure that re-entrant calls to notifyScriptReady don't cause |
// ScriptRunner::execute to do more work than expected. |
- m_platform.runSingleTask(); |
+ m_platform->runSingleTask(); |
EXPECT_THAT(m_order, ElementsAre(1)); |
- m_platform.runSingleTask(); |
+ m_platform->runSingleTask(); |
EXPECT_THAT(m_order, ElementsAre(1, 2)); |
- m_platform.runSingleTask(); |
+ m_platform->runSingleTask(); |
EXPECT_THAT(m_order, ElementsAre(1, 2, 3)); |
} |
@@ -243,13 +245,13 @@ TEST_F(ScriptRunnerTest, QueueReentrantScript_InOrder) { |
// Make sure that re-entrant calls to queueScriptForExecution don't cause |
// ScriptRunner::execute to do more work than expected. |
- m_platform.runSingleTask(); |
+ m_platform->runSingleTask(); |
EXPECT_THAT(m_order, ElementsAre(1)); |
- m_platform.runSingleTask(); |
+ m_platform->runSingleTask(); |
EXPECT_THAT(m_order, ElementsAre(1, 2)); |
- m_platform.runSingleTask(); |
+ m_platform->runSingleTask(); |
EXPECT_THAT(m_order, ElementsAre(1, 2, 3)); |
} |
@@ -283,7 +285,7 @@ TEST_F(ScriptRunnerTest, QueueReentrantScript_ManyAsyncScripts) { |
m_order.push_back(0); |
})); |
- m_platform.runUntilIdle(); |
+ m_platform->runUntilIdle(); |
int expected[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, |
10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; |
@@ -324,10 +326,10 @@ TEST_F(ScriptRunnerTest, ResumeAndSuspend_InOrder) { |
EXPECT_CALL(*scriptLoader3, isReady()).WillRepeatedly(Return(true)); |
m_scriptRunner->notifyScriptReady(scriptLoader3, ScriptRunner::InOrder); |
- m_platform.runSingleTask(); |
+ m_platform->runSingleTask(); |
m_scriptRunner->suspend(); |
m_scriptRunner->resume(); |
- m_platform.runUntilIdle(); |
+ m_platform->runUntilIdle(); |
// Make sure elements are correct and in right order. |
EXPECT_THAT(m_order, ElementsAre(1, 2, 3)); |
@@ -356,10 +358,10 @@ TEST_F(ScriptRunnerTest, ResumeAndSuspend_Async) { |
m_order.push_back(3); |
})); |
- m_platform.runSingleTask(); |
+ m_platform->runSingleTask(); |
m_scriptRunner->suspend(); |
m_scriptRunner->resume(); |
- m_platform.runUntilIdle(); |
+ m_platform->runUntilIdle(); |
// Make sure elements are correct. |
EXPECT_THAT(m_order, WhenSorted(ElementsAre(1, 2, 3))); |
@@ -383,12 +385,12 @@ TEST_F(ScriptRunnerTest, LateNotifications) { |
})); |
m_scriptRunner->notifyScriptReady(scriptLoader1, ScriptRunner::InOrder); |
- m_platform.runUntilIdle(); |
+ m_platform->runUntilIdle(); |
// At this moment all tasks can be already executed. Make sure that we do not |
// crash here. |
m_scriptRunner->notifyScriptReady(scriptLoader2, ScriptRunner::InOrder); |
- m_platform.runUntilIdle(); |
+ m_platform->runUntilIdle(); |
EXPECT_THAT(m_order, ElementsAre(1, 2)); |
} |
@@ -417,7 +419,7 @@ TEST_F(ScriptRunnerTest, TasksWithDeadScriptRunner) { |
EXPECT_CALL(*scriptLoader1, execute()).Times(0); |
EXPECT_CALL(*scriptLoader2, execute()).Times(0); |
- m_platform.runUntilIdle(); |
+ m_platform->runUntilIdle(); |
} |
} // namespace blink |