| 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 "modules/compositorworker/CompositorWorkerThread.h" | 5 #include "modules/compositorworker/CompositorWorkerThread.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptSourceCode.h" | 7 #include "bindings/core/v8/ScriptSourceCode.h" |
| 8 #include "bindings/core/v8/V8GCController.h" | 8 #include "bindings/core/v8/V8GCController.h" |
| 9 #include "core/inspector/ConsoleMessage.h" | 9 #include "core/inspector/ConsoleMessage.h" |
| 10 #include "core/testing/DummyPageHolder.h" | 10 #include "core/testing/DummyPageHolder.h" |
| 11 #include "core/workers/WorkerLoaderProxy.h" | 11 #include "core/workers/WorkerLoaderProxy.h" |
| 12 #include "core/workers/WorkerObjectProxy.h" | 12 #include "core/workers/WorkerObjectProxy.h" |
| 13 #include "core/workers/WorkerThreadStartupData.h" | 13 #include "core/workers/WorkerThreadStartupData.h" |
| 14 #include "core/dom/CompositorProxyClient.h" |
| 14 #include "platform/NotImplemented.h" | 15 #include "platform/NotImplemented.h" |
| 15 #include "platform/ThreadSafeFunctional.h" | 16 #include "platform/ThreadSafeFunctional.h" |
| 16 #include "platform/heap/Handle.h" | 17 #include "platform/heap/Handle.h" |
| 17 #include "platform/testing/TestingPlatformSupport.h" | 18 #include "platform/testing/TestingPlatformSupport.h" |
| 18 #include "platform/testing/UnitTestHelpers.h" | 19 #include "platform/testing/UnitTestHelpers.h" |
| 19 #include "public/platform/Platform.h" | 20 #include "public/platform/Platform.h" |
| 20 #include "public/platform/WebWaitableEvent.h" | 21 #include "public/platform/WebWaitableEvent.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 23 |
| 23 namespace blink { | 24 namespace blink { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 return m_oldPlatform->createWaitableEvent(policy, state); | 114 return m_oldPlatform->createWaitableEvent(policy, state); |
| 114 } | 115 } |
| 115 | 116 |
| 116 WebCompositorSupport* compositorSupport() override { return &m_compositorSup
port; } | 117 WebCompositorSupport* compositorSupport() override { return &m_compositorSup
port; } |
| 117 | 118 |
| 118 private: | 119 private: |
| 119 OwnPtr<WebThread> m_thread; | 120 OwnPtr<WebThread> m_thread; |
| 120 TestingCompositorSupport m_compositorSupport; | 121 TestingCompositorSupport m_compositorSupport; |
| 121 }; | 122 }; |
| 122 | 123 |
| 124 class TestCompositorProxyClient : public CompositorProxyClient { |
| 125 public: |
| 126 TestCompositorProxyClient() {} |
| 127 virtual ~TestCompositorProxyClient() {} |
| 128 |
| 129 void registerCompositorProxy(CompositorProxy*) override {} |
| 130 void unregisterCompositorProxy(CompositorProxy*) override {} |
| 131 void requestSync(CompositorProxy*) override {} |
| 132 |
| 133 void setGlobalScope(WorkerGlobalScope*) override {} |
| 134 void requestMutation() override {} |
| 135 }; |
| 136 |
| 123 } // namespace | 137 } // namespace |
| 124 | 138 |
| 125 class CompositorWorkerThreadTest : public ::testing::Test { | 139 class CompositorWorkerThreadTest : public ::testing::Test { |
| 126 public: | 140 public: |
| 127 void SetUp() override | 141 void SetUp() override |
| 128 { | 142 { |
| 129 m_page = DummyPageHolder::create(); | 143 m_page = DummyPageHolder::create(); |
| 130 m_objectProxy = TestCompositorWorkerObjectProxy::create(&m_page->documen
t()); | 144 m_objectProxy = TestCompositorWorkerObjectProxy::create(&m_page->documen
t()); |
| 131 m_securityOrigin = SecurityOrigin::create(KURL(ParsedURLString, "http://
fake.url/")); | 145 m_securityOrigin = SecurityOrigin::create(KURL(ParsedURLString, "http://
fake.url/")); |
| 132 } | 146 } |
| 133 | 147 |
| 134 void TearDown() override | 148 void TearDown() override |
| 135 { | 149 { |
| 136 ASSERT(!hasThread()); | 150 ASSERT(!hasThread()); |
| 137 ASSERT(!hasIsolate()); | 151 ASSERT(!hasIsolate()); |
| 138 m_page.clear(); | 152 m_page.clear(); |
| 139 } | 153 } |
| 140 | 154 |
| 141 PassRefPtr<TestCompositorWorkerThread> createCompositorWorker(WebWaitableEve
nt* startEvent) | 155 PassRefPtr<TestCompositorWorkerThread> createCompositorWorker(WebWaitableEve
nt* startEvent) |
| 142 { | 156 { |
| 143 TestCompositorWorkerThread* workerThread = new TestCompositorWorkerThrea
d(nullptr, *m_objectProxy, 0, startEvent); | 157 TestCompositorWorkerThread* workerThread = new TestCompositorWorkerThrea
d(nullptr, *m_objectProxy, 0, startEvent); |
| 144 OwnPtrWillBeRawPtr<WorkerClients> clients = nullptr; | 158 OwnPtrWillBeRawPtr<WorkerClients> clients = WorkerClients::create(); |
| 159 provideCompositorProxyClientTo(clients.get(), adoptPtrWillBeNoop(new Tes
tCompositorProxyClient())); |
| 145 workerThread->start(WorkerThreadStartupData::create( | 160 workerThread->start(WorkerThreadStartupData::create( |
| 146 KURL(ParsedURLString, "http://fake.url/"), | 161 KURL(ParsedURLString, "http://fake.url/"), |
| 147 "fake user agent", | 162 "fake user agent", |
| 148 "//fake source code", | 163 "//fake source code", |
| 149 nullptr, | 164 nullptr, |
| 150 DontPauseWorkerGlobalScopeOnStart, | 165 DontPauseWorkerGlobalScopeOnStart, |
| 151 adoptPtr(new Vector<CSPHeaderAndType>()), | 166 adoptPtr(new Vector<CSPHeaderAndType>()), |
| 152 m_securityOrigin.get(), | 167 m_securityOrigin.get(), |
| 153 clients.release(), | 168 clients.release(), |
| 154 V8CacheOptionsDefault)); | 169 V8CacheOptionsDefault)); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 v8::Isolate* secondIsolate = secondWorker->isolate(); | 313 v8::Isolate* secondIsolate = secondWorker->isolate(); |
| 299 ASSERT(secondIsolate); | 314 ASSERT(secondIsolate); |
| 300 EXPECT_EQ(firstIsolate, secondIsolate); | 315 EXPECT_EQ(firstIsolate, secondIsolate); |
| 301 | 316 |
| 302 // Verify that the isolate can run some scripts correctly in the second work
er. | 317 // Verify that the isolate can run some scripts correctly in the second work
er. |
| 303 checkWorkerCanExecuteScript(secondWorker.get()); | 318 checkWorkerCanExecuteScript(secondWorker.get()); |
| 304 secondWorker->terminateAndWait(); | 319 secondWorker->terminateAndWait(); |
| 305 } | 320 } |
| 306 | 321 |
| 307 } // namespace blink | 322 } // namespace blink |
| OLD | NEW |