Add publicly visible mock for DataChannelInterface
Bug: webrtc:11642
Change-Id: I20fc57122fc29602028f2cc2fb27a0122117f855
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191840
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32562}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index cc5975f..fd27681 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -792,6 +792,17 @@
]
}
+ rtc_source_set("mock_data_channel") {
+ visibility = [ "*" ]
+ testonly = true
+ sources = [ "test/mock_data_channel.h" ]
+
+ deps = [
+ ":libjingle_peerconnection_api",
+ "../test:test_support",
+ ]
+ }
+
rtc_source_set("mock_fec_controller_override") {
testonly = true
sources = [ "test/mock_fec_controller_override.h" ]
@@ -1037,6 +1048,7 @@
":fake_frame_decryptor",
":fake_frame_encryptor",
":mock_audio_mixer",
+ ":mock_data_channel",
":mock_frame_decryptor",
":mock_frame_encryptor",
":mock_peer_connection_factory_interface",
diff --git a/api/test/compile_all_headers.cc b/api/test/compile_all_headers.cc
index 4cece5b..0f50f58 100644
--- a/api/test/compile_all_headers.cc
+++ b/api/test/compile_all_headers.cc
@@ -31,6 +31,7 @@
#include "api/test/fake_frame_decryptor.h"
#include "api/test/fake_frame_encryptor.h"
#include "api/test/mock_audio_mixer.h"
+#include "api/test/mock_data_channel.h"
#include "api/test/mock_frame_decryptor.h"
#include "api/test/mock_frame_encryptor.h"
#include "api/test/mock_peer_connection_factory_interface.h"
diff --git a/api/test/mock_data_channel.h b/api/test/mock_data_channel.h
new file mode 100644
index 0000000..9346ffd
--- /dev/null
+++ b/api/test/mock_data_channel.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2020 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_DATA_CHANNEL_H_
+#define API_TEST_MOCK_DATA_CHANNEL_H_
+
+#include <string>
+
+#include "api/data_channel_interface.h"
+#include "test/gmock.h"
+
+namespace webrtc {
+
+class MockDataChannelInterface final
+ : public rtc::RefCountedObject<webrtc::DataChannelInterface> {
+ public:
+ static rtc::scoped_refptr<MockDataChannelInterface> Create() {
+ return new MockDataChannelInterface();
+ }
+
+ MOCK_METHOD(void,
+ RegisterObserver,
+ (DataChannelObserver * observer),
+ (override));
+ MOCK_METHOD(void, UnregisterObserver, (), (override));
+ MOCK_METHOD(std::string, label, (), (const, override));
+ MOCK_METHOD(bool, reliable, (), (const, override));
+ MOCK_METHOD(bool, ordered, (), (const, override));
+ MOCK_METHOD(uint16_t, maxRetransmitTime, (), (const, override));
+ MOCK_METHOD(uint16_t, maxRetransmits, (), (const, override));
+ MOCK_METHOD(absl::optional<int>, maxRetransmitsOpt, (), (const, override));
+ MOCK_METHOD(absl::optional<int>, maxPacketLifeTime, (), (const, override));
+ MOCK_METHOD(std::string, protocol, (), (const, override));
+ MOCK_METHOD(bool, negotiated, (), (const, override));
+ MOCK_METHOD(int, id, (), (const, override));
+ MOCK_METHOD(Priority, priority, (), (const, override));
+ MOCK_METHOD(DataState, state, (), (const, override));
+ MOCK_METHOD(RTCError, error, (), (const, override));
+ MOCK_METHOD(uint32_t, messages_sent, (), (const, override));
+ MOCK_METHOD(uint64_t, bytes_sent, (), (const, override));
+ MOCK_METHOD(uint32_t, messages_received, (), (const, override));
+ MOCK_METHOD(uint64_t, bytes_received, (), (const, override));
+ MOCK_METHOD(uint64_t, buffered_amount, (), (const, override));
+ MOCK_METHOD(void, Close, (), (override));
+ MOCK_METHOD(bool, Send, (const DataBuffer& buffer), (override));
+
+ protected:
+ MockDataChannelInterface() = default;
+};
+
+} // namespace webrtc
+
+#endif // API_TEST_MOCK_DATA_CHANNEL_H_
diff --git a/api/test/mock_peer_connection_factory_interface.h b/api/test/mock_peer_connection_factory_interface.h
index 19c3f40..7319ceb 100644
--- a/api/test/mock_peer_connection_factory_interface.h
+++ b/api/test/mock_peer_connection_factory_interface.h
@@ -22,7 +22,7 @@
class MockPeerConnectionFactoryInterface final
: public rtc::RefCountedObject<webrtc::PeerConnectionFactoryInterface> {
public:
- rtc::scoped_refptr<MockPeerConnectionFactoryInterface> Create() {
+ static rtc::scoped_refptr<MockPeerConnectionFactoryInterface> Create() {
return new MockPeerConnectionFactoryInterface();
}