hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 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 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #ifndef PC_TEST_MOCK_DATA_CHANNEL_H_ |
| 12 | #define PC_TEST_MOCK_DATA_CHANNEL_H_ |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 13 | |
Steve Anton | 36b29d1 | 2017-10-30 09:57:42 -0700 | [diff] [blame] | 14 | #include <string> |
| 15 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 16 | #include "pc/data_channel.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "test/gmock.h" |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
| 20 | |
| 21 | class MockDataChannel : public rtc::RefCountedObject<DataChannel> { |
| 22 | public: |
hbos | cc555c5 | 2016-10-18 12:48:31 -0700 | [diff] [blame] | 23 | MockDataChannel(int id, DataState state) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 24 | : MockDataChannel(id, "MockDataChannel", state, "udp", 0, 0, 0, 0) {} |
| 25 | MockDataChannel(int id, |
| 26 | const std::string& label, |
| 27 | DataState state, |
| 28 | const std::string& protocol, |
| 29 | uint32_t messages_sent, |
| 30 | uint64_t bytes_sent, |
| 31 | uint32_t messages_received, |
| 32 | uint64_t bytes_received) |
| 33 | : rtc::RefCountedObject<DataChannel>(nullptr, cricket::DCT_NONE, label) { |
Mirko Bonadei | 6a489f2 | 2019-04-09 15:11:12 +0200 | [diff] [blame] | 34 | EXPECT_CALL(*this, id()).WillRepeatedly(::testing::Return(id)); |
| 35 | EXPECT_CALL(*this, state()).WillRepeatedly(::testing::Return(state)); |
| 36 | EXPECT_CALL(*this, protocol()).WillRepeatedly(::testing::Return(protocol)); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 37 | EXPECT_CALL(*this, messages_sent()) |
Mirko Bonadei | 6a489f2 | 2019-04-09 15:11:12 +0200 | [diff] [blame] | 38 | .WillRepeatedly(::testing::Return(messages_sent)); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 39 | EXPECT_CALL(*this, bytes_sent()) |
Mirko Bonadei | 6a489f2 | 2019-04-09 15:11:12 +0200 | [diff] [blame] | 40 | .WillRepeatedly(::testing::Return(bytes_sent)); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 41 | EXPECT_CALL(*this, messages_received()) |
Mirko Bonadei | 6a489f2 | 2019-04-09 15:11:12 +0200 | [diff] [blame] | 42 | .WillRepeatedly(::testing::Return(messages_received)); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 43 | EXPECT_CALL(*this, bytes_received()) |
Mirko Bonadei | 6a489f2 | 2019-04-09 15:11:12 +0200 | [diff] [blame] | 44 | .WillRepeatedly(::testing::Return(bytes_received)); |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 45 | } |
hbos | cc555c5 | 2016-10-18 12:48:31 -0700 | [diff] [blame] | 46 | MOCK_CONST_METHOD0(id, int()); |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 47 | MOCK_CONST_METHOD0(state, DataState()); |
hbos | dbb64d8 | 2016-12-21 01:57:46 -0800 | [diff] [blame] | 48 | MOCK_CONST_METHOD0(protocol, std::string()); |
hbos | cc555c5 | 2016-10-18 12:48:31 -0700 | [diff] [blame] | 49 | MOCK_CONST_METHOD0(messages_sent, uint32_t()); |
| 50 | MOCK_CONST_METHOD0(bytes_sent, uint64_t()); |
| 51 | MOCK_CONST_METHOD0(messages_received, uint32_t()); |
| 52 | MOCK_CONST_METHOD0(bytes_received, uint64_t()); |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | } // namespace webrtc |
| 56 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 57 | #endif // PC_TEST_MOCK_DATA_CHANNEL_H_ |