| 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 "core/testing/DummyPageHolder.h" | 5 #include "core/testing/DummyPageHolder.h" |
| 6 #include "modules/webaudio/AudioBasicProcessorHandler.h" | 6 #include "modules/webaudio/AudioBasicProcessorHandler.h" |
| 7 #include "modules/webaudio/OfflineAudioContext.h" | 7 #include "modules/webaudio/OfflineAudioContext.h" |
| 8 #include "platform/audio/AudioProcessor.h" | 8 #include "platform/audio/AudioProcessor.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "wtf/PtrUtil.h" | 10 #include "wtf/PtrUtil.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 unsigned numberOfChannels() const override { return m_numberOfChannels; } | 23 unsigned numberOfChannels() const override { return m_numberOfChannels; } |
| 24 double tailTime() const override { return 0; } | 24 double tailTime() const override { return 0; } |
| 25 double latencyTime() const override { return 0; } | 25 double latencyTime() const override { return 0; } |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 class MockProcessorNode final : public AudioNode { | 28 class MockProcessorNode final : public AudioNode { |
| 29 public: | 29 public: |
| 30 MockProcessorNode(BaseAudioContext& context) : AudioNode(context) { | 30 MockProcessorNode(BaseAudioContext& context) : AudioNode(context) { |
| 31 setHandler(AudioBasicProcessorHandler::create( | 31 setHandler(AudioBasicProcessorHandler::create( |
| 32 AudioHandler::NodeTypeWaveShaper, *this, 48000, | 32 AudioHandler::NodeTypeWaveShaper, *this, 48000, |
| 33 makeUnique<MockAudioProcessor>())); | 33 WTF::makeUnique<MockAudioProcessor>())); |
| 34 handler().initialize(); | 34 handler().initialize(); |
| 35 } | 35 } |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 TEST(AudioBasicProcessorHandlerTest, ProcessorFinalization) { | 38 TEST(AudioBasicProcessorHandlerTest, ProcessorFinalization) { |
| 39 std::unique_ptr<DummyPageHolder> page = DummyPageHolder::create(); | 39 std::unique_ptr<DummyPageHolder> page = DummyPageHolder::create(); |
| 40 OfflineAudioContext* context = OfflineAudioContext::create( | 40 OfflineAudioContext* context = OfflineAudioContext::create( |
| 41 &page->document(), 2, 1, 48000, ASSERT_NO_EXCEPTION); | 41 &page->document(), 2, 1, 48000, ASSERT_NO_EXCEPTION); |
| 42 MockProcessorNode* node = new MockProcessorNode(*context); | 42 MockProcessorNode* node = new MockProcessorNode(*context); |
| 43 AudioBasicProcessorHandler& handler = | 43 AudioBasicProcessorHandler& handler = |
| 44 static_cast<AudioBasicProcessorHandler&>(node->handler()); | 44 static_cast<AudioBasicProcessorHandler&>(node->handler()); |
| 45 EXPECT_TRUE(handler.processor()); | 45 EXPECT_TRUE(handler.processor()); |
| 46 EXPECT_TRUE(handler.processor()->isInitialized()); | 46 EXPECT_TRUE(handler.processor()->isInitialized()); |
| 47 BaseAudioContext::AutoLocker locker(context); | 47 BaseAudioContext::AutoLocker locker(context); |
| 48 handler.dispose(); | 48 handler.dispose(); |
| 49 // The AudioProcessor should live after dispose() and should not be | 49 // The AudioProcessor should live after dispose() and should not be |
| 50 // finalized because an audio thread is using it. | 50 // finalized because an audio thread is using it. |
| 51 EXPECT_TRUE(handler.processor()); | 51 EXPECT_TRUE(handler.processor()); |
| 52 EXPECT_TRUE(handler.processor()->isInitialized()); | 52 EXPECT_TRUE(handler.processor()->isInitialized()); |
| 53 } | 53 } |
| 54 | 54 |
| 55 } // namespace blink | 55 } // namespace blink |
| OLD | NEW |