mock_data_channel.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #ifndef PC_TEST_MOCK_DATA_CHANNEL_H_
  11. #define PC_TEST_MOCK_DATA_CHANNEL_H_
  12. #include <string>
  13. #include "pc/sctp_data_channel.h"
  14. #include "test/gmock.h"
  15. namespace webrtc {
  16. class MockSctpDataChannel : public rtc::RefCountedObject<SctpDataChannel> {
  17. public:
  18. MockSctpDataChannel(int id, DataState state)
  19. : MockSctpDataChannel(id,
  20. "MockSctpDataChannel",
  21. state,
  22. "udp",
  23. 0,
  24. 0,
  25. 0,
  26. 0) {}
  27. MockSctpDataChannel(
  28. int id,
  29. const std::string& label,
  30. DataState state,
  31. const std::string& protocol,
  32. uint32_t messages_sent,
  33. uint64_t bytes_sent,
  34. uint32_t messages_received,
  35. uint64_t bytes_received,
  36. const InternalDataChannelInit& config = InternalDataChannelInit(),
  37. rtc::Thread* signaling_thread = rtc::Thread::Current(),
  38. rtc::Thread* network_thread = rtc::Thread::Current())
  39. : rtc::RefCountedObject<SctpDataChannel>(config,
  40. nullptr,
  41. label,
  42. signaling_thread,
  43. network_thread) {
  44. EXPECT_CALL(*this, id()).WillRepeatedly(::testing::Return(id));
  45. EXPECT_CALL(*this, state()).WillRepeatedly(::testing::Return(state));
  46. EXPECT_CALL(*this, protocol()).WillRepeatedly(::testing::Return(protocol));
  47. EXPECT_CALL(*this, messages_sent())
  48. .WillRepeatedly(::testing::Return(messages_sent));
  49. EXPECT_CALL(*this, bytes_sent())
  50. .WillRepeatedly(::testing::Return(bytes_sent));
  51. EXPECT_CALL(*this, messages_received())
  52. .WillRepeatedly(::testing::Return(messages_received));
  53. EXPECT_CALL(*this, bytes_received())
  54. .WillRepeatedly(::testing::Return(bytes_received));
  55. }
  56. MOCK_METHOD(int, id, (), (const, override));
  57. MOCK_METHOD(DataState, state, (), (const, override));
  58. MOCK_METHOD(std::string, protocol, (), (const, override));
  59. MOCK_METHOD(uint32_t, messages_sent, (), (const, override));
  60. MOCK_METHOD(uint64_t, bytes_sent, (), (const, override));
  61. MOCK_METHOD(uint32_t, messages_received, (), (const, override));
  62. MOCK_METHOD(uint64_t, bytes_received, (), (const, override));
  63. };
  64. } // namespace webrtc
  65. #endif // PC_TEST_MOCK_DATA_CHANNEL_H_