From e2173d9f0d2d991d576ffa71a18761af69b72ede Mon Sep 17 00:00:00 2001 From: eladalon Date: Fri, 28 Jul 2017 10:05:45 -0700 Subject: [PATCH] Only one implementation of MockRtpPacketSink once MockRtpPacketSink has three identical implementations now, so time to move it to its own file. BUG=None Review-Url: https://codereview.webrtc.org/2988853002 Cr-Commit-Position: refs/heads/master@{#19183} --- webrtc/call/BUILD.gn | 17 +++++++++++- webrtc/call/rtp_demuxer_unittest.cc | 7 +---- webrtc/call/rtx_receive_stream_unittest.cc | 6 +---- .../test/mock_rtp_packet_sink_interface.h | 26 +++++++++++++++++++ webrtc/video/BUILD.gn | 1 + 5 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 webrtc/call/test/mock_rtp_packet_sink_interface.h diff --git a/webrtc/call/BUILD.gn b/webrtc/call/BUILD.gn index c40b557d4c..62b8ac465f 100644 --- a/webrtc/call/BUILD.gn +++ b/webrtc/call/BUILD.gn @@ -34,7 +34,7 @@ rtc_source_set("call_interfaces") { } # TODO(nisse): These RTP targets should be moved elsewhere -# when interfaces have stabilized. +# when interfaces have stabilized. See also TODO for |mock_rtp_interfaces|. rtc_source_set("rtp_interfaces") { sources = [ "rtcp_packet_sink_interface.h", @@ -144,6 +144,7 @@ if (rtc_include_tests) { ] deps = [ ":call", + ":mock_rtp_interfaces", ":rtp_interfaces", ":rtp_receiver", ":rtp_sender", @@ -213,4 +214,18 @@ if (rtc_include_tests) { suppressed_configs += [ "//build/config/clang:find_bad_constructs" ] } } + + # TODO(eladalon): This should be moved, as with the TODO for |rtp_interfaces|. + rtc_source_set("mock_rtp_interfaces") { + testonly = true + + sources = [ + "test/mock_rtp_packet_sink_interface.h", + ] + deps = [ + ":rtp_interfaces", + "../test:test_support", + "//testing/gmock", + ] + } } diff --git a/webrtc/call/rtp_demuxer_unittest.cc b/webrtc/call/rtp_demuxer_unittest.cc index 8c2eab11bf..a2b4578a71 100644 --- a/webrtc/call/rtp_demuxer_unittest.cc +++ b/webrtc/call/rtp_demuxer_unittest.cc @@ -14,7 +14,7 @@ #include #include "webrtc/call/rsid_resolution_observer.h" -#include "webrtc/call/rtp_packet_sink_interface.h" +#include "webrtc/call/test/mock_rtp_packet_sink_interface.h" #include "webrtc/common_types.h" #include "webrtc/modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" @@ -35,11 +35,6 @@ using ::testing::AtLeast; using ::testing::InSequence; using ::testing::NiceMock; -class MockRtpPacketSink : public RtpPacketSinkInterface { - public: - MOCK_METHOD1(OnRtpPacket, void(const RtpPacketReceived&)); -}; - class MockRsidResolutionObserver : public RsidResolutionObserver { public: MOCK_METHOD2(OnRsidResolved, void(const std::string& rsid, uint32_t ssrc)); diff --git a/webrtc/call/rtx_receive_stream_unittest.cc b/webrtc/call/rtx_receive_stream_unittest.cc index 91ed2ca2c7..e9c8210521 100644 --- a/webrtc/call/rtx_receive_stream_unittest.cc +++ b/webrtc/call/rtx_receive_stream_unittest.cc @@ -9,6 +9,7 @@ */ #include "webrtc/call/rtx_receive_stream.h" +#include "webrtc/call/test/mock_rtp_packet_sink_interface.h" #include "webrtc/modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" @@ -22,11 +23,6 @@ namespace { using ::testing::_; using ::testing::StrictMock; -class MockRtpPacketSink : public RtpPacketSinkInterface { - public: - MOCK_METHOD1(OnRtpPacket, void(const RtpPacketReceived&)); -}; - constexpr int kMediaPayloadType = 100; constexpr int kRtxPayloadType = 98; constexpr uint32_t kMediaSSRC = 0x3333333; diff --git a/webrtc/call/test/mock_rtp_packet_sink_interface.h b/webrtc/call/test/mock_rtp_packet_sink_interface.h new file mode 100644 index 0000000000..a13900436a --- /dev/null +++ b/webrtc/call/test/mock_rtp_packet_sink_interface.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2017 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 WEBRTC_CALL_TEST_MOCK_RTP_PACKET_SINK_INTERFACE_H_ +#define WEBRTC_CALL_TEST_MOCK_RTP_PACKET_SINK_INTERFACE_H_ + +#include "webrtc/call/rtp_packet_sink_interface.h" + +#include "webrtc/test/gmock.h" + +namespace webrtc { + +class MockRtpPacketSink : public RtpPacketSinkInterface { + public: + MOCK_METHOD1(OnRtpPacket, void(const RtpPacketReceived&)); +}; + +} // namespace webrtc + +#endif // WEBRTC_CALL_TEST_MOCK_RTP_PACKET_SINK_INTERFACE_H_ diff --git a/webrtc/video/BUILD.gn b/webrtc/video/BUILD.gn index 77ba8e92e1..f9c3453d59 100644 --- a/webrtc/video/BUILD.gn +++ b/webrtc/video/BUILD.gn @@ -265,6 +265,7 @@ if (rtc_include_tests) { "../api:video_frame_api", "../api/video_codecs:video_codecs_api", "../call:call_interfaces", + "../call:mock_rtp_interfaces", "../call:rtp_receiver", "../common_video", "../logging:rtc_event_log_api",