1 /*
2 * Copyright (c) 2022-2024 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 #include "dinput_source_callback_unittest.h"
17
18 #include <memory>
19
20 #include "accesstoken_kit.h"
21 #include "dinput_errcode.h"
22 #include "dinput_ipc_interface_code.h"
23 #include "nativetoken_kit.h"
24 #include "token_setproc.h"
25 #include "softbus_common.h"
26
27 namespace OHOS {
28 namespace DistributedHardware {
29 namespace DistributedInput {
30 namespace {
31 const int32_t PERMISSION_ENABLE_INDEX = 0;
32 const int32_t PERMISSION_DATASYNC_INDEX = 1;
33 const int32_t PERMISSION_ACCESS_INDEX = 2;
34 const int32_t PERMISSION_NUMS = 3;
35 }
SetUp()36 void DInputSourceCallBackTest::SetUp()
37 {
38 uint64_t tokenId;
39 const char *perms[PERMISSION_NUMS];
40 perms[PERMISSION_ENABLE_INDEX] = "ohos.permission.ENABLE_DISTRIBUTED_HARDWARE";
41 perms[PERMISSION_DATASYNC_INDEX] = OHOS_PERMISSION_DISTRIBUTED_DATASYNC;
42 perms[PERMISSION_ACCESS_INDEX] = "ohos.permission.ACCESS_DISTRIBUTED_HARDWARE";
43 NativeTokenInfoParams infoInstance = {
44 .dcapsNum = 0,
45 .permsNum = PERMISSION_NUMS,
46 .aclsNum = 0,
47 .dcaps = NULL,
48 .perms = perms,
49 .acls = NULL,
50 .processName = "dinput",
51 .aplStr = "system_core",
52 };
53 tokenId = GetAccessTokenId(&infoInstance);
54 SetSelfTokenID(tokenId);
55 OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
56 }
57
TearDown()58 void DInputSourceCallBackTest::TearDown()
59 {
60 }
61
SetUpTestCase()62 void DInputSourceCallBackTest::SetUpTestCase()
63 {
64 }
65
TearDownTestCase()66 void DInputSourceCallBackTest::TearDownTestCase()
67 {
68 }
69
Init()70 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::Init()
71 {
72 return DH_SUCCESS;
73 }
74
Release()75 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::Release()
76 {
77 return DH_SUCCESS;
78 }
79
RegisterDistributedHardware(const std::string & devId,const std::string & dhId,const std::string & parameters,sptr<IRegisterDInputCallback> callback)80 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::RegisterDistributedHardware(
81 const std::string &devId, const std::string &dhId, const std::string ¶meters,
82 sptr<IRegisterDInputCallback> callback)
83 {
84 (void)devId;
85 (void)dhId;
86 (void)parameters;
87 (void)callback;
88 return DH_SUCCESS;
89 }
90
UnregisterDistributedHardware(const std::string & devId,const std::string & dhId,sptr<IUnregisterDInputCallback> callback)91 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::UnregisterDistributedHardware(
92 const std::string &devId, const std::string &dhId,
93 sptr<IUnregisterDInputCallback> callback)
94 {
95 (void)devId;
96 (void)dhId;
97 (void)callback;
98 return DH_SUCCESS;
99 }
100
PrepareRemoteInput(const std::string & deviceId,sptr<IPrepareDInputCallback> callback)101 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::PrepareRemoteInput(
102 const std::string &deviceId, sptr<IPrepareDInputCallback> callback)
103 {
104 (void)deviceId;
105 (void)callback;
106 return DH_SUCCESS;
107 }
108
UnprepareRemoteInput(const std::string & deviceId,sptr<IUnprepareDInputCallback> callback)109 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::UnprepareRemoteInput(
110 const std::string &deviceId, sptr<IUnprepareDInputCallback> callback)
111 {
112 (void)deviceId;
113 (void)callback;
114 return DH_SUCCESS;
115 }
116
StartRemoteInput(const std::string & deviceId,const uint32_t & inputTypes,sptr<IStartDInputCallback> callback)117 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::StartRemoteInput(
118 const std::string &deviceId, const uint32_t &inputTypes, sptr<IStartDInputCallback> callback)
119 {
120 (void)deviceId;
121 (void)inputTypes;
122 (void)callback;
123 return DH_SUCCESS;
124 }
125
StopRemoteInput(const std::string & deviceId,const uint32_t & inputTypes,sptr<IStopDInputCallback> callback)126 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::StopRemoteInput(
127 const std::string &deviceId, const uint32_t &inputTypes, sptr<IStopDInputCallback> callback)
128 {
129 (void)deviceId;
130 (void)inputTypes;
131 (void)callback;
132 return DH_SUCCESS;
133 }
134
StartRemoteInput(const std::string & srcId,const std::string & sinkId,const uint32_t & inputTypes,sptr<IStartDInputCallback> callback)135 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::StartRemoteInput(
136 const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes,
137 sptr<IStartDInputCallback> callback)
138 {
139 (void)srcId;
140 (void)sinkId;
141 (void)inputTypes;
142 (void)callback;
143 return DH_SUCCESS;
144 }
145
StopRemoteInput(const std::string & srcId,const std::string & sinkId,const uint32_t & inputTypes,sptr<IStopDInputCallback> callback)146 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::StopRemoteInput(
147 const std::string &srcId, const std::string &sinkId, const uint32_t &inputTypes,
148 sptr<IStopDInputCallback> callback)
149 {
150 (void)srcId;
151 (void)sinkId;
152 (void)inputTypes;
153 (void)callback;
154 return DH_SUCCESS;
155 }
156
PrepareRemoteInput(const std::string & srcId,const std::string & sinkId,sptr<IPrepareDInputCallback> callback)157 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::PrepareRemoteInput(
158 const std::string &srcId, const std::string &sinkId,
159 sptr<IPrepareDInputCallback> callback)
160 {
161 (void)srcId;
162 (void)sinkId;
163 (void)callback;
164 return DH_SUCCESS;
165 }
166
UnprepareRemoteInput(const std::string & srcId,const std::string & sinkId,sptr<IUnprepareDInputCallback> callback)167 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::UnprepareRemoteInput(
168 const std::string &srcId, const std::string &sinkId,
169 sptr<IUnprepareDInputCallback> callback)
170 {
171 (void)srcId;
172 (void)sinkId;
173 (void)callback;
174 return DH_SUCCESS;
175 }
176
StartRemoteInput(const std::string & sinkId,const std::vector<std::string> & dhIds,sptr<IStartStopDInputsCallback> callback)177 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::StartRemoteInput(
178 const std::string &sinkId, const std::vector<std::string> &dhIds,
179 sptr<IStartStopDInputsCallback> callback)
180 {
181 (void)sinkId;
182 (void)dhIds;
183 (void)callback;
184 return DH_SUCCESS;
185 }
186
StopRemoteInput(const std::string & sinkId,const std::vector<std::string> & dhIds,sptr<IStartStopDInputsCallback> callback)187 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::StopRemoteInput(
188 const std::string &sinkId, const std::vector<std::string> &dhIds,
189 sptr<IStartStopDInputsCallback> callback)
190 {
191 (void)sinkId;
192 (void)dhIds;
193 (void)callback;
194 return DH_SUCCESS;
195 }
196
StartRemoteInput(const std::string & srcId,const std::string & sinkId,const std::vector<std::string> & dhIds,sptr<IStartStopDInputsCallback> callback)197 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::StartRemoteInput(
198 const std::string &srcId, const std::string &sinkId,
199 const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback)
200 {
201 (void)srcId;
202 (void)sinkId;
203 (void)dhIds;
204 (void)callback;
205 return DH_SUCCESS;
206 }
207
StopRemoteInput(const std::string & srcId,const std::string & sinkId,const std::vector<std::string> & dhIds,sptr<IStartStopDInputsCallback> callback)208 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::StopRemoteInput(
209 const std::string &srcId, const std::string &sinkId,
210 const std::vector<std::string> &dhIds, sptr<IStartStopDInputsCallback> callback)
211 {
212 (void)srcId;
213 (void)sinkId;
214 (void)dhIds;
215 (void)callback;
216 return DH_SUCCESS;
217 }
218
RegisterAddWhiteListCallback(sptr<IAddWhiteListInfosCallback> addWhiteListCallback)219 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::RegisterAddWhiteListCallback(
220 sptr<IAddWhiteListInfosCallback> addWhiteListCallback)
221 {
222 (void)addWhiteListCallback;
223 return DH_SUCCESS;
224 }
225
RegisterDelWhiteListCallback(sptr<IDelWhiteListInfosCallback> delWhiteListCallback)226 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::RegisterDelWhiteListCallback(
227 sptr<IDelWhiteListInfosCallback> delWhiteListCallback)
228 {
229 (void)delWhiteListCallback;
230 return DH_SUCCESS;
231 }
232
RegisterSimulationEventListener(sptr<ISimulationEventListener> listener)233 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::RegisterSimulationEventListener(
234 sptr<ISimulationEventListener> listener)
235 {
236 (void)listener;
237 return DH_SUCCESS;
238 }
239
UnregisterSimulationEventListener(sptr<ISimulationEventListener> listener)240 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::UnregisterSimulationEventListener(
241 sptr<ISimulationEventListener> listener)
242 {
243 (void)listener;
244 return DH_SUCCESS;
245 }
246
RegisterSessionStateCb(sptr<ISessionStateCallback> callback)247 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::RegisterSessionStateCb(
248 sptr<ISessionStateCallback> callback)
249 {
250 (void)callback;
251 return DH_SUCCESS;
252 }
253
UnregisterSessionStateCb()254 int32_t DInputSourceCallBackTest::TestDInputSourceCallBackStub::UnregisterSessionStateCb()
255 {
256 return DH_SUCCESS;
257 }
258
OnResult(const std::string & deviceId,const std::string & strJson)259 void DInputSourceCallBackTest::TestDInputSourceCallBackStub::OnResult(const std::string &deviceId,
260 const std::string &strJson)
261 {
262 deviceId_ = deviceId;
263 strJson_ = strJson;
264 }
265
OnResult(const std::string & devId,const std::string & dhId,const int32_t & status)266 void DInputSourceCallBackTest::TestDInputRegisterCallBack::OnResult(const std::string &devId,
267 const std::string &dhId, const int32_t &status)
268 {
269 (void)devId;
270 (void)dhId;
271 (void)status;
272 return;
273 }
274
OnResult(const std::string & devId,const std::string & dhId,const int32_t & status)275 void DInputSourceCallBackTest::TestDInputUnregisterCallBack::OnResult(const std::string &devId,
276 const std::string &dhId, const int32_t &status)
277 {
278 (void)devId;
279 (void)dhId;
280 (void)status;
281 return;
282 }
283
OnResult(const std::string & deviceId,const int32_t & status)284 void DInputSourceCallBackTest::TestDInputPrepareCallBack::OnResult(
285 const std::string &deviceId, const int32_t &status)
286 {
287 (void)deviceId;
288 (void)status;
289 return;
290 }
291
OnResult(const std::string & deviceId,const int32_t & status)292 void DInputSourceCallBackTest::TestDInputUnprepareCallBack::OnResult(
293 const std::string &deviceId, const int32_t &status)
294 {
295 (void)deviceId;
296 (void)status;
297 return;
298 }
299
OnResult(const std::string & deviceId,const uint32_t & inputTypes,const int32_t & status)300 void DInputSourceCallBackTest::TestDInputStartCallBack::OnResult(
301 const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status)
302 {
303 (void)deviceId;
304 (void)inputTypes;
305 (void)status;
306 return;
307 }
308
OnResult(const std::string & deviceId,const uint32_t & inputTypes,const int32_t & status)309 void DInputSourceCallBackTest::TestDInputStopCallBack::OnResult(
310 const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status)
311 {
312 (void)deviceId;
313 (void)inputTypes;
314 (void)status;
315 return;
316 }
317
OnResultDhids(const std::string & devId,const int32_t & status)318 void DInputSourceCallBackTest::TestVectorStartStopCallBackStub::OnResultDhids(const std::string &devId,
319 const int32_t &status)
320 {
321 (void)devId;
322 (void)status;
323 return;
324 }
325
OnResult(const std::string & deviceId,const std::string & strJson)326 void DInputSourceCallBackTest::TestAddWhiteListInfosCallBack::OnResult(
327 const std::string &deviceId, const std::string &strJson)
328 {
329 (void)deviceId;
330 (void)strJson;
331 return;
332 }
333
OnResult(const std::string & deviceId)334 void DInputSourceCallBackTest::TestDelWhiteListInfosCallBack::OnResult(
335 const std::string &deviceId)
336 {
337 (void)deviceId;
338 return;
339 }
340
OnNodeOnLine(const std::string & srcDevId,const std::string & sinkDevId,const std::string & sinkNodeId,const std::string & sinkNodeDesc)341 void DInputSourceCallBackTest::TestDInputNodeListenerCallBack::OnNodeOnLine(const std::string &srcDevId,
342 const std::string &sinkDevId, const std::string &sinkNodeId, const std::string &sinkNodeDesc)
343 {
344 (void)srcDevId;
345 (void)sinkDevId;
346 (void)sinkNodeId;
347 (void)sinkNodeDesc;
348 return;
349 }
350
OnNodeOffLine(const std::string & srcDevId,const std::string & sinkDevId,const std::string & sinkNodeId)351 void DInputSourceCallBackTest::TestDInputNodeListenerCallBack::OnNodeOffLine(const std::string &srcDevId,
352 const std::string &sinkDevId, const std::string &sinkNodeId)
353 {
354 (void)srcDevId;
355 (void)sinkDevId;
356 (void)sinkNodeId;
357 return;
358 }
359
OnSimulationEvent(uint32_t type,uint32_t code,int32_t value)360 int32_t DInputSourceCallBackTest::TestDInputSimulationEventCallBack::OnSimulationEvent(uint32_t type, uint32_t code,
361 int32_t value)
362 {
363 (void)type;
364 (void)code;
365 (void)value;
366 return DH_SUCCESS;
367 }
368
369 HWTEST_F(DInputSourceCallBackTest, SendRequest01, testing::ext::TestSize.Level1)
370 {
371 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
372 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
373 IDInputSourceInterfaceCode code = IDInputSourceInterfaceCode::INIT;
374 MessageParcel data;
375 MessageParcel reply;
376 bool ret = callBackProxy.SendRequest(static_cast<uint32_t>(code), data, reply);
377 EXPECT_EQ(false, ret);
378 }
379
380 HWTEST_F(DInputSourceCallBackTest, Init01, testing::ext::TestSize.Level1)
381 {
382 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
383 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
384 int32_t ret = callBackProxy.Init();
385 EXPECT_EQ(DH_SUCCESS, ret);
386 }
387
388 HWTEST_F(DInputSourceCallBackTest, Release01, testing::ext::TestSize.Level1)
389 {
390 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
391 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
392 int32_t ret = callBackProxy.Release();
393 EXPECT_EQ(DH_SUCCESS, ret);
394 }
395
396 HWTEST_F(DInputSourceCallBackTest, RegisterDistributedHardware01, testing::ext::TestSize.Level1)
397 {
398 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
399 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
400 const std::string devId = "d6f4s6d4f6";
401 const std::string dhId = "Input_sd4f4s5d4f5s4";
402 const std::string parameters = "d4a6s5d46asd";
403 sptr<IRegisterDInputCallback> callback(new TestDInputRegisterCallBack());
404 int32_t ret = callBackProxy.RegisterDistributedHardware(devId, dhId, parameters, callback);
405 EXPECT_EQ(DH_SUCCESS, ret);
406 }
407
408 HWTEST_F(DInputSourceCallBackTest, UnregisterDistributedHardware01, testing::ext::TestSize.Level1)
409 {
410 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
411 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
412 const std::string devId = "d6f4s6d4f6";
413 const std::string dhId = "Input_sd4f4s5d4f5s4";
414 sptr<TestDInputUnregisterCallBack> callback(new TestDInputUnregisterCallBack());
415 int32_t ret = callBackProxy.UnregisterDistributedHardware(devId, dhId, callback);
416 EXPECT_EQ(DH_SUCCESS, ret);
417 }
418
419 HWTEST_F(DInputSourceCallBackTest, PrepareRemoteInput01, testing::ext::TestSize.Level1)
420 {
421 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
422 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
423 const std::string devId = "d6f4s6d4f6";
424 sptr<TestDInputPrepareCallBack> callback(new TestDInputPrepareCallBack());
425 int32_t ret = callBackProxy.PrepareRemoteInput(devId, callback);
426 EXPECT_EQ(DH_SUCCESS, ret);
427 }
428
429 HWTEST_F(DInputSourceCallBackTest, PrepareRemoteInput02, testing::ext::TestSize.Level1)
430 {
431 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
432 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
433 const std::string srcId = "d6f4s6d4f6";
434 const std::string sinkId = "5sd45s4d5s4d5";
435 sptr<TestDInputPrepareCallBack> callback(new TestDInputPrepareCallBack());
436 int32_t ret = callBackProxy.PrepareRemoteInput(srcId, sinkId, callback);
437 EXPECT_EQ(DH_SUCCESS, ret);
438 }
439
440 HWTEST_F(DInputSourceCallBackTest, UnprepareRemoteInput01, testing::ext::TestSize.Level1)
441 {
442 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
443 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
444 const std::string devId = "d6f4s6d4f6";
445 sptr<TestDInputUnprepareCallBack> callback(new TestDInputUnprepareCallBack());
446 int32_t ret = callBackProxy.UnprepareRemoteInput(devId, callback);
447 EXPECT_EQ(DH_SUCCESS, ret);
448 }
449
450 HWTEST_F(DInputSourceCallBackTest, UnprepareRemoteInput02, testing::ext::TestSize.Level1)
451 {
452 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
453 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
454 const std::string srcId = "d6f4s6d4f6";
455 const std::string sinkId = "5sd45s4d5s4d5";
456 sptr<TestDInputUnprepareCallBack> callback(new TestDInputUnprepareCallBack());
457 int32_t ret = callBackProxy.UnprepareRemoteInput(srcId, sinkId, callback);
458 EXPECT_EQ(DH_SUCCESS, ret);
459 }
460
461 HWTEST_F(DInputSourceCallBackTest, StartRemoteInput01, testing::ext::TestSize.Level1)
462 {
463 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
464 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
465 const std::string devId = "d6f4s6d4f6";
466 uint32_t inputTypes = 1;
467 sptr<TestDInputStartCallBack> callback(new TestDInputStartCallBack());
468 int32_t ret = callBackProxy.StartRemoteInput(devId, inputTypes, callback);
469 EXPECT_EQ(DH_SUCCESS, ret);
470 }
471
472 HWTEST_F(DInputSourceCallBackTest, StartRemoteInput02, testing::ext::TestSize.Level1)
473 {
474 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
475 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
476 const std::string srcId = "d6f4s6d4f6";
477 const std::string sinkId = "5sd45s4d5s4d5";
478 uint32_t inputTypes = 1;
479 sptr<TestDInputStartCallBack> callback(new TestDInputStartCallBack());
480 int32_t ret = callBackProxy.StartRemoteInput(srcId, sinkId, inputTypes, callback);
481 EXPECT_EQ(DH_SUCCESS, ret);
482 }
483
484 HWTEST_F(DInputSourceCallBackTest, StartRemoteInput03, testing::ext::TestSize.Level1)
485 {
486 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
487 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
488 const std::string sinkId = "d6f4s6d4f6";
489 std::vector<std::string> dhIds;
490 dhIds.push_back("Input_6ds54f6sd4f65sd4fsdf4s");
491 sptr<TestVectorStartStopCallBackStub> callback(new TestVectorStartStopCallBackStub());
492 int32_t ret = callBackProxy.StartRemoteInput(sinkId, dhIds, callback);
493 EXPECT_EQ(DH_SUCCESS, ret);
494 }
495
496 HWTEST_F(DInputSourceCallBackTest, StartRemoteInput04, testing::ext::TestSize.Level1)
497 {
498 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
499 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
500 const std::string srcId = "d6f4s6d4f6";
501 const std::string sinkId = "5sd45s4d5s4d5";
502 std::vector<std::string> dhIds;
503 dhIds.push_back("Input_6ds54f6sd4f65sd4fsdf4s");
504 sptr<TestVectorStartStopCallBackStub> callback(new TestVectorStartStopCallBackStub());
505 int32_t ret = callBackProxy.StartRemoteInput(srcId, sinkId, dhIds, callback);
506 EXPECT_EQ(DH_SUCCESS, ret);
507 }
508
509 HWTEST_F(DInputSourceCallBackTest, StopRemoteInput01, testing::ext::TestSize.Level1)
510 {
511 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
512 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
513 const std::string devId = "d6f4s6d4f6";
514 uint32_t inputTypes = 1;
515 sptr<TestDInputStopCallBack> callback(new TestDInputStopCallBack());
516 int32_t ret = callBackProxy.StopRemoteInput(devId, inputTypes, callback);
517 EXPECT_EQ(DH_SUCCESS, ret);
518 }
519
520 HWTEST_F(DInputSourceCallBackTest, StopRemoteInput02, testing::ext::TestSize.Level1)
521 {
522 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
523 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
524 const std::string srcId = "d6f4s6d4f6";
525 const std::string sinkId = "5sd45s4d5s4d5";
526 uint32_t inputTypes = 1;
527 sptr<TestDInputStopCallBack> callback(new TestDInputStopCallBack());
528 int32_t ret = callBackProxy.StopRemoteInput(srcId, sinkId, inputTypes, callback);
529 EXPECT_EQ(DH_SUCCESS, ret);
530 }
531
532 HWTEST_F(DInputSourceCallBackTest, StopRemoteInput03, testing::ext::TestSize.Level1)
533 {
534 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
535 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
536 const std::string sinkId = "d6f4s6d4f6";
537 std::vector<std::string> dhIds;
538 dhIds.push_back("Input_6ds54f6sd4f65sd4fsdf4s");
539 sptr<TestVectorStartStopCallBackStub> callback(new TestVectorStartStopCallBackStub());
540 int32_t ret = callBackProxy.StopRemoteInput(sinkId, dhIds, callback);
541 EXPECT_EQ(DH_SUCCESS, ret);
542 }
543
544 HWTEST_F(DInputSourceCallBackTest, StopRemoteInput04, testing::ext::TestSize.Level1)
545 {
546 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
547 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
548 const std::string srcId = "d6f4s6d4f6";
549 const std::string sinkId = "5sd45s4d5s4d5";
550 std::vector<std::string> dhIds;
551 dhIds.push_back("Input_6ds54f6sd4f65sd4fsdf4s");
552 sptr<TestVectorStartStopCallBackStub> callback(new TestVectorStartStopCallBackStub());
553 int32_t ret = callBackProxy.StopRemoteInput(srcId, sinkId, dhIds, callback);
554 EXPECT_EQ(DH_SUCCESS, ret);
555 }
556
557 HWTEST_F(DInputSourceCallBackTest, RegisterAddWhiteListCallback01, testing::ext::TestSize.Level1)
558 {
559 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
560 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
561 sptr<TestAddWhiteListInfosCallBack> callback(new TestAddWhiteListInfosCallBack());
562 int32_t ret = callBackProxy.RegisterAddWhiteListCallback(callback);
563 EXPECT_EQ(DH_SUCCESS, ret);
564 }
565
566 HWTEST_F(DInputSourceCallBackTest, RegisterDelWhiteListCallback01, testing::ext::TestSize.Level1)
567 {
568 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
569 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
570 sptr<TestDelWhiteListInfosCallBack> callback(new TestDelWhiteListInfosCallBack());
571 int32_t ret = callBackProxy.RegisterDelWhiteListCallback(callback);
572 EXPECT_EQ(DH_SUCCESS, ret);
573 }
574
575 HWTEST_F(DInputSourceCallBackTest, RegisterSimulationEventListener01, testing::ext::TestSize.Level1)
576 {
577 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
578 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
579 sptr<TestDInputSimulationEventCallBack> listener(new TestDInputSimulationEventCallBack());
580 int32_t ret = callBackProxy.RegisterSimulationEventListener(listener);
581 EXPECT_EQ(DH_SUCCESS, ret);
582 }
583
584 HWTEST_F(DInputSourceCallBackTest, UnregisterSimulationEventListener01, testing::ext::TestSize.Level1)
585 {
586 sptr<IRemoteObject> callBackStubPtr(new TestDInputSourceCallBackStub());
587 DistributedInputSourceProxy callBackProxy(callBackStubPtr);
588 sptr<TestDInputSimulationEventCallBack> listener(new TestDInputSimulationEventCallBack());
589 int32_t ret = callBackProxy.UnregisterSimulationEventListener(listener);
590 EXPECT_EQ(DH_SUCCESS, ret);
591 }
592 } // namespace DistributedInput
593 } // namespace DistributedHardware
594 } // namespace OHOS