1 /*
2  * Copyright (c) 2022 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 OHOS_SCREEN_TRANS_TEST_UTILS_H
17 #define OHOS_SCREEN_TRANS_TEST_UTILS_H
18 
19 #include <stddef.h>
20 
21 #include "dscreen_errcode.h"
22 #include "dscreen_log.h"
23 #include "iimage_sink_processor_listener.h"
24 #include "iscreen_sink_trans_callback.h"
25 #include "iscreen_source_trans_callback.h"
26 #include "iscreen_channel_listener.h"
27 #include "iscreen_channel.h"
28 
29 namespace OHOS {
30 namespace DistributedHardware {
31 constexpr int32_t VIDEO_CODEC_TYPE_INVALID = -1;
32 constexpr int32_t VIDEO_DATA_FORMAT_INVALID = -1;
33 constexpr int32_t WIDTH_INVALID = 9999;
34 constexpr int32_t HEIGHT_INVALID = 9999;
35 constexpr double FPS = 30.0;
36 constexpr size_t DATA_LEN = 128;
37 
38 class MockIScreenSinkTransCallback : public IScreenSinkTransCallback {
39 public:
MockIScreenSinkTransCallback()40     explicit MockIScreenSinkTransCallback()
41     {
42     }
43     ~MockIScreenSinkTransCallback() override = default;
44 
OnError(int32_t err,const std::string & content)45     virtual void OnError(int32_t err, const std::string &content) override
46     {
47         (void) err;
48         (void) content;
49     }
50 };
51 
52 class MockIImageSinkProcessorListener : public IImageSinkProcessorListener {
53 public:
MockIImageSinkProcessorListener()54     explicit MockIImageSinkProcessorListener()
55     {
56     }
57     ~MockIImageSinkProcessorListener() override = default;
58 
OnProcessorStateNotify(int32_t state)59     virtual void OnProcessorStateNotify(int32_t state) override
60     {
61         (void) state;
62     }
63 };
64 
65 class MockIScreenSourceTransCallback : public IScreenSourceTransCallback {
66 public:
~MockIScreenSourceTransCallback()67     ~MockIScreenSourceTransCallback() override {};
68 
OnError(int32_t err,const std::string & content)69     virtual void OnError(int32_t err, const std::string &content) override
70     {
71         (void) err;
72         (void) content;
73     }
74 };
75 
76 class MockIScreenChannelListener : public IScreenChannelListener {
77 public:
OnSessionOpened()78     void OnSessionOpened() override {}
OnSessionClosed()79     void OnSessionClosed() override {}
OnDataReceived(const std::shared_ptr<DataBuffer> & data)80     void OnDataReceived(const std::shared_ptr<DataBuffer> &data) override {}
81 };
82 
83 class MockScreenDataChannelImpl : public IScreenChannel {
84 public:
CreateSession(const std::shared_ptr<IScreenChannelListener> & listener)85     int32_t CreateSession(const std::shared_ptr<IScreenChannelListener> &listener) override
86     {
87         return DH_SUCCESS;
88     }
ReleaseSession()89     int32_t ReleaseSession() override
90     {
91         return DH_SUCCESS;
92     }
OpenSession(const std::shared_ptr<IScreenChannelListener> listener)93     int32_t OpenSession(const std::shared_ptr<IScreenChannelListener> listener) override
94     {
95         return DH_SUCCESS;
96     }
CloseSession()97     int32_t CloseSession() override
98     {
99         return ERR_DH_SCREEN_TRANS_SESSION_NOT_OPEN;
100     }
SendData(const std::shared_ptr<DataBuffer> & data)101     int32_t SendData(const std::shared_ptr<DataBuffer> &data) override
102     {
103         (void) data;
104         return DH_SUCCESS;
105     }
SetJpegSessionFlag(bool flag)106     void SetJpegSessionFlag(bool flag) override
107     {
108         return;
109     }
110 };
111 
112 } // namespace DistributedHardware
113 } // namespace OHOS
114 #endif