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/SourceLocation.h" | 8 #include "bindings/core/v8/SourceLocation.h" |
9 #include "bindings/core/v8/V8GCController.h" | 9 #include "bindings/core/v8/V8GCController.h" |
10 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 10 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 private: | 89 private: |
90 std::unique_ptr<WebThread> m_thread; | 90 std::unique_ptr<WebThread> m_thread; |
91 TestingCompositorSupport m_compositorSupport; | 91 TestingCompositorSupport m_compositorSupport; |
92 }; | 92 }; |
93 | 93 |
94 } // namespace | 94 } // namespace |
95 | 95 |
96 class CompositorWorkerThreadTest : public ::testing::Test { | 96 class CompositorWorkerThreadTest : public ::testing::Test { |
97 public: | 97 public: |
98 void SetUp() override { | 98 void SetUp() override { |
| 99 m_testPlatform.reset(WTF::makeUnique<CompositorWorkerTestPlatform>()); |
99 CompositorWorkerThread::createSharedBackingThreadForTest(); | 100 CompositorWorkerThread::createSharedBackingThreadForTest(); |
100 m_objectProxy = TestCompositorWorkerObjectProxy::create(); | 101 m_objectProxy = TestCompositorWorkerObjectProxy::create(); |
101 m_securityOrigin = | 102 m_securityOrigin = |
102 SecurityOrigin::create(KURL(ParsedURLString, "http://fake.url/")); | 103 SecurityOrigin::create(KURL(ParsedURLString, "http://fake.url/")); |
103 } | 104 } |
104 | 105 |
105 void TearDown() override { | 106 void TearDown() override { |
106 CompositorWorkerThread::clearSharedBackingThread(); | 107 CompositorWorkerThread::clearSharedBackingThread(); |
107 } | 108 } |
108 | 109 |
(...skipping 27 matching lines...) Expand all Loading... |
136 WorkerOrWorkletScriptController* scriptController = | 137 WorkerOrWorkletScriptController* scriptController = |
137 worker->globalScope()->scriptController(); | 138 worker->globalScope()->scriptController(); |
138 bool evaluateResult = scriptController->evaluate( | 139 bool evaluateResult = scriptController->evaluate( |
139 ScriptSourceCode("var counter = 0; ++counter;")); | 140 ScriptSourceCode("var counter = 0; ++counter;")); |
140 DCHECK(evaluateResult); | 141 DCHECK(evaluateResult); |
141 waitEvent->signal(); | 142 waitEvent->signal(); |
142 } | 143 } |
143 | 144 |
144 RefPtr<SecurityOrigin> m_securityOrigin; | 145 RefPtr<SecurityOrigin> m_securityOrigin; |
145 std::unique_ptr<InProcessWorkerObjectProxy> m_objectProxy; | 146 std::unique_ptr<InProcessWorkerObjectProxy> m_objectProxy; |
146 CompositorWorkerTestPlatform m_testPlatform; | 147 ScopedTestingPlatformSupport<CompositorWorkerTestPlatform> m_testPlatform; |
147 }; | 148 }; |
148 | 149 |
149 TEST_F(CompositorWorkerThreadTest, Basic) { | 150 TEST_F(CompositorWorkerThreadTest, Basic) { |
150 std::unique_ptr<CompositorWorkerThread> compositorWorker = | 151 std::unique_ptr<CompositorWorkerThread> compositorWorker = |
151 createCompositorWorker(); | 152 createCompositorWorker(); |
152 checkWorkerCanExecuteScript(compositorWorker.get()); | 153 checkWorkerCanExecuteScript(compositorWorker.get()); |
153 compositorWorker->terminateAndWait(); | 154 compositorWorker->terminateAndWait(); |
154 } | 155 } |
155 | 156 |
156 // Tests that the same WebThread is used for new workers if the WebThread is | 157 // Tests that the same WebThread is used for new workers if the WebThread is |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 ASSERT_TRUE(secondIsolate); | 236 ASSERT_TRUE(secondIsolate); |
236 EXPECT_EQ(firstIsolate, secondIsolate); | 237 EXPECT_EQ(firstIsolate, secondIsolate); |
237 | 238 |
238 // Verify that the isolate can run some scripts correctly in the second | 239 // Verify that the isolate can run some scripts correctly in the second |
239 // worker. | 240 // worker. |
240 checkWorkerCanExecuteScript(secondWorker.get()); | 241 checkWorkerCanExecuteScript(secondWorker.get()); |
241 secondWorker->terminateAndWait(); | 242 secondWorker->terminateAndWait(); |
242 } | 243 } |
243 | 244 |
244 } // namespace blink | 245 } // namespace blink |
OLD | NEW |