OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/webaudio/AudioWorkletGlobalScope.h" | 5 #include "modules/webaudio/AudioWorkletGlobalScope.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptSourceCode.h" | 7 #include "bindings/core/v8/ScriptSourceCode.h" |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
10 #include "bindings/core/v8/SourceLocation.h" | 10 #include "bindings/core/v8/SourceLocation.h" |
11 #include "bindings/core/v8/ToV8ForCore.h" | 11 #include "bindings/core/v8/ToV8ForCore.h" |
12 #include "bindings/core/v8/V8Binding.h" | 12 #include "bindings/core/v8/V8Binding.h" |
13 #include "bindings/core/v8/V8BindingForTesting.h" | 13 #include "bindings/core/v8/V8BindingForTesting.h" |
14 #include "bindings/core/v8/V8BindingMacros.h" | 14 #include "bindings/core/v8/V8BindingMacros.h" |
15 #include "bindings/core/v8/V8GCController.h" | 15 #include "bindings/core/v8/V8GCController.h" |
16 #include "bindings/core/v8/V8ObjectConstructor.h" | 16 #include "bindings/core/v8/V8ObjectConstructor.h" |
17 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 17 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
18 #include "core/dom/TaskRunnerHelper.h" | |
19 #include "core/workers/WorkerBackingThread.h" | 18 #include "core/workers/WorkerBackingThread.h" |
20 #include "core/workers/WorkerReportingProxy.h" | 19 #include "core/workers/WorkerReportingProxy.h" |
21 #include "core/workers/WorkerThreadStartupData.h" | 20 #include "core/workers/WorkerThreadStartupData.h" |
22 #include "modules/webaudio/AudioBuffer.h" | 21 #include "modules/webaudio/AudioBuffer.h" |
23 #include "modules/webaudio/AudioWorkletProcessor.h" | 22 #include "modules/webaudio/AudioWorkletProcessor.h" |
24 #include "modules/webaudio/AudioWorkletProcessorDefinition.h" | 23 #include "modules/webaudio/AudioWorkletProcessorDefinition.h" |
25 #include "modules/webaudio/AudioWorkletThread.h" | 24 #include "modules/webaudio/AudioWorkletThread.h" |
26 #include "platform/weborigin/SecurityOrigin.h" | 25 #include "platform/weborigin/SecurityOrigin.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
28 | 27 |
(...skipping 27 matching lines...) Expand all Loading... |
56 KURL(kParsedURLString, "http://fake.url/"), "fake user agent", "", | 55 KURL(kParsedURLString, "http://fake.url/"), "fake user agent", "", |
57 nullptr, kDontPauseWorkerGlobalScopeOnStart, nullptr, "", | 56 nullptr, kDontPauseWorkerGlobalScopeOnStart, nullptr, "", |
58 security_origin_.Get(), nullptr, kWebAddressSpaceLocal, nullptr, | 57 security_origin_.Get(), nullptr, kWebAddressSpaceLocal, nullptr, |
59 nullptr, WorkerV8Settings::Default()), | 58 nullptr, WorkerV8Settings::Default()), |
60 ParentFrameTaskRunners::Create(nullptr)); | 59 ParentFrameTaskRunners::Create(nullptr)); |
61 return thread; | 60 return thread; |
62 } | 61 } |
63 | 62 |
64 void RunBasicTest(WorkerThread* thread) { | 63 void RunBasicTest(WorkerThread* thread) { |
65 WaitableEvent waitable_event; | 64 WaitableEvent waitable_event; |
66 TaskRunnerHelper::Get(TaskType::kUnthrottled, thread) | 65 thread->PostTask( |
67 ->PostTask( | 66 BLINK_FROM_HERE, |
68 BLINK_FROM_HERE, | 67 CrossThreadBind( |
69 CrossThreadBind( | 68 &AudioWorkletGlobalScopeTest::RunBasicTestOnWorkletThread, |
70 &AudioWorkletGlobalScopeTest::RunBasicTestOnWorkletThread, | 69 CrossThreadUnretained(this), CrossThreadUnretained(thread), |
71 CrossThreadUnretained(this), CrossThreadUnretained(thread), | 70 CrossThreadUnretained(&waitable_event))); |
72 CrossThreadUnretained(&waitable_event))); | |
73 waitable_event.Wait(); | 71 waitable_event.Wait(); |
74 } | 72 } |
75 | 73 |
76 void RunSimpleProcessTest(WorkerThread* thread) { | 74 void RunSimpleProcessTest(WorkerThread* thread) { |
77 WaitableEvent waitable_event; | 75 WaitableEvent waitable_event; |
78 TaskRunnerHelper::Get(TaskType::kUnthrottled, thread) | 76 thread->PostTask( |
79 ->PostTask(BLINK_FROM_HERE, | 77 BLINK_FROM_HERE, |
80 CrossThreadBind(&AudioWorkletGlobalScopeTest:: | 78 CrossThreadBind( |
81 RunSimpleProcessTestOnWorkletThread, | 79 &AudioWorkletGlobalScopeTest::RunSimpleProcessTestOnWorkletThread, |
82 CrossThreadUnretained(this), | 80 CrossThreadUnretained(this), CrossThreadUnretained(thread), |
83 CrossThreadUnretained(thread), | 81 CrossThreadUnretained(&waitable_event))); |
84 CrossThreadUnretained(&waitable_event))); | |
85 waitable_event.Wait(); | 82 waitable_event.Wait(); |
86 } | 83 } |
87 | 84 |
88 void RunParsingTest(WorkerThread* thread) { | 85 void RunParsingTest(WorkerThread* thread) { |
89 WaitableEvent waitable_event; | 86 WaitableEvent waitable_event; |
90 TaskRunnerHelper::Get(TaskType::kUnthrottled, thread) | 87 thread->PostTask( |
91 ->PostTask( | 88 BLINK_FROM_HERE, |
92 BLINK_FROM_HERE, | 89 CrossThreadBind( |
93 CrossThreadBind( | 90 &AudioWorkletGlobalScopeTest::RunParsingTestOnWorkletThread, |
94 &AudioWorkletGlobalScopeTest::RunParsingTestOnWorkletThread, | 91 CrossThreadUnretained(this), CrossThreadUnretained(thread), |
95 CrossThreadUnretained(this), CrossThreadUnretained(thread), | 92 CrossThreadUnretained(&waitable_event))); |
96 CrossThreadUnretained(&waitable_event))); | |
97 waitable_event.Wait(); | 93 waitable_event.Wait(); |
98 } | 94 } |
99 | 95 |
100 private: | 96 private: |
101 // Test if AudioWorkletGlobalScope and V8 components (ScriptState, Isolate) | 97 // Test if AudioWorkletGlobalScope and V8 components (ScriptState, Isolate) |
102 // are properly instantiated. Runs a simple processor registration and check | 98 // are properly instantiated. Runs a simple processor registration and check |
103 // if the class definition is correctly registered, then instantiate an | 99 // if the class definition is correctly registered, then instantiate an |
104 // AudioWorkletProcessor instance from the definition. | 100 // AudioWorkletProcessor instance from the definition. |
105 void RunBasicTestOnWorkletThread(WorkerThread* thread, | 101 void RunBasicTestOnWorkletThread(WorkerThread* thread, |
106 WaitableEvent* wait_event) { | 102 WaitableEvent* wait_event) { |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 thread->TerminateAndWait(); | 257 thread->TerminateAndWait(); |
262 } | 258 } |
263 | 259 |
264 TEST_F(AudioWorkletGlobalScopeTest, BufferProcessing) { | 260 TEST_F(AudioWorkletGlobalScopeTest, BufferProcessing) { |
265 std::unique_ptr<AudioWorkletThread> thread = CreateAudioWorkletThread(); | 261 std::unique_ptr<AudioWorkletThread> thread = CreateAudioWorkletThread(); |
266 RunSimpleProcessTest(thread.get()); | 262 RunSimpleProcessTest(thread.get()); |
267 thread->TerminateAndWait(); | 263 thread->TerminateAndWait(); |
268 } | 264 } |
269 | 265 |
270 } // namespace blink | 266 } // namespace blink |
OLD | NEW |