api/test: Create MockAudioSink

Bug: webrtc:9620
Change-Id: Iae339c07c91a42dcb3bb79f0c8003311810224a7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226324
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34489}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index c775a1a8..a5e7d91 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -834,6 +834,17 @@
     ]
   }
 
+  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 @@
       ":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 5ecdcc1..ff4601a 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 0000000..0c17dc4
--- /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<int64_t> absolute_capture_timestamp_ms),
+              (override));
+};
+
+}  // namespace webrtc
+
+#endif  // API_TEST_MOCK_AUDIO_SINK_H_