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