summaryrefslogtreecommitdiff
path: root/voice_engine
diff options
context:
space:
mode:
authorandrew@webrtc.org <andrew@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2013-03-25 21:20:38 +0000
committerandrew@webrtc.org <andrew@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2013-03-25 21:20:38 +0000
commit13f66d1472df67158e2c9d2fe1d6d6dacc69e936 (patch)
tree4365e1ff994edf36b63f4def51053e90651fec37 /voice_engine
parent8826e340dfb6dbbb1a4f63737c554707bdaddfa9 (diff)
downloadwebrtc-13f66d1472df67158e2c9d2fe1d6d6dacc69e936.tar.gz
Add some VoE and AudioProcessing mocks.
Includes a bit of shared helpers in fake_common.h. Review URL: https://webrtc-codereview.appspot.com/1221004 git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@3722 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'voice_engine')
-rw-r--r--voice_engine/include/mock/fake_voe_external_media.h77
-rw-r--r--voice_engine/include/mock/mock_voe_volume_control.h47
2 files changed, 124 insertions, 0 deletions
diff --git a/voice_engine/include/mock/fake_voe_external_media.h b/voice_engine/include/mock/fake_voe_external_media.h
new file mode 100644
index 00000000..8b608ec2
--- /dev/null
+++ b/voice_engine/include/mock/fake_voe_external_media.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_VOICE_ENGINE_INCLUDE_MOCK_FAKE_VOE_EXTERNAL_MEDIA_H_
+#define WEBRTC_VOICE_ENGINE_INCLUDE_MOCK_FAKE_VOE_EXTERNAL_MEDIA_H_
+
+#include <map>
+
+#include "webrtc/test/fake_common.h"
+#include "webrtc/system_wrappers/interface/scoped_ptr.h"
+#include "webrtc/voice_engine/include/voe_external_media.h"
+
+namespace webrtc {
+
+class FakeVoEExternalMedia : public VoEExternalMedia {
+ public:
+ FakeVoEExternalMedia() {}
+ virtual ~FakeVoEExternalMedia() {}
+
+ WEBRTC_STUB(Release, ());
+ WEBRTC_FUNC(RegisterExternalMediaProcessing,
+ (int channel, ProcessingTypes type, VoEMediaProcess& processObject)) {
+ callback_map_[type] = &processObject;
+ return 0;
+ }
+ WEBRTC_FUNC(DeRegisterExternalMediaProcessing,
+ (int channel, ProcessingTypes type)) {
+ callback_map_.erase(type);
+ return 0;
+ }
+ WEBRTC_STUB(SetExternalRecordingStatus, (bool enable));
+ WEBRTC_STUB(SetExternalPlayoutStatus, (bool enable));
+ WEBRTC_STUB(ExternalRecordingInsertData,
+ (const WebRtc_Word16 speechData10ms[], int lengthSamples,
+ int samplingFreqHz, int current_delay_ms));
+ WEBRTC_STUB(ExternalPlayoutGetData,
+ (WebRtc_Word16 speechData10ms[], int samplingFreqHz,
+ int current_delay_ms, int& lengthSamples));
+ WEBRTC_STUB(GetAudioFrame, (int channel, int desired_sample_rate_hz,
+ AudioFrame* frame));
+ WEBRTC_STUB(SetExternalMixing, (int channel, bool enable));
+
+ // Use this to trigger the Process() callback to a registered media processor.
+ // If |audio| is NULL, a zero array of the correct length will be forwarded.
+ void CallProcess(ProcessingTypes type, int16_t* audio,
+ int samples_per_channel, int sample_rate_hz,
+ int num_channels) {
+ const int length = samples_per_channel * num_channels;
+ scoped_array<int16_t> data;
+ if (!audio) {
+ data.reset(new int16_t[length]);
+ memset(data.get(), 0, length * sizeof(data[0]));
+ audio = data.get();
+ }
+
+ std::map<ProcessingTypes, VoEMediaProcess*>::const_iterator it =
+ callback_map_.find(type);
+ if (it != callback_map_.end()) {
+ it->second->Process(0, type, audio, samples_per_channel, sample_rate_hz,
+ num_channels == 2 ? true : false);
+ }
+ }
+
+ private:
+ std::map<ProcessingTypes, VoEMediaProcess*> callback_map_;
+};
+
+} // namespace webrtc
+
+#endif // WEBRTC_VOICE_ENGINE_INCLUDE_MOCK_FAKE_VOE_EXTERNAL_MEDIA_H_
diff --git a/voice_engine/include/mock/mock_voe_volume_control.h b/voice_engine/include/mock/mock_voe_volume_control.h
new file mode 100644
index 00000000..20b09696
--- /dev/null
+++ b/voice_engine/include/mock/mock_voe_volume_control.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef WEBRTC_VOICE_ENGINE_INCLUDE_MOCK_MOCK_VOE_VOLUME_CONTROL_H_
+#define WEBRTC_VOICE_ENGINE_INCLUDE_MOCK_MOCK_VOE_VOLUME_CONTROL_H_
+
+#include "testing/gmock/include/gmock/gmock.h"
+#include "webrtc/voice_engine/include/voe_volume_control.h"
+
+namespace webrtc {
+
+class VoiceEngine;
+
+class MockVoEVolumeControl : public VoEVolumeControl {
+ public:
+ MOCK_METHOD0(Release, int());
+ MOCK_METHOD1(SetSpeakerVolume, int(unsigned int volume));
+ MOCK_METHOD1(GetSpeakerVolume, int(unsigned int& volume));
+ MOCK_METHOD1(SetSystemOutputMute, int(bool enable));
+ MOCK_METHOD1(GetSystemOutputMute, int(bool &enabled));
+ MOCK_METHOD1(SetMicVolume, int(unsigned int volume));
+ MOCK_METHOD1(GetMicVolume, int(unsigned int& volume));
+ MOCK_METHOD2(SetInputMute, int(int channel, bool enable));
+ MOCK_METHOD2(GetInputMute, int(int channel, bool& enabled));
+ MOCK_METHOD1(SetSystemInputMute, int(bool enable));
+ MOCK_METHOD1(GetSystemInputMute, int(bool& enabled));
+ MOCK_METHOD1(GetSpeechInputLevel, int(unsigned int& level));
+ MOCK_METHOD2(GetSpeechOutputLevel, int(int channel, unsigned int& level));
+ MOCK_METHOD1(GetSpeechInputLevelFullRange, int(unsigned int& level));
+ MOCK_METHOD2(GetSpeechOutputLevelFullRange,
+ int(int channel, unsigned int& level));
+ MOCK_METHOD2(SetChannelOutputVolumeScaling, int(int channel, float scaling));
+ MOCK_METHOD2(GetChannelOutputVolumeScaling, int(int channel, float& scaling));
+ MOCK_METHOD3(SetOutputVolumePan, int(int channel, float left, float right));
+ MOCK_METHOD3(GetOutputVolumePan, int(int channel, float& left, float& right));
+};
+
+} // namespace webrtc
+
+#endif // WEBRTC_VOICE_ENGINE_INCLUDE_MOCK_MOCK_VOE_VOLUME_CONTROL_H_