1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "gtest/gtest.h"
17
18 #include <filesystem>
19 #include <fstream>
20 #include <iostream>
21
22 #include "input_display_bind_helper.h"
23 #include "mmi_log.h"
24
25 #undef MMI_LOG_TAG
26 #define MMI_LOG_TAG "InputDisplayBindHelperTest"
27
28 namespace OHOS {
29 namespace MMI {
30 namespace {
31 using namespace testing::ext;
32 const std::string INPUT_NODE_PATH = "/data/input0_test";
33 const std::string INPUT_DEVICE_NAME_FILE = "/data/input0_test/name";
34 const std::string INPUT_DEVICE_NAME_CONFIG = "/data/input_device_name.cfg";
35 const std::string DISPLAY_MAPPING = "0<=>wrapper";
36 const std::string INPUT_NODE_NAME = "wrapper";
37 } // namespace
38 namespace fs = std::filesystem;
39 class InputDisplayBindHelperTest : public testing::Test {
40 public:
SetUpTestCase(void)41 static void SetUpTestCase(void) {}
TearDownTestCase(void)42 static void TearDownTestCase(void) {}
43 static bool WriteConfigFile(const std::string &content);
44 static bool InitInputNode();
45 static bool InitConfigFile();
46 static inline const std::string bindCfgFile_ = "input_display_bind_helper.cfg";
GetCfgFileName()47 static std::string GetCfgFileName()
48 {
49 return bindCfgFile_;
50 }
51 };
52
WriteConfigFile(const std::string & content)53 bool InputDisplayBindHelperTest::WriteConfigFile(const std::string &content)
54 {
55 const std::string &fileName = InputDisplayBindHelperTest::bindCfgFile_;
56 std::ofstream ofs(fileName.c_str());
57 if (!ofs) {
58 MMI_HILOGE("Open file fail.%s\n", fileName.c_str());
59 return false;
60 }
61 ofs << content;
62 ofs.close();
63 return true;
64 }
65
InitInputNode()66 bool InputDisplayBindHelperTest::InitInputNode()
67 {
68 if (fs::exists(INPUT_NODE_PATH) && fs::is_directory(INPUT_NODE_PATH)) {
69 if (fs::remove_all(INPUT_NODE_PATH) == 0) {
70 MMI_HILOGI("Clear success, path:%{private}s", INPUT_NODE_PATH.c_str());
71 } else {
72 MMI_HILOGE("Clear fail, path:%{private}s", INPUT_NODE_PATH.c_str());
73 }
74 }
75 if (fs::create_directory(INPUT_NODE_PATH)) {
76 MMI_HILOGI("Create success, path:%{private}s", INPUT_NODE_PATH.c_str());
77 } else {
78 MMI_HILOGE("Create fail, path:%{private}s", INPUT_NODE_PATH.c_str());
79 return false;
80 }
81 std::ofstream file(INPUT_DEVICE_NAME_FILE);
82 if (!file.is_open()) {
83 MMI_HILOGE("Write fail, path:%{private}s", INPUT_DEVICE_NAME_FILE.c_str());
84 return false;
85 }
86 file << INPUT_NODE_NAME;
87 file.close();
88 MMI_HILOGI("Write success, path:%{private}s", INPUT_DEVICE_NAME_FILE.c_str());
89 return true;
90 }
91
InitConfigFile()92 bool InputDisplayBindHelperTest::InitConfigFile()
93 {
94 if (fs::exists(INPUT_DEVICE_NAME_CONFIG)) {
95 if (std::remove(INPUT_DEVICE_NAME_CONFIG.c_str()) == 0) {
96 MMI_HILOGI("Clear success, path:%{private}s", INPUT_DEVICE_NAME_CONFIG.c_str());
97 } else {
98 MMI_HILOGE("Clear fail, path:%{private}s", INPUT_DEVICE_NAME_CONFIG.c_str());
99 return false;
100 }
101 }
102 std::ofstream file(INPUT_DEVICE_NAME_CONFIG);
103 if (!file.is_open()) {
104 MMI_HILOGE("Write fail, path:%{private}s", INPUT_DEVICE_NAME_CONFIG.c_str());
105 return false;
106 }
107 file << DISPLAY_MAPPING;
108 file.close();
109 MMI_HILOGI("Write success, path:%{private}s", INPUT_DEVICE_NAME_CONFIG.c_str());
110 return true;
111 }
112
113 /**
114 * @tc.name: InputDisplayBindHelperTest_001
115 * @tc.desc: No bind info in disk
116 * @tc.type: FUNC
117 * @tc.require:
118 */
119 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_001, TestSize.Level1)
120 {
121 CALL_TEST_DEBUG;
122 InputDisplayBindHelperTest::WriteConfigFile("");
123 InputDisplayBindHelper bindInfo(InputDisplayBindHelperTest::GetCfgFileName());
124 // 多模初始化
125 bindInfo.Load();
126 // 检测到触摸板设备
127 bindInfo.AddInputDevice(1, "mouse");
128 bindInfo.AddInputDevice(2, "keyboard");
129 // 窗口同步信息
130 bindInfo.AddDisplay(0, "hp 223");
131 bindInfo.AddDisplay(2, "think 123");
132 ASSERT_EQ(bindInfo.Dumps(), std::string("mouse<=>hp 223\nkeyboard<=>think 123\n"));
133 }
134
135 /**
136 * @tc.name: InputDisplayBindHelperTest_002
137 * @tc.desc: Has info with adding order in disk
138 * @tc.type: FUNC
139 * @tc.require:
140 */
141 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_002, TestSize.Level1)
142 {
143 CALL_TEST_DEBUG;
144 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
145 InputDisplayBindHelper bindInfo(InputDisplayBindHelperTest::GetCfgFileName());
146 // 多模初始化
147 bindInfo.Load();
148 // 检测到触摸板设备
149 bindInfo.AddInputDevice(1, "mouse");
150 bindInfo.AddInputDevice(2, "keyboard");
151 // 窗口同步信息
152 bindInfo.AddDisplay(0, "hp 223");
153 bindInfo.AddDisplay(2, "think 123");
154 ASSERT_EQ(bindInfo.Dumps(), std::string("mouse<=>hp 223\nkeyboard<=>think 123\n"));
155 }
156
157 /**
158 * @tc.name: InputDisplayBindHelperTest_003
159 * @tc.desc: Has info without adding order in disk
160 * @tc.type: FUNC
161 * @tc.require:
162 */
163 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_003, TestSize.Level1)
164 {
165 CALL_TEST_DEBUG;
166 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>think 123\nkeyboard<=>hp 223\n");
167 InputDisplayBindHelper bindInfo(InputDisplayBindHelperTest::GetCfgFileName());
168 // 多模初始化
169 bindInfo.Load();
170 // 检测到触摸板设备
171 bindInfo.AddInputDevice(1, "mouse");
172 bindInfo.AddInputDevice(2, "keyboard");
173 // 窗口同步信息
174 bindInfo.AddDisplay(0, "think 123");
175 bindInfo.AddDisplay(2, "hp 223");
176 ASSERT_EQ(bindInfo.Dumps(), std::string("mouse<=>think 123\nkeyboard<=>hp 223\n"));
177 }
178
179 /**
180 * @tc.name: InputDisplayBindHelperTest_004
181 * @tc.desc: Bind and remove test
182 * @tc.type: FUNC
183 * @tc.require:
184 */
185 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_004, TestSize.Level1)
186 {
187 CALL_TEST_DEBUG;
188 InputDisplayBindHelperTest::WriteConfigFile("");
189 InputDisplayBindHelper bindInfo(InputDisplayBindHelperTest::GetCfgFileName());
190 // 多模初始化
191 bindInfo.Load();
192 // 检测到触摸板设备
193 bindInfo.AddInputDevice(1, "mouse");
194 bindInfo.AddInputDevice(2, "keyboard");
195 // 窗口同步信息
196 bindInfo.AddDisplay(0, "hp 223");
197 bindInfo.AddDisplay(2, "think 123");
198 // 显示屏移除
199 bindInfo.RemoveDisplay(2);
200 bindInfo.RemoveDisplay(0);
201 // 输入设备移除
202 bindInfo.RemoveInputDevice(1);
203 bindInfo.RemoveInputDevice(2);
204 bindInfo.RemoveInputDevice(3);
205 // 窗口同步信息
206 bindInfo.AddDisplay(0, "hp 223");
207 bindInfo.AddDisplay(2, "think 123");
208 // 检测到触摸板设备
209 bindInfo.AddInputDevice(1, "mouse");
210 bindInfo.AddInputDevice(2, "keyboard");
211 bindInfo.AddInputDevice(3, "keyboard88");
212
213 bindInfo.Store();
214 bindInfo.Load();
215 bindInfo.Dumps();
216 // 输入设备移除
217 bindInfo.RemoveInputDevice(1);
218 bindInfo.RemoveInputDevice(2);
219 // 触摸板设备移除
220 bindInfo.RemoveDisplay(2);
221 bindInfo.RemoveDisplay(0);
222 ASSERT_EQ(bindInfo.Dumps(), std::string(""));
223 }
224
225 /**
226 * @tc.name: InputDisplayBindHelperTest_005
227 * @tc.desc: Test GetBindDisplayNameByInputDevice
228 * @tc.type: FUNC
229 * @tc.require:
230 */
231 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetBindDisplayNameByInputDevice_005, TestSize.Level1)
232 {
233 CALL_TEST_DEBUG;
234 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>think 123\nkeyboard<=>hp 223\n");
235 InputDisplayBindHelper bindInfo(InputDisplayBindHelperTest::GetCfgFileName());
236 // 多模初始化
237 bindInfo.Load();
238 // 检测到触摸板设备
239 bindInfo.AddInputDevice(1, "mouse");
240 bindInfo.AddInputDevice(2, "keyboard");
241 // 窗口同步信息
242 bindInfo.AddDisplay(0, "think 123");
243 bindInfo.AddDisplay(2, "hp 223");
244 ASSERT_EQ(bindInfo.Dumps(), std::string("mouse<=>think 123\nkeyboard<=>hp 223\n"));
245 // 获取
246 ASSERT_EQ(bindInfo.GetBindDisplayNameByInputDevice(1), std::string("think 123"));
247 ASSERT_EQ(bindInfo.GetBindDisplayNameByInputDevice(2), std::string("hp 223"));
248 ASSERT_EQ(bindInfo.GetBindDisplayNameByInputDevice(3), std::string());
249 // 删除display
250 bindInfo.RemoveDisplay(0);
251 ASSERT_EQ(bindInfo.GetBindDisplayNameByInputDevice(1), std::string());
252 ASSERT_EQ(bindInfo.GetBindDisplayNameByInputDevice(2), std::string("hp 223"));
253 bindInfo.RemoveDisplay(2);
254 ASSERT_EQ(bindInfo.GetBindDisplayNameByInputDevice(1), std::string());
255 ASSERT_EQ(bindInfo.GetBindDisplayNameByInputDevice(2), std::string());
256 }
257
258 /**
259 * @tc.name: InputDisplayBindHelperTest_IsDisplayAdd_006
260 * @tc.desc: Test GetBindDisplayNameByInputDevice
261 * @tc.type: FUNC
262 * @tc.require:
263 */
264 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_IsDisplayAdd_006, TestSize.Level1)
265 {
266 CALL_TEST_DEBUG;
267 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>think 123\nkeyboard<=>hp 223\n");
268 InputDisplayBindHelper bindInfo(InputDisplayBindHelperTest::GetCfgFileName());
269 // 多模初始化
270 bindInfo.Load();
271 ASSERT_FALSE(bindInfo.IsDisplayAdd(0, "hp 223"));
272 ASSERT_FALSE(bindInfo.IsDisplayAdd(2, "think 123"));
273 ASSERT_FALSE(bindInfo.IsDisplayAdd(1, "think 123"));
274 ASSERT_EQ(bindInfo.Dumps(), std::string());
275 // 检测到触摸板设备
276 bindInfo.AddInputDevice(1, "mouse");
277 bindInfo.AddInputDevice(2, "keyboard");
278 // 窗口同步信息
279 bindInfo.AddDisplay(0, "think 123");
280 bindInfo.AddDisplay(2, "hp 223");
281 ASSERT_TRUE(bindInfo.IsDisplayAdd(0, "think 123"));
282 ASSERT_TRUE(bindInfo.IsDisplayAdd(2, "hp 223"));
283 ASSERT_FALSE(bindInfo.IsDisplayAdd(1, "think 123"));
284
285 ASSERT_EQ(bindInfo.Dumps(), std::string("mouse<=>think 123\nkeyboard<=>hp 223\n"));
286 }
287
288 /**
289 * @tc.name: InputDisplayBindHelperTest_GetDisplayIdNames_007
290 * @tc.desc: Test GetBindDisplayNameByInputDevice
291 * @tc.type: FUNC
292 * @tc.require:
293 */
294 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetDisplayIdNames_007, TestSize.Level1)
295 {
296 CALL_TEST_DEBUG;
297 using IdNames = std::set<std::pair<int32_t, std::string>>;
298 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>think 123\nkeyboard<=>hp 223\n");
299 InputDisplayBindHelper bindInfo(InputDisplayBindHelperTest::GetCfgFileName());
300 // 多模初始化
301 bindInfo.Load();
302 IdNames idNames;
303 ASSERT_EQ(bindInfo.GetDisplayIdNames(), idNames);
304 bindInfo.AddDisplay(2, "hp 223");
305 idNames.insert(std::make_pair(2, "hp 223"));
306 ASSERT_EQ(bindInfo.GetDisplayIdNames(), idNames);
307
308 // 检测到触摸板设备
309 bindInfo.AddInputDevice(1, "mouse");
310 bindInfo.AddInputDevice(2, "keyboard");
311
312 // 窗口同步信息
313 bindInfo.AddDisplay(0, "think 123");
314 idNames.insert(std::make_pair(0, "think 123"));
315 ASSERT_EQ(bindInfo.GetDisplayIdNames(), idNames);
316 bindInfo.AddDisplay(2, "hp 223");
317 idNames.insert(std::make_pair(2, "hp 223"));
318 ASSERT_EQ(bindInfo.GetDisplayIdNames(), idNames);
319 ASSERT_EQ(bindInfo.Dumps(), std::string("mouse<=>think 123\nkeyboard<=>hp 223\n"));
320 }
321
322 /**
323 * @tc.name: InputDisplayBindHelperTest_GetInputDeviceById_008
324 * @tc.desc: Test GetInputDeviceById
325 * @tc.type: FUNC
326 * @tc.require:
327 */
328 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetInputDeviceById_008, TestSize.Level1)
329 {
330 CALL_TEST_DEBUG;
331 InputDisplayBindHelper idh("/data/service/el1/public/multimodalinput/0.txt");
332 if (!(InputDisplayBindHelperTest::InitInputNode())) {
333 return;
334 }
335 if (!(InputDisplayBindHelperTest::InitConfigFile())) {
336 return;
337 }
338 // 读取输入节点名称
339 std::string content = idh.GetContent(INPUT_DEVICE_NAME_FILE);
340 ASSERT_EQ(content, INPUT_NODE_NAME);
341 // 根据输入节点名称获取输入节点
342 std::string inputNode = idh.GetInputNode(INPUT_NODE_NAME);
343 ASSERT_EQ(inputNode, "");
344 // 根据id获取输入节点名称
345 std::string inputNodeName = idh.GetInputNodeNameByCfg(1000);
346 ASSERT_EQ(inputNodeName, "");
347 // 根据id获取输入设备
348 std::string inputDevice = idh.GetInputDeviceById(1000);
349 ASSERT_EQ(inputDevice, "");
350 }
351
352 /**
353 * @tc.name: InputDisplayBindHelperTest_SetDisplayBind_01
354 * @tc.desc: Test SetDisplayBind
355 * @tc.type: FUNC
356 * @tc.require:
357 */
358 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_SetDisplayBind_01, TestSize.Level1)
359 {
360 CALL_TEST_DEBUG;
361 int32_t deviceId;
362 int32_t displayId;
363 InputDisplayBindHelper idh("/data/service/el1/public/multimodalinput/0.txt");
364 std::string msg = "deviceId";
365 deviceId = -1;
366 displayId = -1;
367 int32_t ret1 = idh.SetDisplayBind(deviceId, displayId, msg);
368 EXPECT_EQ(ret1, RET_ERR);
369
370 deviceId = 1;
371 displayId = 2;
372 int32_t ret2 = idh.SetDisplayBind(deviceId, displayId, msg);
373 EXPECT_EQ(ret2, RET_ERR);
374 }
375
376 /**
377 * @tc.name: InputDisplayBindHelperTest_GetInputDeviceById_01
378 * @tc.desc: Test GetInputDeviceById
379 * @tc.type: FUNC
380 * @tc.require:
381 */
382 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetInputDeviceById_01, TestSize.Level1)
383 {
384 CALL_TEST_DEBUG;
385 InputDisplayBindHelper idh("/data/service/el1/public/multimodalinput/0.txt");
386 int32_t id = 3;
387 std::string ret1 = idh.GetInputDeviceById(id);
388 EXPECT_EQ(ret1, "");
389
390 id = 6;
391 std::string inputNodeName = "";
392 EXPECT_TRUE(inputNodeName.empty());
393 std::string ret2 = idh.GetInputDeviceById(id);
394 EXPECT_EQ(ret2, "");
395
396 id = 8;
397 std::string inputNode = "";
398 EXPECT_TRUE(inputNode.empty());
399 std::string ret3 = idh.GetInputDeviceById(id);
400 EXPECT_EQ(ret3, "");
401 }
402
403 /**
404 * @tc.name: InputDisplayBindHelperTest_GetInputNodeNameByCfg_01
405 * @tc.desc: Test GetInputNodeNameByCfg
406 * @tc.type: FUNC
407 * @tc.require:
408 */
409 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetInputNodeNameByCfg_01, TestSize.Level1)
410 {
411 CALL_TEST_DEBUG;
412 int32_t id = 3;
413 InputDisplayBindHelper idh("/data/service/el1/public/multimodalinput/0.txt");
414 std::ifstream file(INPUT_DEVICE_NAME_CONFIG);
415 EXPECT_TRUE(file.is_open());
416 std::string ret1 = idh.GetInputNodeNameByCfg(id);
417 EXPECT_EQ(ret1, "");
418
419 id = 2;
420 std::string res = "abc";
421 res.back() = '\n';
422 std::string ret2 = idh.GetInputNodeNameByCfg(id);
423 EXPECT_EQ(ret2, "");
424 }
425
426 /**
427 * @tc.name: InputDisplayBindHelperTest_AddInputDevice_02
428 * @tc.desc: Test AddInputDevice
429 * @tc.type: FUNC
430 * @tc.require:
431 */
432 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_AddInputDevice_02, TestSize.Level1)
433 {
434 CALL_TEST_DEBUG;
435 BindInfo bindInfo;
436 bindInfo.inputDeviceName_ = "mouse";
437 ASSERT_NO_FATAL_FAILURE(bindInfo.AddInputDevice(1, "mouse"));
438 }
439
440 /**
441 * @tc.name: InputDisplayBindHelperTest_AddInputDevice_03
442 * @tc.desc: Test AddInputDevice
443 * @tc.type: FUNC
444 * @tc.require:
445 */
446 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_AddInputDevice_03, TestSize.Level1)
447 {
448 CALL_TEST_DEBUG;
449 BindInfo bindInfo;
450 bindInfo.inputDeviceId_ = 1;
451 ASSERT_NO_FATAL_FAILURE(bindInfo.AddInputDevice(1, "mouse"));
452 }
453
454 /**
455 * @tc.name: InputDisplayBindHelperTest_AddInputDevice_04
456 * @tc.desc: Test AddInputDevice
457 * @tc.type: FUNC
458 * @tc.require:
459 */
460 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_AddInputDevice_04, TestSize.Level1)
461 {
462 CALL_TEST_DEBUG;
463 BindInfo bindInfo;
464 bindInfo.inputDeviceId_ = 1;
465 bindInfo.inputDeviceName_ = "mouse";
466 ASSERT_NO_FATAL_FAILURE(bindInfo.AddInputDevice(1, "mouse"));
467 }
468
469 /**
470 * @tc.name: InputDisplayBindHelperTest_AddDisplay_01
471 * @tc.desc: Test AddDisplay
472 * @tc.type: FUNC
473 * @tc.require:
474 */
475 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_AddDisplay_01, TestSize.Level1)
476 {
477 CALL_TEST_DEBUG;
478 BindInfo bindInfo;
479 ASSERT_NO_FATAL_FAILURE(bindInfo.AddDisplay(0, "hp 223"));
480 }
481
482 /**
483 * @tc.name: InputDisplayBindHelperTest_AddDisplay_02
484 * @tc.desc: Test AddDisplay
485 * @tc.type: FUNC
486 * @tc.require:
487 */
488 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_AddDisplay_02, TestSize.Level1)
489 {
490 CALL_TEST_DEBUG;
491 BindInfo bindInfo;
492 bindInfo.displayName_ = "hp 223";
493 ASSERT_NO_FATAL_FAILURE(bindInfo.AddDisplay(0, "hp 223"));
494 }
495
496 /**
497 * @tc.name: InputDisplayBindHelperTest_AddDisplay_03
498 * @tc.desc: Test AddDisplay
499 * @tc.type: FUNC
500 * @tc.require:
501 */
502 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_AddDisplay_03, TestSize.Level1)
503 {
504 CALL_TEST_DEBUG;
505 BindInfo bindInfo;
506 bindInfo.displayId_ = 0;
507 ASSERT_NO_FATAL_FAILURE(bindInfo.AddDisplay(0, "hp 223"));
508 }
509
510 /**
511 * @tc.name: InputDisplayBindHelperTest_AddDisplay_04
512 * @tc.desc: Test AddDisplay
513 * @tc.type: FUNC
514 * @tc.require:
515 */
516 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_AddDisplay_04, TestSize.Level1)
517 {
518 CALL_TEST_DEBUG;
519 BindInfo bindInfo;
520 bindInfo.displayId_ = 0;
521 bindInfo.displayName_ = "hp 223";
522 ASSERT_NO_FATAL_FAILURE(bindInfo.AddDisplay(0, "hp 223"));
523 }
524
525 /**
526 * @tc.name: InputDisplayBindHelperTest_AddDisplay_05
527 * @tc.desc: Test AddDisplay
528 * @tc.type: FUNC
529 * @tc.require:
530 */
531 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_AddDisplay_05, TestSize.Level1)
532 {
533 CALL_TEST_DEBUG;
534 BindInfo bindInfo;
535 bindInfo.displayId_ = -1;
536 bindInfo.displayName_ = "";
537 bool ret = bindInfo.AddDisplay(1, "hp 223");
538 EXPECT_TRUE(ret);
539 }
540
541 /**
542 * @tc.name: InputDisplayBindHelperTest_AddDisplay_06
543 * @tc.desc: Test AddDisplay
544 * @tc.type: FUNC
545 * @tc.require:
546 */
547 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_AddDisplay_06, TestSize.Level1)
548 {
549 CALL_TEST_DEBUG;
550 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
551 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
552
553 int32_t id = 3;
554 std::string name = "display";
555 std::string deviceName = inputDisplayBindHelper.GetInputDeviceById(id);
556 EXPECT_TRUE(deviceName.empty());
557 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.AddDisplay(id, name));
558 }
559
560 /**
561 * @tc.name: InputDisplayBindHelperTest_GetDesc_01
562 * @tc.desc: Test GetDesc
563 * @tc.type: FUNC
564 * @tc.require:
565 */
566 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetDesc_01, TestSize.Level1)
567 {
568 CALL_TEST_DEBUG;
569 BindInfo bindInfo;
570 bindInfo.inputDeviceId_ = 1;
571 bindInfo.inputDeviceName_ = "mouse";
572 bindInfo.displayId_ = 0;
573 bindInfo.displayName_ = "hp 223";
574 ASSERT_NO_FATAL_FAILURE(bindInfo.GetDesc());
575 }
576
577 /**
578 * @tc.name: InputDisplayBindHelperTest_GetDesc_02
579 * @tc.desc: Test GetDesc
580 * @tc.type: FUNC
581 * @tc.require:
582 */
583 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetDesc_02, TestSize.Level1)
584 {
585 CALL_TEST_DEBUG;
586 BindInfos bindInfos;
587 BindInfo bindInfo;
588 bindInfo.inputDeviceId_ = 1;
589 bindInfo.inputDeviceName_ = "mouse";
590 bindInfo.displayId_ = 0;
591 bindInfo.displayName_ = "hp 223";
592 bindInfos.infos_.push_back(bindInfo);
593 ASSERT_NO_FATAL_FAILURE(bindInfos.GetDesc());
594 }
595
596 /**
597 * @tc.name: InputDisplayBindHelperTest_GetBindDisplayIdByInputDevice_01
598 * @tc.desc: Test GetBindDisplayIdByInputDevice
599 * @tc.type: FUNC
600 * @tc.require:
601 */
602 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetBindDisplayIdByInputDevice_01, TestSize.Level1)
603 {
604 CALL_TEST_DEBUG;
605 BindInfos bindInfos;
606 BindInfo bindInfo;
607 bindInfo.inputDeviceId_ = 1;
608 bindInfo.inputDeviceName_ = "mouse";
609 bindInfo.displayId_ = 0;
610 bindInfo.displayName_ = "hp 223";
611 bindInfos.infos_.push_back(bindInfo);
612 ASSERT_NO_FATAL_FAILURE(bindInfos.GetBindDisplayIdByInputDevice(1));
613 }
614
615 /**
616 * @tc.name: InputDisplayBindHelperTest_GetBindDisplayIdByInputDevice_02
617 * @tc.desc: Test GetBindDisplayIdByInputDevice
618 * @tc.type: FUNC
619 * @tc.require:
620 */
621 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetBindDisplayIdByInputDevice_02, TestSize.Level1)
622 {
623 CALL_TEST_DEBUG;
624 BindInfos bindInfos;
625 BindInfo bindInfo;
626 bindInfo.inputDeviceId_ = 1;
627 bindInfo.inputDeviceName_ = "mouse";
628 bindInfo.displayId_ = -1;
629 bindInfo.displayName_ = "hp 223";
630 bindInfos.infos_.push_back(bindInfo);
631 ASSERT_NO_FATAL_FAILURE(bindInfos.GetBindDisplayIdByInputDevice(1));
632 }
633
634 /**
635 * @tc.name: InputDisplayBindHelperTest_GetBindDisplayIdByInputDevice_03
636 * @tc.desc: Test GetBindDisplayIdByInputDevice
637 * @tc.type: FUNC
638 * @tc.require:
639 */
640 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetBindDisplayIdByInputDevice_03, TestSize.Level1)
641 {
642 CALL_TEST_DEBUG;
643 BindInfos bindInfos;
644 BindInfo bindInfo;
645 bindInfo.inputDeviceId_ = 1;
646 bindInfo.inputDeviceName_ = "mouse";
647 bindInfo.displayId_ = -1;
648 bindInfo.displayName_ = "hp 223";
649 bindInfos.infos_.push_back(bindInfo);
650 ASSERT_NO_FATAL_FAILURE(bindInfos.GetBindDisplayIdByInputDevice(2));
651 }
652
653 /**
654 * @tc.name: InputDisplayBindHelperTest_GetBindDisplayNameByInputDevice_01
655 * @tc.desc: Test GetBindDisplayNameByInputDevice
656 * @tc.type: FUNC
657 * @tc.require:
658 */
659 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetBindDisplayNameByInputDevice_01, TestSize.Level1)
660 {
661 CALL_TEST_DEBUG;
662 BindInfos bindInfos;
663 BindInfo bindInfo;
664 bindInfo.inputDeviceId_ = 1;
665 bindInfo.inputDeviceName_ = "mouse";
666 bindInfo.displayId_ = -1;
667 bindInfo.displayName_ = "hp 223";
668 bindInfos.infos_.push_back(bindInfo);
669 ASSERT_NO_FATAL_FAILURE(bindInfos.GetBindDisplayNameByInputDevice(1));
670 }
671
672 /**
673 * @tc.name: InputDisplayBindHelperTest_GetDisplayIdNames_01
674 * @tc.desc: Test GetDisplayIdNames
675 * @tc.type: FUNC
676 * @tc.require:
677 */
678 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetDisplayIdNames_01, TestSize.Level1)
679 {
680 CALL_TEST_DEBUG;
681 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
682 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
683 BindInfo bindInfo;
684 bindInfo.inputDeviceId_ = 1;
685 bindInfo.inputDeviceName_ = "mouse";
686 bindInfo.displayId_ = -1;
687 bindInfo.displayName_ = "hp 223";
688 inputDisplayBindHelper.infos_->infos_.push_back(bindInfo);
689 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.GetDisplayIdNames());
690 }
691
692 /**
693 * @tc.name: InputDisplayBindHelperTest_AddLocalDisplay_02
694 * @tc.desc: Test AddLocalDisplay
695 * @tc.type: FUNC
696 * @tc.require:
697 */
698 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_AddLocalDisplay_02, TestSize.Level1)
699 {
700 CALL_TEST_DEBUG;
701 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
702 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
703 BindInfo bindInfo;
704 bindInfo.inputDeviceId_ = 1;
705 bindInfo.inputDeviceName_ = "mouse";
706 bindInfo.displayId_ = -1;
707 bindInfo.displayName_ = "hp 223";
708 inputDisplayBindHelper.infos_->infos_.push_back(bindInfo);
709 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.AddLocalDisplay(0, "hp 223"));
710 }
711
712 /**
713 * @tc.name: InputDisplayBindHelperTest_AddLocalDisplay_03
714 * @tc.desc: Test AddLocalDisplay
715 * @tc.type: FUNC
716 * @tc.require:
717 */
718 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_AddLocalDisplay_03, TestSize.Level1)
719 {
720 CALL_TEST_DEBUG;
721 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
722 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
723 BindInfo bindInfo;
724 bindInfo.inputDeviceId_ = 1;
725 bindInfo.inputDeviceName_ = "mouse";
726 bindInfo.displayId_ = 0;
727 bindInfo.displayName_ = "hp 223";
728 inputDisplayBindHelper.infos_->infos_.push_back(bindInfo);
729 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.AddLocalDisplay(0, "hp 223"));
730 }
731
732 /**
733 * @tc.name: InputDisplayBindHelperTest_GetInputDeviceById_02
734 * @tc.desc: Test GetInputDeviceById
735 * @tc.type: FUNC
736 * @tc.require:
737 */
738 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetInputDeviceById_02, TestSize.Level1)
739 {
740 CALL_TEST_DEBUG;
741 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
742 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
743 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.GetInputDeviceById(1));
744 }
745
746 /**
747 * @tc.name: InputDisplayBindHelperTest_GetInputDeviceById_03
748 * @tc.desc: Test GetInputDeviceById
749 * @tc.type: FUNC
750 * @tc.require:
751 */
752 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetInputDeviceById_03, TestSize.Level1)
753 {
754 CALL_TEST_DEBUG;
755 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
756 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
757 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.GetInputDeviceById(1));
758 }
759
760 /**
761 * @tc.name: InputDisplayBindHelperTest_GetInputDeviceById_04
762 * @tc.desc: Test GetInputDeviceById
763 * @tc.type: FUNC
764 * @tc.require:
765 */
766 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetInputDeviceById_04, TestSize.Level1)
767 {
768 CALL_TEST_DEBUG;
769 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
770 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
771 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.GetInputDeviceById(0));
772 }
773
774 /**
775 * @tc.name: InputDisplayBindHelperTest_GetInputDeviceById_05
776 * @tc.desc: Test GetInputDeviceById
777 * @tc.type: FUNC
778 * @tc.require:
779 */
780 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetInputDeviceById_05, TestSize.Level1)
781 {
782 CALL_TEST_DEBUG;
783 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
784 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
785
786 int32_t id = 5;
787 std::string inputNodeName = inputDisplayBindHelper.GetInputNodeNameByCfg(id);
788 EXPECT_TRUE(inputNodeName.empty());
789
790 std::string inputNode = inputDisplayBindHelper.GetInputNode(inputNodeName);
791 EXPECT_TRUE(inputNode.empty());
792
793 std::string ret = inputDisplayBindHelper.GetInputDeviceById(id);
794 EXPECT_EQ(ret, "");
795 }
796
797 /**
798 * @tc.name: InputDisplayBindHelperTest_GetInputDeviceById_06
799 * @tc.desc: Test GetInputDeviceById
800 * @tc.type: FUNC
801 * @tc.require:
802 */
803 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetInputDeviceById_06, TestSize.Level1)
804 {
805 CALL_TEST_DEBUG;
806 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
807 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
808
809 int32_t id = 0;
810 std::string ret1 = inputDisplayBindHelper.GetInputDeviceById(id);
811 EXPECT_EQ(ret1, "");
812
813
814 std::string inputNodeName = "mouse";
815 EXPECT_FALSE(inputNodeName.empty());
816 std::string ret2 = inputDisplayBindHelper.GetInputDeviceById(id);
817 EXPECT_EQ(ret2, "");
818
819 std::string inputNode = "keyboard";
820 EXPECT_FALSE(inputNode.empty());
821 std::string ret3 = inputDisplayBindHelper.GetInputDeviceById(id);
822 EXPECT_EQ(ret3, "");
823
824 std::string inputEvent = inputNode;
825 size_t pos = inputEvent.find("input");
826 EXPECT_TRUE(pos == std::string::npos);
827 std::string ret4 = inputDisplayBindHelper.GetInputDeviceById(id);
828 EXPECT_EQ(ret4, "");
829 }
830
831 /**
832 * @tc.name: InputDisplayBindHelperTest_GetInputNodeNameByCfg_02
833 * @tc.desc: Test GetInputNodeNameByCfg
834 * @tc.type: FUNC
835 * @tc.require:
836 */
837 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetInputNodeNameByCfg_02, TestSize.Level1)
838 {
839 CALL_TEST_DEBUG;
840 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
841 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
842 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.GetInputNodeNameByCfg(0));
843 }
844
845 /**
846 * @tc.name: InputDisplayBindHelperTest_GetInputNodeNameByCfg_03
847 * @tc.desc: Test GetInputNodeNameByCfg
848 * @tc.type: FUNC
849 * @tc.require:
850 */
851 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetInputNodeNameByCfg_03, TestSize.Level1)
852 {
853 CALL_TEST_DEBUG;
854 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
855 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
856
857 int32_t id = 2;
858 std::string displayId = "";
859 std::string inputNodeName = "";
860 size_t pos;
861 pos = std::string::npos;
862 std::string ret = inputDisplayBindHelper.GetInputNodeNameByCfg(id);
863 EXPECT_EQ(ret, "");
864 }
865
866 /**
867 * @tc.name: InputDisplayBindHelperTest_GetInputNodeNameByCfg_04
868 * @tc.desc: Test GetInputNodeNameByCfg
869 * @tc.type: FUNC
870 * @tc.require:
871 */
872 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetInputNodeNameByCfg_04, TestSize.Level1)
873 {
874 CALL_TEST_DEBUG;
875 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
876 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
877
878 int32_t id = 2;
879 std::string displayId = "hp223";
880 std::string inputNodeName = "nodeName";
881 size_t pos;
882 pos = 3;
883 std::string ret = inputDisplayBindHelper.GetInputNodeNameByCfg(id);
884 EXPECT_EQ(ret, "");
885 }
886
887 /**
888 * @tc.name: InputDisplayBindHelperTest_GetInputNode_01
889 * @tc.desc: Test GetInputNode
890 * @tc.type: FUNC
891 * @tc.require:
892 */
893 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetInputNode_01, TestSize.Level1)
894 {
895 CALL_TEST_DEBUG;
896 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
897 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
898 std::string inputNodeName = "input5";
899 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.GetInputNode(inputNodeName));
900 }
901
902 /**
903 * @tc.name: InputDisplayBindHelperTest_GetInputNode_02
904 * @tc.desc: Test GetInputNode
905 * @tc.type: FUNC
906 * @tc.require:
907 */
908 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_GetInputNode_02, TestSize.Level1)
909 {
910 CALL_TEST_DEBUG;
911 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
912 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
913 std::string inputNodeName = "wrapper";
914 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.GetInputNode(inputNodeName));
915 }
916
917 /**
918 * @tc.name: InputDisplayBindHelperTest_Store_01
919 * @tc.desc: Test Store
920 * @tc.type: FUNC
921 * @tc.require:
922 */
923 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_Store_01, TestSize.Level1)
924 {
925 CALL_TEST_DEBUG;
926 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
927 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
928 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.Store());
929 }
930
931 /**
932 * @tc.name: InputDisplayBindHelperTest_Store_02
933 * @tc.desc: Test Store
934 * @tc.type: FUNC
935 * @tc.require:
936 */
937 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_Store_02, TestSize.Level1)
938 {
939 CALL_TEST_DEBUG;
940 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
941 InputDisplayBindHelper inputDisplayBindHelper("input_display_bind_helper_tmp.cfg");
942 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.Store());
943 }
944
945 /**
946 * @tc.name: InputDisplayBindHelperTest_SetDisplayBind_02
947 * @tc.desc: Test SetDisplayBind
948 * @tc.type: FUNC
949 * @tc.require:
950 */
951 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_SetDisplayBind_02, TestSize.Level1)
952 {
953 CALL_TEST_DEBUG;
954 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
955 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
956 int32_t deviceId = -1;
957 int32_t displayId = -1;
958 std::string msg = "touch";
959 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.SetDisplayBind(deviceId, displayId, msg));
960 }
961
962 /**
963 * @tc.name: InputDisplayBindHelperTest_SetDisplayBind_03
964 * @tc.desc: Test SetDisplayBind
965 * @tc.type: FUNC
966 * @tc.require:
967 */
968 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_SetDisplayBind_03, TestSize.Level1)
969 {
970 CALL_TEST_DEBUG;
971 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
972 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
973 int32_t deviceId = -1;
974 int32_t displayId = 0;
975 std::string msg = "touch";
976 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.SetDisplayBind(deviceId, displayId, msg));
977 }
978
979 /**
980 * @tc.name: InputDisplayBindHelperTest_SetDisplayBind_04
981 * @tc.desc: Test SetDisplayBind
982 * @tc.type: FUNC
983 * @tc.require:
984 */
985 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_SetDisplayBind_04, TestSize.Level1)
986 {
987 CALL_TEST_DEBUG;
988 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
989 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
990 int32_t deviceId = 1;
991 int32_t displayId = -1;
992 std::string msg = "touch";
993 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.SetDisplayBind(deviceId, displayId, msg));
994 }
995
996 /**
997 * @tc.name: InputDisplayBindHelperTest_SetDisplayBind_05
998 * @tc.desc: Test SetDisplayBind
999 * @tc.type: FUNC
1000 * @tc.require:
1001 */
1002 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_SetDisplayBind_05, TestSize.Level1)
1003 {
1004 CALL_TEST_DEBUG;
1005 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
1006 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
1007 int32_t deviceId = 1;
1008 int32_t displayId = 0;
1009 std::string msg = "touch";
1010 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.SetDisplayBind(deviceId, displayId, msg));
1011 }
1012
1013 /**
1014 * @tc.name: InputDisplayBindHelperTest_SetDisplayBind_06
1015 * @tc.desc: Test SetDisplayBind
1016 * @tc.type: FUNC
1017 * @tc.require:
1018 */
1019 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_SetDisplayBind_06, TestSize.Level1)
1020 {
1021 CALL_TEST_DEBUG;
1022 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
1023 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
1024 int32_t deviceId = 1;
1025 int32_t displayId = 0;
1026 std::string msg = "touch";
1027 inputDisplayBindHelper.infos_ = nullptr;
1028 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.SetDisplayBind(deviceId, displayId, msg));
1029 }
1030
1031 /**
1032 * @tc.name: InputDisplayBindHelperTest_SetDisplayBind_07
1033 * @tc.desc: Test SetDisplayBind
1034 * @tc.type: FUNC
1035 * @tc.require:
1036 */
1037 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_SetDisplayBind_07, TestSize.Level1)
1038 {
1039 CALL_TEST_DEBUG;
1040 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
1041 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
1042 BindInfo bindInfo;
1043 bindInfo.inputDeviceId_ = 1;
1044 bindInfo.inputDeviceName_ = "mouse";
1045 bindInfo.displayId_ = 0;
1046 bindInfo.displayName_ = "hp 223";
1047 inputDisplayBindHelper.infos_->infos_.push_back(bindInfo);
1048 int32_t deviceId = 1;
1049 int32_t displayId = 0;
1050 std::string msg = "touch";
1051 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.SetDisplayBind(deviceId, displayId, msg));
1052 }
1053
1054 /**
1055 * @tc.name: InputDisplayBindHelperTest_SetDisplayBind_08
1056 * @tc.desc: Test SetDisplayBind
1057 * @tc.type: FUNC
1058 * @tc.require:
1059 */
1060 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_SetDisplayBind_08, TestSize.Level1)
1061 {
1062 CALL_TEST_DEBUG;
1063 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
1064 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
1065 BindInfo bindInfo;
1066 bindInfo.inputDeviceId_ = 1;
1067 bindInfo.inputDeviceName_ = "mouse";
1068 bindInfo.displayId_ = 0;
1069 bindInfo.displayName_ = "hp 223";
1070 inputDisplayBindHelper.infos_->infos_.push_back(bindInfo);
1071 int32_t deviceId = 2;
1072 int32_t displayId = 1;
1073 std::string msg = "touch";
1074 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.SetDisplayBind(deviceId, displayId, msg));
1075 }
1076
1077 /**
1078 * @tc.name: InputDisplayBindHelperTest_SetDisplayBind_09
1079 * @tc.desc: Test SetDisplayBind
1080 * @tc.type: FUNC
1081 * @tc.require:
1082 */
1083 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_SetDisplayBind_09, TestSize.Level1)
1084 {
1085 CALL_TEST_DEBUG;
1086 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
1087 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
1088 BindInfo bindInfo;
1089 bindInfo.inputDeviceId_ = 1;
1090 bindInfo.inputDeviceName_ = "mouse";
1091 bindInfo.displayId_ = -1;
1092 bindInfo.displayName_ = "hp 223";
1093 inputDisplayBindHelper.infos_->infos_.push_back(bindInfo);
1094 int32_t deviceId = 1;
1095 int32_t displayId = 0;
1096 std::string msg = "touch";
1097 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.SetDisplayBind(deviceId, displayId, msg));
1098 }
1099
1100 /**
1101 * @tc.name: InputDisplayBindHelperTest_SetDisplayBind_10
1102 * @tc.desc: Test SetDisplayBind
1103 * @tc.type: FUNC
1104 * @tc.require:
1105 */
1106 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_SetDisplayBind_10, TestSize.Level1)
1107 {
1108 CALL_TEST_DEBUG;
1109 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
1110 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
1111 BindInfo bindInfo;
1112 bindInfo.inputDeviceId_ = 1;
1113 bindInfo.inputDeviceName_ = "mouse";
1114 bindInfo.displayId_ = 0;
1115 bindInfo.displayName_ = "hp 223";
1116 inputDisplayBindHelper.infos_->infos_.push_back(bindInfo);
1117 bindInfo.inputDeviceId_ = 2;
1118 bindInfo.inputDeviceName_ = "mouse";
1119 bindInfo.displayId_ = 1;
1120 bindInfo.displayName_ = "hp 223";
1121 inputDisplayBindHelper.infos_->infos_.push_back(bindInfo);
1122 int32_t deviceId = 1;
1123 int32_t displayId = 1;
1124 std::string msg = "touch";
1125 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.SetDisplayBind(deviceId, displayId, msg));
1126 }
1127
1128 /**
1129 * @tc.name: InputDisplayBindHelperTest_SetDisplayBind_11
1130 * @tc.desc: Test SetDisplayBind
1131 * @tc.type: FUNC
1132 * @tc.require:
1133 */
1134 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_SetDisplayBind_11, TestSize.Level1)
1135 {
1136 CALL_TEST_DEBUG;
1137 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
1138 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
1139 BindInfo bindInfo;
1140 bindInfo.inputDeviceId_ = 1;
1141 bindInfo.inputDeviceName_ = "mouse";
1142 bindInfo.displayId_ = 0;
1143 bindInfo.displayName_ = "hp 223";
1144 inputDisplayBindHelper.infos_->infos_.push_back(bindInfo);
1145 bindInfo.inputDeviceId_ = -1;
1146 bindInfo.inputDeviceName_ = "mouse";
1147 bindInfo.displayId_ = 1;
1148 bindInfo.displayName_ = "hp 223";
1149 inputDisplayBindHelper.infos_->infos_.push_back(bindInfo);
1150 int32_t deviceId = 1;
1151 int32_t displayId = 1;
1152 std::string msg = "touch";
1153 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.SetDisplayBind(deviceId, displayId, msg));
1154 }
1155
1156 /**
1157 * @tc.name: InputDisplayBindHelperTest_SetDisplayBind_12
1158 * @tc.desc: Test SetDisplayBind
1159 * @tc.type: FUNC
1160 * @tc.require:
1161 */
1162 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_SetDisplayBind_12, TestSize.Level1)
1163 {
1164 CALL_TEST_DEBUG;
1165 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
1166 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
1167 BindInfo bindInfo;
1168 bindInfo.inputDeviceId_ = 1;
1169 bindInfo.inputDeviceName_ = "mouse";
1170 bindInfo.displayId_ = -1;
1171 bindInfo.displayName_ = "hp 223";
1172 inputDisplayBindHelper.infos_->infos_.push_back(bindInfo);
1173 bindInfo.inputDeviceId_ = 2;
1174 bindInfo.inputDeviceName_ = "mouse";
1175 bindInfo.displayId_ = 1;
1176 bindInfo.displayName_ = "hp 223";
1177 inputDisplayBindHelper.infos_->infos_.push_back(bindInfo);
1178 int32_t deviceId = 1;
1179 int32_t displayId = 1;
1180 std::string msg = "touch";
1181 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.SetDisplayBind(deviceId, displayId, msg));
1182 }
1183
1184 /**
1185 * @tc.name: InputDisplayBindHelperTest_SetDisplayBind_13
1186 * @tc.desc: Test SetDisplayBind
1187 * @tc.type: FUNC
1188 * @tc.require:
1189 */
1190 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_SetDisplayBind_13, TestSize.Level1)
1191 {
1192 CALL_TEST_DEBUG;
1193 InputDisplayBindHelperTest::WriteConfigFile("mouse<=>hp 223\nkeyboard<=>think 123\n");
1194 InputDisplayBindHelper inputDisplayBindHelper(InputDisplayBindHelperTest::GetCfgFileName());
1195 BindInfo bindInfo;
1196 bindInfo.inputDeviceId_ = 1;
1197 bindInfo.inputDeviceName_ = "mouse";
1198 bindInfo.displayId_ = -1;
1199 bindInfo.displayName_ = "hp 223";
1200 inputDisplayBindHelper.infos_->infos_.push_back(bindInfo);
1201 bindInfo.inputDeviceId_ = -1;
1202 bindInfo.inputDeviceName_ = "mouse";
1203 bindInfo.displayId_ = 1;
1204 bindInfo.displayName_ = "hp 223";
1205 inputDisplayBindHelper.infos_->infos_.push_back(bindInfo);
1206 int32_t deviceId = 1;
1207 int32_t displayId = 1;
1208 std::string msg = "touch";
1209 ASSERT_NO_FATAL_FAILURE(inputDisplayBindHelper.SetDisplayBind(deviceId, displayId, msg));
1210 }
1211
1212 /**
1213 * @tc.name: InputDisplayBindHelperTest_AddLocalDisplay_01
1214 * @tc.desc: Test AddLocalDisplay
1215 * @tc.type: FUNC
1216 * @tc.require:
1217 */
1218 HWTEST_F(InputDisplayBindHelperTest, InputDisplayBindHelperTest_AddLocalDisplay_01, TestSize.Level1)
1219 {
1220 CALL_TEST_DEBUG;
1221 bool isStore;
1222 int32_t id = 3;
1223 std::string name = "localDisplay";
1224 InputDisplayBindHelper idh("/data/service/el1/public/multimodalinput/0.txt");
1225 isStore = false;
1226 ASSERT_NO_FATAL_FAILURE(idh.AddLocalDisplay(id, name));
1227 }
1228 } // namespace MMI
1229 } // namespace OHOS