blob: 34f732ca4dc2298bbbed7904bf6741adde87dd1f [file] [log] [blame]
Erik Språngc84cd952018-10-15 11:55:13 +02001/*
2 * Copyright (c) 2018 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_DECODER_H_
12#define API_TEST_MOCK_VIDEO_DECODER_H_
13
Tommi96c1a9b2022-09-29 12:24:02 +020014#include <utility>
15
Erik Språngc84cd952018-10-15 11:55:13 +020016#include "api/video_codecs/video_decoder.h"
17#include "test/gmock.h"
18
19namespace webrtc {
20
21class MockDecodedImageCallback : public DecodedImageCallback {
22 public:
Danil Chapovalovfc115192020-05-08 15:03:03 +020023 MOCK_METHOD(int32_t,
24 Decoded,
25 (VideoFrame & decoded_image), // NOLINT
26 (override));
27 MOCK_METHOD(int32_t,
28 Decoded,
29 (VideoFrame & decoded_image, // NOLINT
30 int64_t decode_time_ms),
31 (override));
32 MOCK_METHOD(void,
33 Decoded,
34 (VideoFrame & decoded_image, // NOLINT
35 absl::optional<int32_t> decode_time_ms,
36 absl::optional<uint8_t> qp),
37 (override));
Erik Språngc84cd952018-10-15 11:55:13 +020038};
39
40class MockVideoDecoder : public VideoDecoder {
41 public:
Danil Chapovalov355b8d22021-08-13 16:50:37 +020042 MockVideoDecoder() {
43 // Make `Configure` succeed by default, so that individual tests that
44 // verify other methods wouldn't need to stub `Configure`.
45 ON_CALL(*this, Configure).WillByDefault(testing::Return(true));
46 }
47
Tommi96c1a9b2022-09-29 12:24:02 +020048 ~MockVideoDecoder() override { Destruct(); }
49
Danil Chapovalovecc46ef2021-08-09 15:30:47 +020050 MOCK_METHOD(bool, Configure, (const Settings& settings), (override));
Danil Chapovalovfc115192020-05-08 15:03:03 +020051 MOCK_METHOD(int32_t,
Danil Chapovalovfc115192020-05-08 15:03:03 +020052 Decode,
53 (const EncodedImage& input_image,
54 bool missing_frames,
55 int64_t render_time_ms),
56 (override));
57 MOCK_METHOD(int32_t,
58 RegisterDecodeCompleteCallback,
59 (DecodedImageCallback * callback),
60 (override));
61 MOCK_METHOD(int32_t, Release, (), (override));
Tommi96c1a9b2022-09-29 12:24:02 +020062
63 // Special utility method that allows a test to monitor/verify when
64 // destruction of the decoder instance occurs.
65 MOCK_METHOD(void, Destruct, (), ());
Erik Språngc84cd952018-10-15 11:55:13 +020066};
67
68} // namespace webrtc
69
70#endif // API_TEST_MOCK_VIDEO_DECODER_H_