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

Unified Diff: third_party/WebKit/Source/core/dom/ScriptRunnerTest.cpp

Issue 2266443002: Optimize posting of WTF::Closure and improve scheduler test mocks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cut back to just the WTF::Closure fix plus the scheduler test mock refactor. Created 4 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
« no previous file with comments | « content/child/web_url_loader_impl.cc ('k') | third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 003ba1fef026cec7a13498d13af9db8fb3d2662a..3ab28ef9531f4a7b2e780c1a2d98b80f403f8d9f 100644
--- a/third_party/WebKit/Source/core/dom/ScriptRunnerTest.cpp
+++ b/third_party/WebKit/Source/core/dom/ScriptRunnerTest.cpp
@@ -74,7 +74,7 @@ TEST_F(ScriptRunnerTest, QueueSingleScript_Async)
m_scriptRunner->notifyScriptReady(scriptLoader, ScriptRunner::ASYNC_EXECUTION);
EXPECT_CALL(*scriptLoader, execute());
- m_platform.mockWebScheduler()->runAllTasks();
+ m_platform.runUntilIdle();
}
TEST_F(ScriptRunnerTest, QueueSingleScript_InOrder)
@@ -87,7 +87,7 @@ TEST_F(ScriptRunnerTest, QueueSingleScript_InOrder)
m_scriptRunner->notifyScriptReady(scriptLoader, ScriptRunner::IN_ORDER_EXECUTION);
- m_platform.mockWebScheduler()->runAllTasks();
+ m_platform.runUntilIdle();
}
TEST_F(ScriptRunnerTest, QueueMultipleScripts_InOrder)
@@ -125,7 +125,7 @@ TEST_F(ScriptRunnerTest, QueueMultipleScripts_InOrder)
for (int i = 2; i >= 0; i--) {
isReady[i] = true;
m_scriptRunner->notifyScriptReady(scriptLoaders[i], ScriptRunner::IN_ORDER_EXECUTION);
- m_platform.mockWebScheduler()->runAllTasks();
+ m_platform.runUntilIdle();
}
// But ensure the scripts were run in the expected order.
@@ -180,7 +180,7 @@ TEST_F(ScriptRunnerTest, QueueMixedScripts)
m_order.append(5);
}));
- m_platform.mockWebScheduler()->runAllTasks();
+ m_platform.runUntilIdle();
// Async tasks are expected to run first.
EXPECT_THAT(m_order, ElementsAre(4, 5, 1, 2, 3));
@@ -215,13 +215,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.mockWebScheduler()->runSingleTask();
+ m_platform.runSingleTask();
EXPECT_THAT(m_order, ElementsAre(1));
- m_platform.mockWebScheduler()->runSingleTask();
+ m_platform.runSingleTask();
EXPECT_THAT(m_order, ElementsAre(1, 2));
- m_platform.mockWebScheduler()->runSingleTask();
+ m_platform.runSingleTask();
EXPECT_THAT(m_order, ElementsAre(1, 2, 3));
}
@@ -260,13 +260,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.mockWebScheduler()->runSingleTask();
+ m_platform.runSingleTask();
EXPECT_THAT(m_order, ElementsAre(1));
- m_platform.mockWebScheduler()->runSingleTask();
+ m_platform.runSingleTask();
EXPECT_THAT(m_order, ElementsAre(1, 2));
- m_platform.mockWebScheduler()->runSingleTask();
+ m_platform.runSingleTask();
EXPECT_THAT(m_order, ElementsAre(1, 2, 3));
}
@@ -298,7 +298,7 @@ TEST_F(ScriptRunnerTest, QueueReentrantScript_ManyAsyncScripts)
m_order.append(0);
}));
- m_platform.mockWebScheduler()->runAllTasks();
+ 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
@@ -348,10 +348,10 @@ TEST_F(ScriptRunnerTest, ResumeAndSuspend_InOrder)
.WillRepeatedly(Return(true));
m_scriptRunner->notifyScriptReady(scriptLoader3, ScriptRunner::IN_ORDER_EXECUTION);
- m_platform.mockWebScheduler()->runSingleTask();
+ m_platform.runSingleTask();
m_scriptRunner->suspend();
m_scriptRunner->resume();
- m_platform.mockWebScheduler()->runAllTasks();
+ m_platform.runUntilIdle();
// Make sure elements are correct and in right order.
EXPECT_THAT(m_order, ElementsAre(1, 2, 3));
@@ -384,10 +384,10 @@ TEST_F(ScriptRunnerTest, ResumeAndSuspend_Async)
m_order.append(3);
}));
- m_platform.mockWebScheduler()->runSingleTask();
+ m_platform.runSingleTask();
m_scriptRunner->suspend();
m_scriptRunner->resume();
- m_platform.mockWebScheduler()->runAllTasks();
+ m_platform.runUntilIdle();
// Make sure elements are correct.
EXPECT_THAT(m_order, WhenSorted(ElementsAre(1, 2, 3)));
@@ -412,11 +412,11 @@ TEST_F(ScriptRunnerTest, LateNotifications)
}));
m_scriptRunner->notifyScriptReady(scriptLoader1, ScriptRunner::IN_ORDER_EXECUTION);
- m_platform.mockWebScheduler()->runAllTasks();
+ 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::IN_ORDER_EXECUTION);
- m_platform.mockWebScheduler()->runAllTasks();
+ m_platform.runUntilIdle();
EXPECT_THAT(m_order, ElementsAre(1, 2));
}
@@ -443,7 +443,7 @@ TEST_F(ScriptRunnerTest, TasksWithDeadScriptRunner)
EXPECT_CALL(*scriptLoader1, execute()).Times(0);
EXPECT_CALL(*scriptLoader2, execute()).Times(0);
- m_platform.mockWebScheduler()->runAllTasks();
+ m_platform.runUntilIdle();
}
} // namespace blink
« no previous file with comments | « content/child/web_url_loader_impl.cc ('k') | third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698