From 2b4f5130dd4170056b0faaaa67bf9d7b160d415e Mon Sep 17 00:00:00 2001 From: Florent Castelli Date: Fri, 16 Jul 2021 17:13:54 +0200 Subject: [PATCH] api/test: Create MockAudioSink Bug: webrtc:9620 Change-Id: Iae339c07c91a42dcb3bb79f0c8003311810224a7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226324 Commit-Queue: Florent Castelli Reviewed-by: Mirko Bonadei Cr-Commit-Position: refs/heads/master@{#34489} --- api/BUILD.gn | 12 +++++++++ api/test/compile_all_headers.cc | 1 + api/test/mock_audio_sink.h | 44 +++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 api/test/mock_audio_sink.h diff --git a/api/BUILD.gn b/api/BUILD.gn index c775a1a871..a5e7d91a6d 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -834,6 +834,17 @@ if (rtc_include_tests) { ] } + rtc_source_set("mock_audio_sink") { + testonly = true + sources = [ "test/mock_audio_sink.h" ] + + deps = [ + "../api:media_stream_interface", + "../test:test_support", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] + } + rtc_source_set("mock_data_channel") { visibility = [ "*" ] testonly = true @@ -1118,6 +1129,7 @@ if (rtc_include_tests) { ":fake_frame_encryptor", ":mock_async_dns_resolver", ":mock_audio_mixer", + ":mock_audio_sink", ":mock_data_channel", ":mock_frame_decryptor", ":mock_frame_encryptor", diff --git a/api/test/compile_all_headers.cc b/api/test/compile_all_headers.cc index 5ecdcc1eb8..ff4601aa21 100644 --- a/api/test/compile_all_headers.cc +++ b/api/test/compile_all_headers.cc @@ -32,6 +32,7 @@ #include "api/test/fake_frame_encryptor.h" #include "api/test/mock_async_dns_resolver.h" #include "api/test/mock_audio_mixer.h" +#include "api/test/mock_audio_sink.h" #include "api/test/mock_data_channel.h" #include "api/test/mock_frame_decryptor.h" #include "api/test/mock_frame_encryptor.h" diff --git a/api/test/mock_audio_sink.h b/api/test/mock_audio_sink.h new file mode 100644 index 0000000000..0c17dc45ca --- /dev/null +++ b/api/test/mock_audio_sink.h @@ -0,0 +1,44 @@ +/* + * Copyright 2021 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_SINK_H_ +#define API_TEST_MOCK_AUDIO_SINK_H_ + +#include "absl/types/optional.h" +#include "api/media_stream_interface.h" +#include "test/gmock.h" + +namespace webrtc { + +class MockAudioSink final : public webrtc::AudioTrackSinkInterface { + public: + MOCK_METHOD(void, + OnData, + (const void* audio_data, + int bits_per_sample, + int sample_rate, + size_t number_of_channels, + size_t number_of_frames), + (override)); + + MOCK_METHOD(void, + OnData, + (const void* audio_data, + int bits_per_sample, + int sample_rate, + size_t number_of_channels, + size_t number_of_frames, + absl::optional absolute_capture_timestamp_ms), + (override)); +}; + +} // namespace webrtc + +#endif // API_TEST_MOCK_AUDIO_SINK_H_