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

Side by Side Diff: media/audio/mock_audio_manager.h

Issue 2761273003: Switching MediaStreamsManager from using AudioManager interface to AudioSystem one. (Closed)
Patch Set: passing device descriptions by value Created 3 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ 5 #ifndef MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_
6 #define MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ 6 #define MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_
7 7
8 #include "base/callback.h"
8 #include "base/macros.h" 9 #include "base/macros.h"
9 #include "base/sequenced_task_runner_helpers.h" 10 #include "base/sequenced_task_runner_helpers.h"
10 #include "media/audio/audio_manager.h" 11 #include "media/audio/audio_manager.h"
11 12
12 namespace media { 13 namespace media {
13 14
14 // This class is a simple mock around AudioManager, used exclusively for tests, 15 // This class is a simple mock around AudioManager, used exclusively for tests,
15 // which avoids to use the actual (system and platform dependent) AudioManager. 16 // which avoids to use the actual (system and platform dependent) AudioManager.
16 // Some bots does not have input devices, thus using the actual AudioManager 17 // Some bots does not have input devices, thus using the actual AudioManager
17 // would causing failures on classes which expect that. 18 // would causing failures on classes which expect that.
18 class MockAudioManager : public AudioManager { 19 class MockAudioManager : public AudioManager {
19 public: 20 public:
20 class Deleter { 21 class Deleter {
21 public: 22 public:
22 void operator()(const MockAudioManager* instance) const; 23 void operator()(const MockAudioManager* instance) const;
23 }; 24 };
24 25
25 using UniquePtr = std::unique_ptr<MockAudioManager, Deleter>; 26 using UniquePtr = std::unique_ptr<MockAudioManager, Deleter>;
27 using GetDeviceDescriptionsCallback =
28 base::RepeatingCallback<void(AudioDeviceDescriptions*)>;
26 29
27 explicit MockAudioManager( 30 explicit MockAudioManager(
28 scoped_refptr<base::SingleThreadTaskRunner> task_runner); 31 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
29 32
30 bool HasAudioOutputDevices() override; 33 bool HasAudioOutputDevices() override;
31 34
32 bool HasAudioInputDevices() override; 35 bool HasAudioInputDevices() override;
33 36
34 base::string16 GetAudioInputDeviceModel() override; 37 base::string16 GetAudioInputDeviceModel() override;
35 38
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 void DisableOutputDebugRecording() override; 79 void DisableOutputDebugRecording() override;
77 80
78 const char* GetName() override; 81 const char* GetName() override;
79 82
80 // Setters to emulate desired in-test behavior. 83 // Setters to emulate desired in-test behavior.
81 void SetInputStreamParameters(const AudioParameters& params); 84 void SetInputStreamParameters(const AudioParameters& params);
82 void SetOutputStreamParameters(const AudioParameters& params); 85 void SetOutputStreamParameters(const AudioParameters& params);
83 void SetDefaultOutputStreamParameters(const AudioParameters& params); 86 void SetDefaultOutputStreamParameters(const AudioParameters& params);
84 void SetHasInputDevices(bool has_input_devices); 87 void SetHasInputDevices(bool has_input_devices);
85 void SetHasOutputDevices(bool has_output_devices); 88 void SetHasOutputDevices(bool has_output_devices);
89 void SetInputDeviceDescriptionsCallback(
90 GetDeviceDescriptionsCallback callback);
91 void SetOutputDeviceDescriptionsCallback(
92 GetDeviceDescriptionsCallback callback);
86 93
87 protected: 94 protected:
88 ~MockAudioManager() override; 95 ~MockAudioManager() override;
89 96
90 private: 97 private:
91 friend class base::DeleteHelper<MockAudioManager>; 98 friend class base::DeleteHelper<MockAudioManager>;
92 99
93 AudioParameters input_params_; 100 AudioParameters input_params_;
94 AudioParameters output_params_; 101 AudioParameters output_params_;
95 AudioParameters default_output_params_; 102 AudioParameters default_output_params_;
96 bool has_input_devices_ = true; 103 bool has_input_devices_ = true;
97 bool has_output_devices_ = true; 104 bool has_output_devices_ = true;
105 GetDeviceDescriptionsCallback get_input_device_descriptions_cb_;
106 GetDeviceDescriptionsCallback get_output_device_descriptions_cb_;
98 107
99 DISALLOW_COPY_AND_ASSIGN(MockAudioManager); 108 DISALLOW_COPY_AND_ASSIGN(MockAudioManager);
100 }; 109 };
101 110
102 } // namespace media. 111 } // namespace media.
103 112
104 #endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_ 113 #endif // MEDIA_AUDIO_MOCK_AUDIO_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698