• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef MOCK_IPLAYER_ENGINE_H
17 #define MOCK_IPLAYER_ENGINE_H
18 
19 #include "i_player_engine.h"
20 #include "gmock/gmock.h"
21 #include "player.h"
22 
23 namespace OHOS {
24 namespace Media {
25 class MockIPlayerEngineObs : public IPlayerEngineObs {
26 public:
27     MockIPlayerEngineObs() = default;
28     ~MockIPlayerEngineObs() override = default;
29     MOCK_METHOD(void, OnError, (PlayerErrorType errorType, int32_t errorCode), ());
30     MOCK_METHOD(void, OnErrorMessage, (int32_t errorCode, const std::string &errorMsg), ());
OnSystemOperation(PlayerOnSystemOperationType type,PlayerOperationReason reason)31     void OnSystemOperation(PlayerOnSystemOperationType type, PlayerOperationReason reason) override
32     {
33         onSystemOperationFlag = true;
34     }
OnInfo(PlayerOnInfoType type,int32_t extra,const Format & infoBody)35     void OnInfo(PlayerOnInfoType type, int32_t extra, const Format& infoBody) override
36     {
37         onInfoFlag = true;
38     }
39 private:
40     bool onInfoFlag = false;
41     bool onSystemOperationFlag = false;
42 };
43 
44 class MockIPlayerEngine : public IPlayerEngine {
45 public:
46     MockIPlayerEngine() = default;
~MockIPlayerEngine()47     ~MockIPlayerEngine() override {};
48     MOCK_METHOD(int32_t, SetSource, (const std::string &url), ());
49     MOCK_METHOD(int32_t, SetSource, (const std::shared_ptr<IMediaDataSource> &dataSrc), ());
50     MOCK_METHOD(int32_t, SetObs, (const std::weak_ptr<IPlayerEngineObs> &obs), ());
51     MOCK_METHOD(int32_t, AddSubSource, (const std::string &url), ());
52     MOCK_METHOD(int32_t, Play, (), ());
53     MOCK_METHOD(int32_t, Prepare, (), ());
54     MOCK_METHOD(int32_t, SetRenderFirstFrame, (bool display), ());
55     MOCK_METHOD(int32_t, SetPlayRange, (int64_t start, int64_t end), ());
56     MOCK_METHOD(int32_t, SetPlayRangeWithMode, (int64_t start, int64_t end, PlayerSeekMode mode), ());
57     MOCK_METHOD(int32_t, PrepareAsync, (), ());
58     MOCK_METHOD(int32_t, Pause, (bool isSystemOperation), ());
59     MOCK_METHOD(int32_t, Stop, (), ());
60     MOCK_METHOD(int32_t, Reset, (), ());
61     MOCK_METHOD(int32_t, SetVolume, (float leftVolume, float rightVolume), ());
62     MOCK_METHOD(int32_t, SetVolumeMode, (int32_t mode), ());
63     MOCK_METHOD(int32_t, Seek, (int32_t mSeconds, PlayerSeekMode mode), ());
64     MOCK_METHOD(int32_t, GetCurrentTime, (int32_t &currentTime), ());
65     MOCK_METHOD(int32_t, GetVideoTrackInfo, (std::vector<Format> &videoTrack), ());
66     MOCK_METHOD(int32_t, GetPlaybackInfo, (Format &playbackInfo), ());
67     MOCK_METHOD(int32_t, GetAudioTrackInfo, (std::vector<Format> &audioTrack), ());
68     MOCK_METHOD(int32_t, GetVideoWidth, (), ());
69     MOCK_METHOD(int32_t, GetVideoHeight, (), ());
70     MOCK_METHOD(int32_t, GetDuration, (int32_t &duration), ());
71     MOCK_METHOD(int32_t, SetPlaybackSpeed, (PlaybackRateMode mode), ());
72     MOCK_METHOD(int32_t, GetPlaybackSpeed, (PlaybackRateMode &mode), ());
73     MOCK_METHOD(int32_t, SetMediaSource, (const std::shared_ptr<AVMediaSource> &mediaSource,
74         AVPlayStrategy strategy), ());
75     MOCK_METHOD(int32_t, SelectBitRate, (uint32_t bitRate), ());
76     MOCK_METHOD(int32_t, SetDecryptConfig, (const sptr<DrmStandard::IMediaKeySessionService> &keySessionProxy,
77         bool svp), ());
78     MOCK_METHOD(int32_t, SetVideoSurface, (sptr<Surface> surface), ());
79     MOCK_METHOD(float, GetMaxAmplitude, (), ());
80     MOCK_METHOD(int32_t, SetLooping, (bool loop), ());
81     MOCK_METHOD(int32_t, SetParameter, (const Format &param), ());
82     MOCK_METHOD(int32_t, GetCurrentTrack, (int32_t trackType, int32_t &index), ());
83     MOCK_METHOD(int32_t, GetSubtitleTrackInfo, (std::vector<Format> &subtitleTrack), ());
84     MOCK_METHOD(int32_t, SetPlaybackStrategy, (AVPlayStrategy playbackStrategy), ());
85     MOCK_METHOD(int64_t, GetPlayRangeEndTime, (), ());
86     MOCK_METHOD(int32_t, SetMaxAmplitudeCbStatus, (bool status), ());
87 };
88 } // namespace Media
89 } // namespace OHOS
90 #endif