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

Side by Side Diff: third_party/WebKit/Source/modules/compositorworker/AnimationWorkletThreadTest.cpp

Issue 2588403002: TestingPlatformSupport: register Platform instance correctly (Closed)
Patch Set: review #16 and merge master Created 3 years, 11 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 unified diff | Download patch
OLDNEW
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/AnimationWorkletThread.h" 5 #include "modules/compositorworker/AnimationWorkletThread.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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 private: 78 private:
79 std::unique_ptr<WebThread> m_thread; 79 std::unique_ptr<WebThread> m_thread;
80 TestingCompositorSupport m_compositorSupport; 80 TestingCompositorSupport m_compositorSupport;
81 }; 81 };
82 82
83 } // namespace 83 } // namespace
84 84
85 class AnimationWorkletThreadTest : public ::testing::Test { 85 class AnimationWorkletThreadTest : public ::testing::Test {
86 public: 86 public:
87 void SetUp() override { 87 void SetUp() override {
88 m_testPlatform.reset(WTF::makeUnique<AnimationWorkletTestPlatform>());
88 AnimationWorkletThread::createSharedBackingThreadForTest(); 89 AnimationWorkletThread::createSharedBackingThreadForTest();
89 m_reportingProxy = TestAnimationWorkletReportingProxy::create(); 90 m_reportingProxy = TestAnimationWorkletReportingProxy::create();
90 m_securityOrigin = 91 m_securityOrigin =
91 SecurityOrigin::create(KURL(ParsedURLString, "http://fake.url/")); 92 SecurityOrigin::create(KURL(ParsedURLString, "http://fake.url/"));
92 } 93 }
93 94
94 void TearDown() override { 95 void TearDown() override {
95 AnimationWorkletThread::clearSharedBackingThread(); 96 AnimationWorkletThread::clearSharedBackingThread();
96 } 97 }
97 98
(...skipping 23 matching lines...) Expand all
121 private: 122 private:
122 void executeScriptInWorklet(WorkerThread* thread, WaitableEvent* waitEvent) { 123 void executeScriptInWorklet(WorkerThread* thread, WaitableEvent* waitEvent) {
123 WorkerOrWorkletScriptController* scriptController = 124 WorkerOrWorkletScriptController* scriptController =
124 thread->globalScope()->scriptController(); 125 thread->globalScope()->scriptController();
125 scriptController->evaluate(ScriptSourceCode("var counter = 0; ++counter;")); 126 scriptController->evaluate(ScriptSourceCode("var counter = 0; ++counter;"));
126 waitEvent->signal(); 127 waitEvent->signal();
127 } 128 }
128 129
129 RefPtr<SecurityOrigin> m_securityOrigin; 130 RefPtr<SecurityOrigin> m_securityOrigin;
130 std::unique_ptr<WorkerReportingProxy> m_reportingProxy; 131 std::unique_ptr<WorkerReportingProxy> m_reportingProxy;
131 AnimationWorkletTestPlatform m_testPlatform; 132 ScopedTestingPlatformSupport<AnimationWorkletTestPlatform> m_testPlatform;
132 }; 133 };
133 134
134 TEST_F(AnimationWorkletThreadTest, Basic) { 135 TEST_F(AnimationWorkletThreadTest, Basic) {
135 std::unique_ptr<AnimationWorkletThread> worklet = 136 std::unique_ptr<AnimationWorkletThread> worklet =
136 createAnimationWorkletThread(); 137 createAnimationWorkletThread();
137 checkWorkletCanExecuteScript(worklet.get()); 138 checkWorkletCanExecuteScript(worklet.get());
138 worklet->terminateAndWait(); 139 worklet->terminateAndWait();
139 } 140 }
140 141
141 // Tests that the same WebThread is used for new worklets if the WebThread is 142 // Tests that the same WebThread is used for new worklets if the WebThread is
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 ASSERT_TRUE(secondIsolate); 221 ASSERT_TRUE(secondIsolate);
221 EXPECT_EQ(firstIsolate, secondIsolate); 222 EXPECT_EQ(firstIsolate, secondIsolate);
222 223
223 // Verify that the isolate can run some scripts correctly in the second 224 // Verify that the isolate can run some scripts correctly in the second
224 // worklet. 225 // worklet.
225 checkWorkletCanExecuteScript(secondWorklet.get()); 226 checkWorkletCanExecuteScript(secondWorklet.get());
226 secondWorklet->terminateAndWait(); 227 secondWorklet->terminateAndWait();
227 } 228 }
228 229
229 } // namespace blink 230 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698