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