• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024-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_ITRANSCODER_ENGINE_H
17 #define MOCK_ITRANSCODER_ENGINE_H
18 
19 #include "i_transcoder_engine.h"
20 #include "gmock/gmock.h"
21 
22 namespace OHOS {
23 namespace Media {
24 class MockITransCoderEngineObs : public ITransCoderEngineObs {
25 public:
26     MockITransCoderEngineObs() = default;
27     ~MockITransCoderEngineObs() override = default;
OnError(TransCoderErrorType errorType,int32_t errorCode)28     void OnError(TransCoderErrorType errorType, int32_t errorCode) override
29     {
30         onErrorFlag = true;
31     }
OnInfo(TransCoderOnInfoType type,int32_t extra)32     void OnInfo(TransCoderOnInfoType type, int32_t extra) override
33     {
34         onInfoFlag = true;
35     }
36 private:
37     bool onInfoFlag = false;
38     bool onErrorFlag = false;
39 };
40 
41 class MockITransCoderEngine : public ITransCoderEngine {
42 public:
43     MockITransCoderEngine() = default;
~MockITransCoderEngine()44     ~MockITransCoderEngine() override {};
45     MOCK_METHOD(void, SetInstanceId, (uint64_t instanceId), ());
46 
47     MOCK_METHOD(int32_t, SetInputFile, (const std::string &url), ());
48 
49     MOCK_METHOD(int32_t, SetOutputFile, (const int32_t fd), ());
50 
51     MOCK_METHOD(int32_t, SetOutputFormat, (OutputFormatType format), ());
52 
53     MOCK_METHOD(int32_t, SetObs, (const std::weak_ptr<ITransCoderEngineObs> &obs), ());
54 
55     MOCK_METHOD(int32_t, Configure, (const TransCoderParam &recParam), ());
56 
57     MOCK_METHOD(int32_t, Prepare, (), ());
58 
59     MOCK_METHOD(int32_t, Start, (), ());
60 
61     MOCK_METHOD(int32_t, Pause, (), ());
62 
63     MOCK_METHOD(int32_t, Resume, (), ());
64 
65     MOCK_METHOD(int32_t, Cancel, (), ());
66 
67     MOCK_METHOD(int32_t, GetCurrentTime, (int32_t &currentTime), ());
68 
69     MOCK_METHOD(int32_t, GetDuration, (int32_t &duration), ());
70 };
71 } // namespace Media
72 } // namespace OHOS
73 #endif