Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioBasicProcessorHandlerTest.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "modules/webaudio/AudioBasicProcessorHandler.h" 6 #include "modules/webaudio/AudioBasicProcessorHandler.h"
6 #include "core/testing/DummyPageHolder.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"
11 #include <memory>
10 12
11 namespace blink { 13 namespace blink {
12 14
13 class MockAudioProcessor final : public AudioProcessor { 15 class MockAudioProcessor final : public AudioProcessor {
14 public: 16 public:
15 MockAudioProcessor() : AudioProcessor(48000, 2) { } 17 MockAudioProcessor() : AudioProcessor(48000, 2) { }
16 void initialize() override { m_initialized = true; } 18 void initialize() override { m_initialized = true; }
17 void uninitialize() override { m_initialized = false; } 19 void uninitialize() override { m_initialized = false; }
18 void process(const AudioBus*, AudioBus*, size_t) override { } 20 void process(const AudioBus*, AudioBus*, size_t) override { }
19 void reset() override { } 21 void reset() override { }
20 void setNumberOfChannels(unsigned) override { } 22 void setNumberOfChannels(unsigned) override { }
21 unsigned numberOfChannels() const override { return m_numberOfChannels; } 23 unsigned numberOfChannels() const override { return m_numberOfChannels; }
22 double tailTime() const override { return 0; } 24 double tailTime() const override { return 0; }
23 double latencyTime() const override { return 0; } 25 double latencyTime() const override { return 0; }
24 }; 26 };
25 27
26 class MockProcessorNode final : public AudioNode { 28 class MockProcessorNode final : public AudioNode {
27 public: 29 public:
28 MockProcessorNode(AbstractAudioContext& context) 30 MockProcessorNode(AbstractAudioContext& context)
29 : AudioNode(context) 31 : AudioNode(context)
30 { 32 {
31 setHandler(AudioBasicProcessorHandler::create(AudioHandler::NodeTypeWave Shaper, *this, 48000, adoptPtr(new MockAudioProcessor()))); 33 setHandler(AudioBasicProcessorHandler::create(AudioHandler::NodeTypeWave Shaper, *this, 48000, wrapUnique(new MockAudioProcessor())));
32 handler().initialize(); 34 handler().initialize();
33 } 35 }
34 }; 36 };
35 37
36 TEST(AudioBasicProcessorHandlerTest, ProcessorFinalization) 38 TEST(AudioBasicProcessorHandlerTest, ProcessorFinalization)
37 { 39 {
38 OwnPtr<DummyPageHolder> page = DummyPageHolder::create(); 40 std::unique_ptr<DummyPageHolder> page = DummyPageHolder::create();
39 OfflineAudioContext* context = OfflineAudioContext::create(&page->document() , 2, 1, 48000, ASSERT_NO_EXCEPTION); 41 OfflineAudioContext* context = OfflineAudioContext::create(&page->document() , 2, 1, 48000, ASSERT_NO_EXCEPTION);
40 MockProcessorNode* node = new MockProcessorNode(*context); 42 MockProcessorNode* node = new MockProcessorNode(*context);
41 AudioBasicProcessorHandler& handler = static_cast<AudioBasicProcessorHandler &>(node->handler()); 43 AudioBasicProcessorHandler& handler = static_cast<AudioBasicProcessorHandler &>(node->handler());
42 EXPECT_TRUE(handler.processor()); 44 EXPECT_TRUE(handler.processor());
43 EXPECT_TRUE(handler.processor()->isInitialized()); 45 EXPECT_TRUE(handler.processor()->isInitialized());
44 AbstractAudioContext::AutoLocker locker(context); 46 AbstractAudioContext::AutoLocker locker(context);
45 handler.dispose(); 47 handler.dispose();
46 // The AudioProcessor should live after dispose() and should not be 48 // The AudioProcessor should live after dispose() and should not be
47 // finalized because an audio thread is using it. 49 // finalized because an audio thread is using it.
48 EXPECT_TRUE(handler.processor()); 50 EXPECT_TRUE(handler.processor());
49 EXPECT_TRUE(handler.processor()->isInitialized()); 51 EXPECT_TRUE(handler.processor()->isInitialized());
50 } 52 }
51 53
52 } // namespace blink 54 } // namespace blink
53 55
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698