• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 DINPUT_SOURCE_CALLBACK_TEST_H
17 #define DINPUT_SOURCE_CALLBACK_TEST_H
18 
19 #include <gtest/gtest.h>
20 
21 #include "add_white_list_infos_call_back_stub.h"
22 #include "constants_dinput.h"
23 #include "del_white_list_infos_call_back_stub.h"
24 #include "distributed_input_source_proxy.h"
25 #include "distributed_input_source_stub.h"
26 #include "input_node_listener_stub.h"
27 #include "prepare_d_input_call_back_stub.h"
28 #include "register_d_input_call_back_stub.h"
29 #include "start_d_input_call_back_stub.h"
30 #include "stop_d_input_call_back_stub.h"
31 #include "unprepare_d_input_call_back_stub.h"
32 #include "unregister_d_input_call_back_stub.h"
33 #include "start_stop_d_inputs_call_back_stub.h"
34 #include "start_stop_result_call_back_stub.h"
35 #include "simulation_event_listener_stub.h"
36 
37 namespace OHOS {
38 namespace DistributedHardware {
39 namespace DistributedInput {
40 class DInputSourceCallBackTest : public testing::Test {
41 public:
42     static void SetUpTestCase();
43     static void TearDownTestCase();
44     void SetUp() override;
45     void TearDown() override;
46 
47     class TestDInputSourceCallBackStub : public
48         OHOS::DistributedHardware::DistributedInput::DistributedInputSourceStub {
49     public:
50         TestDInputSourceCallBackStub() = default;
51         virtual ~TestDInputSourceCallBackStub() = default;
52         int32_t Init();
53 
54         int32_t Release() ;
55 
56         int32_t RegisterDistributedHardware(
57             const std::string &devId, const std::string &dhId, const std::string &parameters,
58             sptr<IRegisterDInputCallback> callback);
59 
60         int32_t UnregisterDistributedHardware(
61             const std::string &devId, const std::string &dhId,
62             sptr<IUnregisterDInputCallback> callback);
63 
64         int32_t PrepareRemoteInput(const std::string &deviceId, sptr<IPrepareDInputCallback> callback);
65 
66         int32_t UnprepareRemoteInput(const std::string &deviceId, sptr<IUnprepareDInputCallback> callback);
67 
68         int32_t StartRemoteInput(
69             const std::string &deviceId, const uint32_t &inputTypes, sptr<IStartDInputCallback> callback);
70 
71         int32_t StopRemoteInput(
72             const std::string &deviceId, const uint32_t &inputTypes, sptr<IStopDInputCallback> callback);
73 
74         int32_t StartRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes,
75             sptr<IStartDInputCallback> callback);
76 
77         int32_t StopRemoteInput(const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes,
78             sptr<IStopDInputCallback> callback);
79 
80         int32_t PrepareRemoteInput(const std::string &srcId, const std::string &sinkId,
81             sptr<IPrepareDInputCallback> callback);
82 
83         int32_t UnprepareRemoteInput(const std::string &srcId, const std::string &sinkId,
84             sptr<IUnprepareDInputCallback> callback);
85 
86         int32_t StartRemoteInput(const std::string &sinkId, const std::vector<std::string> &dhIds,
87             sptr<IStartStopDInputsCallback> callback);
88 
89         int32_t StopRemoteInput(const std::string &sinkId, const std::vector<std::string> &dhIds,
90             sptr<IStartStopDInputsCallback> callback);
91 
92         int32_t StartRemoteInput(const std::string &srcId, const std::string &sinkId,
93             const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback);
94 
95         int32_t StopRemoteInput(const std::string &srcId, const std::string &sinkId,
96             const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback);
97 
98         int32_t RegisterAddWhiteListCallback(sptr<IAddWhiteListInfosCallback> addWhiteListCallback);
99         int32_t RegisterDelWhiteListCallback(sptr<IDelWhiteListInfosCallback> delWhiteListCallback);
100         int32_t RegisterInputNodeListener(sptr<InputNodeListener> listener);
101         int32_t UnregisterInputNodeListener(sptr<InputNodeListener> listener);
102 
103         int32_t SyncNodeInfoRemoteInput(const std::string &userDevId, const std::string &dhid,
104             const std::string &nodeDesc);
105         int32_t RegisterSimulationEventListener(sptr<ISimulationEventListener> listener);
106         int32_t UnregisterSimulationEventListener(sptr<ISimulationEventListener> listener);
107         void OnResult(const std::string &deviceId, const std::string &strJson);
108         std::string deviceId_;
109         std::string strJson_;
110     };
111 
112     class TestDInputRegisterCallBack : public
113         OHOS::DistributedHardware::DistributedInput::RegisterDInputCallbackStub {
114     public:
115         TestDInputRegisterCallBack() = default;
116         virtual ~TestDInputRegisterCallBack() = default;
117         void OnResult(const std::string &devId, const std::string &dhId, const int32_t &status);
118     };
119 
120     class TestDInputUnregisterCallBack : public
121         OHOS::DistributedHardware::DistributedInput::UnregisterDInputCallbackStub {
122     public:
123         TestDInputUnregisterCallBack() = default;
124         virtual ~TestDInputUnregisterCallBack() = default;
125         void OnResult(const std::string &devId, const std::string &dhId, const int32_t &status);
126     };
127 
128     class TestDInputPrepareCallBack : public
129         OHOS::DistributedHardware::DistributedInput::PrepareDInputCallbackStub {
130     public:
131         TestDInputPrepareCallBack() = default;
132         virtual ~TestDInputPrepareCallBack() = default;
133         void OnResult(const std::string &deviceId, const int32_t &status);
134     };
135 
136     class TestDInputUnprepareCallBack : public
137         OHOS::DistributedHardware::DistributedInput::UnprepareDInputCallbackStub {
138     public:
139         TestDInputUnprepareCallBack() = default;
140         virtual ~TestDInputUnprepareCallBack() = default;
141         void OnResult(const std::string &deviceId, const int32_t &status);
142     };
143 
144     class TestDInputStartCallBack : public
145         OHOS::DistributedHardware::DistributedInput::StartDInputCallbackStub {
146     public:
147         TestDInputStartCallBack() = default;
148         virtual ~TestDInputStartCallBack() = default;
149         void OnResult(const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status);
150     };
151 
152     class TestDInputStopCallBack : public
153         OHOS::DistributedHardware::DistributedInput::StopDInputCallbackStub {
154     public:
155         TestDInputStopCallBack() = default;
156         virtual ~TestDInputStopCallBack() = default;
157         void OnResult(const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status);
158     };
159 
160     class TestVectorStartStopCallBackStub
161         : public OHOS::DistributedHardware::DistributedInput::StartStopDInputsCallbackStub {
162     public:
163         TestVectorStartStopCallBackStub() = default;
164         virtual ~TestVectorStartStopCallBackStub() = default;
165         void OnResultDhids(const std::string &devId, const int32_t &status);
166     };
167 
168     class TestAddWhiteListInfosCallBack : public
169         OHOS::DistributedHardware::DistributedInput::AddWhiteListInfosCallbackStub {
170     public:
171         TestAddWhiteListInfosCallBack() = default;
172         virtual ~TestAddWhiteListInfosCallBack() = default;
173         void OnResult(const std::string &deviceId, const std::string &strJson);
174     };
175 
176     class TestDelWhiteListInfosCallBack : public
177         OHOS::DistributedHardware::DistributedInput::DelWhiteListInfosCallbackStub {
178     public:
179         TestDelWhiteListInfosCallBack() = default;
180         virtual ~TestDelWhiteListInfosCallBack() = default;
181         void OnResult(const std::string &deviceId);
182     };
183 
184     class TestDInputNodeListenerCallBack : public
185         OHOS::DistributedHardware::DistributedInput::InputNodeListenerStub {
186     public:
187         TestDInputNodeListenerCallBack() = default;
188         virtual ~TestDInputNodeListenerCallBack() = default;
189         void OnNodeOnLine(const std::string srcDevId, const std::string sinkDevId,
190             const std::string sinkNodeId, const std::string sinkNodeDesc);
191 
192         void OnNodeOffLine(const std::string srcDevId, const std::string sinkDevId,
193             const std::string sinkNodeId);
194     };
195 
196     class TestDInputSimulationEventCallBack : public
197         OHOS::DistributedHardware::DistributedInput::SimulationEventListenerStub {
198     public:
199         TestDInputSimulationEventCallBack() = default;
200         virtual ~TestDInputSimulationEventCallBack() = default;
201         int32_t OnSimulationEvent(uint32_t type, uint32_t code, int32_t value);
202     };
203 };
204 } // namespace DistributedInput
205 } // namespace DistributedHardware
206 } // namespace OHOS
207 #endif // DINPUT_SOURCE_CALLBACK_TEST_H