1 /*
2  * Copyright (C) 2023 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 COMMON_MOCK_H
17 #define COMMON_MOCK_H
18 
19 #include <string>
20 #include "buffer/avbuffer.h"
21 #include "buffer/avsharedmemory.h"
22 #include "buffer/avsharedmemorybase.h"
23 #include "native_avcodec_base.h"
24 #include "nocopyable.h"
25 #include "surface.h"
26 
27 using AVBuffer = OHOS::Media::AVBuffer;
28 using Status = OHOS::Media::Status;
29 using AVSharedMemory = OHOS::Media::AVSharedMemory;
30 using AVSharedMemoryBase = OHOS::Media::AVSharedMemoryBase;
31 
32 namespace OHOS {
33 namespace MediaAVCodec {
34 class SurfaceMock : public NoCopyable {
35 public:
36     virtual ~SurfaceMock() = default;
37 };
38 
39 class AVMemoryMock : public NoCopyable {
40 public:
41     virtual ~AVMemoryMock() = default;
42     virtual uint8_t *GetAddr() const = 0;
43     virtual int32_t GetSize() const = 0;
44     virtual uint32_t GetFlags() const = 0;
45     virtual int32_t Destory() = 0;
46 };
47 
48 class __attribute__((visibility("default"))) SurfaceMockFactory {
49 public:
50     static std::shared_ptr<SurfaceMock> CreateSurface();
51     static std::shared_ptr<SurfaceMock> CreateSurface(sptr<Surface> &surface);
52 
53 private:
54     SurfaceMockFactory() = delete;
55     ~SurfaceMockFactory() = delete;
56 };
57 
58 class __attribute__((visibility("default"))) AVMemoryMockFactory {
59 public:
60     static std::shared_ptr<AVMemoryMock> CreateAVMemoryMock(int32_t size);
61 private:
62     AVMemoryMockFactory() = delete;
63     ~AVMemoryMockFactory() = delete;
64 };
65 } // namespace MediaAVCodec
66 } // namespace OHOS
67 #endif // COMMON_MOCK_H