forked from webrtc-sdk/webrtc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is for convenience to the users of dcSCTP, which may want to have unit tests where the socket is mocked. And since it's best practice not to mock other teams' or project's classes, a mock will be provided by the upstream project - this one. Bug: webrtc:12614 Change-Id: I65d5d21097e7feda9162567560d3838759c962fc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/224161 Reviewed-by: Florent Castelli <[email protected]> Commit-Queue: Victor Boivie <[email protected]> Cr-Commit-Position: refs/heads/master@{#34385}
- Loading branch information
Victor Boivie
authored and
WebRTC LUCI CQ
committed
Jun 29, 2021
1 parent
da9dfae
commit c362eb2
Showing
3 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (c) 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 NET_DCSCTP_PUBLIC_MOCK_DCSCTP_SOCKET_H_ | ||
#define NET_DCSCTP_PUBLIC_MOCK_DCSCTP_SOCKET_H_ | ||
|
||
#include "net/dcsctp/public/dcsctp_socket.h" | ||
#include "test/gmock.h" | ||
|
||
namespace dcsctp { | ||
|
||
class MockDcSctpSocket : public DcSctpSocketInterface { | ||
public: | ||
MOCK_METHOD(void, | ||
ReceivePacket, | ||
(rtc::ArrayView<const uint8_t> data), | ||
(override)); | ||
|
||
MOCK_METHOD(void, HandleTimeout, (TimeoutID timeout_id), (override)); | ||
|
||
MOCK_METHOD(void, Connect, (), (override)); | ||
|
||
MOCK_METHOD(void, Shutdown, (), (override)); | ||
|
||
MOCK_METHOD(void, Close, (), (override)); | ||
|
||
MOCK_METHOD(SocketState, state, (), (const, override)); | ||
|
||
MOCK_METHOD(const DcSctpOptions&, options, (), (const, override)); | ||
|
||
MOCK_METHOD(void, SetMaxMessageSize, (size_t max_message_size), (override)); | ||
|
||
MOCK_METHOD(SendStatus, | ||
Send, | ||
(DcSctpMessage message, const SendOptions& send_options), | ||
(override)); | ||
|
||
MOCK_METHOD(ResetStreamsStatus, | ||
ResetStreams, | ||
(rtc::ArrayView<const StreamID> outgoing_streams), | ||
(override)); | ||
|
||
MOCK_METHOD(size_t, buffered_amount, (StreamID stream_id), (const, override)); | ||
|
||
MOCK_METHOD(size_t, | ||
buffered_amount_low_threshold, | ||
(StreamID stream_id), | ||
(const, override)); | ||
|
||
MOCK_METHOD(void, | ||
SetBufferedAmountLowThreshold, | ||
(StreamID stream_id, size_t bytes), | ||
(override)); | ||
}; | ||
|
||
} // namespace dcsctp | ||
|
||
#endif // NET_DCSCTP_PUBLIC_MOCK_DCSCTP_SOCKET_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 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. | ||
*/ | ||
#include "net/dcsctp/public/mock_dcsctp_socket.h" | ||
|
||
#include "rtc_base/gunit.h" | ||
#include "test/gmock.h" | ||
|
||
namespace dcsctp { | ||
|
||
// This test exists to ensure that all methods are mocked correctly, and to | ||
// generate compiler errors if they are not. | ||
TEST(MockDcSctpSocketTest, CanInstantiateAndConnect) { | ||
testing::StrictMock<MockDcSctpSocket> socket; | ||
|
||
EXPECT_CALL(socket, Connect); | ||
|
||
socket.Connect(); | ||
} | ||
|
||
} // namespace dcsctp |