1 /* 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef PC_TEST_MOCK_DATA_CHANNEL_H_ 12 #define PC_TEST_MOCK_DATA_CHANNEL_H_ 13 14 #include <string> 15 16 #include "pc/sctp_data_channel.h" 17 #include "test/gmock.h" 18 19 namespace webrtc { 20 21 class MockSctpDataChannel : public rtc::RefCountedObject<SctpDataChannel> { 22 public: MockSctpDataChannel(int id,DataState state)23 MockSctpDataChannel(int id, DataState state) 24 : MockSctpDataChannel(id, 25 "MockSctpDataChannel", 26 state, 27 "udp", 28 0, 29 0, 30 0, 31 0) {} 32 MockSctpDataChannel( 33 int id, 34 const std::string& label, 35 DataState state, 36 const std::string& protocol, 37 uint32_t messages_sent, 38 uint64_t bytes_sent, 39 uint32_t messages_received, 40 uint64_t bytes_received, 41 const InternalDataChannelInit& config = InternalDataChannelInit(), 42 rtc::Thread* signaling_thread = rtc::Thread::Current(), 43 rtc::Thread* network_thread = rtc::Thread::Current()) 44 : rtc::RefCountedObject<SctpDataChannel>(config, 45 nullptr, 46 label, 47 signaling_thread, 48 network_thread) { 49 EXPECT_CALL(*this, id()).WillRepeatedly(::testing::Return(id)); 50 EXPECT_CALL(*this, state()).WillRepeatedly(::testing::Return(state)); 51 EXPECT_CALL(*this, protocol()).WillRepeatedly(::testing::Return(protocol)); 52 EXPECT_CALL(*this, messages_sent()) 53 .WillRepeatedly(::testing::Return(messages_sent)); 54 EXPECT_CALL(*this, bytes_sent()) 55 .WillRepeatedly(::testing::Return(bytes_sent)); 56 EXPECT_CALL(*this, messages_received()) 57 .WillRepeatedly(::testing::Return(messages_received)); 58 EXPECT_CALL(*this, bytes_received()) 59 .WillRepeatedly(::testing::Return(bytes_received)); 60 } 61 MOCK_METHOD(int, id, (), (const, override)); 62 MOCK_METHOD(DataState, state, (), (const, override)); 63 MOCK_METHOD(std::string, protocol, (), (const, override)); 64 MOCK_METHOD(uint32_t, messages_sent, (), (const, override)); 65 MOCK_METHOD(uint64_t, bytes_sent, (), (const, override)); 66 MOCK_METHOD(uint32_t, messages_received, (), (const, override)); 67 MOCK_METHOD(uint64_t, bytes_received, (), (const, override)); 68 }; 69 70 } // namespace webrtc 71 72 #endif // PC_TEST_MOCK_DATA_CHANNEL_H_ 73