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}
This commit is contained in:
Steve Anton 2020-11-04 19:21:49 -08:00 committed by Commit Bot
parent 439ffe462a
commit c49c7d2644
4 changed files with 74 additions and 1 deletions

View File

@ -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",

View File

@ -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"

View File

@ -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_

View File

@ -22,7 +22,7 @@ namespace webrtc {
class MockPeerConnectionFactoryInterface final
: public rtc::RefCountedObject<webrtc::PeerConnectionFactoryInterface> {
public:
rtc::scoped_refptr<MockPeerConnectionFactoryInterface> Create() {
static rtc::scoped_refptr<MockPeerConnectionFactoryInterface> Create() {
return new MockPeerConnectionFactoryInterface();
}