xref: /aosp_15_r20/external/webrtc/api/test/mock_video_track.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2021 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 API_TEST_MOCK_VIDEO_TRACK_H_
12 #define API_TEST_MOCK_VIDEO_TRACK_H_
13 
14 #include <string>
15 
16 #include "api/media_stream_interface.h"
17 #include "api/scoped_refptr.h"
18 #include "rtc_base/ref_counted_object.h"
19 #include "test/gmock.h"
20 
21 namespace webrtc {
22 
23 class MockVideoTrack
24     : public rtc::RefCountedObject<webrtc::VideoTrackInterface> {
25  public:
Create()26   static rtc::scoped_refptr<MockVideoTrack> Create() {
27     return rtc::scoped_refptr<MockVideoTrack>(new MockVideoTrack());
28   }
29 
30   // NotifierInterface
31   MOCK_METHOD(void,
32               RegisterObserver,
33               (ObserverInterface * observer),
34               (override));
35   MOCK_METHOD(void,
36               UnregisterObserver,
37               (ObserverInterface * observer),
38               (override));
39 
40   // MediaStreamTrackInterface
41   MOCK_METHOD(std::string, kind, (), (const, override));
42   MOCK_METHOD(std::string, id, (), (const, override));
43   MOCK_METHOD(bool, enabled, (), (const, override));
44   MOCK_METHOD(bool, set_enabled, (bool enable), (override));
45   MOCK_METHOD(TrackState, state, (), (const, override));
46 
47   // VideoSourceInterface
48   MOCK_METHOD(void,
49               AddOrUpdateSink,
50               (rtc::VideoSinkInterface<VideoFrame> * sink,
51                const rtc::VideoSinkWants& wants),
52               (override));
53   // RemoveSink must guarantee that at the time the method returns,
54   // there is no current and no future calls to VideoSinkInterface::OnFrame.
55   MOCK_METHOD(void,
56               RemoveSink,
57               (rtc::VideoSinkInterface<VideoFrame> * sink),
58               (override));
59 
60   // VideoTrackInterface
61   MOCK_METHOD(VideoTrackSourceInterface*, GetSource, (), (const, override));
62 
63   MOCK_METHOD(ContentHint, content_hint, (), (const, override));
64   MOCK_METHOD(void, set_content_hint, (ContentHint hint), (override));
65 };
66 
67 }  // namespace webrtc
68 
69 #endif  // API_TEST_MOCK_VIDEO_TRACK_H_
70