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

Side by Side Diff: content/renderer/media/mock_audio_device_factory.h

Issue 1834323002: MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE + Workaround to ensure MediaStreamAudioProcessor is destroyed on the main thread. Created 4 years, 7 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_MEDIA_MOCK_AUDIO_DEVICE_FACTORY_H_
6 #define CONTENT_RENDERER_MEDIA_MOCK_AUDIO_DEVICE_FACTORY_H_
7
8 #include "content/renderer/media/audio_device_factory.h"
9
10 #include "media/base/audio_capturer_source.h"
11 #include "media/base/audio_renderer_sink.h"
12 #include "testing/gmock/include/gmock/gmock.h"
13
14 namespace content {
15
16 // MockAudioDeviceFactory creates an instance of this.
17 class MockCapturerSource : public media::AudioCapturerSource {
18 public:
19 MockCapturerSource();
20 MOCK_METHOD3(Initialize, void(const media::AudioParameters& params,
21 CaptureCallback* callback,
22 int session_id));
23 MOCK_METHOD0(Start, void());
24 MOCK_METHOD0(Stop, void());
25 MOCK_METHOD1(SetAutomaticGainControl, void(bool enable));
26 void SetVolume(double volume) override;
27
28 protected:
29 ~MockCapturerSource() override;
30 };
31
32 // Creates one MockCapturerSource instance for unit testing. This replaces the
33 // need for unit tests to open a real platform audio output. Instantiating this
34 // class sets the global content::AudioDeviceFactory implementation to |this|.
35 class MockAudioDeviceFactory : public AudioDeviceFactory {
36 public:
37 MockAudioDeviceFactory();
38 ~MockAudioDeviceFactory() override;
39
40 // Returns the MockCapturerSource created by this factory.
41 const scoped_refptr<MockCapturerSource>& mock_capturer_source() const {
42 return mock_capturer_source_;
43 }
44
45 // These methods are just mocked because tests currently don't need them to be
46 // implemented.
47 MOCK_METHOD4(CreateFinalAudioRendererSink,
48 scoped_refptr<media::AudioRendererSink>(
49 int render_frame_id,
50 int sesssion_id,
51 const std::string& device_id,
52 const url::Origin& security_origin));
53 MOCK_METHOD5(CreateAudioRendererSink,
54 scoped_refptr<media::AudioRendererSink>(
55 SourceType source_type,
56 int render_frame_id,
57 int sesssion_id,
58 const std::string& device_id,
59 const url::Origin& security_origin));
60 MOCK_METHOD5(CreateSwitchableAudioRendererSink,
61 scoped_refptr<media::SwitchableAudioRendererSink>(
62 SourceType source_type,
63 int render_frame_id,
64 int sesssion_id,
65 const std::string& device_id,
66 const url::Origin& security_origin));
67
68 // Returns mock_capturer_source_ once. If called a second time, the process
69 // will crash.
70 scoped_refptr<media::AudioCapturerSource> CreateAudioCapturerSource(
71 int render_frame_id) override;
72
73 private:
74 scoped_refptr<MockCapturerSource> mock_capturer_source_;
75 bool did_create_once_;
76
77 DISALLOW_COPY_AND_ASSIGN(MockAudioDeviceFactory);
78 };
79
80 } // namespace content
81
82 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_source.cc ('k') | content/renderer/media/mock_audio_device_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698