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/ConvolverNode.h" | 5 #include "modules/webaudio/ConvolverNode.h" |
6 | |
7 #if ENABLE(WEB_AUDIO) | |
8 #include "core/testing/DummyPageHolder.h" | 6 #include "core/testing/DummyPageHolder.h" |
9 #include "modules/webaudio/OfflineAudioContext.h" | 7 #include "modules/webaudio/OfflineAudioContext.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
11 | 9 |
12 namespace blink { | 10 namespace blink { |
13 | 11 |
14 TEST(ConvolverNodeTest, ReverbLifetime) | 12 TEST(ConvolverNodeTest, ReverbLifetime) |
15 { | 13 { |
16 OwnPtr<DummyPageHolder> page = DummyPageHolder::create(); | 14 OwnPtr<DummyPageHolder> page = DummyPageHolder::create(); |
17 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); |
18 ConvolverNode* node = context->createConvolver(ASSERT_NO_EXCEPTION); | 16 ConvolverNode* node = context->createConvolver(ASSERT_NO_EXCEPTION); |
19 ConvolverHandler& handler = node->convolverHandler(); | 17 ConvolverHandler& handler = node->convolverHandler(); |
20 EXPECT_FALSE(handler.m_reverb); | 18 EXPECT_FALSE(handler.m_reverb); |
21 node->setBuffer(AudioBuffer::create(2, 1, 48000), ASSERT_NO_EXCEPTION); | 19 node->setBuffer(AudioBuffer::create(2, 1, 48000), ASSERT_NO_EXCEPTION); |
22 EXPECT_TRUE(handler.m_reverb); | 20 EXPECT_TRUE(handler.m_reverb); |
23 AbstractAudioContext::AutoLocker locker(context); | 21 AbstractAudioContext::AutoLocker locker(context); |
24 handler.dispose(); | 22 handler.dispose(); |
25 // m_reverb should live after dispose() because an audio thread is using it. | 23 // m_reverb should live after dispose() because an audio thread is using it. |
26 EXPECT_TRUE(handler.m_reverb); | 24 EXPECT_TRUE(handler.m_reverb); |
27 } | 25 } |
28 | 26 |
29 } // namespace blink | 27 } // namespace blink |
30 | 28 |
31 #endif // ENABLE(WEB_AUDIO) | |
OLD | NEW |