| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/workers/WorkerThread.h" | 6 #include "core/workers/WorkerThread.h" |
| 7 | 7 |
| 8 #include "core/inspector/ConsoleMessage.h" | 8 #include "core/inspector/ConsoleMessage.h" |
| 9 #include "core/workers/WorkerReportingProxy.h" | 9 #include "core/workers/WorkerReportingProxy.h" |
| 10 #include "core/workers/WorkerThreadStartupData.h" | 10 #include "core/workers/WorkerThreadStartupData.h" |
| 11 #include "platform/NotImplemented.h" | 11 #include "platform/NotImplemented.h" |
| 12 #include "public/platform/WebScheduler.h" | 12 #include "public/platform/WebScheduler.h" |
| 13 #include "public/platform/WebWaitableEvent.h" | 13 #include "public/platform/WebWaitableEvent.h" |
| 14 #include <gmock/gmock.h> | 14 #include <gmock/gmock.h> |
| 15 #include <gtest/gtest.h> | 15 #include <gtest/gtest.h> |
| 16 | 16 |
| 17 using testing::_; | 17 using testing::_; |
| 18 using testing::AtMost; | 18 using testing::AtMost; |
| 19 using testing::Invoke; | 19 using testing::Invoke; |
| 20 using testing::Return; | 20 using testing::Return; |
| 21 using testing::Mock; | 21 using testing::Mock; |
| 22 | 22 |
| 23 namespace blink { | 23 namespace blink { |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 |
| 26 class MockWorkerLoaderProxyProvider : public WorkerLoaderProxyProvider { | 27 class MockWorkerLoaderProxyProvider : public WorkerLoaderProxyProvider { |
| 27 public: | 28 public: |
| 28 MockWorkerLoaderProxyProvider() { } | 29 MockWorkerLoaderProxyProvider() { } |
| 29 ~MockWorkerLoaderProxyProvider() override { } | 30 ~MockWorkerLoaderProxyProvider() override { } |
| 30 | 31 |
| 31 void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) override | 32 void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) override |
| 32 { | 33 { |
| 33 notImplemented(); | 34 notImplemented(); |
| 34 } | 35 } |
| 35 | 36 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 expectWorkerLifetimeReportingCalls(); | 248 expectWorkerLifetimeReportingCalls(); |
| 248 start(); | 249 start(); |
| 249 waitForInit(); | 250 waitForInit(); |
| 250 m_workerThread->terminateAndWait(); | 251 m_workerThread->terminateAndWait(); |
| 251 } | 252 } |
| 252 | 253 |
| 253 TEST_F(WorkerThreadTest, StartAndStopImmediately) | 254 TEST_F(WorkerThreadTest, StartAndStopImmediately) |
| 254 { | 255 { |
| 255 EXPECT_CALL(*m_mockWorkerReportingProxy, workerGlobalScopeStarted(_)) | 256 EXPECT_CALL(*m_mockWorkerReportingProxy, workerGlobalScopeStarted(_)) |
| 256 .Times(AtMost(1)); | 257 .Times(AtMost(1)); |
| 257 EXPECT_CALL(*m_mockWorkerReportingProxy, didEvaluateWorkerScript(true)) | 258 EXPECT_CALL(*m_mockWorkerReportingProxy, didEvaluateWorkerScript(_)) |
| 258 .Times(AtMost(1)); | 259 .Times(AtMost(1)); |
| 259 EXPECT_CALL(*m_mockWorkerReportingProxy, workerThreadTerminated()) | 260 EXPECT_CALL(*m_mockWorkerReportingProxy, workerThreadTerminated()) |
| 260 .Times(AtMost(1)); | 261 .Times(AtMost(1)); |
| 261 EXPECT_CALL(*m_mockWorkerReportingProxy, willDestroyWorkerGlobalScope()) | 262 EXPECT_CALL(*m_mockWorkerReportingProxy, willDestroyWorkerGlobalScope()) |
| 262 .Times(AtMost(1)); | 263 .Times(AtMost(1)); |
| 263 start(); | 264 start(); |
| 264 m_workerThread->terminateAndWait(); | 265 m_workerThread->terminateAndWait(); |
| 265 } | 266 } |
| 266 | 267 |
| 267 TEST_F(WorkerThreadTest, StartAndStopOnScriptLoaded) | 268 TEST_F(WorkerThreadTest, StartAndStopOnScriptLoaded) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 332 |
| 332 completion->wait(); | 333 completion->wait(); |
| 333 | 334 |
| 334 // Make sure doIdleGc has not been called by this stage. | 335 // Make sure doIdleGc has not been called by this stage. |
| 335 Mock::VerifyAndClearExpectations(m_workerThread.get()); | 336 Mock::VerifyAndClearExpectations(m_workerThread.get()); |
| 336 | 337 |
| 337 m_workerThread->terminateAndWait(); | 338 m_workerThread->terminateAndWait(); |
| 338 } | 339 } |
| 339 | 340 |
| 340 } // namespace blink | 341 } // namespace blink |
| OLD | NEW |