1 /*
2  * Copyright (c) 2021-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 "distributed_input_sourcemanager_test.h"
17 
18 #include <cstdlib>
19 #include <fcntl.h>
20 #include <iostream>
21 #include <thread>
22 #include <unistd.h>
23 
24 #include <linux/input.h>
25 
26 #include "event_handler.h"
27 #include "if_system_ability_manager.h"
28 #include "iservice_registry.h"
29 #include "nlohmann/json.hpp"
30 #include "system_ability_definition.h"
31 
32 #include "dinput_errcode.h"
33 #include "distributed_input_inject.h"
34 #include "distributed_input_source_transport.h"
35 #include "distributed_input_transport_base.h"
36 #include "dinput_utils_tool.h"
37 
38 using namespace testing::ext;
39 using namespace OHOS::DistributedHardware::DistributedInput;
40 using namespace std;
41 namespace OHOS {
42 namespace DistributedHardware {
43 namespace DistributedInput {
44 namespace {
45     const uint32_t INPUTTYPE = static_cast<uint32_t>(DInputDeviceType::ALL);
46     const uint32_t INPUTTYPE_MOUSE = static_cast<uint32_t>(DInputDeviceType::MOUSE);
47 }
48 
SetUp()49 void DistributedInputSourceManagerTest::SetUp()
50 {
51     sourceManager_ = new DistributedInputSourceManager(DISTRIBUTED_HARDWARE_INPUT_SOURCE_SA_ID, true);
52     statuslistener_ = std::make_shared<DInputSourceListener>(sourceManager_);
53     DistributedInputSourceManagerTest::RegisterSourceRespCallback(statuslistener_);
54 }
55 
TearDown()56 void DistributedInputSourceManagerTest::TearDown()
57 {
58 }
59 
SetUpTestCase()60 void DistributedInputSourceManagerTest::SetUpTestCase()
61 {
62 }
63 
TearDownTestCase()64 void DistributedInputSourceManagerTest::TearDownTestCase()
65 {
66 }
67 
RegisterSourceRespCallback(std::shared_ptr<DInputSourceTransCallback> callback)68 void DistributedInputSourceManagerTest::RegisterSourceRespCallback(std::shared_ptr<DInputSourceTransCallback> callback)
69 {
70     callback_ = callback;
71     return;
72 }
73 
OnResult(const std::string & devId,const std::string & dhId,const int32_t & status)74 void DistributedInputSourceManagerTest::TestRegisterDInputCb::OnResult(
75     const std::string &devId, const std::string &dhId, const int32_t &status)
76 {
77     (void)devId;
78     (void)dhId;
79     (void)status;
80     return;
81 }
82 
OnResult(const std::string & devId,const std::string & dhId,const int32_t & status)83 void DistributedInputSourceManagerTest::TestUnregisterDInputCb::OnResult(
84     const std::string &devId, const std::string &dhId, const int32_t &status)
85 {
86     (void)devId;
87     (void)dhId;
88     (void)status;
89     return;
90 }
91 
OnResult(const std::string & deviceId,const int32_t & status)92 void DistributedInputSourceManagerTest::TestPrepareDInputCallback::OnResult(
93     const std::string &deviceId, const int32_t &status)
94 {
95     (void)deviceId;
96     (void)status;
97     return;
98 }
99 
OnResult(const std::string & deviceId,const int32_t & status)100 void DistributedInputSourceManagerTest::TestUnprepareDInputCallback::OnResult(
101     const std::string &deviceId, const int32_t &status)
102 {
103     (void)deviceId;
104     (void)status;
105     return;
106 }
107 
OnResult(const std::string & deviceId,const uint32_t & inputTypes,const int32_t & status)108 void DistributedInputSourceManagerTest::TestStartDInputCallback::OnResult(
109     const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status)
110 {
111     (void)deviceId;
112     (void)inputTypes;
113     (void)status;
114     return;
115 }
116 
OnResult(const std::string & deviceId,const uint32_t & inputTypes,const int32_t & status)117 void DistributedInputSourceManagerTest::TestStopDInputCallback::OnResult(
118     const std::string &deviceId, const uint32_t &inputTypes, const int32_t &status)
119 {
120     (void)deviceId;
121     (void)inputTypes;
122     (void)status;
123     return;
124 }
125 
OnResultDhids(const std::string & devId,const int32_t & status)126 void DistributedInputSourceManagerTest::TestStartStopVectorCallbackStub::OnResultDhids(const std::string &devId,
127     const int32_t &status)
128 {
129     (void)devId;
130     (void)status;
131     return;
132 }
133 
OnResult(const std::string & deviceId,const std::string & strJson)134 void DistributedInputSourceManagerTest::TestAddWhiteListInfosCb::OnResult(
135     const std::string &deviceId, const std::string &strJson)
136 {
137     (void)deviceId;
138     (void)strJson;
139     return;
140 }
141 
OnResult(const std::string & deviceId)142 void DistributedInputSourceManagerTest::TestDelWhiteListInfosCb::OnResult(
143     const std::string &deviceId)
144 {
145     (void)deviceId;
146     return;
147 }
148 
OnStart(const std::string & srcId,const std::string & sinkId,std::vector<std::string> & devData)149 void DistributedInputSourceManagerTest::TestStartStopResultCb::OnStart(const std::string &srcId,
150     const std::string &sinkId, std::vector<std::string> &devData)
151 {
152     (void)srcId;
153     (void)sinkId;
154     (void)devData;
155     return;
156 }
157 
OnStop(const std::string & srcId,const std::string & sinkId,std::vector<std::string> & devData)158 void DistributedInputSourceManagerTest::TestStartStopResultCb::OnStop(const std::string &srcId,
159     const std::string &sinkId, std::vector<std::string> &devData)
160 {
161     (void)srcId;
162     (void)sinkId;
163     (void)devData;
164     return;
165 }
166 
OnNodeOnLine(const std::string & srcDevId,const std::string & sinkDevId,const std::string & sinkNodeId,const std::string & sinkNodeDesc)167 void DistributedInputSourceManagerTest::TestInputNodeListenerCb::OnNodeOnLine(const std::string &srcDevId,
168     const std::string &sinkDevId, const std::string &sinkNodeId, const std::string &sinkNodeDesc)
169 {
170     (void)srcDevId;
171     (void)sinkDevId;
172     (void)sinkNodeId;
173     (void)sinkNodeDesc;
174     return;
175 }
176 
OnNodeOffLine(const std::string & srcDevId,const std::string & sinkDevId,const std::string & sinkNodeId)177 void DistributedInputSourceManagerTest::TestInputNodeListenerCb::OnNodeOffLine(const std::string &srcDevId,
178     const std::string &sinkDevId, const std::string &sinkNodeId)
179 {
180     (void)srcDevId;
181     (void)sinkDevId;
182     (void)sinkNodeId;
183     return;
184 }
185 
OnSimulationEvent(uint32_t type,uint32_t code,int32_t value)186 int32_t DistributedInputSourceManagerTest::TestSimulationEventCb::OnSimulationEvent(uint32_t type, uint32_t code,
187     int32_t value)
188 {
189     (void)type;
190     (void)code;
191     (void)value;
192     return DH_SUCCESS;
193 }
194 
OnResultDhids(const std::string & devId,const int32_t & status)195 void DistributedInputSourceManagerTest::TestStartStopDInputsCb::OnResultDhids(const std::string &devId,
196     const int32_t &status)
197 {
198     (void)devId;
199     (void)status;
200     return;
201 }
202 
StructTransJson(const InputDevice & pBuf,std::string & strDescriptor) const203 int32_t DistributedInputSourceManagerTest::StructTransJson(const InputDevice &pBuf, std::string &strDescriptor) const
204 {
205     nlohmann::json tmpJson;
206     tmpJson["name"] = pBuf.name;
207     tmpJson["physicalPath"] = pBuf.physicalPath;
208     tmpJson["uniqueId"] = pBuf.uniqueId;
209     tmpJson["bus"] = pBuf.bus;
210     tmpJson["vendor"] = pBuf.vendor;
211     tmpJson["product"] = pBuf.product;
212     tmpJson["version"] = pBuf.version;
213     tmpJson["descriptor"] = pBuf.descriptor;
214     tmpJson["classes"] = pBuf.classes;
215 
216     std::ostringstream stream;
217     stream << tmpJson.dump();
218     strDescriptor = stream.str();
219     return DH_SUCCESS;
220 }
221 
222 HWTEST_F(DistributedInputSourceManagerTest, OnStart_01, testing::ext::TestSize.Level1)
223 {
224     sourceManager_->serviceRunningState_ = ServiceSourceRunningState::STATE_RUNNING;
225     sourceManager_->OnStart();
226     EXPECT_EQ(0, sourceManager_->inputDevice_.size());
227 
228     sourceManager_->serviceRunningState_ = ServiceSourceRunningState::STATE_NOT_START;
229     sourceManager_->OnStart();
230     EXPECT_EQ(0, sourceManager_->inputDevice_.size());
231 }
232 
233 HWTEST_F(DistributedInputSourceManagerTest, Init01, testing::ext::TestSize.Level0)
234 {
235     int32_t ret = sourceManager_->Init();
236     EXPECT_EQ(DH_SUCCESS, ret);
237 }
238 
239 HWTEST_F(DistributedInputSourceManagerTest, CheckRegisterParam_01, testing::ext::TestSize.Level1)
240 {
241     sourceManager_->UnregisterDHFwkPublisher();
242 
243     sourceManager_->startDScreenListener_ = nullptr;
244     sourceManager_->stopDScreenListener_ = nullptr;
245     sourceManager_->deviceOfflineListener_ = nullptr;
246     sourceManager_->UnregisterDHFwkPublisher();
247 
248     std::string devId = "";
249     std::string dhId = "";
250     std::string parameters = "";
251     sptr<IRegisterDInputCallback> callback = nullptr;
252     bool ret = sourceManager_->CheckRegisterParam(devId, dhId, parameters, callback);
253     EXPECT_EQ(false, ret);
254     std::string devcieId(DEV_ID_LENGTH_MAX + 1, 'a');
255     ret = sourceManager_->CheckRegisterParam(devcieId, dhId, parameters, callback);
256     EXPECT_EQ(false, ret);
257 }
258 
259 HWTEST_F(DistributedInputSourceManagerTest, CheckRegisterParam_02, testing::ext::TestSize.Level1)
260 {
261     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
262     std::string dhId = "";
263     std::string parameters = "";
264     sptr<IRegisterDInputCallback> callback = nullptr;
265     bool ret = sourceManager_->CheckRegisterParam(devId, dhId, parameters, callback);
266     EXPECT_EQ(false, ret);
267     std::string dhIds(DEV_ID_LENGTH_MAX + 1, 'a');
268     ret = sourceManager_->CheckRegisterParam(devId, dhIds, parameters, callback);
269     EXPECT_EQ(false, ret);
270 }
271 
272 HWTEST_F(DistributedInputSourceManagerTest, CheckRegisterParam_03, testing::ext::TestSize.Level1)
273 {
274     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
275     std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8";
276     std::string parameters = "";
277     sptr<IRegisterDInputCallback> callback = nullptr;
278     bool ret = sourceManager_->CheckRegisterParam(devId, dhId, parameters, callback);
279     EXPECT_EQ(false, ret);
280     parameters = "parameters_test";
281     ret = sourceManager_->CheckRegisterParam(devId, dhId, parameters, callback);
282     EXPECT_EQ(false, ret);
283 }
284 
285 HWTEST_F(DistributedInputSourceManagerTest, RegisterDistributedHardware_01, testing::ext::TestSize.Level1)
286 {
287     std::string devId = "";
288     std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8";
289     std::string parameters = "";
290     sptr<TestRegisterDInputCb> callback(new TestRegisterDInputCb());
291     int32_t ret = sourceManager_->RegisterDistributedHardware(devId, dhId, parameters, callback);
292     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_REGISTER_FAIL, ret);
293 }
294 
295 HWTEST_F(DistributedInputSourceManagerTest, RegisterDistributedHardware_02, testing::ext::TestSize.Level1)
296 {
297     InputDevice pBuffer;
298     pBuffer.name = "uinput_name_touch";
299     pBuffer.bus = 0x03;
300     pBuffer.vendor = 0x1233;
301     pBuffer.product = 0xfedb;
302     pBuffer.version = 3;
303     pBuffer.physicalPath = "usb-hiusb-ehci-2.1/input1";
304     pBuffer.uniqueId = "3";
305     pBuffer.classes = INPUT_DEVICE_CLASS_TOUCH;
306     pBuffer.descriptor = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8";
307 
308     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
309     std::string dhId = pBuffer.descriptor;
310     std::string parameters;
311     StructTransJson(pBuffer, parameters);
312     sptr<TestRegisterDInputCb> callback(new TestRegisterDInputCb());
313     DistributedInputSourceManager::InputDeviceId inputDeviceId {devId, dhId, GetNodeDesc(parameters)};
314     sourceManager_->inputDevice_.push_back(inputDeviceId);
315     int32_t ret = sourceManager_->RegisterDistributedHardware(devId, dhId, parameters, callback);
316     EXPECT_EQ(DH_SUCCESS, ret);
317 }
318 
319 HWTEST_F(DistributedInputSourceManagerTest, handleStartServerCallback_01, testing::ext::TestSize.Level1)
320 {
321     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
322     std::string dhId = "input_slkdiek3kddkeojfe";
323     DistributedInputSourceManager::InputDeviceId inputDeviceId {devId, dhId};
324     sourceManager_->inputDevice_.push_back(inputDeviceId);
325     sourceManager_->handleStartServerCallback(devId);
326     EXPECT_EQ(1, sourceManager_->inputDevice_.size());
327 }
328 
329 HWTEST_F(DistributedInputSourceManagerTest, handleStartServerCallback_02, testing::ext::TestSize.Level1)
330 {
331     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
332     sourceManager_->handleStartServerCallback(devId);
333 
334     sourceManager_->DeviceMap_[devId] = DINPUT_SOURCE_SWITCH_ON;
335     devId = "devId_20221221_test";
336     sourceManager_->handleStartServerCallback(devId);
337     EXPECT_EQ(2, sourceManager_->DeviceMap_.size());
338 }
339 
340 HWTEST_F(DistributedInputSourceManagerTest, UnregCallbackNotify_01, testing::ext::TestSize.Level1)
341 {
342     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
343     std::string dhId = "input_slkdiek3kddkeojfe";
344     int32_t ret = sourceManager_->UnregCallbackNotify(devId, dhId);
345     EXPECT_EQ(DH_SUCCESS, ret);
346 
347     sptr<TestUnregisterDInputCb> callback(new TestUnregisterDInputCb());
348     DistributedInputSourceManager::DInputClientUnregistInfo info {devId, dhId, callback};
349     sourceManager_->unregCallbacks_.push_back(info);
350     devId = "devId_20221221_test";
351     sourceManager_->UnregCallbackNotify(devId, dhId);
352     EXPECT_EQ(DH_SUCCESS, ret);
353 
354     dhId = "input_48094810_test";
355     sourceManager_->UnregCallbackNotify(devId, dhId);
356     EXPECT_EQ(DH_SUCCESS, ret);
357 
358     devId = "umkyu1b165e1be98151891erbe8r91ev";
359     sourceManager_->UnregCallbackNotify(devId, dhId);
360     EXPECT_EQ(DH_SUCCESS, ret);
361 }
362 
363 HWTEST_F(DistributedInputSourceManagerTest, CheckUnregisterParam_01, testing::ext::TestSize.Level1)
364 {
365     std::string devId = "";
366     std::string dhId = "";
367     sptr<TestUnregisterDInputCb> callback = nullptr;
368     bool ret = sourceManager_->CheckUnregisterParam(devId, dhId, callback);
369     EXPECT_EQ(false, ret);
370     std::string devcieId(DEV_ID_LENGTH_MAX + 1, 'a');
371     ret = sourceManager_->CheckUnregisterParam(devcieId, dhId, callback);
372     EXPECT_EQ(false, ret);
373     devId = "umkyu1b165e1be98151891erbe8r91ev";
374     ret = sourceManager_->CheckUnregisterParam(devId, dhId, callback);
375     EXPECT_EQ(false, ret);
376     std::string dhIds(DEV_ID_LENGTH_MAX + 1, 'a');
377     sourceManager_->CheckUnregisterParam(devId, dhIds, callback);
378     EXPECT_EQ(false, ret);
379     dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8";
380     sourceManager_->CheckUnregisterParam(devId, dhId, callback);
381     EXPECT_EQ(false, ret);
382 }
383 
384 HWTEST_F(DistributedInputSourceManagerTest, CheckDeviceIsExists_01, testing::ext::TestSize.Level1)
385 {
386     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
387     std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8";
388     sptr<TestUnregisterDInputCb> callback(new TestUnregisterDInputCb());
389     DistributedInputSourceManager::InputDeviceId inputDeviceId {devId, dhId};
390     sourceManager_->inputDevice_.push_back(inputDeviceId);
391     auto it = sourceManager_->inputDevice_.begin();
392     int32_t ret = sourceManager_->CheckDeviceIsExists(devId, dhId, inputDeviceId, it);
393     EXPECT_EQ(DH_SUCCESS, ret);
394 }
395 
396 HWTEST_F(DistributedInputSourceManagerTest, UnregisterDistributedHardware_01, testing::ext::TestSize.Level1)
397 {
398     std::string devId = "";
399     std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8";
400     sptr<TestUnregisterDInputCb> callback(new TestUnregisterDInputCb());
401     int32_t ret = sourceManager_->UnregisterDistributedHardware(devId, dhId, callback);
402     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNREGISTER_FAIL, ret);
403 }
404 
405 HWTEST_F(DistributedInputSourceManagerTest, UnregisterDistributedHardware_02, testing::ext::TestSize.Level1)
406 {
407     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
408     std::string dhId = "1ds56v18e1v21v8v1erv15r1v8r1j1ty8";
409     sptr<TestUnregisterDInputCb> callback(new TestUnregisterDInputCb());
410     int32_t ret = sourceManager_->UnregisterDistributedHardware(devId, dhId, callback);
411     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNREGISTER_FAIL, ret);
412 }
413 
414 /**
415  * @tc.name: PrepareRemoteInput
416  * @tc.desc: verify the function of distributing data from any device.
417  * @tc.type: FUNC
418  * @tc.require: SR000H9J75
419  */
420 HWTEST_F(DistributedInputSourceManagerTest, PrepareRemoteInput_01, testing::ext::TestSize.Level1)
421 {
422     std::string devId = "";
423     sptr<TestPrepareDInputCallback> callback(new TestPrepareDInputCallback());
424     int32_t ret = sourceManager_->PrepareRemoteInput(devId, callback);
425     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_PREPARE_FAIL, ret);
426 }
427 
428 HWTEST_F(DistributedInputSourceManagerTest, PrepareRemoteInput_02, testing::ext::TestSize.Level1)
429 {
430     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
431     sptr<TestPrepareDInputCallback> callback(new TestPrepareDInputCallback());
432     int32_t ret = sourceManager_->PrepareRemoteInput(devId, callback);
433     EXPECT_EQ(DH_SUCCESS, ret);
434     DistributedInputSourceTransport::GetInstance().CloseInputSoftbus(devId, false);
435 }
436 
437 HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput_01, testing::ext::TestSize.Level1)
438 {
439     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
440     int32_t sessionId = 1;
441     sptr<TestUnprepareDInputCallback> callback(new TestUnprepareDInputCallback());
442     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[devId] = sessionId;
443     int32_t ret = sourceManager_->UnprepareRemoteInput(devId, callback);
444     EXPECT_EQ(DH_SUCCESS, ret);
445 }
446 
447 HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput_02, testing::ext::TestSize.Level1)
448 {
449     std::string devId = "";
450     sptr<TestUnprepareDInputCallback> callback(new TestUnprepareDInputCallback());
451     int32_t ret = sourceManager_->UnprepareRemoteInput(devId, callback);
452     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_FAIL, ret);
453 
454     devId = "umkyu1b165e1be98151891erbe8r91ev";
455     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
456     ret = sourceManager_->UnprepareRemoteInput(devId, callback);
457     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_FAIL, ret);
458 }
459 
460 /**
461  * @tc.name: StartRemoteInput
462  * @tc.desc: verify the function of starting distributed input on InputDeviceType.
463  * @tc.type: FUNC
464  * @tc.require: SR000H9J75
465  */
466 HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_01, testing::ext::TestSize.Level1)
467 {
468     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
469     int32_t sessionId = 1;
470     sptr<TestStartDInputCallback> callback(new TestStartDInputCallback());
471     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[devId] = sessionId;
472     int32_t ret = sourceManager_->StartRemoteInput(devId, INPUTTYPE, callback);
473     EXPECT_EQ(DH_SUCCESS, ret);
474 
475     ret = sourceManager_->StartRemoteInput(devId, INPUTTYPE_MOUSE, callback);
476     EXPECT_EQ(DH_SUCCESS, ret);
477 }
478 
479 HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_02, testing::ext::TestSize.Level1)
480 {
481     std::string devId = "";
482     sptr<TestStartDInputCallback> callback(new TestStartDInputCallback());
483     int32_t ret = sourceManager_->StartRemoteInput(devId, INPUTTYPE, callback);
484     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
485     devId = "umkyu1b165e1be98151891erbe8r91ev";
486     DistributedInputSourceManager::DInputClientStartInfo info {devId, INPUTTYPE, callback};
487     sourceManager_->staCallbacks_.push_back(info);
488     ret = sourceManager_->StartRemoteInput(devId, INPUTTYPE, callback);
489     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
490 
491     ret = sourceManager_->StartRemoteInput(devId, INPUTTYPE, callback);
492     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
493 }
494 
495 HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_03, testing::ext::TestSize.Level1)
496 {
497     std::string devId = "devId_4810input4809_test";
498     sptr<TestStartDInputCallback> callback(new TestStartDInputCallback());
499     int32_t ret = sourceManager_->StartRemoteInput(devId, INPUTTYPE, callback);
500     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
501 }
502 
503 /**
504  * @tc.name: StopRemoteInput
505  * @tc.desc: verify the function of stoping distributed input on InputDeviceType.
506  * @tc.type: FUNC
507  * @tc.require: SR000H9J75
508  */
509 HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_01, testing::ext::TestSize.Level1)
510 {
511     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
512     sptr<TestStopDInputCallback> callback(new TestStopDInputCallback());
513     int32_t ret = sourceManager_->StopRemoteInput(devId, INPUTTYPE, callback);
514     EXPECT_EQ(DH_SUCCESS, ret);
515 
516     ret = sourceManager_->StopRemoteInput(devId, INPUTTYPE_MOUSE, callback);
517     EXPECT_EQ(DH_SUCCESS, ret);
518 }
519 
520 HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_02, testing::ext::TestSize.Level1)
521 {
522     std::string devId = "";
523     sptr<TestStopDInputCallback> callback(new TestStopDInputCallback());
524     int32_t ret = sourceManager_->StopRemoteInput(devId, INPUTTYPE, callback);
525     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
526     devId = "umkyu1b165e1be98151891erbe8r91ev";
527     DistributedInputSourceManager::DInputClientStopInfo info {devId, INPUTTYPE, callback};
528     sourceManager_->stpCallbacks_.push_back(info);
529     ret = sourceManager_->StopRemoteInput(devId, INPUTTYPE, callback);
530     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
531 }
532 
533 HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_03, testing::ext::TestSize.Level1)
534 {
535     sptr<TestStopDInputCallback> callback(new TestStopDInputCallback());
536     std::string devId = "devId_4810input4809_test";
537     int32_t ret = sourceManager_->StopRemoteInput(devId, INPUTTYPE, callback);
538     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
539 }
540 
541 /**
542  * @tc.name: StartRemoteInput
543  * @tc.desc: verify the function of starting distributed input on InputDeviceType.
544  * @tc.type: FUNC
545  * @tc.require: SR000H9J75
546  */
547 HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_04, testing::ext::TestSize.Level1)
548 {
549     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
550     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
551     sptr<TestStartDInputCallback> callback(new TestStartDInputCallback());
552     int32_t ret = sourceManager_->StartRemoteInput(srcId, sinkId, INPUTTYPE, callback);
553     EXPECT_EQ(DH_SUCCESS, ret);
554 }
555 
556 HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_05, testing::ext::TestSize.Level1)
557 {
558     std::string srcId = "";
559     std::string sinkId = "";
560     sptr<TestStartDInputCallback> callback(new TestStartDInputCallback());
561     int32_t ret = sourceManager_->StartRemoteInput(srcId, sinkId, INPUTTYPE, callback);
562     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
563     srcId = "srcId_4810input4809_test";
564     sinkId = "umkyu1b165e1be98151891erbe8r91ev";
565     DistributedInputSourceManager::DInputClientStartTypeInfo info(srcId, sinkId, INPUTTYPE, callback);
566     sourceManager_->relayStaTypeCallbacks_.push_back(info);
567     ret = sourceManager_->StartRemoteInput(srcId, sinkId, INPUTTYPE, callback);
568     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
569     srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
570     DistributedInputSourceManager::DInputClientStartInfo startInfo {sinkId, INPUTTYPE, callback};
571     sourceManager_->staCallbacks_.push_back(startInfo);
572     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
573     ret = sourceManager_->StartRemoteInput(srcId, sinkId, INPUTTYPE, callback);
574     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
575 }
576 
577 HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_06, testing::ext::TestSize.Level1)
578 {
579     sptr<TestStartDInputCallback> callback(new TestStartDInputCallback());
580     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
581     std::string sinkId = "devId_4810input4809_test";
582     int32_t ret = sourceManager_->StartRemoteInput(srcId, sinkId, INPUTTYPE, callback);
583     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
584 }
585 
586 /**
587  * @tc.name: StopRemoteInput
588  * @tc.desc: verify the function of stoping distributed input on InputDeviceType.
589  * @tc.type: FUNC
590  * @tc.require: SR000H9J75
591  */
592 HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_04, testing::ext::TestSize.Level1)
593 {
594     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
595     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
596     int32_t sessionId = 1;
597     sptr<TestStopDInputCallback> callback(new TestStopDInputCallback());
598     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[sinkId] = sessionId;
599     int32_t ret = sourceManager_->StopRemoteInput(srcId, sinkId, INPUTTYPE, callback);
600     EXPECT_EQ(DH_SUCCESS, ret);
601 }
602 
603 HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_05, testing::ext::TestSize.Level1)
604 {
605     std::string srcId = "";
606     std::string sinkId = "";
607     sptr<TestStopDInputCallback> callback(new TestStopDInputCallback());
608     int32_t ret = sourceManager_->StopRemoteInput(srcId, sinkId,
609         INPUTTYPE, callback);
610     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
611     srcId = "srcId_4810input4809_test";
612     sinkId = "umkyu1b165e1be98151891erbe8r91ev";
613     DistributedInputSourceManager::DInputClientStopTypeInfo info(srcId, sinkId, INPUTTYPE, callback);
614     sourceManager_->relayStpTypeCallbacks_.push_back(info);
615     ret = sourceManager_->StopRemoteInput(srcId, sinkId, INPUTTYPE, callback);
616     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
617     srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
618     DistributedInputSourceManager::DInputClientStopInfo stopInfo {sinkId, INPUTTYPE, callback};
619     sourceManager_->stpCallbacks_.push_back(stopInfo);
620     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
621     ret = sourceManager_->StopRemoteInput(srcId, sinkId, INPUTTYPE, callback);
622     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
623 }
624 
625 HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_06, testing::ext::TestSize.Level1)
626 {
627     sptr<TestStopDInputCallback> callback(new TestStopDInputCallback());
628     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
629     std::string sinkId = "devId_4810input4809_test";
630     int32_t ret = sourceManager_->StopRemoteInput(srcId, sinkId, INPUTTYPE, callback);
631     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
632 }
633 
634 HWTEST_F(DistributedInputSourceManagerTest, RelayStartRemoteInputByType_01, testing::ext::TestSize.Level1)
635 {
636     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
637     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
638     sptr<TestStartDInputCallback> callback(new TestStartDInputCallback());
639     int32_t sessionId = 1;
640     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
641     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[srcId] = sessionId;
642     int32_t ret = sourceManager_->RelayStartRemoteInputByType(srcId, sinkId, INPUTTYPE, callback);
643     EXPECT_EQ(DH_SUCCESS, ret);
644 
645     sinkId = "sinkId_test";
646     ret = sourceManager_->RelayStartRemoteInputByType(srcId, sinkId, INPUTTYPE, callback);
647     EXPECT_EQ(DH_SUCCESS, ret);
648 
649     ret = sourceManager_->RelayStartRemoteInputByType(srcId, sinkId, INPUTTYPE_MOUSE, callback);
650     EXPECT_EQ(DH_SUCCESS, ret);
651 }
652 
653 HWTEST_F(DistributedInputSourceManagerTest, RelayStartRemoteInputByType_02, testing::ext::TestSize.Level1)
654 {
655     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
656     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
657     sptr<TestStartDInputCallback> callback(new TestStartDInputCallback());
658     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
659     int32_t ret = sourceManager_->RelayStartRemoteInputByType(srcId, sinkId, INPUTTYPE, callback);
660     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
661 }
662 
663 HWTEST_F(DistributedInputSourceManagerTest, RelayStopRemoteInputByType_01, testing::ext::TestSize.Level1)
664 {
665     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
666     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
667     sptr<TestStopDInputCallback> callback(new TestStopDInputCallback());
668     int32_t sessionId = 1;
669     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
670     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[srcId] = sessionId;
671     int32_t ret = sourceManager_->RelayStopRemoteInputByType(srcId, sinkId, INPUTTYPE, callback);
672     EXPECT_EQ(DH_SUCCESS, ret);
673 
674     sinkId = "sinkId_test";
675     ret = sourceManager_->RelayStopRemoteInputByType(srcId, sinkId, INPUTTYPE, callback);
676     EXPECT_EQ(DH_SUCCESS, ret);
677 
678     ret = sourceManager_->RelayStopRemoteInputByType(srcId, sinkId, INPUTTYPE_MOUSE, callback);
679     EXPECT_EQ(DH_SUCCESS, ret);
680 }
681 
682 HWTEST_F(DistributedInputSourceManagerTest, RelayStopRemoteInputByType_02, testing::ext::TestSize.Level1)
683 {
684     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
685     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
686     sptr<TestStopDInputCallback> callback(new TestStopDInputCallback());
687     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
688     int32_t ret = sourceManager_->RelayStopRemoteInputByType(srcId, sinkId, INPUTTYPE, callback);
689     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
690 }
691 
692 /**
693  * @tc.name: PrepareRemoteInput
694  * @tc.desc: verify the function of distributing data from any device.
695  * @tc.type: FUNC
696  * @tc.require: SR000H9J77
697  */
698 HWTEST_F(DistributedInputSourceManagerTest, PrepareRemoteInput_03, testing::ext::TestSize.Level1)
699 {
700     std::string srcId = "";
701     std::string sinkId = "";
702     sptr<TestPrepareDInputCallback> callback(new TestPrepareDInputCallback());
703     int32_t ret = sourceManager_->PrepareRemoteInput(srcId, sinkId, callback);
704     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_PREPARE_FAIL, ret);
705 
706     srcId = "srcId_4810input4809_test";
707     sinkId = "umkyu1b165e1be98151891erbe8r91ev";
708     ret = sourceManager_->PrepareRemoteInput(srcId, sinkId, callback);
709     EXPECT_EQ(DH_SUCCESS, ret);
710 
711     srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
712     ret = sourceManager_->PrepareRemoteInput(srcId, sinkId, callback);
713     EXPECT_EQ(DH_SUCCESS, ret);
714     DistributedInputSourceTransport::GetInstance().CloseInputSoftbus(sinkId, false);
715 }
716 
717 /**
718  * @tc.name: UnprepareRemoteInput
719  * @tc.desc: verify the function of disabling a peripheral device.
720  * @tc.type: FUNC
721  * @tc.require: SR000H9J77
722  */
723 
724 HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput_04, testing::ext::TestSize.Level1)
725 {
726     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
727     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
728     int32_t sessionId = 1;
729     sptr<TestUnprepareDInputCallback> callback(new TestUnprepareDInputCallback());
730     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
731     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[sinkId] = sessionId;
732     int32_t ret = sourceManager_->UnprepareRemoteInput(srcId, sinkId, callback);
733     EXPECT_EQ(DH_SUCCESS, ret);
734 }
735 
736 HWTEST_F(DistributedInputSourceManagerTest, UnprepareRemoteInput_05, testing::ext::TestSize.Level1)
737 {
738     std::string srcId = "";
739     std::string sinkId = "";
740     sptr<TestUnprepareDInputCallback> callback(new TestUnprepareDInputCallback());
741     int32_t ret = sourceManager_->UnprepareRemoteInput(srcId, sinkId, callback);
742     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_FAIL, ret);
743     srcId = "srcId_4810input4809_test";
744     sinkId = "umkyu1b165e1be98151891erbe8r91ev";
745     ret = sourceManager_->UnprepareRemoteInput(srcId, sinkId, callback);
746     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_FAIL, ret);
747 
748     int32_t sessionId = 1;
749     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[srcId] = sessionId;
750     ret = sourceManager_->UnprepareRemoteInput(srcId, sinkId, callback);
751     EXPECT_EQ(DH_SUCCESS, ret);
752 
753     srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
754     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
755     ret = sourceManager_->UnprepareRemoteInput(srcId, sinkId, callback);
756     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_FAIL, ret);
757 }
758 
759 /**
760  * @tc.name: StartRemoteInput
761  * @tc.desc: verify the function of starting distributed input with dhid.
762  * @tc.type: FUNC
763  * @tc.require: SR000H9J74
764  */
765 HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_07, testing::ext::TestSize.Level1)
766 {
767     std::vector<std::string> dhIds;
768     int32_t sessionId = 1;
769     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
770     sptr<TestStartStopVectorCallbackStub> callback(new TestStartStopVectorCallbackStub());
771     dhIds.push_back("Input_slkdiek3kddkeojfe");
772     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[sinkId] = sessionId;
773     int32_t ret = sourceManager_->StartRemoteInput(sinkId, dhIds, callback);
774     EXPECT_EQ(DH_SUCCESS, ret);
775 
776     sinkId = "sinkId_20221221_test";
777     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
778     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[sinkId] = sessionId;
779     ret = sourceManager_->StartRemoteInput(sinkId, dhIds, callback);
780     EXPECT_EQ(DH_SUCCESS, ret);
781 
782     dhIds.push_back("Input_48094810_test");
783     ret = sourceManager_->StartRemoteInput(sinkId, dhIds, callback);
784     EXPECT_EQ(DH_SUCCESS, ret);
785 }
786 
787 HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_08, testing::ext::TestSize.Level1)
788 {
789     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
790     std::string sinkId = "";
791     std::vector<std::string> dhIds;
792     dhIds.push_back("Input_slkdiek3kddkeojfe");
793     sptr<TestStartStopVectorCallbackStub> callback(new TestStartStopVectorCallbackStub());
794     int32_t ret = sourceManager_->StartRemoteInput(sinkId, dhIds, callback);
795     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
796 
797     sinkId = "umkyu1b165e1be98151891erbe8r91ev";
798     DistributedInputSourceManager::DInputClientStartDhidInfo info {srcId, sinkId, dhIds, callback};
799     sourceManager_->staStringCallbacks_.push_back(info);
800     ret = sourceManager_->StartRemoteInput(sinkId, dhIds, callback);
801     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
802 }
803 
804 HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_09, testing::ext::TestSize.Level1)
805 {
806     std::vector<std::string> dhIds;
807     dhIds.push_back("Input_slkdiek3kddkeojfe");
808     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
809     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
810     sptr<TestStartStopVectorCallbackStub> callback(new TestStartStopVectorCallbackStub());
811     sourceManager_->staStringCallbacks_.clear();
812     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
813     int32_t ret = sourceManager_->StartRemoteInput(sinkId, dhIds, callback);
814     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
815 }
816 
817 /**
818  * @tc.name: StopRemoteInput
819  * @tc.desc: verify the function of stoping distributed input with dhid.
820  * @tc.type: FUNC
821  * @tc.require: SR000H9J74
822  */
823 HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_07, testing::ext::TestSize.Level1)
824 {
825     std::vector<std::string> dhIds;
826     sptr<TestStartStopVectorCallbackStub> callback(new TestStartStopVectorCallbackStub());
827     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
828     dhIds.push_back("Input_slkdiek3kddkeojfe");
829     int32_t sessionId = 1;
830     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
831     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[sinkId] = sessionId;
832     int32_t ret = sourceManager_->StopRemoteInput(sinkId, dhIds, callback);
833     EXPECT_EQ(DH_SUCCESS, ret);
834 
835     sinkId = "sinkId_20221221_test";
836     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
837     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[sinkId] = sessionId;
838     ret = sourceManager_->StopRemoteInput(sinkId, dhIds, callback);
839     EXPECT_EQ(DH_SUCCESS, ret);
840 
841     dhIds.push_back("Input_48094810_test");
842     ret = sourceManager_->StopRemoteInput(sinkId, dhIds, callback);
843     EXPECT_EQ(DH_SUCCESS, ret);
844 }
845 
846 HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_08, testing::ext::TestSize.Level1)
847 {
848     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
849     std::string sinkId = "";
850     std::vector<std::string> dhIds;
851     sptr<TestStartStopVectorCallbackStub> callback(new TestStartStopVectorCallbackStub());
852     int32_t ret = sourceManager_->StopRemoteInput(sinkId, dhIds, callback);
853     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
854     sinkId = "umkyu1b165e1be98151891erbe8r91ev";
855     DistributedInputSourceManager::DInputClientStopDhidInfo info {srcId, sinkId, dhIds, callback};
856     sourceManager_->stpStringCallbacks_.push_back(info);
857     ret = sourceManager_->StopRemoteInput(sinkId, dhIds, callback);
858     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
859 }
860 
861 HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_09, testing::ext::TestSize.Level1)
862 {
863     std::vector<std::string> dhIds;
864     dhIds.push_back("Input_slkdiek3kddkeojfe");
865     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
866     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
867     sptr<TestStartStopVectorCallbackStub> callback(new TestStartStopVectorCallbackStub());
868     sourceManager_->stpStringCallbacks_.clear();
869     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
870     int32_t ret = sourceManager_->StopRemoteInput(sinkId, dhIds, callback);
871     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
872 }
873 
874 /**
875  * @tc.name: StartRemoteInput
876  * @tc.desc: verify the function of starting distributed input with dhid.
877  * @tc.type: FUNC
878  * @tc.require: SR000H9J74
879  */
880 HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_10, testing::ext::TestSize.Level1)
881 {
882     std::vector<std::string> dhIds;
883     sptr<TestStartStopVectorCallbackStub> callback(new TestStartStopVectorCallbackStub());
884     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
885     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
886     dhIds.push_back("Input_slkdiek3kddkeojfe");
887     int32_t sessionId = 1;
888     sourceManager_->stpStringCallbacks_.clear();
889     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
890     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[sinkId] = sessionId;
891     int32_t ret = sourceManager_->StartRemoteInput(srcId, sinkId, dhIds, callback);
892     EXPECT_EQ(DH_SUCCESS, ret);
893 
894     sinkId = "sinkId_20221221_test";
895     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
896     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[sinkId] = sessionId;
897     ret = sourceManager_->StartRemoteInput(srcId, sinkId, dhIds, callback);
898     EXPECT_EQ(DH_SUCCESS, ret);
899 
900     dhIds.push_back("Input_48094810_test");
901     ret = sourceManager_->StartRemoteInput(srcId, sinkId, dhIds, callback);
902     EXPECT_EQ(DH_SUCCESS, ret);
903 }
904 
905 HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_11, testing::ext::TestSize.Level1)
906 {
907     std::string srcId = "";
908     std::string sinkId = "";
909     std::vector<std::string> dhIds;
910     sptr<TestStartStopVectorCallbackStub> callback(new TestStartStopVectorCallbackStub());
911     int32_t ret = sourceManager_->StartRemoteInput(srcId, sinkId, dhIds, callback);
912     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
913 
914     dhIds.push_back("Input_slkdiek3kddkeojfe");
915     sinkId = "umkyu1b165e1be98151891erbe8r91ev";
916     srcId = "srcId_4810input4809_test";
917     DistributedInputSourceManager::DInputClientStartDhidInfo info{srcId, sinkId, dhIds, callback};
918     sourceManager_->relayStaDhidCallbacks_.push_back(info);
919     ret = sourceManager_->StartRemoteInput(srcId, sinkId, dhIds, callback);
920     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
921 
922     srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
923     DistributedInputSourceManager::DInputClientStartDhidInfo startDhIdInfo {srcId, sinkId, dhIds, callback};
924     sourceManager_->staStringCallbacks_.push_back(startDhIdInfo);
925     ret = sourceManager_->StartRemoteInput(srcId, sinkId, dhIds, callback);
926     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
927 }
928 
929 HWTEST_F(DistributedInputSourceManagerTest, StartRemoteInput_12, testing::ext::TestSize.Level1)
930 {
931     std::vector<std::string> dhIds;
932     dhIds.push_back("Input_slkdiek3kddkeojfe");
933     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
934     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
935     sptr<TestStartStopVectorCallbackStub> callback(new TestStartStopVectorCallbackStub());
936     sourceManager_->staStringCallbacks_.clear();
937     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
938     int32_t ret = sourceManager_->StartRemoteInput(srcId, sinkId, dhIds, callback);
939     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
940 }
941 
942 /**
943  * @tc.name: StopRemoteInput
944  * @tc.desc: verify the function of stoping distributed input with dhid.
945  * @tc.type: FUNC
946  * @tc.require: SR000H9J74
947  */
948 HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_10, testing::ext::TestSize.Level1)
949 {
950     std::vector<std::string> dhIds;
951     sptr<TestStartStopVectorCallbackStub> callback(new TestStartStopVectorCallbackStub());
952     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
953     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
954     dhIds.push_back("Input_slkdiek3kddkeojfe");
955     int32_t sessionId = 1;
956     sourceManager_->stpStringCallbacks_.clear();
957     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
958     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[sinkId] = sessionId;
959     int32_t ret = sourceManager_->StopRemoteInput(srcId, sinkId, dhIds, callback);
960     EXPECT_EQ(DH_SUCCESS, ret);
961 
962     sinkId = "sinkId_20221221_test";
963     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
964     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[sinkId] = sessionId;
965     ret = sourceManager_->StopRemoteInput(srcId, sinkId, dhIds, callback);
966     EXPECT_EQ(DH_SUCCESS, ret);
967 
968     dhIds.push_back("Input_48094810_test");
969     ret = sourceManager_->StopRemoteInput(srcId, sinkId, dhIds, callback);
970     EXPECT_EQ(DH_SUCCESS, ret);
971 }
972 
973 HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_11, testing::ext::TestSize.Level1)
974 {
975     std::string srcId = "";
976     std::string sinkId = "";
977     std::vector<std::string> dhIds;
978     sptr<TestStartStopVectorCallbackStub> callback(new TestStartStopVectorCallbackStub());
979     int32_t ret = sourceManager_->StopRemoteInput(srcId, sinkId, dhIds, callback);
980     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
981 
982     dhIds.push_back("Input_slkdiek3kddkeojfe");
983     sinkId = "umkyu1b165e1be98151891erbe8r91ev";
984     srcId = "srcId_4810input4809_test";
985     DistributedInputSourceManager::DInputClientStopDhidInfo info{srcId, sinkId, dhIds, callback};
986     sourceManager_->relayStpDhidCallbacks_.push_back(info);
987     ret = sourceManager_->StopRemoteInput(srcId, sinkId, dhIds, callback);
988     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
989 
990     srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
991     DistributedInputSourceManager::DInputClientStopDhidInfo stopDhIdInfo {srcId, sinkId, dhIds, callback};
992     sourceManager_->stpStringCallbacks_.push_back(stopDhIdInfo);
993     ret = sourceManager_->StopRemoteInput(srcId, sinkId, dhIds, callback);
994     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
995 }
996 
997 HWTEST_F(DistributedInputSourceManagerTest, StopRemoteInput_12, testing::ext::TestSize.Level1)
998 {
999     std::vector<std::string> dhIds;
1000     dhIds.push_back("Input_slkdiek3kddkeojfe");
1001     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1002     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1003     sptr<TestStartStopVectorCallbackStub> callback(new TestStartStopVectorCallbackStub());
1004     sourceManager_->stpStringCallbacks_.clear();
1005     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
1006     int32_t ret = sourceManager_->StopRemoteInput(srcId, sinkId, dhIds, callback);
1007     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
1008 }
1009 
1010 HWTEST_F(DistributedInputSourceManagerTest, IsStringDataSame_01, testing::ext::TestSize.Level1)
1011 {
1012     std::vector<std::string> oldDhIds;
1013     std::vector<std::string> newDhIds;
1014     oldDhIds.push_back("afv4s8b1dr1b8er1bd65fb16redb1dfb18d1b56df1b68d");
1015     bool ret = sourceManager_->IsStringDataSame(oldDhIds, newDhIds);
1016     EXPECT_EQ(false, ret);
1017 }
1018 
1019 HWTEST_F(DistributedInputSourceManagerTest, IsStringDataSame_02, testing::ext::TestSize.Level1)
1020 {
1021     std::vector<std::string> oldDhIds;
1022     std::vector<std::string> newDhIds;
1023     oldDhIds.push_back("afv4s8b1dr1b8er1bd65fb16redb1dfb18d1b56df1b68d");
1024     newDhIds.push_back("rt12r1nr81n521be8rb1erbe1w8bg1erb18");
1025     bool ret = sourceManager_->IsStringDataSame(oldDhIds, newDhIds);
1026     EXPECT_EQ(false, ret);
1027     oldDhIds.push_back("rt12r1nr81n521be8rb1erbe1w8bg1erb18");
1028     newDhIds.push_back("afv4s8b1dr1b8er1bd65fb16redb1dfb18d1b56df1b68d");
1029     ret = sourceManager_->IsStringDataSame(oldDhIds, newDhIds);
1030     EXPECT_EQ(true, ret);
1031 }
1032 
1033 HWTEST_F(DistributedInputSourceManagerTest, RegisterAddWhiteListCallback01, testing::ext::TestSize.Level0)
1034 {
1035     sptr<TestAddWhiteListInfosCb> callback = nullptr;
1036     int32_t ret = sourceManager_->RegisterAddWhiteListCallback(callback);
1037     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_REG_CALLBACK_ERR, ret);
1038 }
1039 
1040 HWTEST_F(DistributedInputSourceManagerTest, RegisterAddWhiteListCallback02, testing::ext::TestSize.Level0)
1041 {
1042     sptr<TestAddWhiteListInfosCb> callback(new TestAddWhiteListInfosCb());
1043     int32_t ret = sourceManager_->RegisterAddWhiteListCallback(callback);
1044     EXPECT_EQ(DH_SUCCESS, ret);
1045 }
1046 
1047 HWTEST_F(DistributedInputSourceManagerTest, RegisterDelWhiteListCallback01, testing::ext::TestSize.Level0)
1048 {
1049     sptr<TestDelWhiteListInfosCb> callback = nullptr;
1050     int32_t ret = sourceManager_->RegisterDelWhiteListCallback(callback);
1051     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_REG_CALLBACK_ERR, ret);
1052 }
1053 
1054 HWTEST_F(DistributedInputSourceManagerTest, RegisterDelWhiteListCallback02, testing::ext::TestSize.Level0)
1055 {
1056     sptr<TestDelWhiteListInfosCb> callback(new TestDelWhiteListInfosCb());
1057     int32_t ret = sourceManager_->RegisterDelWhiteListCallback(callback);
1058     EXPECT_EQ(DH_SUCCESS, ret);
1059 }
1060 
1061 HWTEST_F(DistributedInputSourceManagerTest, RegisterSimulationEventListener_01, testing::ext::TestSize.Level1)
1062 {
1063     sptr<TestSimulationEventCb> callback = nullptr;
1064     int32_t ret = sourceManager_->RegisterSimulationEventListener(callback);
1065     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_SIMULATION_EVENT_CALLBACK_ERR, ret);
1066 
1067     ret = sourceManager_->UnregisterSimulationEventListener(callback);
1068     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_SIMULATION_EVENT_CALLBACK_ERR, ret);
1069 }
1070 
1071 HWTEST_F(DistributedInputSourceManagerTest, UnregisterSimulationEventListener_02, testing::ext::TestSize.Level1)
1072 {
1073     sptr<TestSimulationEventCb> callback(new TestSimulationEventCb());
1074     int32_t ret = sourceManager_->RegisterSimulationEventListener(callback);
1075     EXPECT_EQ(DH_SUCCESS, ret);
1076 
1077     ret = sourceManager_->UnregisterSimulationEventListener(callback);
1078     EXPECT_EQ(DH_SUCCESS, ret);
1079 }
1080 
1081 HWTEST_F(DistributedInputSourceManagerTest, RelayPrepareRemoteInput_01, testing::ext::TestSize.Level1)
1082 {
1083     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1084     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1085     sptr<TestPrepareDInputCallback> callback(new TestPrepareDInputCallback());
1086     int32_t sessionId = 1;
1087     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
1088     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[srcId] = sessionId;
1089     int32_t ret = sourceManager_->RelayPrepareRemoteInput(srcId, sinkId, callback);
1090     EXPECT_EQ(DH_SUCCESS, ret);
1091 
1092     sinkId = "sinkId_test";
1093     sourceManager_->RelayPrepareRemoteInput(srcId, sinkId, callback);
1094     EXPECT_EQ(DH_SUCCESS, ret);
1095 }
1096 
1097 HWTEST_F(DistributedInputSourceManagerTest, RelayUnprepareRemoteInput_01, testing::ext::TestSize.Level1)
1098 {
1099     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1100     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1101     sptr<TestUnprepareDInputCallback> callback(new TestUnprepareDInputCallback());
1102     int32_t ret = sourceManager_->RelayUnprepareRemoteInput(srcId, sinkId, callback);
1103     EXPECT_EQ(DH_SUCCESS, ret);
1104 
1105     sinkId = "sinkId_test";
1106     sourceManager_->RelayUnprepareRemoteInput(srcId, sinkId, callback);
1107     EXPECT_EQ(DH_SUCCESS, ret);
1108 }
1109 
1110 HWTEST_F(DistributedInputSourceManagerTest, RelayUnprepareRemoteInput_02, testing::ext::TestSize.Level1)
1111 {
1112     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1113     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1114     sptr<TestUnprepareDInputCallback> callback(new TestUnprepareDInputCallback());
1115     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
1116     int32_t ret = sourceManager_->RelayUnprepareRemoteInput(srcId, sinkId, callback);
1117     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_UNPREPARE_FAIL, ret);
1118 }
1119 
1120 HWTEST_F(DistributedInputSourceManagerTest, RelayStartRemoteInputByDhid_01, testing::ext::TestSize.Level1)
1121 {
1122     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1123     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1124     std::vector<std::string> dhIds;
1125     dhIds.push_back("input_slkdiek3kddkeojfe");
1126     sptr<TestStartStopDInputsCb> callback(new TestStartStopDInputsCb());
1127     int32_t sessionId = 1;
1128     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[srcId] = sessionId;
1129     int32_t ret = sourceManager_->RelayStartRemoteInputByDhid(srcId, sinkId, dhIds, callback);
1130     EXPECT_EQ(DH_SUCCESS, ret);
1131 
1132     srcId = "srcId_20221221_test";
1133     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[srcId] = sessionId;
1134     ret = sourceManager_->RelayStartRemoteInputByDhid(srcId, sinkId, dhIds, callback);
1135     EXPECT_EQ(DH_SUCCESS, ret);
1136 
1137     sinkId = "sinkId_20221221_test";
1138     sourceManager_->RelayStartRemoteInputByDhid(srcId, sinkId, dhIds, callback);
1139     EXPECT_EQ(DH_SUCCESS, ret);
1140 
1141     dhIds.push_back("Input_48094810_test");
1142     sourceManager_->RelayStartRemoteInputByDhid(srcId, sinkId, dhIds, callback);
1143     EXPECT_EQ(DH_SUCCESS, ret);
1144 }
1145 
1146 HWTEST_F(DistributedInputSourceManagerTest, RelayStartRemoteInputByDhid_02, testing::ext::TestSize.Level1)
1147 {
1148     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1149     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1150     std::vector<std::string> dhIds;
1151     dhIds.push_back("input_slkdiek3kddkeojfe");
1152     sptr<TestStartStopDInputsCb> callback(new TestStartStopDInputsCb());
1153     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
1154     int32_t ret = sourceManager_->RelayStartRemoteInputByDhid(srcId, sinkId, dhIds, callback);
1155     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_START_FAIL, ret);
1156 }
1157 
1158 HWTEST_F(DistributedInputSourceManagerTest, RelayStopRemoteInputByDhid_01, testing::ext::TestSize.Level1)
1159 {
1160     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1161     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1162     std::vector<std::string> dhIds;
1163     dhIds.push_back("input_slkdiek3kddkeojfe");
1164     sptr<TestStartStopDInputsCb> callback(new TestStartStopDInputsCb());
1165     int32_t sessionId = 1;
1166     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[srcId] = sessionId;
1167     int32_t ret = sourceManager_->RelayStopRemoteInputByDhid(srcId, sinkId, dhIds, callback);
1168     EXPECT_EQ(DH_SUCCESS, ret);
1169 
1170     srcId = "srcId_20221221_test";
1171     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_[srcId] = sessionId;
1172     ret = sourceManager_->RelayStopRemoteInputByDhid(srcId, sinkId, dhIds, callback);
1173     EXPECT_EQ(DH_SUCCESS, ret);
1174 
1175     sinkId = "sinkId_20221221_test";
1176     sourceManager_->RelayStopRemoteInputByDhid(srcId, sinkId, dhIds, callback);
1177     EXPECT_EQ(DH_SUCCESS, ret);
1178 
1179     dhIds.push_back("Input_48094810_test");
1180     sourceManager_->RelayStopRemoteInputByDhid(srcId, sinkId, dhIds, callback);
1181     EXPECT_EQ(DH_SUCCESS, ret);
1182 }
1183 
1184 HWTEST_F(DistributedInputSourceManagerTest, RelayStopRemoteInputByDhid_02, testing::ext::TestSize.Level1)
1185 {
1186     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1187     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1188     std::vector<std::string> dhIds;
1189     dhIds.push_back("input_slkdiek3kddkeojfe");
1190     sptr<TestStartStopDInputsCb> callback(new TestStartStopDInputsCb());
1191     DistributedInputTransportBase::GetInstance().remoteDevSessionMap_.clear();
1192     int32_t ret = sourceManager_->RelayStopRemoteInputByDhid(srcId, sinkId, dhIds, callback);
1193     EXPECT_EQ(ERR_DH_INPUT_SERVER_SOURCE_MANAGER_STOP_FAIL, ret);
1194 }
1195 
1196 HWTEST_F(DistributedInputSourceManagerTest, RunRegisterCallback_01, testing::ext::TestSize.Level1)
1197 {
1198     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
1199     std::string dhId = "input_slkdiek3kddkeojfe";
1200     int32_t status = 0;
1201     sptr<TestRegisterDInputCb> callback(new TestRegisterDInputCb());
1202     DistributedInputSourceManager::DInputClientRegistInfo info {devId, dhId, callback};
1203     sourceManager_->regCallbacks_.push_back(info);
1204     sourceManager_->RunRegisterCallback(devId, dhId, status);
1205     EXPECT_EQ(0, sourceManager_->regCallbacks_.size());
1206 
1207     DistributedInputSourceManager::DInputClientRegistInfo regInfo {devId, dhId, callback};
1208     sourceManager_->regCallbacks_.push_back(regInfo);
1209     devId = "devId_20221221_test";
1210     sourceManager_->RunRegisterCallback(devId, dhId, status);
1211     EXPECT_EQ(1, sourceManager_->regCallbacks_.size());
1212 
1213     dhId = "dhId_20221221_test";
1214     sourceManager_->RunRegisterCallback(devId, dhId, status);
1215     EXPECT_EQ(1, sourceManager_->regCallbacks_.size());
1216 
1217     devId = "umkyu1b165e1be98151891erbe8r91ev";
1218     sourceManager_->RunRegisterCallback(devId, dhId, status);
1219     EXPECT_EQ(1, sourceManager_->regCallbacks_.size());
1220 }
1221 
1222 HWTEST_F(DistributedInputSourceManagerTest, RunUnregisterCallback_01, testing::ext::TestSize.Level1)
1223 {
1224     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
1225     std::string dhId = "input_slkdiek3kddkeojfe";
1226     int32_t status = 0;
1227     sptr<TestUnregisterDInputCb> callback(new TestUnregisterDInputCb());
1228     DistributedInputSourceManager::DInputClientUnregistInfo info {devId, dhId, callback};
1229     sourceManager_->unregCallbacks_.push_back(info);
1230     sourceManager_->RunUnregisterCallback(devId, dhId, status);
1231     EXPECT_EQ(0, sourceManager_->unregCallbacks_.size());
1232 
1233     DistributedInputSourceManager::DInputClientUnregistInfo unpreInfo {devId, dhId, callback};
1234     sourceManager_->unregCallbacks_.push_back(unpreInfo);
1235     devId = "devId_20221221_test";
1236     sourceManager_->RunRegisterCallback(devId, dhId, status);
1237     EXPECT_EQ(1, sourceManager_->unregCallbacks_.size());
1238 
1239     dhId = "dhId_20221221_test";
1240     sourceManager_->RunRegisterCallback(devId, dhId, status);
1241     EXPECT_EQ(1, sourceManager_->unregCallbacks_.size());
1242 
1243     devId = "umkyu1b165e1be98151891erbe8r91ev";
1244     sourceManager_->RunRegisterCallback(devId, dhId, status);
1245     EXPECT_EQ(1, sourceManager_->unregCallbacks_.size());
1246 }
1247 
1248 HWTEST_F(DistributedInputSourceManagerTest, RunPrepareCallback_01, testing::ext::TestSize.Level1)
1249 {
1250     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
1251     int32_t status = 0;
1252     std::string object = "runprepareobject";
1253     sptr<TestPrepareDInputCallback> callback(new TestPrepareDInputCallback());
1254     DistributedInputSourceManager::DInputClientPrepareInfo info {devId, callback};
1255     sourceManager_->preCallbacks_.insert(info);
1256     sourceManager_->RunPrepareCallback(devId, status, object);
1257     EXPECT_EQ(0, sourceManager_->preCallbacks_.size());
1258 
1259     DistributedInputSourceManager::DInputClientPrepareInfo preInfo {devId, callback};
1260     sourceManager_->preCallbacks_.insert(preInfo);
1261     devId = "devId_20221221_test";
1262     sourceManager_->RunPrepareCallback(devId, status, object);
1263     EXPECT_EQ(1, sourceManager_->preCallbacks_.size());
1264 }
1265 
1266 HWTEST_F(DistributedInputSourceManagerTest, RunWhiteListCallback_01, testing::ext::TestSize.Level1)
1267 {
1268     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
1269     std::string object = "runwhitelistobject";
1270     sptr<TestAddWhiteListInfosCb> callback(new TestAddWhiteListInfosCb());
1271     sourceManager_->addWhiteListCallbacks_.insert(callback);
1272     sourceManager_->RunWhiteListCallback(devId, object);
1273     EXPECT_EQ(1, sourceManager_->addWhiteListCallbacks_.size());
1274 }
1275 
1276 HWTEST_F(DistributedInputSourceManagerTest, RunRelayPrepareCallback_01, testing::ext::TestSize.Level1)
1277 {
1278     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1279     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1280     int32_t status = 0;
1281     sptr<TestPrepareDInputCallback> callback(new TestPrepareDInputCallback());
1282     DistributedInputSourceManager::DInputClientRelayPrepareInfo info {srcId, sinkId, callback};
1283     sourceManager_->relayPreCallbacks_.insert(info);
1284     sourceManager_->RunRelayPrepareCallback(srcId, sinkId, status);
1285     EXPECT_EQ(0, sourceManager_->relayPreCallbacks_.size());
1286 
1287     DistributedInputSourceManager::DInputClientRelayPrepareInfo preInfo {srcId, sinkId, callback};
1288     sourceManager_->relayPreCallbacks_.insert(preInfo);
1289     srcId = "devId_20221221_test";
1290     sourceManager_->RunRelayPrepareCallback(srcId, sinkId, status);
1291     EXPECT_EQ(1, sourceManager_->relayPreCallbacks_.size());
1292 
1293     sinkId = "sinkId_20221221_test";
1294     sourceManager_->RunRelayPrepareCallback(srcId, sinkId, status);
1295     EXPECT_EQ(1, sourceManager_->relayPreCallbacks_.size());
1296 
1297     srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1298     sourceManager_->RunRelayPrepareCallback(srcId, sinkId, status);
1299     EXPECT_EQ(1, sourceManager_->relayPreCallbacks_.size());
1300 }
1301 
1302 HWTEST_F(DistributedInputSourceManagerTest, RunRelayUnprepareCallback_01, testing::ext::TestSize.Level1)
1303 {
1304     sourceManager_->relayUnpreCallbacks_.clear();
1305     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1306     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1307     int32_t status = 0;
1308     sptr<TestUnprepareDInputCallback> callback(new TestUnprepareDInputCallback());
1309     DistributedInputSourceManager::DInputClientRelayUnprepareInfo info {srcId, sinkId, callback};
1310     sourceManager_->relayUnpreCallbacks_.insert(info);
1311     sourceManager_->RunRelayUnprepareCallback(srcId, sinkId, status);
1312     EXPECT_EQ(0, sourceManager_->relayUnpreCallbacks_.size());
1313 
1314     DistributedInputSourceManager::DInputClientRelayUnprepareInfo unpreInfo {srcId, sinkId, callback};
1315     sourceManager_->relayUnpreCallbacks_.insert(unpreInfo);
1316     srcId = "devId_20221221_test";
1317     sourceManager_->RunRelayUnprepareCallback(srcId, sinkId, status);
1318     EXPECT_EQ(1, sourceManager_->relayUnpreCallbacks_.size());
1319 
1320     sinkId = "sinkId_20221221_test";
1321     sourceManager_->RunRelayUnprepareCallback(srcId, sinkId, status);
1322     EXPECT_EQ(1, sourceManager_->relayUnpreCallbacks_.size());
1323 
1324     srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1325     sourceManager_->RunRelayUnprepareCallback(srcId, sinkId, status);
1326     EXPECT_EQ(1, sourceManager_->relayUnpreCallbacks_.size());
1327 }
1328 
1329 HWTEST_F(DistributedInputSourceManagerTest, RunUnprepareCallback_01, testing::ext::TestSize.Level1)
1330 {
1331     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
1332     int32_t status = 0;
1333     std::string object = "runprepareobject";
1334     sptr<TestUnprepareDInputCallback> callback(new TestUnprepareDInputCallback());
1335     DistributedInputSourceManager::DInputClientUnprepareInfo info {devId, callback};
1336     sourceManager_->unpreCallbacks_.insert(info);
1337     sourceManager_->RunUnprepareCallback(devId, status);
1338     EXPECT_EQ(0, sourceManager_->unpreCallbacks_.size());
1339 
1340     DistributedInputSourceManager::DInputClientUnprepareInfo unpreInfo {devId, callback};
1341     sourceManager_->unpreCallbacks_.insert(unpreInfo);
1342 
1343     devId = "devId_20221221_test";
1344     sourceManager_->RunUnprepareCallback(devId, status);
1345     EXPECT_EQ(1, sourceManager_->unpreCallbacks_.size());
1346 }
1347 
1348 HWTEST_F(DistributedInputSourceManagerTest, RunStartCallback_01, testing::ext::TestSize.Level1)
1349 {
1350     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
1351     int32_t status = 0;
1352     uint32_t inputTypes = 1;
1353     sptr<TestStartDInputCallback> callback(new TestStartDInputCallback());
1354     DistributedInputSourceManager::DInputClientStartInfo info {devId, inputTypes, callback};
1355     sourceManager_->staCallbacks_.push_back(info);
1356     sourceManager_->RunStartCallback(devId, inputTypes, status);
1357     EXPECT_EQ(0, sourceManager_->staCallbacks_.size());
1358 
1359     DistributedInputSourceManager::DInputClientStartInfo startInfo {devId, inputTypes, callback};
1360     sourceManager_->staCallbacks_.push_back(startInfo);
1361     devId = "devId_20221221_test";
1362     sourceManager_->RunStartCallback(devId, inputTypes, status);
1363     EXPECT_EQ(1, sourceManager_->staCallbacks_.size());
1364 
1365     inputTypes = 3;
1366     sourceManager_->RunStartCallback(devId, inputTypes, status);
1367     EXPECT_EQ(1, sourceManager_->staCallbacks_.size());
1368 
1369     devId = "umkyu1b165e1be98151891erbe8r91ev";
1370     sourceManager_->RunStartCallback(devId, inputTypes, status);
1371     EXPECT_EQ(1, sourceManager_->staCallbacks_.size());
1372 }
1373 
1374 HWTEST_F(DistributedInputSourceManagerTest, RunStopCallback_01, testing::ext::TestSize.Level1)
1375 {
1376     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
1377     int32_t status = 0;
1378     uint32_t inputTypes = 1;
1379     sptr<TestStopDInputCallback> callback(new TestStopDInputCallback());
1380     DistributedInputSourceManager::DInputClientStopInfo info {devId, inputTypes, callback};
1381     sourceManager_->stpCallbacks_.push_back(info);
1382     sourceManager_->RunStopCallback(devId, inputTypes, status);
1383     EXPECT_EQ(0, sourceManager_->stpCallbacks_.size());
1384 
1385     DistributedInputSourceManager::DInputClientStopInfo stopInfo {devId, inputTypes, callback};
1386     sourceManager_->stpCallbacks_.push_back(stopInfo);
1387     devId = "devId_20221221_test";
1388     sourceManager_->RunStopCallback(devId, inputTypes, status);
1389     EXPECT_EQ(1, sourceManager_->stpCallbacks_.size());
1390 
1391     inputTypes = 3;
1392     sourceManager_->RunStopCallback(devId, inputTypes, status);
1393     EXPECT_EQ(1, sourceManager_->stpCallbacks_.size());
1394 
1395     devId = "umkyu1b165e1be98151891erbe8r91ev";
1396     sourceManager_->RunStopCallback(devId, inputTypes, status);
1397     EXPECT_EQ(1, sourceManager_->stpCallbacks_.size());
1398 }
1399 
1400 HWTEST_F(DistributedInputSourceManagerTest, RunStartDhidCallback_01, testing::ext::TestSize.Level1)
1401 {
1402     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1403     int32_t status = 0;
1404     std::string dhId = "input_slkdiek3kddkeojfe";
1405     std::string localNetworkId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1406     std::vector<std::string> dhIds;
1407     dhIds.push_back("input_slkdiek3kddkeojfe");
1408     sptr<TestStartStopDInputsCb> callback(new TestStartStopDInputsCb());
1409     DistributedInputSourceManager::DInputClientStartDhidInfo info {localNetworkId, sinkId, dhIds, callback};
1410     sourceManager_->staStringCallbacks_.push_back(info);
1411     sourceManager_->RunStartDhidCallback(sinkId, dhId, status);
1412     EXPECT_EQ(0, sourceManager_->staStringCallbacks_.size());
1413 
1414     DistributedInputSourceManager::DInputClientStartDhidInfo startInfo {localNetworkId, sinkId, dhIds, callback};
1415     sourceManager_->staStringCallbacks_.push_back(startInfo);
1416     sinkId = "sinkId_20221221_test";
1417     sourceManager_->RunStartDhidCallback(sinkId, dhId, status);
1418     EXPECT_EQ(1, sourceManager_->staStringCallbacks_.size());
1419 
1420     dhIds.clear();
1421     dhIds.push_back("input_48104809_test");
1422     sourceManager_->RunStartDhidCallback(sinkId, dhId, status);
1423     EXPECT_EQ(1, sourceManager_->staStringCallbacks_.size());
1424 }
1425 
1426 HWTEST_F(DistributedInputSourceManagerTest, RunStopDhidCallback_01, testing::ext::TestSize.Level1)
1427 {
1428     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1429     int32_t status = 0;
1430     std::string dhId = "input_slkdiek3kddkeojfe";
1431     std::string localNetworkId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1432     std::vector<std::string> dhIds;
1433     dhIds.push_back(dhId);
1434     sptr<TestStartStopDInputsCb> callback(new TestStartStopDInputsCb());
1435     DistributedInputSourceManager::DInputClientStopDhidInfo info {localNetworkId, sinkId, dhIds, callback};
1436     sourceManager_->stpStringCallbacks_.push_back(info);
1437     sourceManager_->RunStopDhidCallback(sinkId, dhId, status);
1438     EXPECT_EQ(0, sourceManager_->stpStringCallbacks_.size());
1439 
1440     DistributedInputSourceManager::DInputClientStopDhidInfo stopInfo {localNetworkId, sinkId, dhIds, callback};
1441     sourceManager_->stpStringCallbacks_.push_back(stopInfo);
1442     sinkId = "sinkId_20221221_test";
1443     sourceManager_->RunStopDhidCallback(sinkId, dhId, status);
1444     EXPECT_EQ(1, sourceManager_->stpStringCallbacks_.size());
1445 
1446     dhIds.clear();
1447     dhIds.push_back("input_48104809_test");
1448     sourceManager_->RunStopDhidCallback(sinkId, dhId, status);
1449     EXPECT_EQ(1, sourceManager_->stpStringCallbacks_.size());
1450 }
1451 
1452 HWTEST_F(DistributedInputSourceManagerTest, RunRelayStartDhidCallback_01, testing::ext::TestSize.Level1)
1453 {
1454     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1455     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1456     int32_t status = 0;
1457     std::string dhId = "input_slkdiek3kddkeojfe";
1458     std::vector<std::string> dhIds;
1459     dhIds.push_back(dhId);
1460     sptr<TestStartStopDInputsCb> callback(new TestStartStopDInputsCb());
1461     DistributedInputSourceManager::DInputClientStartDhidInfo info{srcId, sinkId, dhIds, callback};
1462     sourceManager_->relayStaDhidCallbacks_.push_back(info);
1463     sourceManager_->RunRelayStartDhidCallback(srcId, sinkId, status, dhId);
1464     EXPECT_EQ(0, sourceManager_->relayStaDhidCallbacks_.size());
1465 
1466     DistributedInputSourceManager::DInputClientStartDhidInfo startInfo{srcId, sinkId, dhIds, callback};
1467     sourceManager_->relayStaDhidCallbacks_.push_back(startInfo);
1468     srcId = "devId_20221221_test";
1469     sourceManager_->RunRelayStartDhidCallback(srcId, sinkId, status, dhId);
1470     EXPECT_EQ(1, sourceManager_->relayStaDhidCallbacks_.size());
1471 
1472     sinkId = "sinkId_20221221_test";
1473     sourceManager_->RunRelayStartDhidCallback(srcId, sinkId, status, dhId);
1474     EXPECT_EQ(1, sourceManager_->relayStaDhidCallbacks_.size());
1475 
1476     dhIds.clear();
1477     dhIds.push_back("input_48104809_test");
1478     sourceManager_->RunRelayStartDhidCallback(srcId, sinkId, status, dhId);
1479     EXPECT_EQ(1, sourceManager_->relayStaDhidCallbacks_.size());
1480 }
1481 
1482 HWTEST_F(DistributedInputSourceManagerTest, RunRelayStartDhidCallback_02, testing::ext::TestSize.Level1)
1483 {
1484     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1485     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1486     int32_t status = 0;
1487     std::string dhId = "input_slkdiek3kddkeojfe";
1488     std::vector<std::string> dhIds;
1489     dhIds.push_back(dhId);
1490     sourceManager_->relayStaDhidCallbacks_.clear();
1491     sptr<TestStartStopDInputsCb> cb = nullptr;
1492     DistributedInputSourceManager::DInputClientStartDhidInfo startDhIdInfo {srcId, sinkId, dhIds, cb};
1493     sourceManager_->relayStaDhidCallbacks_.push_back(startDhIdInfo);
1494     sourceManager_->RunRelayStartDhidCallback(srcId, sinkId, status, dhId);
1495     EXPECT_EQ(0, sourceManager_->relayStaDhidCallbacks_.size());
1496 }
1497 
1498 HWTEST_F(DistributedInputSourceManagerTest, RunRelayStopDhidCallback_01, testing::ext::TestSize.Level1)
1499 {
1500     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1501     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1502     int32_t status = 0;
1503     std::string dhId = "input_slkdiek3kddkeojfe";
1504     std::vector<std::string> dhIds;
1505     dhIds.push_back(dhId);
1506     sptr<TestStartStopDInputsCb> callback(new TestStartStopDInputsCb());
1507     DistributedInputSourceManager::DInputClientStopDhidInfo info{srcId, sinkId, dhIds, callback};
1508     sourceManager_->relayStpDhidCallbacks_.push_back(info);
1509     sourceManager_->RunRelayStopDhidCallback(srcId, sinkId, status, dhId);
1510     EXPECT_EQ(0, sourceManager_->relayStpDhidCallbacks_.size());
1511 
1512     DistributedInputSourceManager::DInputClientStopDhidInfo stopInfo{srcId, sinkId, dhIds, callback};
1513     sourceManager_->relayStpDhidCallbacks_.push_back(stopInfo);
1514     srcId = "devId_20221221_test";
1515     sourceManager_->RunRelayStopDhidCallback(srcId, sinkId, status, dhId);
1516     EXPECT_EQ(1, sourceManager_->relayStpDhidCallbacks_.size());
1517 
1518     sinkId = "sinkId_20221221_test";
1519     sourceManager_->RunRelayStopDhidCallback(srcId, sinkId, status, dhId);
1520     EXPECT_EQ(1, sourceManager_->relayStpDhidCallbacks_.size());
1521 
1522     dhIds.clear();
1523     dhIds.push_back("input_48104809_test");
1524     sourceManager_->RunRelayStopDhidCallback(srcId, sinkId, status, dhId);
1525     EXPECT_EQ(1, sourceManager_->relayStpDhidCallbacks_.size());
1526 }
1527 
1528 HWTEST_F(DistributedInputSourceManagerTest, RunRelayStopDhidCallback_02, testing::ext::TestSize.Level1)
1529 {
1530     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1531     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1532     int32_t status = 0;
1533     std::string dhId = "input_slkdiek3kddkeojfe";
1534     std::vector<std::string> dhIds;
1535     dhIds.push_back(dhId);
1536     sourceManager_->relayStpDhidCallbacks_.clear();
1537     sptr<TestStartStopDInputsCb> cb = nullptr;
1538     DistributedInputSourceManager::DInputClientStopDhidInfo stopDhIdInfo {srcId, sinkId, dhIds, cb};
1539     sourceManager_->relayStpDhidCallbacks_.push_back(stopDhIdInfo);
1540     sourceManager_->RunRelayStopDhidCallback(srcId, sinkId, status, dhId);
1541     EXPECT_EQ(0, sourceManager_->relayStpDhidCallbacks_.size());
1542 }
1543 
1544 HWTEST_F(DistributedInputSourceManagerTest, RunRelayStartTypeCallback_01, testing::ext::TestSize.Level1)
1545 {
1546     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1547     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1548     int32_t status = 0;
1549     uint32_t inputTypes = 1;
1550     sptr<TestStartDInputCallback> callback(new TestStartDInputCallback());
1551     DistributedInputSourceManager::DInputClientStartTypeInfo info(srcId, sinkId, inputTypes, callback);
1552     sourceManager_->relayStaTypeCallbacks_.push_back(info);
1553     sourceManager_->RunRelayStartTypeCallback(srcId, sinkId, status, inputTypes);
1554     EXPECT_EQ(0, sourceManager_->relayStaTypeCallbacks_.size());
1555 
1556     DistributedInputSourceManager::DInputClientStartTypeInfo startInfo(srcId, sinkId, inputTypes, callback);
1557     sourceManager_->relayStaTypeCallbacks_.push_back(startInfo);
1558     srcId = "devId_20221221_test";
1559     sourceManager_->RunRelayStartTypeCallback(srcId, sinkId, status, inputTypes);
1560     EXPECT_EQ(1, sourceManager_->relayStaTypeCallbacks_.size());
1561 
1562     sinkId = "sinkId_20221221_test";
1563     sourceManager_->RunRelayStartTypeCallback(srcId, sinkId, status, inputTypes);
1564     EXPECT_EQ(1, sourceManager_->relayStaTypeCallbacks_.size());
1565 
1566     inputTypes = 3;
1567     sourceManager_->RunRelayStartTypeCallback(srcId, sinkId, status, inputTypes);
1568     EXPECT_EQ(1, sourceManager_->relayStaTypeCallbacks_.size());
1569 }
1570 
1571 HWTEST_F(DistributedInputSourceManagerTest, RunRelayStopTypeCallback_01, testing::ext::TestSize.Level1)
1572 {
1573     std::string srcId = "networkidc08647073e02e7a78f09473aa122ff57fc81c00";
1574     std::string sinkId = "umkyu1b165e1be98151891erbe8r91ev";
1575     int32_t status = 0;
1576     uint32_t inputTypes = 1;
1577     sptr<TestStopDInputCallback> callback(new TestStopDInputCallback());
1578     DistributedInputSourceManager::DInputClientStopTypeInfo info(srcId, sinkId, inputTypes, callback);
1579     sourceManager_->relayStpTypeCallbacks_.push_back(info);
1580     sourceManager_->RunRelayStopTypeCallback(srcId, sinkId, status, inputTypes);
1581     EXPECT_EQ(0, sourceManager_->relayStpTypeCallbacks_.size());
1582 
1583     DistributedInputSourceManager::DInputClientStopTypeInfo stopInfo(srcId, sinkId, inputTypes, callback);
1584     sourceManager_->relayStpTypeCallbacks_.push_back(stopInfo);
1585     srcId = "devId_20221221_test";
1586     sourceManager_->RunRelayStopTypeCallback(srcId, sinkId, status, inputTypes);
1587     EXPECT_EQ(1, sourceManager_->relayStpTypeCallbacks_.size());
1588 
1589     sinkId = "sinkId_20221221_test";
1590     sourceManager_->RunRelayStopTypeCallback(srcId, sinkId, status, inputTypes);
1591     EXPECT_EQ(1, sourceManager_->relayStpTypeCallbacks_.size());
1592 
1593     inputTypes = 3;
1594     sourceManager_->RunRelayStopTypeCallback(srcId, sinkId, status, inputTypes);
1595     EXPECT_EQ(1, sourceManager_->relayStpTypeCallbacks_.size());
1596 }
1597 
1598 HWTEST_F(DistributedInputSourceManagerTest, RemoveInputDeviceId_01, testing::ext::TestSize.Level1)
1599 {
1600     std::string deviceId = "umkyu1b165e1be98151891erbe8r91ev";
1601     std::string dhId = "input_slkdiek3kddkeojfe";
1602     sourceManager_->RemoveInputDeviceId(deviceId, dhId);
1603     EXPECT_EQ(0, sourceManager_->inputDevice_.size());
1604 
1605     DistributedInputSourceManager::InputDeviceId inputDeviceId {deviceId, dhId};
1606     sourceManager_->inputDevice_.push_back(inputDeviceId);
1607     sourceManager_->RemoveInputDeviceId(deviceId, dhId);
1608     EXPECT_EQ(0, sourceManager_->inputDevice_.size());
1609 }
1610 
1611 HWTEST_F(DistributedInputSourceManagerTest, GetDeviceMapAllDevSwitchOff_01, testing::ext::TestSize.Level1)
1612 {
1613     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
1614     sourceManager_->DeviceMap_[devId] = DINPUT_SOURCE_SWITCH_OFF;
1615     bool ret = sourceManager_->GetDeviceMapAllDevSwitchOff();
1616     EXPECT_EQ(true, ret);
1617 }
1618 
1619 HWTEST_F(DistributedInputSourceManagerTest, GetDeviceMapAllDevSwitchOff_02, testing::ext::TestSize.Level1)
1620 {
1621     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
1622     sourceManager_->DeviceMap_[devId] = DINPUT_SOURCE_SWITCH_ON;
1623     bool ret = sourceManager_->GetDeviceMapAllDevSwitchOff();
1624     EXPECT_EQ(false, ret);
1625 }
1626 
1627 HWTEST_F(DistributedInputSourceManagerTest, GetInputTypesMap_01, testing::ext::TestSize.Level1)
1628 {
1629     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
1630     sourceManager_->InputTypesMap_[devId] = 1;
1631     uint32_t ret = sourceManager_->GetInputTypesMap(devId);
1632     EXPECT_EQ(static_cast<uint32_t>(DInputDeviceType::MOUSE), ret);
1633 }
1634 
1635 HWTEST_F(DistributedInputSourceManagerTest, GetAllInputTypesMap_01, testing::ext::TestSize.Level1)
1636 {
1637     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
1638     sourceManager_->InputTypesMap_[devId] = 1;
1639     uint32_t ret = sourceManager_->GetAllInputTypesMap();
1640     EXPECT_EQ(static_cast<uint32_t>(DInputDeviceType::MOUSE), ret);
1641 }
1642 
1643 HWTEST_F(DistributedInputSourceManagerTest, SetInputTypesMap_01, testing::ext::TestSize.Level1)
1644 {
1645     std::string devId = "umkyu1b165e1be98151891erbe8r91ev";
1646     uint32_t value = 0;
1647     sourceManager_->InputTypesMap_[devId] = 1;
1648     sourceManager_->SetInputTypesMap(devId, value);
1649     EXPECT_EQ(true, sourceManager_->InputTypesMap_.empty());
1650 }
1651 
1652 HWTEST_F(DistributedInputSourceManagerTest, Dump_01, testing::ext::TestSize.Level1)
1653 {
1654     int32_t fd = 1;
1655     std::vector<std::u16string> args;
1656     int32_t ret = sourceManager_->Dump(fd, args);
1657     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1658 }
1659 
1660 HWTEST_F(DistributedInputSourceManagerTest, OnResponseRegisterDistributedHardware_01, testing::ext::TestSize.Level1)
1661 {
1662     std::string deviceId = "djfhskjdhf5465456ds4f654sdf6";
1663     std::string dhId = "Input_s4df65s5d6f56asd5f6asdfasdfasdfv";
1664     bool result = true;
1665     callback_->OnResponseRegisterDistributedHardware(deviceId, dhId, result);
1666 
1667     int32_t fd = 1;
1668     std::vector<std::u16string> args;
1669     int32_t ret = sourceManager_->Dump(fd, args);
1670     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1671 }
1672 
1673 HWTEST_F(DistributedInputSourceManagerTest, OnResponsePrepareRemoteInput_01, testing::ext::TestSize.Level1)
1674 {
1675     std::string deviceId = "djfhskjdhf5465456ds4f654sdf6";
1676     bool result = true;
1677     std::string object = "46sdf5g454dfsdfg4sd6fg";
1678     callback_->OnResponsePrepareRemoteInput(deviceId, result, object);
1679 
1680     int32_t fd = 1;
1681     std::vector<std::u16string> args;
1682     int32_t ret = sourceManager_->Dump(fd, args);
1683     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1684 }
1685 
1686 HWTEST_F(DistributedInputSourceManagerTest, OnResponseUnprepareRemoteInput_01, testing::ext::TestSize.Level1)
1687 {
1688     std::string deviceId = "djfhskjdhf5465456ds4f654sdf6";
1689     bool result = true;
1690     callback_->OnResponseUnprepareRemoteInput(deviceId, result);
1691 
1692     int32_t fd = 1;
1693     std::vector<std::u16string> args;
1694     int32_t ret = sourceManager_->Dump(fd, args);
1695     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1696 }
1697 
1698 HWTEST_F(DistributedInputSourceManagerTest, OnResponseStartRemoteInput_01, testing::ext::TestSize.Level1)
1699 {
1700     std::string deviceId = "djfhskjdhf5465456ds4f654sdf6";
1701     uint32_t inputTypes = 7;
1702     bool result = true;
1703     callback_->OnResponseStartRemoteInput(deviceId, inputTypes, result);
1704 
1705     int32_t fd = 1;
1706     std::vector<std::u16string> args;
1707     int32_t ret = sourceManager_->Dump(fd, args);
1708     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1709 }
1710 
1711 HWTEST_F(DistributedInputSourceManagerTest, OnResponseStopRemoteInput_01, testing::ext::TestSize.Level1)
1712 {
1713     std::string deviceId = "djfhskjdhf5465456ds4f654sdf6";
1714     uint32_t inputTypes = 7;
1715     bool result = true;
1716     callback_->OnResponseStopRemoteInput(deviceId, inputTypes, result);
1717 
1718     int32_t fd = 1;
1719     std::vector<std::u16string> args;
1720     int32_t ret = sourceManager_->Dump(fd, args);
1721     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1722 }
1723 
1724 HWTEST_F(DistributedInputSourceManagerTest, OnResponseStartRemoteInputDhid_01, testing::ext::TestSize.Level1)
1725 {
1726     std::string deviceId = "djfhskjdhf5465456ds4f654sdf6";
1727     std::string dhids = "Input_s4df65s5d6f56asd5f6asdfasdfasdfv";
1728     bool result = true;
1729     callback_->OnResponseStartRemoteInputDhid(deviceId, dhids, result);
1730 
1731     int32_t fd = 1;
1732     std::vector<std::u16string> args;
1733     int32_t ret = sourceManager_->Dump(fd, args);
1734     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1735 }
1736 
1737 HWTEST_F(DistributedInputSourceManagerTest, OnResponseStopRemoteInputDhid_01, testing::ext::TestSize.Level1)
1738 {
1739     std::string deviceId = "djfhskjdhf5465456ds4f654sdf6";
1740     std::string dhids = "Input_s4df65s5d6f56asd5f6asdfasdfasdfv";
1741     bool result = true;
1742     callback_->OnResponseStopRemoteInputDhid(deviceId, dhids, result);
1743 
1744     int32_t fd = 1;
1745     std::vector<std::u16string> args;
1746     int32_t ret = sourceManager_->Dump(fd, args);
1747     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1748 }
1749 
1750 HWTEST_F(DistributedInputSourceManagerTest, OnResponseRelayPrepareRemoteInput_01, testing::ext::TestSize.Level1)
1751 {
1752     int32_t toSrcSessionId = 1;
1753     std::string deviceId = "as5d4a65sd4a65sd456as4d";
1754     bool result = true;
1755     std::string object = "46sdf5g454dfsdfg4sd6fg";
1756     callback_->OnResponseRelayPrepareRemoteInput(toSrcSessionId, deviceId, result, object);
1757 
1758     int32_t fd = 1;
1759     std::vector<std::u16string> args;
1760     int32_t ret = sourceManager_->Dump(fd, args);
1761     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1762 }
1763 
1764 HWTEST_F(DistributedInputSourceManagerTest, OnResponseRelayUnprepareRemoteInput_01, testing::ext::TestSize.Level1)
1765 {
1766     int32_t toSrcSessionId = 1;
1767     std::string deviceId = "as5d4a65sd4a65sd456as4d";
1768     bool result = true;
1769     callback_->OnResponseRelayUnprepareRemoteInput(toSrcSessionId, deviceId, result);
1770 
1771     int32_t fd = 1;
1772     std::vector<std::u16string> args;
1773     int32_t ret = sourceManager_->Dump(fd, args);
1774     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1775 }
1776 
1777 HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayPrepareResult_01, testing::ext::TestSize.Level1)
1778 {
1779     int32_t status = 1;
1780     std::string srcId = "djfhskjdhf5465456ds4f654sdf6";
1781     std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb";
1782     callback_->OnReceiveRelayPrepareResult(status, srcId, sinkId);
1783 
1784     int32_t fd = 1;
1785     std::vector<std::u16string> args;
1786     int32_t ret = sourceManager_->Dump(fd, args);
1787     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1788 }
1789 
1790 HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayUnprepareResult_01, testing::ext::TestSize.Level1)
1791 {
1792     int32_t status = 1;
1793     std::string srcId = "djfhskjdhf5465456ds4f654sdf6";
1794     std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb";
1795     callback_->OnReceiveRelayUnprepareResult(status, srcId, sinkId);
1796 
1797     int32_t fd = 1;
1798     std::vector<std::u16string> args;
1799     int32_t ret = sourceManager_->Dump(fd, args);
1800     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1801 }
1802 
1803 HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStartDhidResult_01, testing::ext::TestSize.Level1)
1804 {
1805     int32_t status = 1;
1806     std::string srcId = "djfhskjdhf5465456ds4f654sdf6";
1807     std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb";
1808     std::string dhid = "Input_s4df65s5d6f56asd5f6asdfasdfasdfv";
1809     callback_->OnReceiveRelayStartDhidResult(status, srcId, sinkId, dhid);
1810 
1811     int32_t fd = 1;
1812     std::vector<std::u16string> args;
1813     int32_t ret = sourceManager_->Dump(fd, args);
1814     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1815 }
1816 
1817 HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStopDhidResult_01, testing::ext::TestSize.Level1)
1818 {
1819     int32_t status = 1;
1820     std::string srcId = "djfhskjdhf5465456ds4f654sdf6";
1821     std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb";
1822     std::string dhid = "Input_s4df65s5d6f56asd5f6asdfasdfasdfv";
1823     callback_->OnReceiveRelayStopDhidResult(status, srcId, sinkId, dhid);
1824 
1825     int32_t fd = 1;
1826     std::vector<std::u16string> args;
1827     int32_t ret = sourceManager_->Dump(fd, args);
1828     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1829 }
1830 
1831 HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStartTypeResult_01, testing::ext::TestSize.Level1)
1832 {
1833     int32_t status = 1;
1834     std::string srcId = "djfhskjdhf5465456ds4f654sdf6";
1835     std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb";
1836     uint32_t inputTypes = 7;
1837     callback_->OnReceiveRelayStartTypeResult(status, srcId, sinkId, inputTypes);
1838 
1839     int32_t fd = 1;
1840     std::vector<std::u16string> args;
1841     int32_t ret = sourceManager_->Dump(fd, args);
1842     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1843 }
1844 
1845 HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStopTypeResult_01, testing::ext::TestSize.Level1)
1846 {
1847     int32_t status = 1;
1848     std::string srcId = "djfhskjdhf5465456ds4f654sdf6";
1849     std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb";
1850     uint32_t inputTypes = 7;
1851     callback_->OnReceiveRelayStopTypeResult(status, srcId, sinkId, inputTypes);
1852 
1853     int32_t fd = 1;
1854     std::vector<std::u16string> args;
1855     int32_t ret = sourceManager_->Dump(fd, args);
1856     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1857 }
1858 
1859 HWTEST_F(DistributedInputSourceManagerTest, InitAuto_01, testing::ext::TestSize.Level1)
1860 {
1861     bool ret = sourceManager_->InitAuto();
1862     EXPECT_EQ(true, ret);
1863 }
1864 
1865 HWTEST_F(DistributedInputSourceManagerTest, OnResponseRegisterDistributedHardware_02, testing::ext::TestSize.Level1)
1866 {
1867     sourceManager_->InitAuto();
1868 
1869     std::string deviceId = "djfhskjdhf5465456ds4f654sdf6";
1870     std::string dhId = "Input_s4df65s5d6f56asd5f6asdfasdfasdfv";
1871     bool result = true;
1872     callback_->OnResponseRegisterDistributedHardware(deviceId, dhId, result);
1873 
1874     int32_t fd = 1;
1875     std::vector<std::u16string> args;
1876     int32_t ret = sourceManager_->Dump(fd, args);
1877     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1878 }
1879 
1880 HWTEST_F(DistributedInputSourceManagerTest, OnResponsePrepareRemoteInput_02, testing::ext::TestSize.Level1)
1881 {
1882     sourceManager_->InitAuto();
1883 
1884     std::string deviceId = "djfhskjdhf5465456ds4f654sdf6";
1885     bool result = true;
1886     std::string object = "46sdf5g454dfsdfg4sd6fg";
1887     callback_->OnResponsePrepareRemoteInput(deviceId, result, object);
1888 
1889     int32_t fd = 1;
1890     std::vector<std::u16string> args;
1891     int32_t ret = sourceManager_->Dump(fd, args);
1892     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1893 }
1894 
1895 HWTEST_F(DistributedInputSourceManagerTest, OnResponseUnprepareRemoteInput_02, testing::ext::TestSize.Level1)
1896 {
1897     sourceManager_->InitAuto();
1898 
1899     std::string deviceId = "djfhskjdhf5465456ds4f654sdf6";
1900     bool result = true;
1901     callback_->OnResponseUnprepareRemoteInput(deviceId, result);
1902 
1903     int32_t fd = 1;
1904     std::vector<std::u16string> args;
1905     int32_t ret = sourceManager_->Dump(fd, args);
1906     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1907 }
1908 
1909 HWTEST_F(DistributedInputSourceManagerTest, OnResponseStartRemoteInput_02, testing::ext::TestSize.Level1)
1910 {
1911     sourceManager_->InitAuto();
1912 
1913     std::string deviceId = "djfhskjdhf5465456ds4f654sdf6";
1914     uint32_t inputTypes = 7;
1915     bool result = true;
1916     callback_->OnResponseStartRemoteInput(deviceId, inputTypes, result);
1917 
1918     int32_t fd = 1;
1919     std::vector<std::u16string> args;
1920     int32_t ret = sourceManager_->Dump(fd, args);
1921     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1922 }
1923 
1924 HWTEST_F(DistributedInputSourceManagerTest, OnResponseStopRemoteInput_02, testing::ext::TestSize.Level1)
1925 {
1926     sourceManager_->InitAuto();
1927 
1928     std::string deviceId = "djfhskjdhf5465456ds4f654sdf6";
1929     uint32_t inputTypes = 7;
1930     bool result = true;
1931     callback_->OnResponseStopRemoteInput(deviceId, inputTypes, result);
1932 
1933     int32_t fd = 1;
1934     std::vector<std::u16string> args;
1935     int32_t ret = sourceManager_->Dump(fd, args);
1936     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1937 }
1938 
1939 HWTEST_F(DistributedInputSourceManagerTest, OnResponseStartRemoteInputDhid_02, testing::ext::TestSize.Level1)
1940 {
1941     sourceManager_->InitAuto();
1942 
1943     std::string deviceId = "djfhskjdhf5465456ds4f654sdf6";
1944     std::string dhids = "Input_s4df65s5d6f56asd5f6asdfasdfasdfv";
1945     bool result = true;
1946     callback_->OnResponseStartRemoteInputDhid(deviceId, dhids, result);
1947 
1948     int32_t fd = 1;
1949     std::vector<std::u16string> args;
1950     int32_t ret = sourceManager_->Dump(fd, args);
1951     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1952 }
1953 
1954 HWTEST_F(DistributedInputSourceManagerTest, OnResponseStopRemoteInputDhid_02, testing::ext::TestSize.Level1)
1955 {
1956     sourceManager_->InitAuto();
1957 
1958     std::string deviceId = "djfhskjdhf5465456ds4f654sdf6";
1959     std::string dhids = "Input_s4df65s5d6f56asd5f6asdfasdfasdfv";
1960     bool result = true;
1961     callback_->OnResponseStopRemoteInputDhid(deviceId, dhids, result);
1962 
1963     int32_t fd = 1;
1964     std::vector<std::u16string> args;
1965     int32_t ret = sourceManager_->Dump(fd, args);
1966     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1967 }
1968 
1969 HWTEST_F(DistributedInputSourceManagerTest, OnResponseRelayPrepareRemoteInput_02, testing::ext::TestSize.Level1)
1970 {
1971     sourceManager_->InitAuto();
1972 
1973     int32_t toSrcSessionId = 1;
1974     std::string deviceId = "as5d4a65sd4a65sd456as4d";
1975     bool result = true;
1976     std::string object = "46sdf5g454dfsdfg4sd6fg";
1977     callback_->OnResponseRelayPrepareRemoteInput(toSrcSessionId, deviceId, result, object);
1978 
1979     int32_t fd = 1;
1980     std::vector<std::u16string> args;
1981     int32_t ret = sourceManager_->Dump(fd, args);
1982     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1983 }
1984 
1985 HWTEST_F(DistributedInputSourceManagerTest, OnResponseRelayUnprepareRemoteInput_02, testing::ext::TestSize.Level1)
1986 {
1987     sourceManager_->InitAuto();
1988 
1989     int32_t toSrcSessionId = 1;
1990     std::string deviceId = "as5d4a65sd4a65sd456as4d";
1991     bool result = true;
1992     callback_->OnResponseRelayUnprepareRemoteInput(toSrcSessionId, deviceId, result);
1993 
1994     int32_t fd = 1;
1995     std::vector<std::u16string> args;
1996     int32_t ret = sourceManager_->Dump(fd, args);
1997     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
1998 }
1999 
2000 HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayPrepareResult_02, testing::ext::TestSize.Level1)
2001 {
2002     sourceManager_->InitAuto();
2003 
2004     int32_t status = 1;
2005     std::string srcId = "djfhskjdhf5465456ds4f654sdf6";
2006     std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb";
2007     callback_->OnReceiveRelayPrepareResult(status, srcId, sinkId);
2008 
2009     int32_t fd = 1;
2010     std::vector<std::u16string> args;
2011     int32_t ret = sourceManager_->Dump(fd, args);
2012     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
2013 }
2014 
2015 HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayUnprepareResult_02, testing::ext::TestSize.Level1)
2016 {
2017     sourceManager_->InitAuto();
2018 
2019     int32_t status = 1;
2020     std::string srcId = "djfhskjdhf5465456ds4f654sdf6";
2021     std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb";
2022     callback_->OnReceiveRelayUnprepareResult(status, srcId, sinkId);
2023 
2024     int32_t fd = 1;
2025     std::vector<std::u16string> args;
2026     int32_t ret = sourceManager_->Dump(fd, args);
2027     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
2028 }
2029 
2030 HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStartDhidResult_02, testing::ext::TestSize.Level1)
2031 {
2032     sourceManager_->InitAuto();
2033 
2034     int32_t status = 1;
2035     std::string srcId = "djfhskjdhf5465456ds4f654sdf6";
2036     std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb";
2037     std::string dhid = "Input_s4df65s5d6f56asd5f6asdfasdfasdfv";
2038     callback_->OnReceiveRelayStartDhidResult(status, srcId, sinkId, dhid);
2039 
2040     int32_t fd = 1;
2041     std::vector<std::u16string> args;
2042     int32_t ret = sourceManager_->Dump(fd, args);
2043     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
2044 }
2045 
2046 HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStopDhidResult_02, testing::ext::TestSize.Level1)
2047 {
2048     sourceManager_->InitAuto();
2049 
2050     int32_t status = 1;
2051     std::string srcId = "djfhskjdhf5465456ds4f654sdf6";
2052     std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb";
2053     std::string dhid = "Input_s4df65s5d6f56asd5f6asdfasdfasdfv";
2054     callback_->OnReceiveRelayStopDhidResult(status, srcId, sinkId, dhid);
2055 
2056     int32_t fd = 1;
2057     std::vector<std::u16string> args;
2058     int32_t ret = sourceManager_->Dump(fd, args);
2059     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
2060 }
2061 
2062 HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStartTypeResult_02, testing::ext::TestSize.Level1)
2063 {
2064     sourceManager_->InitAuto();
2065 
2066     int32_t status = 1;
2067     std::string srcId = "djfhskjdhf5465456ds4f654sdf6";
2068     std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb";
2069     uint32_t inputTypes = 7;
2070     callback_->OnReceiveRelayStartTypeResult(status, srcId, sinkId, inputTypes);
2071 
2072     int32_t fd = 1;
2073     std::vector<std::u16string> args;
2074     int32_t ret = sourceManager_->Dump(fd, args);
2075     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
2076 }
2077 
2078 HWTEST_F(DistributedInputSourceManagerTest, OnReceiveRelayStopTypeResult_02, testing::ext::TestSize.Level1)
2079 {
2080     sourceManager_->InitAuto();
2081 
2082     int32_t status = 1;
2083     std::string srcId = "djfhskjdhf5465456ds4f654sdf6";
2084     std::string sinkId = "asd4a65sd46as4da6s4d6asdasdafwebrb";
2085     uint32_t inputTypes = 7;
2086     callback_->OnReceiveRelayStopTypeResult(status, srcId, sinkId, inputTypes);
2087 
2088     int32_t fd = 1;
2089     std::vector<std::u16string> args;
2090     int32_t ret = sourceManager_->Dump(fd, args);
2091     EXPECT_EQ(ERR_DH_INPUT_HIDUMP_DUMP_PROCESS_FAIL, ret);
2092 }
2093 
2094 HWTEST_F(DistributedInputSourceManagerTest, ParseMessage_01, testing::ext::TestSize.Level1)
2095 {
2096     DistributedInputSourceManager::StopDScreenListener stopListener;
2097 
2098     stopListener.OnMessage(DHTopic::TOPIC_START_DSCREEN, "msessage_test");
2099     std::string messages = "";
2100     stopListener.OnMessage(DHTopic::TOPIC_STOP_DSCREEN, messages);
2101 
2102     std::string sinkDevId = "";
2103     uint64_t sourceWinId = 0;
2104     nlohmann::json jsonObj;
2105     jsonObj[SINK_DEVICE_ID] = 100;
2106     int32_t ret = stopListener.ParseMessage(jsonObj.dump(), sinkDevId, sourceWinId);
2107     EXPECT_EQ(ERR_DH_INPUT_JSON_PARSE_FAIL, ret);
2108 
2109     jsonObj[SINK_DEVICE_ID] = "asd4a65sd46as4da6s4d6asdasdafwebrb";
2110     jsonObj[SOURCE_WINDOW_ID] = "source_window_id_test";
2111     ret = stopListener.ParseMessage(jsonObj.dump(), sinkDevId, sourceWinId);
2112     EXPECT_EQ(ERR_DH_INPUT_JSON_PARSE_FAIL, ret);
2113 
2114     jsonObj[SOURCE_WINDOW_ID] = 100;
2115     ret = stopListener.ParseMessage(jsonObj.dump(), sinkDevId, sourceWinId);
2116     EXPECT_EQ(DH_SUCCESS, ret);
2117 }
2118 
2119 HWTEST_F(DistributedInputSourceManagerTest, ParseMessage_02, testing::ext::TestSize.Level1)
2120 {
2121     DistributedInputSourceManager::StartDScreenListener startListener;
2122 
2123     startListener.OnMessage(DHTopic::TOPIC_STOP_DSCREEN, "msessage_test");
2124     std::string message(SCREEN_MSG_MAX + 1, 'a');
2125     startListener.OnMessage(DHTopic::TOPIC_START_DSCREEN, message);
2126     std::string messages = "";
2127     startListener.OnMessage(DHTopic::TOPIC_START_DSCREEN, messages);
2128 
2129     std::string sinkDevId = "";
2130     SrcScreenInfo srcScreenInfo = {};
2131     nlohmann::json jsonObj;
2132     jsonObj[SINK_DEVICE_ID] = 100;
2133     int32_t ret = startListener.ParseMessage(jsonObj.dump(), sinkDevId, srcScreenInfo);
2134     EXPECT_EQ(ERR_DH_INPUT_JSON_PARSE_FAIL, ret);
2135 
2136     jsonObj[SINK_DEVICE_ID] = "asd4a65sd46as4da6s4d6asdasdafwebrb";
2137     jsonObj[SOURCE_WINDOW_ID] = "source_window_id_test";
2138     ret = startListener.ParseMessage(jsonObj.dump(), sinkDevId, srcScreenInfo);
2139     EXPECT_EQ(ERR_DH_INPUT_JSON_PARSE_FAIL, ret);
2140 
2141     jsonObj[SOURCE_WINDOW_ID] = 100;
2142     jsonObj[SOURCE_WINDOW_WIDTH] = "source_window_width_test";
2143     ret = startListener.ParseMessage(jsonObj.dump(), sinkDevId, srcScreenInfo);
2144     EXPECT_EQ(ERR_DH_INPUT_JSON_PARSE_FAIL, ret);
2145 
2146     jsonObj[SOURCE_WINDOW_WIDTH] = 100;
2147     jsonObj[SOURCE_WINDOW_HEIGHT] = "source_window_height_test";
2148     ret = startListener.ParseMessage(jsonObj.dump(), sinkDevId, srcScreenInfo);
2149     EXPECT_EQ(ERR_DH_INPUT_JSON_PARSE_FAIL, ret);
2150 
2151     jsonObj[SOURCE_WINDOW_HEIGHT] = 100;
2152     ret = startListener.ParseMessage(jsonObj.dump(), sinkDevId, srcScreenInfo);
2153     EXPECT_EQ(DH_SUCCESS, ret);
2154 }
2155 } // namespace DistributedInput
2156 } // namespace DistributedHardware
2157 } // namespace OHOS