diff --git a/api/BUILD.gn b/api/BUILD.gn index cc5975f59e..fd27681396 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -792,6 +792,17 @@ if (rtc_include_tests) { ] } + 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 @@ if (rtc_include_tests) { ":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 4cece5b286..0f50f582cb 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 0000000000..9346ffd638 --- /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 + +#include "api/data_channel_interface.h" +#include "test/gmock.h" + +namespace webrtc { + +class MockDataChannelInterface final + : public rtc::RefCountedObject { + public: + static rtc::scoped_refptr 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, maxRetransmitsOpt, (), (const, override)); + MOCK_METHOD(absl::optional, 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 19c3f4063e..7319cebbcc 100644 --- a/api/test/mock_peer_connection_factory_interface.h +++ b/api/test/mock_peer_connection_factory_interface.h @@ -22,7 +22,7 @@ namespace webrtc { class MockPeerConnectionFactoryInterface final : public rtc::RefCountedObject { public: - rtc::scoped_refptr Create() { + static rtc::scoped_refptr Create() { return new MockPeerConnectionFactoryInterface(); }