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

Unified Diff: third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp

Issue 2280523002: Worker: Unify worker thread shutdown sequence (Closed)
Patch Set: tweak Created 4 years, 3 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 | « third_party/WebKit/Source/core/workers/WorkerThread.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp
diff --git a/third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp b/third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp
index 1c6a8e1b56f3a0112fda24c9b1bae99aa0049db5..ba00ef36f83aed37e8b1e83a4143cca7152913a6 100644
--- a/third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp
+++ b/third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp
@@ -85,7 +85,7 @@ protected:
void expectReportingCallsForWorkerPossiblyTerminatedBeforeInitialization()
{
- EXPECT_CALL(*m_reportingProxy, didCreateWorkerGlobalScope(_)).Times(AtMost(1));
+ EXPECT_CALL(*m_reportingProxy, didCreateWorkerGlobalScope(_)).Times(1);
EXPECT_CALL(*m_reportingProxy, didInitializeWorkerContext()).Times(AtMost(1));
EXPECT_CALL(*m_reportingProxy, willEvaluateWorkerScriptMock(_, _)).Times(AtMost(1));
EXPECT_CALL(*m_reportingProxy, didEvaluateWorkerScript(_)).Times(AtMost(1));
@@ -174,15 +174,11 @@ TEST_F(WorkerThreadTest, AsyncTerminate_ImmediatelyAfterStart)
expectReportingCallsForWorkerPossiblyTerminatedBeforeInitialization();
start();
- // There are two possible cases depending on timing:
- // (1) If the thread hasn't been initialized on the worker thread yet,
- // terminate() should not attempt to shut down the thread.
- // (2) If the thread has already been initialized on the worker thread,
- // terminate() should gracefully shut down the thread.
+ // The worker thread is not being blocked, so the worker thread should be
+ // gracefully shut down.
m_workerThread->terminate();
m_workerThread->waitForShutdownForTesting();
- ExitCode exitCode = getExitCode();
- EXPECT_EQ(ExitCode::GracefullyTerminated, exitCode);
+ EXPECT_EQ(ExitCode::GracefullyTerminated, getExitCode());
}
TEST_F(WorkerThreadTest, SyncTerminate_ImmediatelyAfterStart)
@@ -192,10 +188,14 @@ TEST_F(WorkerThreadTest, SyncTerminate_ImmediatelyAfterStart)
// There are two possible cases depending on timing:
// (1) If the thread hasn't been initialized on the worker thread yet,
- // terminateAndWait() should not attempt to shut down the thread.
+ // terminateAndWait() should wait for initialization and shut down the
+ // thread immediately after that.
// (2) If the thread has already been initialized on the worker thread,
// terminateAndWait() should synchronously forcibly terminates the worker
// execution.
+ // TODO(nhiroki): Make this test deterministically pass through the case 1),
+ // that is, terminateAndWait() is called before initializeOnWorkerThread().
+ // Then, rename this test to SyncTerminate_BeforeInitialization.
m_workerThread->terminateAndWait();
ExitCode exitCode = getExitCode();
EXPECT_TRUE(ExitCode::GracefullyTerminated == exitCode || ExitCode::SyncForciblyTerminated == exitCode);
« no previous file with comments | « third_party/WebKit/Source/core/workers/WorkerThread.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698