summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/webrtc/api/test
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/libwebrtc/webrtc/api/test')
-rw-r--r--third_party/libwebrtc/webrtc/api/test/fakeconstraints.h116
-rw-r--r--third_party/libwebrtc/webrtc/api/test/mock_audio_mixer.h32
-rw-r--r--third_party/libwebrtc/webrtc/api/test/mock_rtpreceiver.h36
-rw-r--r--third_party/libwebrtc/webrtc/api/test/mock_rtpsender.h37
-rw-r--r--third_party/libwebrtc/webrtc/api/test/mock_video_decoder_factory.h42
-rw-r--r--third_party/libwebrtc/webrtc/api/test/mock_video_encoder_factory.h45
6 files changed, 308 insertions, 0 deletions
diff --git a/third_party/libwebrtc/webrtc/api/test/fakeconstraints.h b/third_party/libwebrtc/webrtc/api/test/fakeconstraints.h
new file mode 100644
index 0000000000..2010400aa4
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/api/test/fakeconstraints.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2012 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 API_TEST_FAKECONSTRAINTS_H_
+#define API_TEST_FAKECONSTRAINTS_H_
+
+#include <string>
+#include <vector>
+
+#include "api/mediaconstraintsinterface.h"
+#include "rtc_base/stringencode.h"
+
+namespace webrtc {
+
+class FakeConstraints : public webrtc::MediaConstraintsInterface {
+ public:
+ FakeConstraints() { }
+ virtual ~FakeConstraints() { }
+
+ virtual const Constraints& GetMandatory() const {
+ return mandatory_;
+ }
+
+ virtual const Constraints& GetOptional() const {
+ return optional_;
+ }
+
+ template <class T>
+ void AddMandatory(const std::string& key, const T& value) {
+ mandatory_.push_back(Constraint(key, rtc::ToString<T>(value)));
+ }
+
+ template <class T>
+ void SetMandatory(const std::string& key, const T& value) {
+ std::string value_str;
+ if (mandatory_.FindFirst(key, &value_str)) {
+ for (Constraints::iterator iter = mandatory_.begin();
+ iter != mandatory_.end(); ++iter) {
+ if (iter->key == key) {
+ mandatory_.erase(iter);
+ break;
+ }
+ }
+ }
+ mandatory_.push_back(Constraint(key, rtc::ToString<T>(value)));
+ }
+
+ template <class T>
+ void AddOptional(const std::string& key, const T& value) {
+ optional_.push_back(Constraint(key, rtc::ToString<T>(value)));
+ }
+
+ void SetMandatoryMinAspectRatio(double ratio) {
+ SetMandatory(MediaConstraintsInterface::kMinAspectRatio, ratio);
+ }
+
+ void SetMandatoryMinWidth(int width) {
+ SetMandatory(MediaConstraintsInterface::kMinWidth, width);
+ }
+
+ void SetMandatoryMinHeight(int height) {
+ SetMandatory(MediaConstraintsInterface::kMinHeight, height);
+ }
+
+ void SetOptionalMaxWidth(int width) {
+ AddOptional(MediaConstraintsInterface::kMaxWidth, width);
+ }
+
+ void SetMandatoryMaxFrameRate(int frame_rate) {
+ SetMandatory(MediaConstraintsInterface::kMaxFrameRate, frame_rate);
+ }
+
+ void SetMandatoryReceiveAudio(bool enable) {
+ SetMandatory(MediaConstraintsInterface::kOfferToReceiveAudio, enable);
+ }
+
+ void SetMandatoryReceiveVideo(bool enable) {
+ SetMandatory(MediaConstraintsInterface::kOfferToReceiveVideo, enable);
+ }
+
+ void SetMandatoryUseRtpMux(bool enable) {
+ SetMandatory(MediaConstraintsInterface::kUseRtpMux, enable);
+ }
+
+ void SetMandatoryIceRestart(bool enable) {
+ SetMandatory(MediaConstraintsInterface::kIceRestart, enable);
+ }
+
+ void SetAllowRtpDataChannels() {
+ SetMandatory(MediaConstraintsInterface::kEnableRtpDataChannels, true);
+ SetMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, false);
+ }
+
+ void SetOptionalVAD(bool enable) {
+ AddOptional(MediaConstraintsInterface::kVoiceActivityDetection, enable);
+ }
+
+ void SetAllowDtlsSctpDataChannels() {
+ SetMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, true);
+ }
+
+ private:
+ Constraints mandatory_;
+ Constraints optional_;
+};
+
+} // namespace webrtc
+
+#endif // API_TEST_FAKECONSTRAINTS_H_
diff --git a/third_party/libwebrtc/webrtc/api/test/mock_audio_mixer.h b/third_party/libwebrtc/webrtc/api/test/mock_audio_mixer.h
new file mode 100644
index 0000000000..7a6c7420e8
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/api/test/mock_audio_mixer.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2016 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 API_TEST_MOCK_AUDIO_MIXER_H_
+#define API_TEST_MOCK_AUDIO_MIXER_H_
+
+#include "api/audio/audio_mixer.h"
+
+#include "test/gmock.h"
+
+namespace webrtc {
+namespace test {
+
+class MockAudioMixer : public AudioMixer {
+ public:
+ MOCK_METHOD1(AddSource, bool(Source* audio_source));
+ MOCK_METHOD1(RemoveSource, void(Source* audio_source));
+ MOCK_METHOD2(Mix,
+ void(size_t number_of_channels,
+ AudioFrame* audio_frame_for_mixing));
+};
+} // namespace test
+} // namespace webrtc
+
+#endif // API_TEST_MOCK_AUDIO_MIXER_H_
diff --git a/third_party/libwebrtc/webrtc/api/test/mock_rtpreceiver.h b/third_party/libwebrtc/webrtc/api/test/mock_rtpreceiver.h
new file mode 100644
index 0000000000..7097adc02d
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/api/test/mock_rtpreceiver.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2016 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 API_TEST_MOCK_RTPRECEIVER_H_
+#define API_TEST_MOCK_RTPRECEIVER_H_
+
+#include <string>
+#include <vector>
+
+#include "api/rtpreceiverinterface.h"
+#include "test/gmock.h"
+
+namespace webrtc {
+
+class MockRtpReceiver : public rtc::RefCountedObject<RtpReceiverInterface> {
+ public:
+ MOCK_METHOD1(SetTrack, void(MediaStreamTrackInterface*));
+ MOCK_CONST_METHOD0(track, rtc::scoped_refptr<MediaStreamTrackInterface>());
+ MOCK_CONST_METHOD0(media_type, cricket::MediaType());
+ MOCK_CONST_METHOD0(id, std::string());
+ MOCK_CONST_METHOD0(GetParameters, RtpParameters());
+ MOCK_METHOD1(SetParameters, bool(const RtpParameters&));
+ MOCK_METHOD1(SetObserver, void(RtpReceiverObserverInterface*));
+ MOCK_CONST_METHOD0(GetSources, std::vector<RtpSource>());
+};
+
+} // namespace webrtc
+
+#endif // API_TEST_MOCK_RTPRECEIVER_H_
diff --git a/third_party/libwebrtc/webrtc/api/test/mock_rtpsender.h b/third_party/libwebrtc/webrtc/api/test/mock_rtpsender.h
new file mode 100644
index 0000000000..a89fa9264a
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/api/test/mock_rtpsender.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2016 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 API_TEST_MOCK_RTPSENDER_H_
+#define API_TEST_MOCK_RTPSENDER_H_
+
+#include <string>
+#include <vector>
+
+#include "api/rtpsenderinterface.h"
+#include "test/gmock.h"
+
+namespace webrtc {
+
+class MockRtpSender : public rtc::RefCountedObject<RtpSenderInterface> {
+ public:
+ MOCK_METHOD1(SetTrack, bool(MediaStreamTrackInterface*));
+ MOCK_CONST_METHOD0(track, rtc::scoped_refptr<MediaStreamTrackInterface>());
+ MOCK_CONST_METHOD0(ssrc, uint32_t());
+ MOCK_CONST_METHOD0(media_type, cricket::MediaType());
+ MOCK_CONST_METHOD0(id, std::string());
+ MOCK_CONST_METHOD0(stream_ids, std::vector<std::string>());
+ MOCK_CONST_METHOD0(GetParameters, RtpParameters());
+ MOCK_METHOD1(SetParameters, bool(const RtpParameters&));
+ MOCK_CONST_METHOD0(GetDtmfSender, rtc::scoped_refptr<DtmfSenderInterface>());
+};
+
+} // namespace webrtc
+
+#endif // API_TEST_MOCK_RTPSENDER_H_
diff --git a/third_party/libwebrtc/webrtc/api/test/mock_video_decoder_factory.h b/third_party/libwebrtc/webrtc/api/test/mock_video_decoder_factory.h
new file mode 100644
index 0000000000..915e3911f0
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/api/test/mock_video_decoder_factory.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017 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 API_TEST_MOCK_VIDEO_DECODER_FACTORY_H_
+#define API_TEST_MOCK_VIDEO_DECODER_FACTORY_H_
+
+#include <memory>
+#include <vector>
+
+#include "api/video_codecs/sdp_video_format.h"
+#include "api/video_codecs/video_decoder_factory.h"
+#include "test/gmock.h"
+
+namespace webrtc {
+
+class MockVideoDecoderFactory : public webrtc::VideoDecoderFactory {
+ public:
+ MOCK_CONST_METHOD0(GetSupportedFormats,
+ std::vector<webrtc::SdpVideoFormat>());
+
+ // We need to proxy to a return type that is copyable.
+ std::unique_ptr<webrtc::VideoDecoder> CreateVideoDecoder(
+ const webrtc::SdpVideoFormat& format) {
+ return std::unique_ptr<webrtc::VideoDecoder>(
+ CreateVideoDecoderProxy(format));
+ }
+ MOCK_METHOD1(CreateVideoDecoderProxy,
+ webrtc::VideoDecoder*(const webrtc::SdpVideoFormat&));
+
+ MOCK_METHOD0(Die, void());
+ ~MockVideoDecoderFactory() { Die(); }
+};
+} // namespace webrtc
+
+#endif // API_TEST_MOCK_VIDEO_DECODER_FACTORY_H_
diff --git a/third_party/libwebrtc/webrtc/api/test/mock_video_encoder_factory.h b/third_party/libwebrtc/webrtc/api/test/mock_video_encoder_factory.h
new file mode 100644
index 0000000000..a694b636e0
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/api/test/mock_video_encoder_factory.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017 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 API_TEST_MOCK_VIDEO_ENCODER_FACTORY_H_
+#define API_TEST_MOCK_VIDEO_ENCODER_FACTORY_H_
+
+#include <memory>
+#include <vector>
+
+#include "api/video_codecs/sdp_video_format.h"
+#include "api/video_codecs/video_encoder_factory.h"
+#include "test/gmock.h"
+
+namespace webrtc {
+
+class MockVideoEncoderFactory : public webrtc::VideoEncoderFactory {
+ public:
+ MOCK_CONST_METHOD0(GetSupportedFormats,
+ std::vector<webrtc::SdpVideoFormat>());
+ MOCK_CONST_METHOD1(QueryVideoEncoder,
+ CodecInfo(const webrtc::SdpVideoFormat&));
+
+ // We need to proxy to a return type that is copyable.
+ std::unique_ptr<webrtc::VideoEncoder> CreateVideoEncoder(
+ const webrtc::SdpVideoFormat& format) {
+ return std::unique_ptr<webrtc::VideoEncoder>(
+ CreateVideoEncoderProxy(format));
+ }
+ MOCK_METHOD1(CreateVideoEncoderProxy,
+ webrtc::VideoEncoder*(const webrtc::SdpVideoFormat&));
+
+ MOCK_METHOD0(Die, void());
+ ~MockVideoEncoderFactory() { Die(); }
+};
+
+} // namespace webrtc
+
+#endif // API_TEST_MOCK_VIDEO_ENCODER_FACTORY_H_