api/test: Move MockVideoTrack to its own file for sharing
Bug: webrtc:9620 Change-Id: Iebe11d3e481dd8046771ded2608a4c57288cd22d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226325 Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Florent Castelli <orphis@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34494}
This commit is contained in:
parent
523a5886c3
commit
63cc46c1f5
15
api/BUILD.gn
15
api/BUILD.gn
@ -1057,6 +1057,20 @@ if (rtc_include_tests) {
|
||||
]
|
||||
}
|
||||
|
||||
rtc_library("mock_video_track") {
|
||||
visibility = [ "*" ]
|
||||
|
||||
testonly = true
|
||||
sources = [ "test/mock_video_track.h" ]
|
||||
|
||||
deps = [
|
||||
"../api:media_stream_interface",
|
||||
"../api:scoped_refptr",
|
||||
"../rtc_base:refcount",
|
||||
"../test:test_support",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_library("create_time_controller") {
|
||||
visibility = [ "*" ]
|
||||
testonly = true
|
||||
@ -1145,6 +1159,7 @@ if (rtc_include_tests) {
|
||||
":mock_video_codec_factory",
|
||||
":mock_video_decoder",
|
||||
":mock_video_encoder",
|
||||
":mock_video_track",
|
||||
":rtc_api_unittests",
|
||||
"units:units_unittests",
|
||||
]
|
||||
|
||||
4
api/DEPS
4
api/DEPS
@ -275,6 +275,10 @@ specific_include_rules = {
|
||||
"+rtc_base/ref_counted_object.h",
|
||||
],
|
||||
|
||||
"mock_video_track\.h": [
|
||||
"+rtc_base/ref_counted_object.h",
|
||||
],
|
||||
|
||||
"simulated_network\.h": [
|
||||
"+rtc_base/random.h",
|
||||
"+rtc_base/thread_annotations.h",
|
||||
|
||||
@ -49,3 +49,4 @@
|
||||
#include "api/test/mock_video_decoder_factory.h"
|
||||
#include "api/test/mock_video_encoder.h"
|
||||
#include "api/test/mock_video_encoder_factory.h"
|
||||
#include "api/test/mock_video_track.h"
|
||||
|
||||
69
api/test/mock_video_track.h
Normal file
69
api/test/mock_video_track.h
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright 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 API_TEST_MOCK_VIDEO_TRACK_H_
|
||||
#define API_TEST_MOCK_VIDEO_TRACK_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "api/media_stream_interface.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "rtc_base/ref_counted_object.h"
|
||||
#include "test/gmock.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class MockVideoTrack final
|
||||
: public rtc::RefCountedObject<webrtc::VideoTrackInterface> {
|
||||
public:
|
||||
static rtc::scoped_refptr<MockVideoTrack> Create() {
|
||||
return new MockVideoTrack();
|
||||
}
|
||||
|
||||
// NotifierInterface
|
||||
MOCK_METHOD(void,
|
||||
RegisterObserver,
|
||||
(ObserverInterface * observer),
|
||||
(override));
|
||||
MOCK_METHOD(void,
|
||||
UnregisterObserver,
|
||||
(ObserverInterface * observer),
|
||||
(override));
|
||||
|
||||
// MediaStreamTrackInterface
|
||||
MOCK_METHOD(std::string, kind, (), (const, override));
|
||||
MOCK_METHOD(std::string, id, (), (const, override));
|
||||
MOCK_METHOD(bool, enabled, (), (const, override));
|
||||
MOCK_METHOD(bool, set_enabled, (bool enable), (override));
|
||||
MOCK_METHOD(TrackState, state, (), (const, override));
|
||||
|
||||
// VideoSourceInterface
|
||||
MOCK_METHOD(void,
|
||||
AddOrUpdateSink,
|
||||
(rtc::VideoSinkInterface<VideoFrame> * sink,
|
||||
const rtc::VideoSinkWants& wants),
|
||||
(override));
|
||||
// RemoveSink must guarantee that at the time the method returns,
|
||||
// there is no current and no future calls to VideoSinkInterface::OnFrame.
|
||||
MOCK_METHOD(void,
|
||||
RemoveSink,
|
||||
(rtc::VideoSinkInterface<VideoFrame> * sink),
|
||||
(override));
|
||||
|
||||
// VideoTrackInterface
|
||||
MOCK_METHOD(VideoTrackSourceInterface*, GetSource, (), (const, override));
|
||||
|
||||
MOCK_METHOD(ContentHint, content_hint, (), (const, override));
|
||||
MOCK_METHOD(void, set_content_hint, (ContentHint hint), (override));
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // API_TEST_MOCK_VIDEO_TRACK_H_
|
||||
@ -1094,6 +1094,7 @@ if (rtc_include_tests && !build_with_chromium) {
|
||||
"../api:libjingle_peerconnection_api",
|
||||
"../api:media_stream_interface",
|
||||
"../api:mock_rtp",
|
||||
"../api:mock_video_track",
|
||||
"../api:packet_socket_factory",
|
||||
"../api:rtc_error",
|
||||
"../api:rtp_transceiver_direction",
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "api/rtp_sender_interface.h"
|
||||
#include "api/test/mock_video_track.h"
|
||||
#include "api/transport/rtp/rtp_source.h"
|
||||
#include "media/base/media_channel.h"
|
||||
#include "pc/audio_track.h"
|
||||
@ -31,45 +32,6 @@ namespace webrtc {
|
||||
|
||||
namespace {
|
||||
|
||||
class MockVideoTrack : public VideoTrackInterface {
|
||||
public:
|
||||
// NotifierInterface
|
||||
MOCK_METHOD(void,
|
||||
RegisterObserver,
|
||||
(ObserverInterface * observer),
|
||||
(override));
|
||||
MOCK_METHOD(void,
|
||||
UnregisterObserver,
|
||||
(ObserverInterface * observer),
|
||||
(override));
|
||||
|
||||
// MediaStreamTrackInterface
|
||||
MOCK_METHOD(std::string, kind, (), (const, override));
|
||||
MOCK_METHOD(std::string, id, (), (const, override));
|
||||
MOCK_METHOD(bool, enabled, (), (const, override));
|
||||
MOCK_METHOD(bool, set_enabled, (bool enable), (override));
|
||||
MOCK_METHOD(TrackState, state, (), (const, override));
|
||||
|
||||
// VideoSourceInterface
|
||||
MOCK_METHOD(void,
|
||||
AddOrUpdateSink,
|
||||
(rtc::VideoSinkInterface<VideoFrame> * sink,
|
||||
const rtc::VideoSinkWants& wants),
|
||||
(override));
|
||||
// RemoveSink must guarantee that at the time the method returns,
|
||||
// there is no current and no future calls to VideoSinkInterface::OnFrame.
|
||||
MOCK_METHOD(void,
|
||||
RemoveSink,
|
||||
(rtc::VideoSinkInterface<VideoFrame> * sink),
|
||||
(override));
|
||||
|
||||
// VideoTrackInterface
|
||||
MOCK_METHOD(VideoTrackSourceInterface*, GetSource, (), (const, override));
|
||||
|
||||
MOCK_METHOD(ContentHint, content_hint, (), (const, override));
|
||||
MOCK_METHOD(void, set_content_hint, (ContentHint hint), (override));
|
||||
};
|
||||
|
||||
RtpParameters CreateRtpParametersWithSsrcs(
|
||||
std::initializer_list<uint32_t> ssrcs) {
|
||||
RtpParameters params;
|
||||
@ -126,7 +88,7 @@ rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack(
|
||||
|
||||
rtc::scoped_refptr<VideoTrackInterface> CreateMockVideoTrack(
|
||||
const std::string& id) {
|
||||
auto track = rtc::make_ref_counted<MockVideoTrack>();
|
||||
auto track = MockVideoTrack::Create();
|
||||
EXPECT_CALL(*track, kind())
|
||||
.WillRepeatedly(::testing::Return(VideoTrack::kVideoKind));
|
||||
return track;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user