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/webaudio/ScriptProcessorNode.h" |
5 #include "core/testing/DummyPageHolder.h" | 6 #include "core/testing/DummyPageHolder.h" |
6 #include "modules/webaudio/OfflineAudioContext.h" | 7 #include "modules/webaudio/OfflineAudioContext.h" |
7 #include "modules/webaudio/ScriptProcessorNode.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include <memory> | |
10 | 9 |
11 namespace blink { | 10 namespace blink { |
12 | 11 |
13 TEST(ScriptProcessorNodeTest, BufferLifetime) | 12 TEST(ScriptProcessorNodeTest, BufferLifetime) |
14 { | 13 { |
15 std::unique_ptr<DummyPageHolder> page = DummyPageHolder::create(); | 14 OwnPtr<DummyPageHolder> page = DummyPageHolder::create(); |
16 OfflineAudioContext* context = OfflineAudioContext::create(&page->document()
, 2, 1, 48000, ASSERT_NO_EXCEPTION); | 15 OfflineAudioContext* context = OfflineAudioContext::create(&page->document()
, 2, 1, 48000, ASSERT_NO_EXCEPTION); |
17 ScriptProcessorNode* node = context->createScriptProcessor(ASSERT_NO_EXCEPTI
ON); | 16 ScriptProcessorNode* node = context->createScriptProcessor(ASSERT_NO_EXCEPTI
ON); |
18 ScriptProcessorHandler& handler = static_cast<ScriptProcessorHandler&>(node-
>handler()); | 17 ScriptProcessorHandler& handler = static_cast<ScriptProcessorHandler&>(node-
>handler()); |
19 EXPECT_EQ(2u, handler.m_inputBuffers.size()); | 18 EXPECT_EQ(2u, handler.m_inputBuffers.size()); |
20 EXPECT_EQ(2u, handler.m_outputBuffers.size()); | 19 EXPECT_EQ(2u, handler.m_outputBuffers.size()); |
21 AbstractAudioContext::AutoLocker locker(context); | 20 AbstractAudioContext::AutoLocker locker(context); |
22 handler.dispose(); | 21 handler.dispose(); |
23 // Buffers should live after dispose() because an audio thread is using | 22 // Buffers should live after dispose() because an audio thread is using |
24 // them. | 23 // them. |
25 EXPECT_EQ(2u, handler.m_inputBuffers.size()); | 24 EXPECT_EQ(2u, handler.m_inputBuffers.size()); |
26 EXPECT_EQ(2u, handler.m_outputBuffers.size()); | 25 EXPECT_EQ(2u, handler.m_outputBuffers.size()); |
27 } | 26 } |
28 | 27 |
29 } // namespace blink | 28 } // namespace blink |
30 | 29 |
OLD | NEW |