1 /*
2 * Copyright (c) 2021-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 <cstdio>
17 #include <fstream>
18 #include <gtest/gtest.h>
19
20 #include "event_filter_handler.h"
21 #include "input_device_manager.h"
22 #include "input_event_handler.h"
23 #include "input_windows_manager.h"
24 #include "i_pointer_drawing_manager.h"
25 #include "fingersense_wrapper.h"
26 #include "mmi_log.h"
27 #include "pointer_drawing_manager.h"
28 #include "proto.h"
29 #include "scene_board_judgement.h"
30 #include "struct_multimodal.h"
31 #include "uds_server.h"
32 #include "window_info.h"
33
34 #undef MMI_LOG_TAG
35 #define MMI_LOG_TAG "InputWindowsManagerTest"
36 namespace OHOS {
37 namespace MMI {
38 using namespace testing::ext;
39 namespace {
40 InputWindowsManager *g_instance;
41 constexpr uint32_t DEFAULT_ICON_COLOR { 0xFF };
42 constexpr int32_t MIDDLE_PIXEL_MAP_WIDTH { 400 };
43 constexpr int32_t MIDDLE_PIXEL_MAP_HEIGHT { 400 };
44 constexpr int32_t MAX_PIXEL_MAP_WIDTH { 600 };
45 constexpr int32_t MAX_PIXEL_MAP_HEIGHT { 600 };
46 constexpr int32_t INT32_BYTE { 4 };
47 } // namespace
48
49 #ifdef WIN_MGR
50 #undef WIN_MGR
51 #endif
52 #define WIN_MGR g_instance
53
54 class InputWindowsManagerTest : public testing::Test {
55 public:
56 static void SetUpTestCase(void);
TearDownTestCase(void)57 static void TearDownTestCase(void) {};
58 static std::shared_ptr<Media::PixelMap> CreatePixelMap(int32_t width, int32_t height);
SetUp(void)59 void SetUp(void)
60 {
61 // 创建displayGroupInfo_
62 DisplayGroupInfo displayGroupInfo;
63 displayGroupInfo.width = 20;
64 displayGroupInfo.height = 20;
65 displayGroupInfo.focusWindowId = 1;
66 uint32_t num = 1;
67 for (uint32_t i = 0; i < num; i++) {
68 WindowInfo info;
69 info.id = 1;
70 info.pid = 1;
71 info.uid = 1;
72 info.area = {1, 1, 1, 1};
73 info.defaultHotAreas = { info.area };
74 info.pointerHotAreas = { info.area };
75 info.agentWindowId = 1;
76 info.flags = 1;
77 info.transform = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};
78 info.pointerChangeAreas = { 1, 2, 1, 2, 1, 2, 1, 2, 1 };
79 displayGroupInfo.windowsInfo.push_back(info);
80 }
81 for (uint32_t i = 0; i < num; i++) {
82 DisplayInfo info;
83 info.id = 1;
84 info.x =1;
85 info.y = 1;
86 info.width = 2;
87 info.height = 2;
88 info.dpi = 240;
89 info.name = "pp";
90 info.uniq = "pp";
91 info.direction = DIRECTION0;
92 displayGroupInfo.displaysInfo.push_back(info);
93 }
94 WIN_MGR->UpdateDisplayInfo(displayGroupInfo);
95 preHoverScrollState_ = WIN_MGR->GetHoverScrollState();
96 } // void SetUp(void)
97
TearDown(void)98 void TearDown(void)
99 {
100 WIN_MGR->SetHoverScrollState(preHoverScrollState_);
101 }
102
103 private:
104 bool preHoverScrollState_ { true };
105 };
106
SetUpTestCase(void)107 void InputWindowsManagerTest::SetUpTestCase(void)
108 {
109 g_instance = static_cast<InputWindowsManager *>(IInputWindowsManager::GetInstance().get());
110 }
111
FingersenseWrapperTest(int32_t num)112 void FingersenseWrapperTest(int32_t num) {}
113
CreatePixelMap(int32_t width,int32_t height)114 std::shared_ptr<Media::PixelMap> InputWindowsManagerTest::CreatePixelMap(int32_t width, int32_t height)
115 {
116 CALL_DEBUG_ENTER;
117 if (width <= 0 || width > MAX_PIXEL_MAP_WIDTH || height <= 0 || height > MAX_PIXEL_MAP_HEIGHT) {
118 return nullptr;
119 }
120 Media::InitializationOptions opts;
121 opts.size.height = height;
122 opts.size.width = width;
123 opts.pixelFormat = Media::PixelFormat::BGRA_8888;
124 opts.alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_OPAQUE;
125 opts.scaleMode = Media::ScaleMode::FIT_TARGET_SIZE;
126
127 int32_t colorLen = width * height;
128 uint32_t *pixelColors = new (std::nothrow) uint32_t[colorLen];
129 CHKPP(pixelColors);
130 int32_t colorByteCount = colorLen * INT32_BYTE;
131 errno_t ret = memset_s(pixelColors, colorByteCount, DEFAULT_ICON_COLOR, colorByteCount);
132 if (ret != EOK) {
133 delete[] pixelColors;
134 return nullptr;
135 }
136 std::shared_ptr<Media::PixelMap> pixelMap = Media::PixelMap::Create(pixelColors, colorLen, opts);
137 if (pixelMap == nullptr) {
138 delete[] pixelColors;
139 return nullptr;
140 }
141 delete[] pixelColors;
142 return pixelMap;
143 }
144
145 /**
146 * @tc.name: InputWindowsManagerTest_GetClientFd_001
147 * @tc.desc: Test GetClientFd
148 * @tc.type: FUNC
149 * @tc.require:
150 */
151 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetClientFd_001, TestSize.Level1)
152 {
153 CALL_TEST_DEBUG;
154 auto pointerEvent = PointerEvent::Create();
155 UDSServer udsServer;
156 WIN_MGR->Init(udsServer);
157 WIN_MGR->GetDisplayGroupInfo();
158 int32_t idNames = -1;
159 ASSERT_EQ(WIN_MGR->GetClientFd(pointerEvent), idNames);
160 }
161
162 /**
163 * @tc.name: InputWindowsManagerTest_UpdateTarget_003
164 * @tc.desc: Test UpdateTarget
165 * @tc.type: FUNC
166 * @tc.require:
167 */
168 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTarget_003, TestSize.Level1)
169 {
170 CALL_TEST_DEBUG;
171 UDSServer udsServer;
172 WIN_MGR->Init(udsServer);
173 auto keyEvent = KeyEvent::Create();
174 ASSERT_NE(keyEvent, nullptr);
175 keyEvent->SetDeviceId(1);
176 keyEvent->SetTargetWindowId(1);
177 keyEvent->SetAgentWindowId(1);
178 EXPECT_NO_FATAL_FAILURE(WIN_MGR->UpdateTarget(keyEvent));
179 }
180
181 /**
182 * @tc.name: InputWindowsManagerTest_HandleKeyEventWindowId_003
183 * @tc.desc: Test HandleKeyEventWindowId
184 * @tc.type: FUNC
185 * @tc.require:
186 */
187 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandleKeyEventWindowId_001, TestSize.Level1)
188 {
189 CALL_TEST_DEBUG;
190 UDSServer udsServer;
191 WIN_MGR->Init(udsServer);
192 auto keyEvent = KeyEvent::Create();
193 ASSERT_NE(keyEvent, nullptr);
194 keyEvent->SetDeviceId(1);
195 keyEvent->SetTargetWindowId(1);
196 keyEvent->SetAgentWindowId(1);
197 WIN_MGR->HandleKeyEventWindowId(keyEvent);
198 }
199
200 /**
201 * @tc.name: InputWindowsManagerTest_UpdateWindow_002
202 * @tc.desc: Test UpdateWindow
203 * @tc.type: FUNC
204 * @tc.require:
205 */
206 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateWindow_002, TestSize.Level1)
207 {
208 CALL_TEST_DEBUG;
209 WindowInfo window;
210 window.id = 11;
211 window.pid = 1221;
212 window.uid = 1;
213 window.area = {1, 1, 1, 1};
214 window.defaultHotAreas = { window.area };
215 window.pointerHotAreas = { window.area };
216 window.pointerChangeAreas = {1, 2, 1, 2};
217 window.displayId = 0;
218 window.agentWindowId = 1;
219 window.flags = 1;
220 window.action = WINDOW_UPDATE_ACTION::UNKNOWN;
221 WIN_MGR->UpdateWindowInfo({0, 11, {window}});
222 ASSERT_EQ(WIN_MGR->GetWindowPid(11), -1);
223 }
224
225 /**
226 * @tc.name: InputWindowsManagerTest_UpdateTargetPointer_005
227 * @tc.desc: Test UpdateTargetPointer
228 * @tc.type: FUNC
229 * @tc.require:
230 */
231 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTargetPointer_005, TestSize.Level1)
232 {
233 CALL_TEST_DEBUG;
234 UDSServer udsServer;
235 WIN_MGR->Init(udsServer);
236 auto pointerEvent = PointerEvent::Create();
237 ASSERT_EQ(WIN_MGR->UpdateTargetPointer(pointerEvent), -1);
238 }
239
240 /**
241 * @tc.name: InputWindowsManagerTest_IsNeedRefreshLayer_006
242 * @tc.desc: Test IsNeedRefreshLayer
243 * @tc.type: FUNC
244 * @tc.require:
245 */
246 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsNeedRefreshLayer_006, TestSize.Level1)
247 {
248 CALL_TEST_DEBUG;
249 UDSServer udsServer;
250 WIN_MGR->Init(udsServer);
251 if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
252 ASSERT_EQ(WIN_MGR->IsNeedRefreshLayer(-1), true);
253 ASSERT_EQ(WIN_MGR->IsNeedRefreshLayer(0), true);
254 ASSERT_EQ(WIN_MGR->IsNeedRefreshLayer(1), true);
255 } else {
256 ASSERT_EQ(WIN_MGR->IsNeedRefreshLayer(-1), false);
257 ASSERT_EQ(WIN_MGR->IsNeedRefreshLayer(0), false);
258 ASSERT_EQ(WIN_MGR->IsNeedRefreshLayer(1), false);
259 }
260 }
261
262 /**
263 * @tc.name: InputWindowsManagerTest_SetMouseCaptureMode_008
264 * @tc.desc: Test SetMouseCaptureMode
265 * @tc.type: FUNC
266 * @tc.require:
267 */
268 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetMouseCaptureMode_008, TestSize.Level1)
269 {
270 CALL_TEST_DEBUG;
271 UDSServer udsServer;
272 WIN_MGR->Init(udsServer);
273 bool isCaptureMode = false;
274 ASSERT_EQ(WIN_MGR->SetMouseCaptureMode(-1, isCaptureMode), -1);
275 ASSERT_EQ(WIN_MGR->SetMouseCaptureMode(1, isCaptureMode), 0);
276 isCaptureMode = true;
277 ASSERT_EQ(WIN_MGR->SetMouseCaptureMode(1, isCaptureMode), 0);
278 }
279
280 /**
281 * @tc.name: InputWindowsManagerTest_SetDisplayBind_009
282 * @tc.desc: Test SetDisplayBind
283 * @tc.type: FUNC
284 * @tc.require:
285 */
286 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetDisplayBind_009, TestSize.Level1)
287 {
288 CALL_TEST_DEBUG;
289 UDSServer udsServer;
290 WIN_MGR->Init(udsServer);
291 std::string sysUid = "james";
292 std::string devStatus = "add";
293 WIN_MGR->DeviceStatusChanged(2, sysUid, devStatus);
294 devStatus = "remove";
295 WIN_MGR->DeviceStatusChanged(2, sysUid, devStatus);
296 std::string msg = "There is in InputWindowsManagerTest_GetDisplayIdNames_009";
297 ASSERT_EQ(WIN_MGR->SetDisplayBind(-1, 1, msg), -1);
298 }
299
300 /**
301 * @tc.name: InputWindowsManagerTest_SetHoverScrollState_010
302 * @tc.desc: Test SetHoverScrollState
303 * @tc.type: FUNC
304 * @tc.require:
305 */
306 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetHoverScrollState_010, TestSize.Level1)
307 {
308 CALL_TEST_DEBUG;
309 ASSERT_TRUE(WIN_MGR->SetHoverScrollState(false) == RET_OK);
310 WIN_MGR->SetHoverScrollState(true);
311 }
312
313 /**
314 * @tc.name: InputWindowsManagerTest_GetHoverScrollState_011
315 * @tc.desc: Test GetHoverScrollState
316 * @tc.type: FUNC
317 * @tc.require:
318 */
319 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetHoverScrollState_011, TestSize.Level1)
320 {
321 CALL_TEST_DEBUG;
322 WIN_MGR->SetHoverScrollState(true);
323 ASSERT_TRUE(WIN_MGR->GetHoverScrollState());
324 }
325
326 /**
327 * @tc.name: InputWindowsManagerTest_InitMouseDownInfo_001
328 * @tc.desc: Test initializing mouse down information
329 * @tc.type: FUNC
330 * @tc.require:
331 */
332 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_InitMouseDownInfo_001, TestSize.Level1)
333 {
334 CALL_TEST_DEBUG;
335 WIN_MGR->InitMouseDownInfo();
336 EXPECT_EQ(WIN_MGR->mouseDownInfo_.id, -1);
337 EXPECT_EQ(WIN_MGR->mouseDownInfo_.pid, -1);
338 EXPECT_TRUE(WIN_MGR->mouseDownInfo_.defaultHotAreas.empty());
339 EXPECT_TRUE(WIN_MGR->mouseDownInfo_.pointerHotAreas.empty());
340 }
341
342 /**
343 * @tc.name: InputWindowsManagerTest_InitMouseDownInfo_002
344 * @tc.desc: Test initializing mouse down information
345 * @tc.type: FUNC
346 * @tc.require:
347 */
348 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_InitMouseDownInfo_002, TestSize.Level1)
349 {
350 CALL_TEST_DEBUG;
351 WIN_MGR->mouseDownInfo_.id = 1;
352 WIN_MGR->mouseDownInfo_.pid = 123;
353 WIN_MGR->mouseDownInfo_.defaultHotAreas.push_back({0, 0, 100, 100});
354 WIN_MGR->InitMouseDownInfo();
355 EXPECT_EQ(WIN_MGR->mouseDownInfo_.id, -1);
356 EXPECT_EQ(WIN_MGR->mouseDownInfo_.pid, -1);
357 EXPECT_TRUE(WIN_MGR->mouseDownInfo_.defaultHotAreas.empty());
358 EXPECT_TRUE(WIN_MGR->mouseDownInfo_.pointerHotAreas.empty());
359 }
360
361 /**
362 * @tc.name: InputWindowsManagerTest_GetWindowGroupInfoByDisplayId_001
363 * @tc.desc: Test getting window group information by display ID
364 * @tc.type: FUNC
365 * @tc.require:
366 */
367 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowGroupInfoByDisplayId_001, TestSize.Level1)
368 {
369 CALL_TEST_DEBUG;
370 int32_t displayId = -1;
371 const std::vector<WindowInfo>& windowGroupInfo = WIN_MGR->GetWindowGroupInfoByDisplayId(displayId);
372 EXPECT_EQ(windowGroupInfo.size(), 1);
373 }
374
375 /**
376 * @tc.name: InputWindowsManagerTest_GetWindowGroupInfoByDisplayId_002
377 * @tc.desc: Test getting window group information by display ID
378 * @tc.type: FUNC
379 * @tc.require:
380 */
381 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowGroupInfoByDisplayId_002, TestSize.Level1)
382 {
383 CALL_TEST_DEBUG;
384 int32_t displayId = 1;
385 const std::vector<WindowInfo>& windowGroupInfo = WIN_MGR->GetWindowGroupInfoByDisplayId(displayId);
386 EXPECT_FALSE(windowGroupInfo.empty());
387 }
388
389 /**
390 * @tc.name: InputWindowsManagerTest_GetDisplayId_001
391 * @tc.desc: Test getting the display ID
392 * @tc.type: FUNC
393 * @tc.require:
394 */
395 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetDisplayId_001, TestSize.Level1)
396 {
397 CALL_TEST_DEBUG;
398 int32_t expectedDisplayId = 1;
399 std::shared_ptr<InputEvent> inputEvent = InputEvent::Create();
400 EXPECT_NE(inputEvent, nullptr);
401 inputEvent->SetTargetDisplayId(expectedDisplayId);
402 int32_t ret = WIN_MGR->GetDisplayId(inputEvent);
403 EXPECT_EQ(ret, expectedDisplayId);
404 }
405
406 /**
407 * @tc.name: InputWindowsManagerTest_GetPidAndUpdateTarget_001
408 * @tc.desc: Test getting PID and updating the target
409 * @tc.type: FUNC
410 * @tc.require:
411 */
412 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPidAndUpdateTarget_001, TestSize.Level1)
413 {
414 CALL_TEST_DEBUG;
415 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
416 EXPECT_NE(keyEvent, nullptr);
417 int32_t targetDisplayId = 0;
418 keyEvent->SetTargetDisplayId(targetDisplayId);
419 ASSERT_NO_FATAL_FAILURE(WIN_MGR->GetPidAndUpdateTarget(keyEvent));
420 }
421
422 /**
423 * @tc.name: InputWindowsManagerTest_GetWindowPid_001
424 * @tc.desc: Test getting the process ID of a window
425 * @tc.type: FUNC
426 * @tc.require:
427 */
428 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowPid_001, TestSize.Level1)
429 {
430 CALL_TEST_DEBUG;
431 int32_t windowId = 100;
432 std::vector<WindowInfo> windowsInfo;
433 int32_t ret = WIN_MGR->GetWindowPid(windowId, windowsInfo);
434 EXPECT_EQ(ret, -1);
435 }
436
437 /**
438 * @tc.name: InputWindowsManagerTest_CheckFocusWindowChange_001
439 * @tc.desc: Test checking focus window changes
440 * @tc.type: FUNC
441 * @tc.require:
442 */
443 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckFocusWindowChange_001, TestSize.Level1)
444 {
445 CALL_TEST_DEBUG;
446 DisplayGroupInfo displayGroupInfo;
447 displayGroupInfo.focusWindowId = 123;
448 ASSERT_NO_FATAL_FAILURE(WIN_MGR->CheckFocusWindowChange(displayGroupInfo));
449 }
450
451 /**
452 * @tc.name: InputWindowsManagerTest_CheckFocusWindowChange_002
453 * @tc.desc: Test checking focus window changes
454 * @tc.type: FUNC
455 * @tc.require:
456 */
457 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckFocusWindowChange_002, TestSize.Level1)
458 {
459 CALL_TEST_DEBUG;
460 DisplayGroupInfo displayGroupInfo;
461 DisplayGroupInfo displayGroupInfo_;
462 displayGroupInfo.focusWindowId = 123;
463 displayGroupInfo_.focusWindowId = 456;
464 ASSERT_NO_FATAL_FAILURE(WIN_MGR->CheckFocusWindowChange(displayGroupInfo));
465 ASSERT_NO_FATAL_FAILURE(WIN_MGR->CheckFocusWindowChange(displayGroupInfo_));
466 }
467
468 /**
469 * @tc.name: InputWindowsManagerTest_CheckZorderWindowChange_001
470 * @tc.desc: Test checking Z-order window changes
471 * @tc.type: FUNC
472 * @tc.require:
473 */
474 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckZorderWindowChange_001, TestSize.Level1)
475 {
476 CALL_TEST_DEBUG;
477 std::vector<WindowInfo> oldWindowsInfo = {{1}};
478 std::vector<WindowInfo> newWindowsInfo = {{2}};
479 ASSERT_NO_FATAL_FAILURE(WIN_MGR->CheckZorderWindowChange(oldWindowsInfo, newWindowsInfo));
480 }
481
482 /**
483 * @tc.name: InputWindowsManagerTest_UpdateDisplayIdAndName_001
484 * @tc.desc: Test updating display ID and name
485 * @tc.type: FUNC
486 * @tc.require:
487 */
488 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayIdAndName_001, TestSize.Level1)
489 {
490 CALL_TEST_DEBUG;
491 ASSERT_NO_FATAL_FAILURE(WIN_MGR->UpdateDisplayIdAndName());
492 assert(WIN_MGR->GetDisplayIdNames().size() == 2);
493 assert(WIN_MGR->IsDisplayAdd(1, "A"));
494 assert(WIN_MGR->IsDisplayAdd(2, "B"));
495 ASSERT_NO_FATAL_FAILURE(WIN_MGR->UpdateDisplayIdAndName());
496 assert(WIN_MGR->GetDisplayIdNames().size() == 2);
497 assert(WIN_MGR->IsDisplayAdd(1, "A"));
498 assert(WIN_MGR->IsDisplayAdd(3, "C"));
499 assert(!WIN_MGR->IsDisplayAdd(2, "B"));
500 }
501
502 /**
503 * @tc.name: InputWindowsManagerTest_GetDisplayBindInfo_001
504 * @tc.desc: Test getting display binding information
505 * @tc.type: FUNC
506 * @tc.require:
507 */
508 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetDisplayBindInfo_001, TestSize.Level1)
509 {
510 CALL_TEST_DEBUG;
511 int32_t deviceId = 1;
512 int32_t displayId = 2;
513 DisplayBindInfos infos;
514 std::string msg;
515 int32_t ret = WIN_MGR->SetDisplayBind(deviceId, displayId, msg);
516 EXPECT_EQ(ret, -1);
517 ret = WIN_MGR->GetDisplayBindInfo(infos);
518 EXPECT_EQ(ret, 0);
519 }
520
521 /**
522 * @tc.name: InputWindowsManagerTest_UpdateCaptureMode_001
523 * @tc.desc: Test updating capture mode
524 * @tc.type: FUNC
525 * @tc.require:
526 */
527 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateCaptureMode_001, TestSize.Level1)
528 {
529 CALL_TEST_DEBUG;
530 DisplayGroupInfo displayGroupInfo;
531 displayGroupInfo.focusWindowId = 123;
532 WIN_MGR->UpdateCaptureMode(displayGroupInfo);
533 EXPECT_FALSE(WIN_MGR->captureModeInfo_.isCaptureMode);
534 }
535
536 /**
537 * @tc.name: InputWindowsManagerTest_UpdateDisplayInfoByIncrementalInfo_001
538 * @tc.desc: Test updating display information by incremental info
539 * @tc.type: FUNC
540 * @tc.require:
541 */
542 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayInfoByIncrementalInfo_001, TestSize.Level1)
543 {
544 CALL_TEST_DEBUG;
545 DisplayGroupInfo displayGroupInfo;
546 displayGroupInfo.focusWindowId = 1;
547 WindowInfo window;
548 WIN_MGR->UpdateDisplayInfoByIncrementalInfo(window, displayGroupInfo);
549 EXPECT_EQ(displayGroupInfo.windowsInfo.size(), 0);
550 }
551
552 /**
553 * @tc.name: InputWindowsManagerTest_UpdateWindowsInfoPerDisplay_001
554 * @tc.desc: Test updating window information for each display
555 * @tc.type: FUNC
556 * @tc.require:
557 */
558 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateWindowsInfoPerDisplay_001, TestSize.Level1)
559 {
560 CALL_TEST_DEBUG;
561 DisplayGroupInfo displayGroupInfo;
562 displayGroupInfo.focusWindowId = 2;
563 WIN_MGR->UpdateWindowsInfoPerDisplay(displayGroupInfo);
564 WindowInfo window1{1};
565 WindowInfo window2{2};
566 displayGroupInfo.windowsInfo.push_back(window1);
567 displayGroupInfo.windowsInfo.push_back(window2);
568 WIN_MGR->UpdateDisplayInfo(displayGroupInfo);
569 ASSERT_EQ(displayGroupInfo.windowsInfo.size(), 2);
570 ASSERT_EQ(displayGroupInfo.windowsInfo[0].zOrder, 0);
571 ASSERT_EQ(displayGroupInfo.windowsInfo[1].zOrder, 0);
572 }
573
574 /**
575 * @tc.name: InputWindowsManagerTest_UpdateDisplayInfo_001
576 * @tc.desc: Test updating display information
577 * @tc.type: FUNC
578 * @tc.require:
579 */
580 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayInfo_001, TestSize.Level1)
581 {
582 CALL_TEST_DEBUG;
583 DisplayGroupInfo displayGroupInfo;
584 WindowInfo windowInfo1;
585 windowInfo1.zOrder = 1;
586 windowInfo1.action = WINDOW_UPDATE_ACTION::ADD_END;
587 WindowInfo windowInfo2;
588 windowInfo2.zOrder = 2;
589 windowInfo2.action = WINDOW_UPDATE_ACTION::ADD_END;
590 displayGroupInfo.windowsInfo.push_back(windowInfo1);
591 displayGroupInfo.windowsInfo.push_back(windowInfo2);
592 ASSERT_NO_FATAL_FAILURE(WIN_MGR->UpdateDisplayInfo(displayGroupInfo));
593 }
594
595 /**
596 * @tc.name: InputWindowsManagerTest_NeedUpdatePointDrawFlag_001
597 * @tc.desc: Test whether the point draw flag needs to be updated
598 * @tc.type: FUNC
599 * @tc.require:
600 */
601 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_NeedUpdatePointDrawFlag_001, TestSize.Level1)
602 {
603 CALL_TEST_DEBUG;
604 std::vector<WindowInfo> windows1;
605 EXPECT_FALSE(WIN_MGR->NeedUpdatePointDrawFlag(windows1));
606 std::vector<WindowInfo> windows2;
607 windows2.push_back(WindowInfo());
608 windows2.back().action = OHOS::MMI::WINDOW_UPDATE_ACTION::ADD;
609 EXPECT_FALSE(WIN_MGR->NeedUpdatePointDrawFlag(windows2));
610 std::vector<WindowInfo> windows3;
611 windows3.push_back(WindowInfo());
612 windows3.back().action = OHOS::MMI::WINDOW_UPDATE_ACTION::ADD_END;
613 EXPECT_TRUE(WIN_MGR->NeedUpdatePointDrawFlag(windows3));
614 }
615
616 /**
617 * @tc.name: InputWindowsManagerTest_GetPointerStyleByArea_001
618 * @tc.desc: Test getting pointer style by area
619 * @tc.type: FUNC
620 * @tc.require:
621 */
622 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPointerStyleByArea_001, TestSize.Level1)
623 {
624 CALL_TEST_DEBUG;
625 WindowArea area;
626 int32_t pid = 123;
627 int32_t winId = 678;
628 PointerStyle pointerStyle;
629 pointerStyle.size = 1;
630 pointerStyle.color = 2;
631 pointerStyle.id = 3;
632 area = WindowArea::TOP_LEFT_LIMIT;
633 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
634 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::SOUTH_EAST);
635 area = WindowArea::TOP_RIGHT_LIMIT;
636 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
637 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::SOUTH_WEST);
638 area = WindowArea::TOP_LIMIT;
639 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
640 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::SOUTH);
641 area = WindowArea::LEFT_LIMIT;
642 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
643 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::EAST);
644 area = WindowArea::RIGHT_LIMIT;
645 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
646 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::WEST);
647 area = WindowArea::BOTTOM_LEFT_LIMIT;
648 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
649 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::NORTH_WEST);
650 area = WindowArea::BOTTOM_LIMIT;
651 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
652 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::NORTH_WEST);
653 area = WindowArea::BOTTOM_RIGHT_LIMIT;
654 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
655 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::NORTH_WEST);
656 area = WindowArea::FOCUS_ON_INNER;
657 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
658 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::NORTH_WEST);
659 }
660
661 /**
662 * @tc.name: InputWindowsManagerTest_GetPointerStyleByArea_002
663 * @tc.desc: Test getting pointer style by area
664 * @tc.type: FUNC
665 * @tc.require:
666 */
667 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPointerStyleByArea_002, TestSize.Level1)
668 {
669 CALL_TEST_DEBUG;
670 WindowArea area;
671 int32_t pid = 123;
672 int32_t winId = 678;
673 PointerStyle pointerStyle;
674 pointerStyle.size = 1;
675 pointerStyle.color = 2;
676 pointerStyle.id = 3;
677 area = WindowArea::ENTER;
678 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
679 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::SOUTH);
680 area = WindowArea::EXIT;
681 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
682 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::SOUTH);
683 area = WindowArea::FOCUS_ON_TOP_LEFT;
684 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
685 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::NORTH_WEST_SOUTH_EAST);
686 area = WindowArea::FOCUS_ON_BOTTOM_RIGHT;
687 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
688 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::NORTH_WEST_SOUTH_EAST);
689 area = WindowArea::FOCUS_ON_TOP_RIGHT;
690 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
691 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::NORTH_EAST_SOUTH_WEST);
692 area = WindowArea::FOCUS_ON_BOTTOM_LEFT;
693 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
694 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::NORTH_EAST_SOUTH_WEST);
695 area = WindowArea::FOCUS_ON_TOP;
696 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
697 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::NORTH_SOUTH);
698 area = WindowArea::FOCUS_ON_BOTTOM;
699 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
700 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::NORTH_SOUTH);
701 area = WindowArea::FOCUS_ON_LEFT;
702 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
703 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::WEST_EAST);
704 area = WindowArea::FOCUS_ON_RIGHT;
705 WIN_MGR->GetPointerStyleByArea(area, pid, winId, pointerStyle);
706 EXPECT_EQ(pointerStyle.id, MOUSE_ICON::WEST_EAST);
707 }
708
709 /**
710 * @tc.name: InputWindowsManagerTest_SetWindowPointerStyle_001
711 * @tc.desc: Test setting window pointer style
712 * @tc.type: FUNC
713 * @tc.require:
714 */
715 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetWindowPointerStyle_001, TestSize.Level1)
716 {
717 CALL_TEST_DEBUG;
718 WindowArea area;
719 int32_t pid = 1;
720 int32_t windowId = 2;
721 IconStyle defaultIconStyle;
722 area = WindowArea::ENTER;
723 defaultIconStyle.iconPath = "default_icon_path";
724 WIN_MGR->SetWindowPointerStyle(area, pid, windowId);
725 assert(lastPointerStyle_.id == pointerStyle.id);
726 assert(windowId != GLOBAL_WINDOW_ID && (pointerStyle.id == MOUSE_ICON::DEFAULT &&
727 mouseIcons[MOUSE_ICON(pointerStyle.id)].iconPath != DEFAULT_ICON_PATH));
728 assert(WIN_MGR->GetPointerStyle(pid, GLOBAL_WINDOW_ID, style) == RET_OK);
729 assert(lastPointerStyle_.id == style.id);
730 }
731
732 /**
733 * @tc.name: InputWindowsManagerTest_UpdateWindowPointerVisible_001
734 * @tc.desc: Test updating window pointer visibility
735 * @tc.type: FUNC
736 * @tc.require:
737 */
738 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateWindowPointerVisible_001, TestSize.Level1)
739 {
740 CALL_TEST_DEBUG;
741 int32_t pid = 123;
742 bool visible = true;
743 int32_t priority = 456;
744 IPointerDrawingManager::GetInstance()->GetPointerVisible(pid);
745 IPointerDrawingManager::GetInstance()->SetPointerVisible(pid, visible, priority, false);
746 ASSERT_NO_FATAL_FAILURE(WIN_MGR->UpdateWindowPointerVisible(pid));
747 }
748
749 /**
750 * @tc.name: InputWindowsManagerTest_DispatchPointer_001
751 * @tc.desc: Test dispatching pointer events
752 * @tc.type: FUNC
753 * @tc.require:
754 */
755 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DispatchPointer_001, TestSize.Level1)
756 {
757 CALL_TEST_DEBUG;
758 int32_t pointerAction = PointerEvent::POINTER_ACTION_ENTER_WINDOW;
759 ASSERT_NO_FATAL_FAILURE(WIN_MGR->DispatchPointer(pointerAction));
760 pointerAction = PointerEvent::POINTER_ACTION_LEAVE_WINDOW;
761 ASSERT_NO_FATAL_FAILURE(WIN_MGR->DispatchPointer(pointerAction));
762 pointerAction = PointerEvent::POINTER_ACTION_MOVE;
763 ASSERT_NO_FATAL_FAILURE(WIN_MGR->DispatchPointer(pointerAction));
764 }
765
766 /**
767 * @tc.name: InputWindowsManagerTest_NotifyPointerToWindow_001
768 * @tc.desc: Test notifying pointer events to window
769 * @tc.type: FUNC
770 * @tc.require:
771 */
772 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_NotifyPointerToWindow_001, TestSize.Level1)
773 {
774 CALL_TEST_DEBUG;
775 InputWindowsManager inputWindowsManager;
776 inputWindowsManager.lastPointerEvent_ = nullptr;
777 inputWindowsManager.NotifyPointerToWindow();
778 EXPECT_EQ(inputWindowsManager.lastWindowInfo_.id, -1);
779 }
780
781 /**
782 * @tc.name: InputWindowsManagerTest_PrintWindowInfo_001
783 * @tc.desc: Test printing window information
784 * @tc.type: FUNC
785 * @tc.require:
786 */
787 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintWindowInfo_001, TestSize.Level1)
788 {
789 CALL_TEST_DEBUG;
790 WindowInfo windowInfo1;
791 windowInfo1.id = 1;
792 windowInfo1.pid = 100;
793 windowInfo1.uid = 200;
794 windowInfo1.area = {0, 0, 800, 600};
795 windowInfo1.defaultHotAreas = {{10, 10, 100, 100}, {200, 200, 50, 50}};
796 windowInfo1.pointerHotAreas = {{30, 30, 150, 150}, {400, 400, 70, 70}};
797 windowInfo1.agentWindowId = 10;
798 windowInfo1.flags = 1;
799 windowInfo1.displayId = 3;
800 windowInfo1.zOrder = 4.0f;
801 windowInfo1.pointerChangeAreas = {10, 20, 30};
802 windowInfo1.transform = {1.0f, 2.0f, 3.0f};
803 WindowInfo windowInfo2;
804 windowInfo2.id = 2;
805 windowInfo2.pid = 101;
806 windowInfo2.uid = 201;
807 windowInfo2.area = {800, 600, 1024, 768};
808 windowInfo2.defaultHotAreas = {{50, 50, 200, 200}, {600, 600, 100, 100}};
809 windowInfo2.pointerHotAreas = {{70, 70, 250, 250}, {800, 800, 120, 120}};
810 windowInfo2.agentWindowId = 20;
811 windowInfo2.flags = 2;
812 windowInfo2.displayId = 4;
813 windowInfo2.zOrder = 5.0f;
814 windowInfo2.pointerChangeAreas = {40, 50, 60};
815 windowInfo2.transform = {4.0f, 5.0f, 6.0f};
816 std::vector<WindowInfo> windowsInfo = {windowInfo1, windowInfo2};
817 ASSERT_NO_FATAL_FAILURE(WIN_MGR->PrintWindowInfo(windowsInfo));
818 }
819
820 /**
821 * @tc.name: InputWindowsManagerTest_PrintWindowGroupInfo_001
822 * @tc.desc: Test printing window group information
823 * @tc.type: FUNC
824 * @tc.require:
825 */
826 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintWindowGroupInfo_001, TestSize.Level1)
827 {
828 CALL_TEST_DEBUG;
829 WindowGroupInfo testData;
830 testData.focusWindowId = 1;
831 testData.displayId = 2;
832 ASSERT_NO_FATAL_FAILURE(WIN_MGR->PrintWindowGroupInfo(testData));
833 }
834
835 /**
836 * @tc.name: InputWindowsManagerTest_PrintDisplayInfo_001
837 * @tc.desc: Test printing display information
838 * @tc.type: FUNC
839 * @tc.require:
840 */
841 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintDisplayInfo_001, TestSize.Level1)
842 {
843 CALL_TEST_DEBUG;
844 InputWindowsManager manager;
845 manager.displayGroupInfo_.width = 1920;
846 manager.displayGroupInfo_.height = 1080;
847 manager.displayGroupInfo_.focusWindowId = 1;
848 manager.displayGroupInfo_.windowsInfo.push_back(WindowInfo());
849 manager.displayGroupInfo_.displaysInfo.push_back(DisplayInfo());
850 ASSERT_NO_FATAL_FAILURE(WIN_MGR->PrintDisplayInfo());
851 }
852
853 /**
854 * @tc.name: InputWindowsManagerTest_FindPhysicalDisplayInfo_001
855 * @tc.desc: Test finding physical display information
856 * @tc.type: FUNC
857 * @tc.require:
858 */
859 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_FindPhysicalDisplayInfo_001, TestSize.Level1)
860 {
861 CALL_TEST_DEBUG;
862 InputWindowsManager manager;
863 ASSERT_EQ(manager.FindPhysicalDisplayInfo("test"), nullptr);
864 DisplayInfo info1;
865 info1.id = 123;
866 manager.displayGroupInfo_.displaysInfo.push_back(info1);
867 ASSERT_NE(manager.FindPhysicalDisplayInfo("test"), nullptr);
868 DisplayInfo info2;
869 info2.id = 456;
870 manager.displayGroupInfo_.displaysInfo.push_back(info2);
871 ASSERT_NE(manager.FindPhysicalDisplayInfo("test"), nullptr);
872 ASSERT_NE(manager.FindPhysicalDisplayInfo("not_matching"), nullptr);
873 ASSERT_NE(manager.FindPhysicalDisplayInfo("nonexistent"), nullptr);
874 }
875
876 /**
877 * @tc.name: InputWindowsManagerTest_RotateScreen_001
878 * @tc.desc: Test rotating the screen
879 * @tc.type: FUNC
880 * @tc.require:
881 */
882 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_RotateScreen_001, TestSize.Level1)
883 {
884 CALL_TEST_DEBUG;
885 DisplayInfo info;
886 PhysicalCoordinate coord;
887 info.direction = DIRECTION0;
888 coord.x = 10;
889 coord.y = 20;
890 WIN_MGR->RotateScreen(info, coord);
891 EXPECT_EQ(coord.x, 10);
892 EXPECT_EQ(coord.y, 20);
893 }
894
895 /**
896 * @tc.name: InputWindowsManagerTest_RotateScreen_002
897 * @tc.desc: Test rotating the screen
898 * @tc.type: FUNC
899 * @tc.require:
900 */
901 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_RotateScreen_002, TestSize.Level1)
902 {
903 CALL_TEST_DEBUG;
904 DisplayInfo info;
905 PhysicalCoordinate coord;
906 info.direction = DIRECTION90;
907 info.width = 800;
908 info.height = 600;
909 coord.x = 10;
910 coord.y = 20;
911 WIN_MGR->RotateScreen(info, coord);
912 EXPECT_EQ(coord.x, 580);
913 EXPECT_EQ(coord.y, 10);
914 }
915
916 /**
917 * @tc.name: InputWindowsManagerTest_RotateScreen_003
918 * @tc.desc: Test rotating the screen
919 * @tc.type: FUNC
920 * @tc.require:
921 */
922 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_RotateScreen_003, TestSize.Level1)
923 {
924 CALL_TEST_DEBUG;
925 DisplayInfo info;
926 PhysicalCoordinate coord;
927 info.direction = DIRECTION180;
928 info.width = 800;
929 info.height = 600;
930 coord.x = 10;
931 coord.y = 20;
932 WIN_MGR->RotateScreen(info, coord);
933 EXPECT_EQ(coord.x, 790);
934 EXPECT_EQ(coord.y, 580);
935 }
936
937 /**
938 * @tc.name: InputWindowsManagerTest_RotateScreen_004
939 * @tc.desc: Test rotating the screen
940 * @tc.type: FUNC
941 * @tc.require:
942 */
943 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_RotateScreen_004, TestSize.Level1)
944 {
945 CALL_TEST_DEBUG;
946 DisplayInfo info;
947 PhysicalCoordinate coord;
948 info.direction = DIRECTION270;
949 info.width = 800;
950 info.height = 600;
951 coord.x = 10;
952 coord.y = 20;
953 WIN_MGR->RotateScreen(info, coord);
954 EXPECT_EQ(coord.x, 20);
955 EXPECT_EQ(coord.y, 790);
956 }
957
958 /**
959 * @tc.name: InputWindowsManagerTest_IsNeedRefreshLayer_001
960 * @tc.desc: Test whether layer refresh is needed
961 * @tc.type: FUNC
962 * @tc.require:
963 */
964 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsNeedRefreshLayer_001, TestSize.Level1)
965 {
966 CALL_TEST_DEBUG;
967 EXPECT_FALSE(WIN_MGR->IsNeedRefreshLayer(1));
968 WIN_MGR->GetWindowInfo(0, 0)->id = 2;
969 EXPECT_FALSE(WIN_MGR->IsNeedRefreshLayer(GLOBAL_WINDOW_ID));
970 WIN_MGR->GetWindowInfo(0, 0)->id = 3;
971 EXPECT_FALSE(WIN_MGR->IsNeedRefreshLayer(1));
972 }
973
974 /**
975 * @tc.name: InputWindowsManagerTest_OnSessionLost_001
976 * @tc.desc: Test handling when session is lost
977 * @tc.type: FUNC
978 * @tc.require:
979 */
980 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_OnSessionLost_001, TestSize.Level1)
981 {
982 CALL_TEST_DEBUG;
983 SessionPtr session = std::shared_ptr<UDSSession>();
984 WIN_MGR->OnSessionLost(session);
985 ASSERT_NO_FATAL_FAILURE(WIN_MGR->GetDisplayGroupInfo());
986 }
987
988 /**
989 * @tc.name: InputWindowsManagerTest_UpdatePoinerStyle_001
990 * @tc.desc: Test updating pointer style
991 * @tc.type: FUNC
992 * @tc.require:
993 */
994 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePoinerStyle_001, TestSize.Level1)
995 {
996 CALL_TEST_DEBUG;
997 int32_t pid = 1;
998 int32_t windowId = 2;
999 PointerStyle pointerStyle;
1000 int32_t ret = WIN_MGR->UpdatePoinerStyle(pid, windowId, pointerStyle);
1001 EXPECT_EQ(ret, 0);
1002 pid = -1;
1003 windowId = -2;
1004 ret = WIN_MGR->UpdatePoinerStyle(pid, windowId, pointerStyle);
1005 EXPECT_EQ(ret, 401);
1006 pid = 1;
1007 windowId = -2;
1008 ret = WIN_MGR->UpdatePoinerStyle(pid, windowId, pointerStyle);
1009 EXPECT_EQ(ret, 0);
1010 }
1011
1012 /**
1013 * @tc.name: InputWindowsManagerTest_UpdateSceneBoardPointerStyle_001
1014 * @tc.desc: Test updating scene board pointer style
1015 * @tc.type: FUNC
1016 * @tc.require:
1017 */
1018 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateSceneBoardPointerStyle_001, TestSize.Level1)
1019 {
1020 CALL_TEST_DEBUG;
1021 int32_t pid = 1;
1022 int32_t windowId = 2;
1023 PointerStyle pointerStyle;
1024 pointerStyle.id = 3;
1025 int32_t ret = WIN_MGR->UpdateSceneBoardPointerStyle(pid, windowId, pointerStyle);
1026 EXPECT_EQ(ret, RET_OK);
1027 pid = -1;
1028 windowId = -2;
1029 ret = WIN_MGR->UpdateSceneBoardPointerStyle(pid, windowId, pointerStyle);
1030 EXPECT_EQ(ret, RET_OK);
1031 }
1032
1033 /**
1034 * @tc.name: InputWindowsManagerTest_SetPointerStyle_001
1035 * @tc.desc: Test setting pointer style
1036 * @tc.type: FUNC
1037 * @tc.require:
1038 */
1039 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetPointerStyle_001, TestSize.Level1)
1040 {
1041 CALL_TEST_DEBUG;
1042 int32_t pid = 1;
1043 int32_t windowId = GLOBAL_WINDOW_ID;
1044 PointerStyle pointerStyle;
1045 pointerStyle.id = 1;
1046 int32_t ret = WIN_MGR->SetPointerStyle(pid, windowId, pointerStyle);
1047 EXPECT_EQ(ret, RET_OK);
1048 EXPECT_EQ(WIN_MGR->globalStyle_.id, pointerStyle.id);
1049 pid = 1;
1050 windowId = 2;
1051 ret = WIN_MGR->SetPointerStyle(pid, windowId, pointerStyle);
1052 EXPECT_EQ(ret, WIN_MGR->UpdatePoinerStyle(pid, windowId, pointerStyle));
1053 pid = 1;
1054 windowId = 2;
1055 ret = WIN_MGR->SetPointerStyle(pid, windowId, pointerStyle);
1056 EXPECT_EQ(ret, WIN_MGR->UpdateSceneBoardPointerStyle(pid, windowId, pointerStyle));
1057 }
1058
1059 /**
1060 * @tc.name: InputWindowsManagerTest_ClearWindowPointerStyle_001
1061 * @tc.desc: Test clearing window pointer style
1062 * @tc.type: FUNC
1063 * @tc.require:
1064 */
1065 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ClearWindowPointerStyle_001, TestSize.Level1)
1066 {
1067 CALL_TEST_DEBUG;
1068 int32_t pid = 123;
1069 int32_t windowId = 678;
1070 int32_t ret = WIN_MGR->ClearWindowPointerStyle(pid, windowId);
1071 EXPECT_EQ(ret, RET_OK);
1072 }
1073
1074 /**
1075 * @tc.name: InputWindowsManagerTest_GetPointerStyle_001
1076 * @tc.desc: Test getting pointer style
1077 * @tc.type: FUNC
1078 * @tc.require:
1079 */
1080 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPointerStyle_001, TestSize.Level1)
1081 {
1082 CALL_TEST_DEBUG;
1083 PointerStyle style;
1084 int32_t ret = WIN_MGR->GetPointerStyle(1, GLOBAL_WINDOW_ID, style);
1085 EXPECT_EQ(ret, RET_OK);
1086 EXPECT_EQ(style.id, 1);
1087 ret = WIN_MGR->GetPointerStyle(3, 1, style);
1088 EXPECT_EQ(ret, RET_OK);
1089 EXPECT_EQ(style.id, 1);
1090 ret = WIN_MGR->GetPointerStyle(1, 1, style);
1091 EXPECT_EQ(ret, RET_OK);
1092 EXPECT_EQ(style.id, 1);
1093 }
1094
1095 /**
1096 * @tc.name: InputWindowsManagerTest_IsInHotArea_001
1097 * @tc.desc: Test whether input is in the hot area
1098 * @tc.type: FUNC
1099 * @tc.require:
1100 */
1101 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsInHotArea_001, TestSize.Level1)
1102 {
1103 CALL_TEST_DEBUG;
1104 WIN_MGR->InitPointerStyle();
1105 int32_t x = 10;
1106 int32_t y = 20;
1107 std::vector<Rect> rects = {{0, 0, 30, 40}};
1108 WindowInfo window;
1109 bool ret = WIN_MGR->IsInHotArea(x, y, rects, window);
1110 EXPECT_TRUE(ret);
1111 x = -10;
1112 y = 20;
1113 ret = WIN_MGR->IsInHotArea(x, y, rects, window);
1114 EXPECT_FALSE(ret);
1115 x = 10;
1116 y = -10;
1117 ret = WIN_MGR->IsInHotArea(x, y, rects, window);
1118 EXPECT_FALSE(ret);
1119 }
1120
1121 /**
1122 * @tc.name: InputWindowsManagerTest_InWhichHotArea_001
1123 * @tc.desc: Test which hot area the input is in
1124 * @tc.type: FUNC
1125 * @tc.require:
1126 */
1127 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_InWhichHotArea_001, TestSize.Level1)
1128 {
1129 CALL_TEST_DEBUG;
1130 int32_t x = 50;
1131 int32_t y = 50;
1132 std::vector<Rect> rects = {{0, 0, 100, 100}, {100, 100, 200, 200}};
1133 PointerStyle pointerStyle;
1134 WIN_MGR->InWhichHotArea(x, y, rects, pointerStyle);
1135 ASSERT_EQ(pointerStyle.id, 6);
1136 x = 250;
1137 y = 250;
1138 WIN_MGR->InWhichHotArea(x, y, rects, pointerStyle);
1139 ASSERT_EQ(pointerStyle.id, 6);
1140 }
1141
1142 /**
1143 * @tc.name: InputWindowsManagerTest_AdjustDisplayCoordinate_001
1144 * @tc.desc: Test adjusting display coordinates
1145 * @tc.type: FUNC
1146 * @tc.require:
1147 */
1148 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_AdjustDisplayCoordinate_001, TestSize.Level1)
1149 {
1150 CALL_TEST_DEBUG;
1151 DisplayInfo displayInfo;
1152 displayInfo.width = 10;
1153 displayInfo.height = 20;
1154 displayInfo.direction = DIRECTION90;
1155 double physicalX = -5;
1156 double physicalY = 15;
1157 WIN_MGR->AdjustDisplayCoordinate(displayInfo, physicalX, physicalY);
1158 EXPECT_EQ(physicalX, 0);
1159 EXPECT_EQ(physicalY, 15);
1160 displayInfo.width = 10;
1161 displayInfo.height = 20;
1162 displayInfo.direction = DIRECTION270;
1163 physicalX = 15;
1164 physicalY = 25;
1165 WIN_MGR->AdjustDisplayCoordinate(displayInfo, physicalX, physicalY);
1166 EXPECT_EQ(physicalX, 9);
1167 EXPECT_EQ(physicalY, 19);
1168 displayInfo.width = 10;
1169 displayInfo.height = 20;
1170 displayInfo.direction = DIRECTION270;
1171 physicalX = -5;
1172 physicalY = -15;
1173 WIN_MGR->AdjustDisplayCoordinate(displayInfo, physicalX, physicalY);
1174 EXPECT_EQ(physicalX, 0);
1175 EXPECT_EQ(physicalY, 0);
1176 }
1177
1178 /**
1179 * @tc.name: InputWindowsManagerTest_IsTransparentWin
1180 * @tc.desc: Test IsTransparentWin
1181 * @tc.type: FUNC
1182 * @tc.require:
1183 */
1184 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsTransparentWin, TestSize.Level1)
1185 {
1186 CALL_TEST_DEBUG;
1187 std::unique_ptr<Media::PixelMap> pixelMap = nullptr;
1188 int32_t logicalX = 0;
1189 int32_t logicalY = 0;
1190 bool result = WIN_MGR->IsTransparentWin(pixelMap, logicalX, logicalY);
1191 EXPECT_FALSE(result);
1192 }
1193
1194 /**
1195 * @tc.name: InputWindowsManagerTest_CheckWindowIdPermissionByPid
1196 * @tc.desc: Test CheckWindowIdPermissionByPid
1197 * @tc.type: FUNC
1198 * @tc.require:
1199 */
1200 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckWindowIdPermissionByPid, TestSize.Level1)
1201 {
1202 CALL_TEST_DEBUG;
1203 int32_t windowId = 12345;
1204 int32_t pid = 6789;
1205 int32_t result = WIN_MGR->CheckWindowIdPermissionByPid(windowId, pid);
1206 EXPECT_EQ(result, RET_ERR);
1207 }
1208
1209 /**
1210 * @tc.name: InputWindowsManagerTest_IsWindowVisible
1211 * @tc.desc: Test IsWindowVisible
1212 * @tc.type: FUNC
1213 * @tc.require:
1214 */
1215 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsWindowVisible, TestSize.Level1)
1216 {
1217 CALL_TEST_DEBUG;
1218 int32_t pid = -1;
1219 bool result = WIN_MGR->IsWindowVisible(pid);
1220 EXPECT_TRUE(result);
1221 }
1222
1223 /**
1224 * @tc.name: InputWindowsManagerTest_CoordinateCorrection_001
1225 * @tc.desc: Test CoordinateCorrection
1226 * @tc.type: FUNC
1227 * @tc.require:
1228 */
1229 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CoordinateCorrection_001, TestSize.Level1)
1230 {
1231 CALL_TEST_DEBUG;
1232 int32_t width = 100;
1233 int32_t height = 200;
1234 int32_t integerX = -1;
1235 int32_t integerY = 1;
1236 WIN_MGR->CoordinateCorrection(width, height, integerX, integerY);
1237 EXPECT_EQ(integerX, 0);
1238 }
1239
1240 /**
1241 * @tc.name: InputWindowsManagerTest_CoordinateCorrection_002
1242 * @tc.desc: Test CoordinateCorrection
1243 * @tc.type: FUNC
1244 * @tc.require:
1245 */
1246 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CoordinateCorrection_002, TestSize.Level1)
1247 {
1248 CALL_TEST_DEBUG;
1249 int32_t width = 100;
1250 int32_t height = 200;
1251 int32_t integerX = 150;
1252 int32_t integerY = 100;
1253 WIN_MGR->CoordinateCorrection(width, height, integerX, integerY);
1254 EXPECT_EQ(integerX, 99);
1255 }
1256
1257 /**
1258 * @tc.name: InputWindowsManagerTest_CoordinateCorrection_003
1259 * @tc.desc: Test CoordinateCorrection
1260 * @tc.type: FUNC
1261 * @tc.require:
1262 */
1263 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CoordinateCorrection_003, TestSize.Level1)
1264 {
1265 CALL_TEST_DEBUG;
1266 int32_t width = 100;
1267 int32_t height = 200;
1268 int32_t integerX = 1;
1269 int32_t integerY = -1;
1270 WIN_MGR->CoordinateCorrection(width, height, integerX, integerY);
1271 EXPECT_EQ(integerY, 0);
1272 }
1273
1274 /**
1275 * @tc.name: InputWindowsManagerTest_CoordinateCorrection_004
1276 * @tc.desc: Test CoordinateCorrection
1277 * @tc.type: FUNC
1278 * @tc.require:
1279 */
1280 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CoordinateCorrection_004, TestSize.Level1)
1281 {
1282 CALL_TEST_DEBUG;
1283 int32_t width = 100;
1284 int32_t height = 200;
1285 int32_t integerX = 100;
1286 int32_t integerY = 250;
1287 WIN_MGR->CoordinateCorrection(width, height, integerX, integerY);
1288 EXPECT_EQ(integerY, 199);
1289 }
1290
1291 /**
1292 * @tc.name: InputWindowsManagerTest_HandleWindowInputType_001
1293 * @tc.desc: Test HandleWindowInputType
1294 * @tc.type: FUNC
1295 * @tc.require:
1296 */
1297 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandleWindowInputType_001, TestSize.Level1)
1298 {
1299 CALL_TEST_DEBUG;
1300 UDSServer udsServer;
1301 WIN_MGR->Init(udsServer);
1302 auto pointerEvent = PointerEvent::Create();
1303 ASSERT_NE(pointerEvent, nullptr);
1304 WindowInfo window;
1305 window.windowInputType = WindowInputType::NORMAL;
1306 ASSERT_FALSE(WIN_MGR->HandleWindowInputType(window, pointerEvent));
1307 }
1308
1309 /**
1310 * @tc.name: InputWindowsManagerTest_HandleWindowInputType_002
1311 * @tc.desc: Test HandleWindowInputType
1312 * @tc.type: FUNC
1313 * @tc.require:
1314 */
1315 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandleWindowInputType_002, TestSize.Level1)
1316 {
1317 CALL_TEST_DEBUG;
1318 UDSServer udsServer;
1319 WIN_MGR->Init(udsServer);
1320 auto pointerEvent = PointerEvent::Create();
1321 ASSERT_NE(pointerEvent, nullptr);
1322 WindowInfo window;
1323 window.windowInputType = WindowInputType::TRANSMIT_ALL;
1324 ASSERT_FALSE(WIN_MGR->HandleWindowInputType(window, pointerEvent));
1325 }
1326
1327 /**
1328 * @tc.name: InputWindowsManagerTest_HandleWindowInputType_003
1329 * @tc.desc: Test HandleWindowInputType
1330 * @tc.type: FUNC
1331 * @tc.require:
1332 */
1333 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandleWindowInputType_003, TestSize.Level1)
1334 {
1335 CALL_TEST_DEBUG;
1336 UDSServer udsServer;
1337 WIN_MGR->Init(udsServer);
1338 auto pointerEvent = PointerEvent::Create();
1339 ASSERT_NE(pointerEvent, nullptr);
1340 WindowInfo window;
1341 window.windowInputType = WindowInputType::ANTI_MISTAKE_TOUCH;
1342 ASSERT_FALSE(WIN_MGR->HandleWindowInputType(window, pointerEvent));
1343 }
1344
1345 /**
1346 * @tc.name: InputWindowsManagerTest_UpdateDisplayId_001
1347 * @tc.desc: Test updating display ID
1348 * @tc.type: FUNC
1349 * @tc.require:
1350 */
1351 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayId_001, TestSize.Level1)
1352 {
1353 CALL_TEST_DEBUG;
1354 int32_t displayId = 1;
1355 bool ret = WIN_MGR->UpdateDisplayId(displayId);
1356 EXPECT_TRUE(ret);
1357 displayId = 0;
1358 ret = WIN_MGR->UpdateDisplayId(displayId);
1359 EXPECT_FALSE(ret);
1360 displayId = -1;
1361 ret = WIN_MGR->UpdateDisplayId(displayId);
1362 EXPECT_TRUE(ret);
1363 }
1364
1365 /**
1366 * @tc.name: InputWindowsManagerTest_SelectWindowInfo_001
1367 * @tc.desc: Test selecting window information
1368 * @tc.type: FUNC
1369 * @tc.require:
1370 */
1371 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectWindowInfo_001, TestSize.Level1)
1372 {
1373 CALL_TEST_DEBUG;
1374 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
1375 ASSERT_NE(pointerEvent, nullptr);
1376 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
1377 pointerEvent->SetPressedKeys({1});
1378 pointerEvent->SetTargetDisplayId(0);
1379 pointerEvent->SetTargetWindowId(1);
1380 std::optional<WindowInfo> result = WIN_MGR->SelectWindowInfo(400, 300, pointerEvent);
1381 EXPECT_FALSE(result.has_value());
1382 int32_t ret1 = result->id;
1383 EXPECT_EQ(ret1, 0);
1384 int32_t ret2 = result->flags;
1385 EXPECT_EQ(ret2, 0);
1386 int32_t ret3 = result->pid;
1387 EXPECT_EQ(ret3, 0);
1388 }
1389
1390 /**
1391 * @tc.name: InputWindowsManagerTest_SelectWindowInfo_002
1392 * @tc.desc: Test selecting window information
1393 * @tc.type: FUNC
1394 * @tc.require:
1395 */
1396 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectWindowInfo_002, TestSize.Level1)
1397 {
1398 CALL_TEST_DEBUG;
1399 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
1400 ASSERT_NE(pointerEvent, nullptr);
1401 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
1402 pointerEvent->SetPressedKeys({1});
1403 pointerEvent->SetTargetDisplayId(0);
1404 pointerEvent->SetTargetWindowId(1);
1405 std::optional<WindowInfo> result = WIN_MGR->SelectWindowInfo(-123, -456, pointerEvent);
1406 EXPECT_FALSE(result.has_value());
1407 int32_t ret1 = result->id;
1408 EXPECT_EQ(ret1, 0);
1409 int32_t ret2 = result->flags;
1410 EXPECT_EQ(ret2, 0);
1411 int32_t ret3 = result->pid;
1412 EXPECT_EQ(ret3, 0);
1413 }
1414
1415 /**
1416 * @tc.name: InputWindowsManagerTest_GetWindowInfo_001
1417 * @tc.desc: Test getting window information
1418 * @tc.type: FUNC
1419 * @tc.require:
1420 */
1421 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowInfo_001, TestSize.Level1)
1422 {
1423 CALL_TEST_DEBUG;
1424 WindowInfo windowInfo1 = {1, WindowInfo::FLAG_BIT_UNTOUCHABLE, {}};
1425 WindowInfo windowInfo2 = {2, 0, {}};
1426 WIN_MGR->displayGroupInfo_.windowsInfo = {windowInfo1, windowInfo2};
1427 auto result = WIN_MGR->GetWindowInfo(0, 0);
1428 EXPECT_FALSE(result.has_value());
1429 int32_t ret1 = result->id;
1430 EXPECT_EQ(ret1, 0);
1431 }
1432
1433 /**
1434 * @tc.name: InputWindowsManagerTest_SelectPointerChangeArea_001
1435 * @tc.desc: Test selecting pointer change area
1436 * @tc.type: FUNC
1437 * @tc.require:
1438 */
1439 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectPointerChangeArea_001, TestSize.Level1)
1440 {
1441 CALL_TEST_DEBUG;
1442 WindowInfo windowInfo;
1443 windowInfo.id = 1;
1444 PointerStyle pointerStyle;
1445 int32_t logicalX = 0;
1446 int32_t logicalY = 0;
1447 bool result = WIN_MGR->SelectPointerChangeArea(windowInfo, pointerStyle, logicalX, logicalY);
1448 EXPECT_FALSE(result);
1449 }
1450
1451 /**
1452 * @tc.name: InputWindowsManagerTest_SelectPointerChangeArea_002
1453 * @tc.desc: Test selecting pointer change area
1454 * @tc.type: FUNC
1455 * @tc.require:
1456 */
1457 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectPointerChangeArea_002, TestSize.Level1)
1458 {
1459 CALL_TEST_DEBUG;
1460 WindowInfo windowInfo;
1461 windowInfo.id = 1;
1462 PointerStyle pointerStyle;
1463 int32_t logicalX = -1;
1464 int32_t logicalY = -2;
1465 bool result = WIN_MGR->SelectPointerChangeArea(windowInfo, pointerStyle, logicalX, logicalY);
1466 EXPECT_FALSE(result);
1467 }
1468
1469 /**
1470 * @tc.name: InputWindowsManagerTest_UpdatePointerChangeAreas_001
1471 * @tc.desc: Test updating pointer change areas
1472 * @tc.type: FUNC
1473 * @tc.require:
1474 */
1475 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerChangeAreas_001, TestSize.Level1)
1476 {
1477 CALL_TEST_DEBUG;
1478 DisplayGroupInfo displayGroupInfo;
1479 WIN_MGR->UpdatePointerChangeAreas(displayGroupInfo);
1480 EXPECT_TRUE(WIN_MGR->windowsHotAreas_.empty());
1481 }
1482
1483 /**
1484 * @tc.name: InputWindowsManagerTest_UpdatePointerChangeAreas_002
1485 * @tc.desc: Test updating pointer change areas
1486 * @tc.type: FUNC
1487 * @tc.require:
1488 */
1489 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerChangeAreas_002, TestSize.Level1)
1490 {
1491 CALL_TEST_DEBUG;
1492 DisplayGroupInfo displayGroupInfo;
1493 WIN_MGR->UpdatePointerChangeAreas();
1494 WIN_MGR->UpdatePointerChangeAreas(displayGroupInfo);
1495 EXPECT_EQ(WIN_MGR->windowsHotAreas_.size(), 1);
1496 EXPECT_EQ(WIN_MGR->windowsHotAreas_[1].size(), 8);
1497 }
1498
1499 /**
1500 * @tc.name: InputWindowsManagerTest_UpdateTopBottomArea_001
1501 * @tc.desc: Test updating top-bottom area
1502 * @tc.type: FUNC
1503 * @tc.require:
1504 */
1505 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTopBottomArea_001, TestSize.Level1)
1506 {
1507 CALL_TEST_DEBUG;
1508 Rect windowArea = {0, 0, 100, 100};
1509 std::vector<int32_t> pointerChangeAreas = {10, 20, 30, 40, 50, 60, 70, 80};
1510 std::vector<Rect> windowHotAreas;
1511 WIN_MGR->UpdateTopBottomArea(windowArea, pointerChangeAreas, windowHotAreas);
1512 int32_t ret1 = windowHotAreas.size();
1513 EXPECT_EQ(ret1, 2);
1514 int32_t ret2 = windowHotAreas[0].x;
1515 EXPECT_EQ(ret2, 10);
1516 int32_t ret3 = windowHotAreas[0].y;
1517 EXPECT_EQ(ret3, -20);
1518 int32_t ret4 = windowHotAreas[0].width;
1519 EXPECT_EQ(ret4, 60);
1520 int32_t ret5 = windowHotAreas[0].height;
1521 EXPECT_EQ(ret5, 40);
1522 int32_t ret6 = windowHotAreas[1].x;
1523 EXPECT_EQ(ret6, 70);
1524 int32_t ret7 = windowHotAreas[1].y;
1525 EXPECT_EQ(ret7, 40);
1526 int32_t ret8 = windowHotAreas[1].width;
1527 EXPECT_EQ(ret8, -20);
1528 int32_t ret9 = windowHotAreas[1].height;
1529 EXPECT_EQ(ret9, 80);
1530 }
1531
1532 /**
1533 * @tc.name: InputWindowsManagerTest_UpdateTopBottomArea_002
1534 * @tc.desc: Test updating top-bottom area
1535 * @tc.type: FUNC
1536 * @tc.require:
1537 */
1538 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTopBottomArea_002, TestSize.Level1)
1539 {
1540 CALL_TEST_DEBUG;
1541 Rect windowArea = {0, 0, 100, 100};
1542 std::vector<int32_t> pointerChangeAreas = {0, 0, 0, 0, 0, 0, 0, 0};
1543 std::vector<Rect> windowHotAreas;
1544 WIN_MGR->UpdateTopBottomArea(windowArea, pointerChangeAreas, windowHotAreas);
1545 int32_t ret1 = windowHotAreas.size();
1546 EXPECT_EQ(ret1, 2);
1547 int32_t ret2 = windowHotAreas[0].width;
1548 EXPECT_EQ(ret2, 0);
1549 int32_t ret3 = windowHotAreas[0].height;
1550 EXPECT_EQ(ret3, 0);
1551 int32_t ret4 = windowHotAreas[1].width;
1552 EXPECT_EQ(ret4, 0);
1553 int32_t ret5 = windowHotAreas[1].height;
1554 EXPECT_EQ(ret5, 0);
1555 }
1556
1557 /**
1558 * @tc.name: InputWindowsManagerTest_UpdateLeftRightArea_001
1559 * @tc.desc: Test updating left-right area
1560 * @tc.type: FUNC
1561 * @tc.require:
1562 */
1563 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateLeftRightArea_001, TestSize.Level1)
1564 {
1565 CALL_TEST_DEBUG;
1566 Rect windowArea = {0, 0, 100, 100};
1567 std::vector<int32_t> pointerChangeAreas = {10, 20, 30, 40, 50, 60, 70, 80};
1568 std::vector<Rect> windowHotAreas;
1569 WIN_MGR->UpdateLeftRightArea(windowArea, pointerChangeAreas, windowHotAreas);
1570 int32_t ret1 = windowHotAreas.size();
1571 EXPECT_EQ(ret1, 2);
1572 int32_t ret2 = windowHotAreas[0].x;
1573 EXPECT_EQ(ret2, -20);
1574 int32_t ret3 = windowHotAreas[0].y;
1575 EXPECT_EQ(ret3, 10);
1576 int32_t ret4 = windowHotAreas[0].width;
1577 EXPECT_EQ(ret4, 100);
1578 int32_t ret5 = windowHotAreas[0].height;
1579 EXPECT_EQ(ret5, 20);
1580 int32_t ret6 = windowHotAreas[1].x;
1581 EXPECT_EQ(ret6, 60);
1582 int32_t ret7 = windowHotAreas[1].y;
1583 EXPECT_EQ(ret7, 30);
1584 int32_t ret8 = windowHotAreas[1].width;
1585 EXPECT_EQ(ret8, 60);
1586 int32_t ret9 = windowHotAreas[1].height;
1587 EXPECT_EQ(ret9, 20);
1588 }
1589
1590 /**
1591 * @tc.name: InputWindowsManagerTest_UpdateLeftRightArea_002
1592 * @tc.desc: Test updating left-right area
1593 * @tc.type: FUNC
1594 * @tc.require:
1595 */
1596 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateLeftRightArea_002, TestSize.Level1)
1597 {
1598 CALL_TEST_DEBUG;
1599 Rect windowArea = {0, 0, 100, 100};
1600 std::vector<int32_t> pointerChangeAreas = {10, 0, 30, 40, 50, 60, 70, 80};
1601 std::vector<Rect> windowHotAreas;
1602 WIN_MGR->UpdateLeftRightArea(windowArea, pointerChangeAreas, windowHotAreas);
1603 int32_t ret1 = windowHotAreas.size();
1604 EXPECT_EQ(ret1, 2);
1605 int32_t ret2 = windowHotAreas[0].x;
1606 EXPECT_EQ(ret2, -20);
1607 int32_t ret3 = windowHotAreas[0].y;
1608 EXPECT_EQ(ret3, 10);
1609 int32_t ret4 = windowHotAreas[0].width;
1610 EXPECT_EQ(ret4, 100);
1611 int32_t ret5 = windowHotAreas[0].height;
1612 EXPECT_EQ(ret5, 20);
1613 int32_t ret6 = windowHotAreas[1].x;
1614 EXPECT_EQ(ret6, 60);
1615 int32_t ret7 = windowHotAreas[1].y;
1616 EXPECT_EQ(ret7, 30);
1617 int32_t ret8 = windowHotAreas[1].width;
1618 EXPECT_EQ(ret8, 60);
1619 int32_t ret9 = windowHotAreas[1].height;
1620 EXPECT_EQ(ret9, 20);
1621 }
1622
1623 /**
1624 * @tc.name: InputWindowsManagerTest_UpdateInnerAngleArea_001
1625 * @tc.desc: Test updating inner angle area
1626 * @tc.type: FUNC
1627 * @tc.require:
1628 */
1629 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateInnerAngleArea_001, TestSize.Level1)
1630 {
1631 CALL_TEST_DEBUG;
1632 Rect windowArea;
1633 windowArea.x = 10;
1634 windowArea.y = 20;
1635 windowArea.width = 100;
1636 windowArea.height = 200;
1637 std::vector<int32_t> pointerChangeAreas(4, 10);
1638 std::vector<Rect> windowHotAreas;
1639 WIN_MGR->UpdateInnerAngleArea(windowArea, pointerChangeAreas, windowHotAreas);
1640 int32_t ret1 = windowHotAreas.size();
1641 EXPECT_EQ(ret1, 4);
1642 int32_t ret2 = windowHotAreas[0].x;
1643 EXPECT_EQ(ret2, -10);
1644 int32_t ret3 = windowHotAreas[0].y;
1645 EXPECT_EQ(ret3, 0);
1646 int32_t ret4 = windowHotAreas[0].width;
1647 EXPECT_EQ(ret4, 30);
1648 int32_t ret5 = windowHotAreas[0].height;
1649 EXPECT_EQ(ret5, 30);
1650 int32_t ret6 = windowHotAreas[1].x;
1651 EXPECT_EQ(ret6, 100);
1652 int32_t ret7 = windowHotAreas[1].y;
1653 EXPECT_EQ(ret7, 0);
1654 int32_t ret8 = windowHotAreas[1].width;
1655 EXPECT_EQ(ret8, 30);
1656 int32_t ret9 = windowHotAreas[1].height;
1657 EXPECT_EQ(ret9, 30);
1658 int32_t ret10 = windowHotAreas[2].x;
1659 EXPECT_EQ(ret10, -10);
1660 int32_t ret11 = windowHotAreas[2].y;
1661 EXPECT_NE(ret11, 110);
1662 int32_t ret12 = windowHotAreas[2].width;
1663 EXPECT_NE(ret12, 11);
1664 int32_t ret13 = windowHotAreas[2].height;
1665 EXPECT_NE(ret13, 11);
1666 }
1667
1668 /**
1669 * @tc.name: InputWindowsManagerTest_UpdatePointerEvent_001
1670 * @tc.desc: Test updating pointer event
1671 * @tc.type: FUNC
1672 * @tc.require:
1673 */
1674 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerEvent_001, TestSize.Level1)
1675 {
1676 CALL_TEST_DEBUG;
1677 InputWindowsManager inputWindowsManager;
1678 int32_t logicalX = 10;
1679 int32_t logicalY = 20;
1680 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
1681 ASSERT_NE(pointerEvent, nullptr);
1682 WindowInfo touchWindow;
1683 touchWindow.id = 2;
1684 WIN_MGR->UpdatePointerEvent(logicalX, logicalY, pointerEvent, touchWindow);
1685 EXPECT_EQ(inputWindowsManager.lastLogicX_, RET_ERR);
1686 EXPECT_EQ(inputWindowsManager.lastLogicY_, RET_ERR);
1687 }
1688
1689 /**
1690 * @tc.name: InputWindowsManagerTest_UpdatePointerEvent_002
1691 * @tc.desc: Test updating pointer event
1692 * @tc.type: FUNC
1693 * @tc.require:
1694 */
1695 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerEvent_002, TestSize.Level1)
1696 {
1697 CALL_TEST_DEBUG;
1698 InputWindowsManager inputWindowsManager;
1699 int32_t logicalX = 10;
1700 int32_t logicalY = 20;
1701 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
1702 ASSERT_NE(pointerEvent, nullptr);
1703 WindowInfo touchWindow;
1704 touchWindow.id = 0;
1705 WIN_MGR->UpdatePointerEvent(logicalX, logicalY, pointerEvent, touchWindow);
1706 EXPECT_EQ(inputWindowsManager.lastLogicX_, RET_ERR);
1707 EXPECT_EQ(inputWindowsManager.lastLogicY_, RET_ERR);
1708 }
1709
1710 /**
1711 * @tc.name: InputWindowsManagerTest_SetHoverScrollState_001
1712 * @tc.desc: Test setting hover scroll state
1713 * @tc.type: FUNC
1714 * @tc.require:
1715 */
1716 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetHoverScrollState_001, TestSize.Level1)
1717 {
1718 CALL_TEST_DEBUG;
1719 int32_t result = WIN_MGR->SetHoverScrollState(true);
1720 EXPECT_EQ(result, 0);
1721 result = WIN_MGR->SetHoverScrollState(false);
1722 EXPECT_EQ(result, 0);
1723 }
1724
1725 /**
1726 * @tc.name: InputWindowsManagerTest_GetHoverScrollState_001
1727 * @tc.desc: Test getting hover scroll state
1728 * @tc.type: FUNC
1729 * @tc.require:
1730 */
1731 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetHoverScrollState_001, TestSize.Level1)
1732 {
1733 CALL_TEST_DEBUG;
1734 bool result = WIN_MGR->GetHoverScrollState();
1735 EXPECT_TRUE(result);
1736 result = WIN_MGR->GetHoverScrollState();
1737 EXPECT_TRUE(result);
1738 }
1739
1740 /**
1741 * @tc.name: InputWindowsManagerTest_UpdateMouseTarget_001
1742 * @tc.desc: Test updating mouse target
1743 * @tc.type: FUNC
1744 * @tc.require:
1745 */
1746 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateMouseTarget_001, TestSize.Level1)
1747 {
1748 CALL_TEST_DEBUG;
1749 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
1750 ASSERT_NE(pointerEvent, nullptr);
1751 int32_t result =WIN_MGR->UpdateMouseTarget(pointerEvent);
1752 EXPECT_EQ(result, RET_ERR);
1753 }
1754
1755 /**
1756 * @tc.name: InputWindowsManagerTest_SkipNavigationWindow_001
1757 * @tc.desc: Test updating window information for each display
1758 * @tc.type: FUNC
1759 * @tc.require:
1760 */
1761 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SkipNavigationWindow_001, TestSize.Level1)
1762 {
1763 WIN_MGR->SetAntiMisTakeStatus(false);
1764 ASSERT_FALSE(WIN_MGR->SkipNavigationWindow(WindowInputType::ANTI_MISTAKE_TOUCH, PointerEvent::TOOL_TYPE_PEN));
1765 }
1766
1767 /**
1768 * @tc.name: InputWindowsManagerTest_SkipNavigationWindow_002
1769 * @tc.desc: Test updating window information for each display
1770 * @tc.type: FUNC
1771 * @tc.require:
1772 */
1773 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SkipNavigationWindow_002, TestSize.Level1)
1774 {
1775 WIN_MGR->SetAntiMisTakeStatus(false);
1776 ASSERT_FALSE(WIN_MGR->SkipNavigationWindow(WindowInputType::NORMAL, PointerEvent::TOOL_TYPE_RUBBER));
1777 }
1778
1779 /**
1780 * @tc.name: InputWindowsManagerTest_SkipNavigationWindow_003
1781 * @tc.desc: Test updating window information for each display
1782 * @tc.type: FUNC
1783 * @tc.require:
1784 */
1785 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SkipNavigationWindow_003, TestSize.Level1)
1786 {
1787 WIN_MGR->SetAntiMisTakeStatus(false);
1788 ASSERT_FALSE(WIN_MGR->SkipNavigationWindow(WindowInputType::NORMAL, PointerEvent::TOOL_TYPE_PEN));
1789 }
1790
1791 /**
1792 * @tc.name: InputWindowsManagerTest_SkipNavigationWindow_004
1793 * @tc.desc: Test updating window information for each display
1794 * @tc.type: FUNC
1795 * @tc.require:
1796 */
1797 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SkipNavigationWindow_004, TestSize.Level1)
1798 {
1799 WIN_MGR->SetAntiMisTakeStatus(false);
1800 ASSERT_FALSE(WIN_MGR->SkipNavigationWindow(WindowInputType::ANTI_MISTAKE_TOUCH, PointerEvent::TOOL_TYPE_RUBBER));
1801 }
1802
1803 /**
1804 * @tc.name: InputWindowsManagerTest_SkipNavigationWindow_005
1805 * @tc.desc: Test updating window information for each display
1806 * @tc.type: FUNC
1807 * @tc.require:
1808 */
1809 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SkipNavigationWindow_005, TestSize.Level1)
1810 {
1811 WIN_MGR->SetAntiMisTake(true);
1812 WIN_MGR->SetAntiMisTakeStatus(false);
1813 ASSERT_FALSE(WIN_MGR->SkipNavigationWindow(WindowInputType::ANTI_MISTAKE_TOUCH, PointerEvent::TOOL_TYPE_PEN));
1814 }
1815
1816 /**
1817 * @tc.name: InputWindowsManagerTest_JudgMouseIsDownOrUp_001
1818 * @tc.desc: This test verifies the functionality of judging whether the mouse button is down or up
1819 * @tc.type: FUNC
1820 * @tc.require:
1821 */
1822 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_JudgMouseIsDownOrUp_001, TestSize.Level1)
1823 {
1824 CALL_TEST_DEBUG;
1825 WIN_MGR->JudgMouseIsDownOrUp(false);
1826 EXPECT_FALSE(WIN_MGR->GetMouseFlag());
1827 WIN_MGR->JudgMouseIsDownOrUp(true);
1828 EXPECT_FALSE(WIN_MGR->GetMouseFlag());
1829 }
1830
1831 /**
1832 * @tc.name: InputWindowsManagerTest_SetMouseCaptureMode_001
1833 * @tc.desc: This test verifies the functionality of setting the mouse capture mode
1834 * @tc.type: FUNC
1835 * @tc.require:
1836 */
1837 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetMouseCaptureMode_001, TestSize.Level1)
1838 {
1839 CALL_TEST_DEBUG;
1840 int32_t windowId = -1;
1841 bool isCaptureMode = true;
1842 int32_t result = WIN_MGR->SetMouseCaptureMode(windowId, isCaptureMode);
1843 EXPECT_EQ(result, RET_ERR);
1844 windowId = 1;
1845 isCaptureMode = false;
1846 result = WIN_MGR->SetMouseCaptureMode(windowId, isCaptureMode);
1847 EXPECT_EQ(result, RET_OK);
1848 windowId = 1;
1849 isCaptureMode = true;
1850 result = WIN_MGR->SetMouseCaptureMode(windowId, isCaptureMode);
1851 EXPECT_EQ(result, RET_OK);
1852 EXPECT_TRUE(WIN_MGR->GetMouseIsCaptureMode());
1853 }
1854
1855 /**
1856 * @tc.name: InputWindowsManagerTest_IsNeedDrawPointer_001
1857 * @tc.desc: This test verifies the functionality of determining whether to draw the pointer
1858 * @tc.type: FUNC
1859 * @tc.require:
1860 */
1861 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsNeedDrawPointer_001, TestSize.Level1)
1862 {
1863 CALL_TEST_DEBUG;
1864 PointerEvent::PointerItem pointerItem;
1865 pointerItem.SetToolType(PointerEvent::TOOL_TYPE_PEN);
1866 pointerItem.SetDeviceId(1);
1867 bool result = WIN_MGR->IsNeedDrawPointer(pointerItem);
1868 EXPECT_FALSE(result);
1869 }
1870
1871 /**
1872 * @tc.name: InputWindowsManagerTest_SkipAnnotationWindow_001
1873 * @tc.desc: This test verifies the functionality of determining whether to draw the pointer
1874 * @tc.type: FUNC
1875 * @tc.require:
1876 */
1877 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SkipAnnotationWindow_001, TestSize.Level1)
1878 {
1879 CALL_TEST_DEBUG;
1880 uint32_t flag = WindowInfo::FLAG_BIT_HANDWRITING;
1881 int32_t toolType = PointerEvent::TOOL_TYPE_FINGER;
1882 bool result = WIN_MGR->SkipAnnotationWindow(flag, toolType);
1883 EXPECT_TRUE(result);
1884 flag = WindowInfo::FLAG_BIT_HANDWRITING;
1885 toolType = PointerEvent::TOOL_TYPE_PEN;
1886 result = WIN_MGR->SkipAnnotationWindow(flag, toolType);
1887 EXPECT_FALSE(result);
1888 flag = 0;
1889 toolType = PointerEvent::TOOL_TYPE_FINGER;
1890 result = WIN_MGR->SkipAnnotationWindow(flag, toolType);
1891 EXPECT_FALSE(result);
1892 flag = 0;
1893 toolType = PointerEvent::TOOL_TYPE_PEN;
1894 result = WIN_MGR->SkipAnnotationWindow(flag, toolType);
1895 EXPECT_FALSE(result);
1896 }
1897
1898 /**
1899 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_001
1900 * @tc.desc: This test verifies the functionality of updating the touch screen target
1901 * @tc.type: FUNC
1902 * @tc.require:
1903 */
1904 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_001, TestSize.Level1)
1905 {
1906 CALL_TEST_DEBUG;
1907 auto result = WIN_MGR->UpdateTouchScreenTarget(nullptr);
1908 EXPECT_NE(result, RET_ERR);
1909 auto pointerEvent = PointerEvent::Create();
1910 pointerEvent->SetTargetDisplayId(-1);
1911 result = WIN_MGR->UpdateTouchScreenTarget(pointerEvent);
1912 EXPECT_EQ(result, RET_ERR);
1913 pointerEvent->SetTargetDisplayId(1);
1914 pointerEvent->SetPointerId(1);
1915 result = WIN_MGR->UpdateTouchScreenTarget(pointerEvent);
1916 EXPECT_EQ(result, RET_ERR);
1917 }
1918
1919 /**
1920 * @tc.name: InputWindowsManagerTest_PullEnterLeaveEvent_001
1921 * @tc.desc: This test verifies the functionality of pulling enter and leave events
1922 * @tc.type: FUNC
1923 * @tc.require:
1924 */
1925 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PullEnterLeaveEvent_001, TestSize.Level1)
1926 {
1927 CALL_TEST_DEBUG;
1928 int32_t logicalX = 100;
1929 int32_t logicalY = 200;
1930 auto pointerEvent = PointerEvent::Create();
1931 WindowInfo touchWindow;
1932 WIN_MGR->PullEnterLeaveEvent(logicalX, logicalY, pointerEvent, &touchWindow);
1933 logicalX = -123;
1934 logicalY = -456;
1935 WIN_MGR->PullEnterLeaveEvent(logicalX, logicalY, pointerEvent, &touchWindow);
1936 }
1937
1938 /**
1939 * @tc.name: InputWindowsManagerTest_DispatchTouch_001
1940 * @tc.desc: This test verifies the functionality of touch event dispatching
1941 * @tc.type: FUNC
1942 * @tc.require:
1943 */
1944 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DispatchTouch_001, TestSize.Level1)
1945 {
1946 CALL_TEST_DEBUG;
1947 int32_t pointerAction = PointerEvent::POINTER_ACTION_PULL_IN_WINDOW;
1948 ASSERT_NO_FATAL_FAILURE(WIN_MGR->DispatchTouch(pointerAction));
1949 pointerAction = PointerEvent::POINTER_ACTION_DOWN;
1950 ASSERT_NO_FATAL_FAILURE(WIN_MGR->DispatchTouch(pointerAction));
1951 }
1952
1953 /**
1954 * @tc.name: InputWindowsManagerTest_UpdateTouchPadTarget_001
1955 * @tc.desc: This test verifies the functionality of updating the touchpad target
1956 * @tc.type: FUNC
1957 * @tc.require:
1958 */
1959 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchPadTarget_001, TestSize.Level1)
1960 {
1961 CALL_TEST_DEBUG;
1962 auto pointerEvent = PointerEvent::Create();
1963 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
1964 int32_t result = WIN_MGR->UpdateTouchPadTarget(pointerEvent);
1965 EXPECT_EQ(result, RET_ERR);
1966 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_UP);
1967 result = WIN_MGR->UpdateTouchPadTarget(pointerEvent);
1968 EXPECT_EQ(result, RET_ERR);
1969 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
1970 result = WIN_MGR->UpdateTouchPadTarget(pointerEvent);
1971 EXPECT_EQ(result, RET_ERR);
1972 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
1973 result = WIN_MGR->UpdateTouchPadTarget(pointerEvent);
1974 EXPECT_EQ(result, RET_ERR);
1975 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UP);
1976 result = WIN_MGR->UpdateTouchPadTarget(pointerEvent);
1977 EXPECT_EQ(result, RET_ERR);
1978 pointerEvent->SetPointerAction(9999);
1979 result = WIN_MGR->UpdateTouchPadTarget(pointerEvent);
1980 EXPECT_EQ(result, RET_ERR);
1981 }
1982
1983 /**
1984 * @tc.name: InputWindowsManagerTest_DrawTouchGraphic_001
1985 * @tc.desc: This test verifies the functionality of drawing touch graphics
1986 * @tc.type: FUNC
1987 * @tc.require:
1988 */
1989 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DrawTouchGraphic_001, TestSize.Level1)
1990 {
1991 CALL_TEST_DEBUG;
1992 auto pointerEvent = PointerEvent::Create();
1993 WIN_MGR->DrawTouchGraphic(pointerEvent);
1994 }
1995
1996 /**
1997 * @tc.name: InputWindowsManagerTest_UpdateTargetPointer_001
1998 * @tc.desc: This test verifies the functionality of updating the target pointer
1999 * @tc.type: FUNC
2000 * @tc.require:
2001 */
2002 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTargetPointer_001, TestSize.Level1)
2003 {
2004 CALL_TEST_DEBUG;
2005 auto pointerEvent = PointerEvent::Create();
2006 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
2007 pointerEvent->SetPointerAction(1);
2008 int32_t result = WIN_MGR->UpdateTargetPointer(pointerEvent);
2009 EXPECT_EQ(result, RET_ERR);
2010 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
2011 pointerEvent->SetPointerAction(1);
2012 result = WIN_MGR->UpdateTargetPointer(pointerEvent);
2013 EXPECT_EQ(result, RET_ERR);
2014 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
2015 pointerEvent->SetPointerAction(1);
2016 result = WIN_MGR->UpdateTargetPointer(pointerEvent);
2017 EXPECT_EQ(result, RET_ERR);
2018 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_JOYSTICK);
2019 pointerEvent->SetPointerAction(1);
2020 result = WIN_MGR->UpdateTargetPointer(pointerEvent);
2021 EXPECT_EQ(result, RET_OK);
2022 pointerEvent->SetSourceType(999);
2023 pointerEvent->SetPointerAction(1);
2024 result = WIN_MGR->UpdateTargetPointer(pointerEvent);
2025 EXPECT_EQ(result, RET_ERR);
2026 }
2027
2028 /**
2029 * @tc.name: InputWindowsManagerTest_IsInsideDisplay_001
2030 * @tc.desc: This test verifies the functionality of determining whether it is inside the display area
2031 * @tc.type: FUNC
2032 * @tc.require:
2033 */
2034 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsInsideDisplay_001, TestSize.Level1)
2035 {
2036 CALL_TEST_DEBUG;
2037 DisplayInfo displayInfo;
2038 displayInfo.width = 1920;
2039 displayInfo.height = 1080;
2040 int32_t physicalX = 500;
2041 int32_t physicalY = 10;
2042 bool result = WIN_MGR->IsInsideDisplay(displayInfo, physicalX, physicalY);
2043 EXPECT_TRUE(result);
2044 physicalX = -10;
2045 physicalY = 500;
2046 result = WIN_MGR->IsInsideDisplay(displayInfo, physicalX, physicalY);
2047 EXPECT_FALSE(result);
2048 physicalX = 500;
2049 physicalY = -10;
2050 result = WIN_MGR->IsInsideDisplay(displayInfo, physicalX, physicalY);
2051 EXPECT_FALSE(result);
2052 physicalX = -500;
2053 physicalY = -10;
2054 result = WIN_MGR->IsInsideDisplay(displayInfo, physicalX, physicalY);
2055 EXPECT_FALSE(result);
2056 }
2057
2058 /**
2059 * @tc.name: InputWindowsManagerTest_FindPhysicalDisplay_001
2060 * @tc.desc: This test verifies the functionality of finding physical displays
2061 * @tc.type: FUNC
2062 * @tc.require:
2063 */
2064 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_FindPhysicalDisplay_001, TestSize.Level1)
2065 {
2066 CALL_TEST_DEBUG;
2067 DisplayInfo displayInfo = {10, 20};
2068 int32_t physicalX, physicalY, displayId;
2069 WIN_MGR->FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
2070 EXPECT_EQ(physicalX, RET_OK);
2071 EXPECT_EQ(physicalY, RET_OK);
2072 EXPECT_EQ(displayId, RET_OK);
2073 displayInfo.x = INT32_MAX;
2074 displayInfo.y = INT32_MAX;
2075 WIN_MGR->FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
2076 EXPECT_EQ(physicalX, RET_OK);
2077 EXPECT_EQ(physicalY, RET_OK);
2078 EXPECT_EQ(displayId, RET_OK);
2079 displayInfo.x = 50;
2080 displayInfo.y = 60;
2081 WIN_MGR->FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
2082 EXPECT_EQ(physicalX, RET_OK);
2083 EXPECT_EQ(physicalY, RET_OK);
2084 EXPECT_EQ(displayId, RET_OK);
2085 }
2086
2087 /**
2088 * @tc.name: InputWindowsManagerTest_Dump_001
2089 * @tc.desc: Test the dump function of the input window manager
2090 * @tc.type: FUNC
2091 * @tc.require:
2092 */
2093 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_Dump_001, TestSize.Level1)
2094 {
2095 CALL_TEST_DEBUG;
2096 int32_t fd = 1;
2097 std::vector<std::string> args;
2098 ASSERT_NO_FATAL_FAILURE(WIN_MGR->Dump(fd, args));
2099 }
2100
2101 /**
2102 * @tc.name: InputWindowsManagerTest_TransformWindowXY_001
2103 * @tc.desc: Test the TransformWindowXY function of the input window manager
2104 * @tc.type: FUNC
2105 * @tc.require:
2106 */
2107 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_TransformWindowXY_001, TestSize.Level1)
2108 {
2109 CALL_TEST_DEBUG;
2110 WindowInfo window;
2111 double logicX = 10.0;
2112 double logicY = 20.0;
2113 std::pair<double, double> result =WIN_MGR->TransformWindowXY(window, logicX, logicY);
2114 double ret = result.first;
2115 EXPECT_EQ(ret, logicX);
2116 double ret1 = result.second;
2117 EXPECT_EQ(ret1, logicY);
2118 }
2119
2120 /**
2121 * @tc.name: InputWindowsManagerTest_IsValidZorderWindow_001
2122 * @tc.desc: Test the validity of the input window manager
2123 * @tc.type: FUNC
2124 * @tc.require:
2125 */
2126 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsValidZorderWindow_001, TestSize.Level1)
2127 {
2128 CALL_TEST_DEBUG;
2129 WindowInfo window;
2130 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
2131 ASSERT_NE(pointerEvent, nullptr);
2132 pointerEvent->HasFlag(InputEvent::EVENT_FLAG_SIMULATE);
2133 bool result = WIN_MGR->IsValidZorderWindow(window, pointerEvent);
2134 EXPECT_TRUE(result);
2135 }
2136
2137 /**
2138 * @tc.name: InputWindowsManagerTest_HandleWindowInputType_004
2139 * @tc.desc: Test the functionality of handling window input types in the Input Windows Manage
2140 * @tc.type: FUNC
2141 * @tc.require:
2142 */
2143 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandleWindowInputType_004, TestSize.Level1)
2144 {
2145 CALL_TEST_DEBUG;
2146 UDSServer udsServer;
2147 WIN_MGR->Init(udsServer);
2148 auto pointerEvent = PointerEvent::Create();
2149 ASSERT_NE(pointerEvent, nullptr);
2150 WindowInfo window;
2151 window.windowInputType = WindowInputType::TRANSMIT_EXCEPT_MOVE;
2152 ASSERT_FALSE(WIN_MGR->HandleWindowInputType(window, pointerEvent));
2153 }
2154
2155 /**
2156 * @tc.name: InputWindowsManagerTest_GetWindowAndDisplayInfo_001
2157 * @tc.desc: Test the function of getting window and display information
2158 * @tc.type: FUNC
2159 * @tc.require:
2160 */
2161 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowAndDisplayInfo_001, TestSize.Level1)
2162 {
2163 CALL_TEST_DEBUG;
2164 int32_t windowId = 1;
2165 int32_t displayId = 1;
2166 auto result = WIN_MGR->GetWindowAndDisplayInfo(windowId, displayId);
2167 ASSERT_TRUE(result.has_value());
2168 EXPECT_EQ(result->id, windowId);
2169 windowId = -1;
2170 displayId = 1;
2171 result = WIN_MGR->GetWindowAndDisplayInfo(windowId, displayId);
2172 ASSERT_FALSE(result.has_value());
2173 windowId = 1;
2174 displayId = -1;
2175 result = WIN_MGR->GetWindowAndDisplayInfo(windowId, displayId);
2176 ASSERT_TRUE(result.has_value());
2177 }
2178
2179 /**
2180 * @tc.name: InputWindowsManagerTest_GetTargetWindowIds_001
2181 * @tc.desc: Test the functionality of getting target window IDs
2182 * @tc.type: FUNC
2183 * @tc.require:
2184 */
2185 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetTargetWindowIds_001, TestSize.Level1)
2186 {
2187 CALL_TEST_DEBUG;
2188 std::vector<int32_t> windowIds;
2189 int32_t pointerItemId = 1;
2190 int32_t windowId = 100;
2191 int32_t sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
2192 WIN_MGR->AddTargetWindowIds(pointerItemId, sourceType, windowId);
2193 WIN_MGR->GetTargetWindowIds(pointerItemId, sourceType, windowIds);
2194 ASSERT_TRUE(!windowIds.empty());
2195 WIN_MGR->ClearTargetWindowId(pointerItemId);
2196 }
2197
2198 /**
2199 * @tc.name: InputWindowsManagerTest_AddTargetWindowIds_001
2200 * @tc.desc: Test the functionality of adding target window IDs
2201 * @tc.type: FUNC
2202 * @tc.require:
2203 */
2204 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_AddTargetWindowIds_001, TestSize.Level1)
2205 {
2206 CALL_TEST_DEBUG;
2207 InputWindowsManager manager;
2208 int32_t pointerItemId = 1;
2209 int32_t windowId = 100;
2210 int32_t sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
2211 WIN_MGR->AddTargetWindowIds(pointerItemId, sourceType, windowId);
2212 ASSERT_FALSE(manager.targetTouchWinIds_.find(pointerItemId) != manager.targetTouchWinIds_.end());
2213 ASSERT_EQ(manager.targetTouchWinIds_[pointerItemId].size(), 0);
2214 }
2215
2216 /**
2217 * @tc.name: InputWindowsManagerTest_AddTargetWindowIds_002
2218 * @tc.desc: Test the functionality of adding target window IDs
2219 * @tc.type: FUNC
2220 * @tc.require:
2221 */
2222 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_AddTargetWindowIds_002, TestSize.Level1)
2223 {
2224 CALL_TEST_DEBUG;
2225 InputWindowsManager manager;
2226 int32_t pointerItemId = 2;
2227 int32_t windowId1 = 200;
2228 int32_t windowId2 = 201;
2229 int32_t sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
2230 manager.targetTouchWinIds_[pointerItemId] = {windowId1};
2231 WIN_MGR->AddTargetWindowIds(pointerItemId, sourceType, windowId2);
2232 ASSERT_TRUE(manager.targetTouchWinIds_.find(pointerItemId) != manager.targetTouchWinIds_.end());
2233 ASSERT_EQ(manager.targetTouchWinIds_[pointerItemId].size(), 1);
2234 ASSERT_EQ(manager.targetTouchWinIds_[pointerItemId][0], windowId1);
2235 ASSERT_NE(manager.targetTouchWinIds_[pointerItemId][1], windowId2);
2236 }
2237
2238 /**
2239 * @tc.name: InputWindowsManagerTest_CheckWindowIdPermissionByPid_002
2240 * @tc.desc: Test the functionality of checking window ID permission by process ID
2241 * @tc.type: FUNC
2242 * @tc.require:
2243 */
2244 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckWindowIdPermissionByPid_002, TestSize.Level1)
2245 {
2246 CALL_TEST_DEBUG;
2247 int32_t windowId = -123;
2248 int32_t pid = -456;
2249 int32_t result = WIN_MGR->CheckWindowIdPermissionByPid(windowId, pid);
2250 EXPECT_EQ(result, RET_ERR);
2251 }
2252
2253 /**
2254 * @tc.name: InputWindowsManagerTest_IsTransparentWin_001
2255 * @tc.desc: Test the functionality of transparent windows
2256 * @tc.type: FUNC
2257 * @tc.require:
2258 */
2259 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsTransparentWin_001, TestSize.Level1)
2260 {
2261 CALL_TEST_DEBUG;
2262 std::unique_ptr<Media::PixelMap> pixelMap = nullptr;
2263 int32_t logicalX = 0;
2264 int32_t logicalY = 0;
2265 auto result = WIN_MGR->IsTransparentWin(pixelMap, logicalX, logicalY);
2266 EXPECT_FALSE(result);
2267 }
2268
2269 /**
2270 * @tc.name: InputWindowsManagerTest_GetWidthAndHeight_001
2271 * @tc.desc: Test the method for retrieving width and height
2272 * @tc.type: FUNC
2273 * @tc.require:
2274 */
2275 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWidthAndHeight_001, TestSize.Level1)
2276 {
2277 CALL_TEST_DEBUG;
2278 DisplayInfo displayInfo;
2279 displayInfo.displayDirection = DIRECTION0;
2280 displayInfo.direction = DIRECTION0;
2281 int32_t width = 1920;
2282 int32_t height = 1080;
2283 WIN_MGR->GetWidthAndHeight(&displayInfo, width, height);
2284 EXPECT_EQ(width, RET_OK);
2285 EXPECT_EQ(height, RET_OK);
2286 displayInfo.direction = DIRECTION90;
2287 WIN_MGR->GetWidthAndHeight(&displayInfo, width, height);
2288 EXPECT_EQ(width, RET_OK);
2289 EXPECT_EQ(height, RET_OK);
2290 displayInfo.displayDirection = DIRECTION180;
2291 displayInfo.direction = DIRECTION0;
2292 WIN_MGR->GetWidthAndHeight(&displayInfo, width, height);
2293 EXPECT_EQ(width, RET_OK);
2294 EXPECT_EQ(height, RET_OK);
2295 }
2296
2297 /**
2298 * @tc.name: InputWindowsManagerTest_ReverseRotateScreen_001
2299 * @tc.desc: Test the method for reversing screen rotation
2300 * @tc.type: FUNC
2301 * @tc.require:
2302 */
2303 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ReverseRotateScreen_001, TestSize.Level1)
2304 {
2305 CALL_TEST_DEBUG;
2306 DisplayInfo info;
2307 Coordinate2D cursorPos;
2308 info.direction = DIRECTION0;
2309 info.width = 1920;
2310 info.height = 1080;
2311 WIN_MGR->ReverseRotateScreen(info, 100.0, 200.0, cursorPos);
2312 EXPECT_EQ(cursorPos.x, 100);
2313 EXPECT_EQ(cursorPos.y, 200);
2314 info.direction = DIRECTION90;
2315 WIN_MGR->ReverseRotateScreen(info, 100.0, 200.0, cursorPos);;
2316 EXPECT_EQ(cursorPos.x, 200);
2317 EXPECT_EQ(cursorPos.y, 1820);
2318 info.direction = DIRECTION180;
2319 WIN_MGR->ReverseRotateScreen(info, 100.0, 200.0, cursorPos);
2320 EXPECT_EQ(cursorPos.x, 1820);
2321 EXPECT_EQ(cursorPos.y, 880);
2322 info.direction = DIRECTION270;
2323 WIN_MGR->ReverseRotateScreen(info, 100.0, 200.0, cursorPos);
2324 EXPECT_EQ(cursorPos.x, 880);
2325 EXPECT_EQ(cursorPos.y, 100);
2326 }
2327
2328 /**
2329 * @tc.name: InputWindowsManagerTest_UpdateAndAdjustMouseLocation_001
2330 * @tc.desc: Test the method for updating and adjusting mouse location
2331 * @tc.type: FUNC
2332 * @tc.require:
2333 */
2334 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateAndAdjustMouseLocation_001, TestSize.Level1)
2335 {
2336 CALL_TEST_DEBUG;
2337 int32_t displayId = 2;
2338 double x = 100.5;
2339 double y = 200.5;
2340 bool isRealData = true;
2341 std::shared_ptr<InputEvent> inputEvent = InputEvent::Create();
2342 ASSERT_NE(inputEvent, nullptr);
2343 WIN_MGR->UpdateAndAdjustMouseLocation(displayId, x, y, isRealData);
2344 auto ret = WIN_MGR->GetDisplayId(inputEvent);
2345 EXPECT_NE(displayId, ret);
2346 displayId = -1;
2347 x = 100.5;
2348 y = 200.5;
2349 isRealData = true;
2350 WIN_MGR->UpdateAndAdjustMouseLocation(displayId, x, y, isRealData);
2351 ret = WIN_MGR->GetDisplayId(inputEvent);
2352 EXPECT_NE(displayId, ret);
2353 displayId = 0;
2354 x = -100.5;
2355 y = -200.5;
2356 isRealData = true;
2357 WIN_MGR->UpdateAndAdjustMouseLocation(displayId, x, y, isRealData);
2358 ret = WIN_MGR->GetDisplayId(inputEvent);
2359 EXPECT_NE(displayId, ret);
2360 displayId = 0;
2361 x = 100.5;
2362 y = 200.5;
2363 isRealData = false;
2364 WIN_MGR->UpdateAndAdjustMouseLocation(displayId, x, y, isRealData);
2365 ret = WIN_MGR->GetDisplayId(inputEvent);
2366 EXPECT_NE(displayId, ret);
2367 }
2368
2369 /**
2370 * @tc.name: InputWindowsManagerTest_GetMouseInfo_001
2371 * @tc.desc: Test the GetMouseInfo method
2372 * @tc.type: FUNC
2373 * @tc.require:
2374 */
2375 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetMouseInfo_001, TestSize.Level1)
2376 {
2377 CALL_TEST_DEBUG;
2378 DisplayGroupInfo displayGroupInfo;
2379 MouseLocation mouseLocation;
2380 displayGroupInfo.displaysInfo.clear();
2381 MouseLocation result = WIN_MGR->GetMouseInfo();
2382 DisplayInfo displayInfo;
2383 displayInfo.id = 1;
2384 displayInfo.width = 1920;
2385 displayInfo.height = 1080;
2386 displayGroupInfo.displaysInfo.push_back(displayInfo);
2387 mouseLocation.displayId = 0;
2388 result = WIN_MGR->GetMouseInfo();
2389 displayGroupInfo.displaysInfo.push_back(displayInfo);
2390 mouseLocation.displayId = -1;
2391 MouseLocation expectedResult;
2392 expectedResult.displayId = 1;
2393 expectedResult.physicalX = 960;
2394 expectedResult.physicalY = 540;
2395 ASSERT_NO_FATAL_FAILURE(WIN_MGR->GetMouseInfo());
2396 }
2397
2398 /**
2399 * @tc.name: InputWindowsManagerTest_GetCursorPos_001
2400 * @tc.desc: Test the functionality of getting the cursor position
2401 * @tc.type: FUNC
2402 * @tc.require:
2403 */
2404 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetCursorPos_001, TestSize.Level1)
2405 {
2406 InputWindowsManager manager;
2407 manager.cursorPos_.displayId = -1;
2408 manager.displayGroupInfo_.displaysInfo.push_back({0, 800, 600});
2409 CursorPosition result = WIN_MGR->GetCursorPos();
2410 EXPECT_NE(result.displayId, RET_ERR);
2411 EXPECT_NE(result.cursorPos.x, RET_OK);
2412 EXPECT_NE(result.cursorPos.y, RET_OK);
2413 manager.cursorPos_.displayId = 1;
2414 manager.displayGroupInfo_.displaysInfo.push_back({1, 800, 600});
2415 result = WIN_MGR->GetCursorPos();
2416 EXPECT_NE(result.displayId, RET_ERR);
2417 EXPECT_NE(result.cursorPos.x, RET_OK);
2418 EXPECT_NE(result.cursorPos.y, RET_OK);
2419 }
2420
2421 /**
2422 * @tc.name: InputWindowsManagerTest_ResetCursorPos_001
2423 * @tc.desc: Test the functionality of resetting cursor position
2424 * @tc.type: FUNC
2425 * @tc.require:
2426 */
2427 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ResetCursorPos_001, TestSize.Level1)
2428 {
2429 InputWindowsManager manager;
2430 manager.displayGroupInfo_.displaysInfo.push_back({1, 800, 600});
2431 CursorPosition result = WIN_MGR->ResetCursorPos();
2432 EXPECT_NE(result.displayId, RET_ERR);
2433 EXPECT_NE(result.cursorPos.x, RET_OK);
2434 EXPECT_NE(result.cursorPos.y, RET_OK);
2435 manager.displayGroupInfo_.displaysInfo.clear();
2436 result = WIN_MGR->ResetCursorPos();
2437 EXPECT_NE(result.displayId, RET_ERR);
2438 EXPECT_NE(result.cursorPos.x, RET_OK);
2439 EXPECT_NE(result.cursorPos.y, RET_OK);
2440 }
2441
2442 /**
2443 * @tc.name: InputWindowsManagerTest_AppendExtraData_001
2444 * @tc.desc: Test the functionality of appending extra data in the input window manager
2445 * @tc.type: FUNC
2446 * @tc.require:
2447 */
2448 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_AppendExtraData_001, TestSize.Level1)
2449 {
2450 InputWindowsManager manager;
2451 ExtraData extraData;
2452 extraData.appended = true;
2453 extraData.buffer = std::vector<uint8_t>{1, 2, 3};
2454 extraData.pointerId = 12345;
2455 int32_t result = WIN_MGR->AppendExtraData(extraData);
2456 ASSERT_EQ(result, RET_OK);
2457 ASSERT_NE(manager.GetExtraData().appended, extraData.appended);
2458 ASSERT_NE(manager.GetExtraData().buffer, extraData.buffer);
2459 ASSERT_NE(manager.GetExtraData().pointerId, extraData.pointerId);
2460 }
2461
2462 /**
2463 * @tc.name: InputWindowsManagerTest_ClearExtraData_001
2464 * @tc.desc: Test the functionality of clearing extra data
2465 * @tc.type: FUNC
2466 * @tc.require:
2467 */
2468 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ClearExtraData_001, TestSize.Level1)
2469 {
2470 InputWindowsManager manager;
2471 manager.extraData_.appended = true;
2472 manager.extraData_.buffer.push_back(1);
2473 manager.extraData_.sourceType = 0;
2474 manager.extraData_.pointerId = 1;
2475 WIN_MGR->ClearExtraData();
2476 EXPECT_TRUE(manager.extraData_.appended);
2477 EXPECT_FALSE(manager.extraData_.buffer.empty());
2478 EXPECT_NE(-1, manager.extraData_.sourceType);
2479 EXPECT_NE(-1, manager.extraData_.pointerId);
2480 }
2481
2482 /**
2483 * @tc.name: InputWindowsManagerTest_GetExtraData_001
2484 * @tc.desc: Test the functionality of getting extra data in the input window manager
2485 * @tc.type: FUNC
2486 * @tc.require:
2487 */
2488 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetExtraData_001, TestSize.Level1)
2489 {
2490 CALL_TEST_DEBUG;
2491 ASSERT_NO_FATAL_FAILURE(WIN_MGR->GetExtraData());
2492 }
2493
2494 /**
2495 * @tc.name: InputWindowsManagerTest_IsWindowVisible_001
2496 * @tc.desc: Test the window visibility functionality of the input window manager
2497 * @tc.type: FUNC
2498 * @tc.require:
2499 */
2500 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsWindowVisible_001, TestSize.Level1)
2501 {
2502 int32_t invalidPid = -1;
2503 bool result = WIN_MGR->IsWindowVisible(invalidPid);
2504 EXPECT_TRUE(result);
2505 int32_t visiblePid = 0;
2506 result = WIN_MGR->IsWindowVisible(visiblePid);
2507 EXPECT_FALSE(result);
2508 int32_t invisiblePid = 1;
2509 result = WIN_MGR->IsWindowVisible(invisiblePid);
2510 EXPECT_FALSE(result);
2511 }
2512
2513 /**
2514 * @tc.name: InputWindowsManagerTest_UpdatePointerAction_001
2515 * @tc.desc: Test the update function of pointer action in Input Windows Manager
2516 * @tc.type: FUNC
2517 * @tc.require:
2518 */
2519 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerAction_001, TestSize.Level1)
2520 {
2521 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
2522 ASSERT_NE(pointerEvent, nullptr);
2523 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
2524 WIN_MGR->UpdatePointerAction(pointerEvent);
2525 EXPECT_EQ(pointerEvent->GetPointerAction(), PointerEvent::POINTER_ACTION_PULL_MOVE);
2526 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_UP);
2527 WIN_MGR->UpdatePointerAction(pointerEvent);
2528 EXPECT_EQ(pointerEvent->GetPointerAction(), PointerEvent::POINTER_ACTION_PULL_UP);
2529 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UP);
2530 WIN_MGR->UpdatePointerAction(pointerEvent);
2531 EXPECT_EQ(pointerEvent->GetPointerAction(), PointerEvent::POINTER_ACTION_PULL_UP);
2532 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_ENTER_WINDOW);
2533 WIN_MGR->UpdatePointerAction(pointerEvent);
2534 EXPECT_EQ(pointerEvent->GetPointerAction(), PointerEvent::POINTER_ACTION_PULL_IN_WINDOW);
2535 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_LEAVE_WINDOW);
2536 WIN_MGR->UpdatePointerAction(pointerEvent);
2537 EXPECT_EQ(pointerEvent->GetPointerAction(), PointerEvent::POINTER_ACTION_PULL_OUT_WINDOW);
2538 pointerEvent->SetPointerAction(100);
2539 WIN_MGR->UpdatePointerAction(pointerEvent);
2540 EXPECT_EQ(pointerEvent->GetPointerAction(), 100);
2541 }
2542
2543 /**
2544 * @tc.name: InputWindowsManagerTest_UpdatePointerAction_01
2545 * @tc.desc: Test UpdatePointerAction
2546 * @tc.type: FUNC
2547 * @tc.require:
2548 */
2549 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerAction_01, TestSize.Level1)
2550 {
2551 UDSServer udsServer;
2552 WIN_MGR->Init(udsServer);
2553 auto pointerEvent = PointerEvent::Create();
2554 ASSERT_NE(pointerEvent, nullptr);
2555 int32_t action = pointerEvent->GetPointerAction();
2556 action = PointerEvent::POINTER_ACTION_MOVE;
2557 WIN_MGR->UpdatePointerAction(pointerEvent);
2558 ASSERT_NO_FATAL_FAILURE(pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_MOVE));
2559 }
2560
2561 /**
2562 * @tc.name: InputWindowsManagerTest_UpdatePointerAction_02
2563 * @tc.desc: Test UpdatePointerAction
2564 * @tc.type: FUNC
2565 * @tc.require:
2566 */
2567 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerAction_02, TestSize.Level1)
2568 {
2569 UDSServer udsServer;
2570 WIN_MGR->Init(udsServer);
2571 auto pointerEvent = PointerEvent::Create();
2572 ASSERT_NE(pointerEvent, nullptr);
2573 int32_t action = pointerEvent->GetPointerAction();
2574 action = PointerEvent::POINTER_ACTION_UP;
2575 WIN_MGR->UpdatePointerAction(pointerEvent);
2576 ASSERT_NO_FATAL_FAILURE(pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_UP));
2577 }
2578
2579 /**
2580 * @tc.name: InputWindowsManagerTest_UpdatePointerAction_03
2581 * @tc.desc: Test UpdatePointerAction
2582 * @tc.type: FUNC
2583 * @tc.require:
2584 */
2585 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerAction_03, TestSize.Level1)
2586 {
2587 UDSServer udsServer;
2588 WIN_MGR->Init(udsServer);
2589 auto pointerEvent = PointerEvent::Create();
2590 ASSERT_NE(pointerEvent, nullptr);
2591 int32_t action = pointerEvent->GetPointerAction();
2592 action = PointerEvent::POINTER_ACTION_ENTER_WINDOW;
2593 WIN_MGR->UpdatePointerAction(pointerEvent);
2594 ASSERT_NO_FATAL_FAILURE(pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_IN_WINDOW));
2595 }
2596
2597 /**
2598 * @tc.name: InputWindowsManagerTest_UpdatePointerAction_04
2599 * @tc.desc: Test UpdatePointerAction
2600 * @tc.type: FUNC
2601 * @tc.require:
2602 */
2603 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerAction_04, TestSize.Level1)
2604 {
2605 UDSServer udsServer;
2606 WIN_MGR->Init(udsServer);
2607 auto pointerEvent = PointerEvent::Create();
2608 ASSERT_NE(pointerEvent, nullptr);
2609
2610 int32_t action = pointerEvent->GetPointerAction();
2611 action = PointerEvent::POINTER_ACTION_LEAVE_WINDOW;
2612 WIN_MGR->UpdatePointerAction(pointerEvent);
2613 ASSERT_NO_FATAL_FAILURE(pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_OUT_WINDOW));
2614 }
2615
2616 /**
2617 * @tc.name: InputWindowsManagerTest_UpdateDisplayId_002
2618 * @tc.desc: Test UpdateDisplayId
2619 * @tc.type: FUNC
2620 * @tc.require:
2621 */
2622 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayId_002, TestSize.Level1)
2623 {
2624 auto pointerEvent = PointerEvent::Create();
2625 pointerEvent->SetTargetDisplayId(1);
2626 auto id = pointerEvent->GetTargetDisplayId();
2627 ASSERT_TRUE(WIN_MGR->UpdateDisplayId(id));
2628 }
2629
2630 /**
2631 * @tc.name: InputWindowsManagerTest_UpdateDisplayId_003
2632 * @tc.desc: Test UpdateDisplayId
2633 * @tc.type: FUNC
2634 * @tc.require:
2635 */
2636 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayId_003, TestSize.Level1)
2637 {
2638 auto pointerEvent = PointerEvent::Create();
2639 pointerEvent->SetTargetDisplayId(10);
2640 auto id = pointerEvent->GetTargetDisplayId();
2641 ASSERT_FALSE(WIN_MGR->UpdateDisplayId(id));
2642 }
2643
2644 /**
2645 * @tc.name: InputWindowsManagerTest_Init_001
2646 * @tc.desc: Test Init
2647 * @tc.type: FUNC
2648 * @tc.require:
2649 */
2650 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_Init_001, TestSize.Level1)
2651 {
2652 UDSServer udsServer;
2653 WIN_MGR->Init(udsServer);
2654 EXPECT_TRUE(true);
2655 }
2656
2657 /**
2658 * @tc.name: InputWindowsManagerTest_UpdateCaptureMode_002
2659 * @tc.desc: Test UpdateCaptureMode
2660 * @tc.type: FUNC
2661 * @tc.require:
2662 */
2663 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateCaptureMode_002, TestSize.Level1)
2664 {
2665 DisplayGroupInfo displayGroupInfo;
2666 DisplayInfo info;
2667 info.id = 1;
2668 info.x =1;
2669 info.y = 1;
2670 info.width = 2;
2671 info.height = 2;
2672 info.dpi = 240;
2673 info.name = "pp";
2674 info.uniq = "pp";
2675 info.direction = DIRECTION0;
2676 displayGroupInfo.displaysInfo.push_back(info);
2677 WIN_MGR->UpdateCaptureMode(displayGroupInfo);
2678 ASSERT_FALSE(WIN_MGR->captureModeInfo_.isCaptureMode);
2679 }
2680
2681 /**
2682 * @tc.name: InputWindowsManagerTest_IsWindowVisible_002
2683 * @tc.desc: Test IsWindowVisible
2684 * @tc.type: FUNC
2685 * @tc.require:
2686 */
2687 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsWindowVisible_002, TestSize.Level1)
2688 {
2689 int32_t pid = 1000;
2690 auto ret = WIN_MGR->IsWindowVisible(pid);
2691 ASSERT_FALSE(ret);
2692 }
2693
2694 /**
2695 * @tc.name: InputWindowsManagerTest_IsWindowVisible_003
2696 * @tc.desc: Test IsWindowVisible
2697 * @tc.type: FUNC
2698 * @tc.require:
2699 */
2700 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsWindowVisible_003, TestSize.Level1)
2701 {
2702 int32_t pid = -1;
2703 auto ret = WIN_MGR->IsWindowVisible(pid);
2704 ASSERT_TRUE(ret);
2705 }
2706
2707 /**
2708 * @tc.name: InputWindowsManagerTest_GetWindowGroupInfoByDisplayId
2709 * @tc.desc: Test GetWindowGroupInfoByDisplayId
2710 * @tc.type: FUNC
2711 * @tc.require:
2712 */
2713 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowGroupInfoByDisplayId, TestSize.Level1)
2714 {
2715 CALL_TEST_DEBUG;
2716 InputWindowsManager inputWindowsManager;
2717 WindowGroupInfo windowGroupInfo;
2718 int32_t displayId = 1;
2719 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(displayId, windowGroupInfo));
2720 EXPECT_TRUE(inputWindowsManager.GetWindowGroupInfoByDisplayId(displayId).empty());
2721
2722 WindowInfo windowInfo;
2723 displayId = 2;
2724 windowInfo.id = 1;
2725 windowGroupInfo.windowsInfo.push_back(windowInfo);
2726 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(displayId, windowGroupInfo));
2727 EXPECT_TRUE(!inputWindowsManager.GetWindowGroupInfoByDisplayId(displayId).empty());
2728 }
2729
2730 /**
2731 * @tc.name: InputWindowsManagerTest_GetClientFd
2732 * @tc.desc: Test GetClientFd
2733 * @tc.type: FUNC
2734 * @tc.require:
2735 */
2736 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetClientFd, TestSize.Level1)
2737 {
2738 InputWindowsManager inputWindowsManager;
2739 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
2740 EXPECT_NE(pointerEvent, nullptr);
2741 WindowInfoEX windowInfoEX;
2742 windowInfoEX.flag = false;
2743 pointerEvent->SetPointerId(0);
2744 inputWindowsManager.touchItemDownInfos_.insert(std::make_pair(pointerEvent->GetPointerId(), windowInfoEX));
2745 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent), INVALID_FD);
2746 pointerEvent->SetPointerId(1);
2747 pointerEvent->SetTargetDisplayId(10);
2748 pointerEvent->SetTargetWindowId(15);
2749 WindowGroupInfo windowGroupInfo;
2750 WindowInfo windowInfo;
2751 windowInfo.id = 0;
2752 windowInfo.pid = 5;
2753 windowGroupInfo.windowsInfo.push_back(windowInfo);
2754 windowInfo.id = 15;
2755 windowInfo.pid = 6;
2756 windowGroupInfo.windowsInfo.push_back(windowInfo);
2757 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(pointerEvent->GetTargetDisplayId(), windowGroupInfo));
2758 UDSServer udsServer;
2759 udsServer.idxPidMap_.insert(std::make_pair(6, 15));
2760 inputWindowsManager.udsServer_ = &udsServer;
2761 EXPECT_NE(inputWindowsManager.udsServer_, nullptr);
2762 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent), 15);
2763 pointerEvent->SetTargetWindowId(20);
2764 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_LEAVE_WINDOW);
2765 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent), INVALID_FD);
2766 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
2767 inputWindowsManager.touchItemDownInfos_.clear();
2768 windowInfoEX.flag = true;
2769 windowInfoEX.window.agentWindowId = 1;
2770 pointerEvent->SetPointerId(0);
2771 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
2772 inputWindowsManager.touchItemDownInfos_.insert(std::make_pair(pointerEvent->GetPointerId(), windowInfoEX));
2773 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent), INVALID_FD);
2774 pointerEvent->SetPointerId(7);
2775 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent), INVALID_FD);
2776 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
2777 inputWindowsManager.mouseDownInfo_.pid = 1;
2778 inputWindowsManager.mouseDownInfo_.agentWindowId = 6;
2779 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent), INVALID_FD);
2780 inputWindowsManager.mouseDownInfo_.pid = -1;
2781 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent), INVALID_FD);
2782 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_JOYSTICK);
2783 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent), INVALID_FD);
2784 }
2785
2786 /**
2787 * @tc.name: InputWindowsManagerTest_GetClientFd_002
2788 * @tc.desc: Test GetClientFd
2789 * @tc.type: FUNC
2790 * @tc.require:
2791 */
2792 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetClientFd_002, TestSize.Level1)
2793 {
2794 CALL_TEST_DEBUG;
2795 InputWindowsManager inputWindowsManager;
2796 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
2797 EXPECT_NE(pointerEvent, nullptr);
2798 UDSServer udsServer;
2799 int32_t udsPid = 20;
2800 int32_t udsFd = 15;
2801 udsServer.idxPidMap_.insert(std::make_pair(udsPid, udsFd));
2802 inputWindowsManager.udsServer_ = &udsServer;
2803 int32_t windowId = 15;
2804 EXPECT_NE(inputWindowsManager.udsServer_, nullptr);
2805 WindowGroupInfo widGroupInfo;
2806 WindowInfo windowInfo;
2807 pointerEvent->SetTargetDisplayId(15);
2808 windowInfo.id = 5;
2809 windowInfo.pid = 10;
2810 widGroupInfo.windowsInfo.push_back(windowInfo);
2811 windowInfo.id = 15;
2812 windowInfo.pid = 20;
2813 widGroupInfo.windowsInfo.push_back(windowInfo);
2814 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(pointerEvent->GetTargetDisplayId(), widGroupInfo));
2815 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent, windowId), udsFd);
2816 windowId = 7;
2817 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent, windowId), INVALID_FD);
2818 }
2819
2820 /**
2821 * @tc.name: InputWindowsManagerTest_CheckFocusWindowChange
2822 * @tc.desc: Test CheckFocusWindowChange
2823 * @tc.type: FUNC
2824 * @tc.require:
2825 */
2826 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckFocusWindowChange, TestSize.Level1)
2827 {
2828 CALL_TEST_DEBUG;
2829 InputWindowsManager inputWindowsManager;
2830 DisplayGroupInfo displayGroupInfo;
2831 displayGroupInfo.focusWindowId = 1;
2832 inputWindowsManager.displayGroupInfo_.focusWindowId = 1;
2833 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CheckFocusWindowChange(displayGroupInfo));
2834 }
2835
2836 /**
2837 * @tc.name: InputWindowsManagerTest_CheckZorderWindowChange
2838 * @tc.desc: Test CheckZorderWindowChange
2839 * @tc.type: FUNC
2840 * @tc.require:
2841 */
2842 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckZorderWindowChange, TestSize.Level1)
2843 {
2844 CALL_TEST_DEBUG;
2845 InputWindowsManager inputWindowsManager;
2846 std::vector<WindowInfo> oldWindowsInfo;
2847 std::vector<WindowInfo> newWindowsInfo;
2848 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CheckZorderWindowChange(oldWindowsInfo, newWindowsInfo));
2849 }
2850
2851 /**
2852 * @tc.name: InputWindowsManagerTest_UpdateCaptureMode
2853 * @tc.desc: Test UpdateCaptureMode
2854 * @tc.type: FUNC
2855 * @tc.require:
2856 */
2857 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateCaptureMode, TestSize.Level1)
2858 {
2859 CALL_TEST_DEBUG;
2860 InputWindowsManager inputWindowsManager;
2861 DisplayGroupInfo displayGroupInfo;
2862 WindowInfo windowInfo;
2863 inputWindowsManager.captureModeInfo_.isCaptureMode = true;
2864 inputWindowsManager.displayGroupInfo_.focusWindowId = 25;
2865 displayGroupInfo.focusWindowId = 25;
2866 windowInfo.id = 10;
2867 inputWindowsManager.displayGroupInfo_.windowsInfo.push_back(windowInfo);
2868 windowInfo.id = 11;
2869 displayGroupInfo.windowsInfo.push_back(windowInfo);
2870 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateCaptureMode(displayGroupInfo));
2871 }
2872
2873 /**
2874 * @tc.name: InputWindowsManagerTest_UpdateDisplayInfoByIncrementalInfo
2875 * @tc.desc: Test UpdateDisplayInfoByIncrementalInfo
2876 * @tc.type: FUNC
2877 * @tc.require:
2878 */
2879 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayInfoByIncrementalInfo, TestSize.Level1)
2880 {
2881 CALL_TEST_DEBUG;
2882 InputWindowsManager inputWindowsManager;
2883 WindowInfo window;
2884 DisplayGroupInfo displayGroupInfo;
2885 WindowInfo windowInfo;
2886 window.action = WINDOW_UPDATE_ACTION::ADD_END;
2887 window.id = 5;
2888 windowInfo.id = 10;
2889 displayGroupInfo.windowsInfo.push_back(windowInfo);
2890 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayInfoByIncrementalInfo(window, displayGroupInfo));
2891 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayInfoByIncrementalInfo(window, displayGroupInfo));
2892 window.id = 5;
2893 window.action = WINDOW_UPDATE_ACTION::DEL;
2894 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayInfoByIncrementalInfo(window, displayGroupInfo));
2895 window.action = WINDOW_UPDATE_ACTION::CHANGE;
2896 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayInfoByIncrementalInfo(window, displayGroupInfo));
2897 window.id = 10;
2898 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayInfoByIncrementalInfo(window, displayGroupInfo));
2899 window.action = WINDOW_UPDATE_ACTION::UNKNOWN;
2900 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayInfoByIncrementalInfo(window, displayGroupInfo));
2901 }
2902
2903 /**
2904 * @tc.name: InputWindowsManagerTest_UpdateDisplayMode
2905 * @tc.desc: Test UpdateDisplayMode
2906 * @tc.type: FUNC
2907 * @tc.require:
2908 */
2909 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayMode, TestSize.Level1)
2910 {
2911 CALL_TEST_DEBUG;
2912 InputWindowsManager inputWindowsManager;
2913 DisplayInfo displayInfo;
2914 displayInfo.displayMode = DisplayMode::FULL;
2915 inputWindowsManager.displayMode_ = DisplayMode::FULL;
2916 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displayInfo);
2917 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayMode());
2918 inputWindowsManager.displayMode_ = DisplayMode::MAIN;
2919 FINGERSENSE_WRAPPER->sendFingerSenseDisplayMode_ = nullptr;
2920 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayMode());
2921 inputWindowsManager.displayMode_ = DisplayMode::MAIN;
2922 FINGERSENSE_WRAPPER->sendFingerSenseDisplayMode_ = FingersenseWrapperTest;
2923 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayMode());
2924 }
2925
2926 /**
2927 * @tc.name: InputWindowsManagerTest_GetPhysicalDisplay
2928 * @tc.desc: Test GetPhysicalDisplay
2929 * @tc.type: FUNC
2930 * @tc.require:
2931 */
2932 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPhysicalDisplay, TestSize.Level1)
2933 {
2934 CALL_TEST_DEBUG;
2935 InputWindowsManager inputWindowsManager;
2936 int32_t id = 1;
2937 DisplayInfo displayInfo;
2938 displayInfo.id = 0;
2939 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displayInfo);
2940 displayInfo.id = 1;
2941 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displayInfo);
2942 EXPECT_NE(inputWindowsManager.GetPhysicalDisplay(id), nullptr);
2943 }
2944
2945 /**
2946 * @tc.name: InputWindowsManagerTest_FindPhysicalDisplayInfo
2947 * @tc.desc: Test FindPhysicalDisplayInfo
2948 * @tc.type: FUNC
2949 * @tc.require:
2950 */
2951 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_FindPhysicalDisplayInfo, TestSize.Level1)
2952 {
2953 CALL_TEST_DEBUG;
2954 InputWindowsManager inputWindowsManager;
2955 DisplayInfo displayInfo;
2956 std::string uniq = "uniq_test";
2957 displayInfo.uniq = "uniq_test";
2958 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displayInfo);
2959 EXPECT_NE(inputWindowsManager.FindPhysicalDisplayInfo(uniq), nullptr);
2960 }
2961
2962 /**
2963 * @tc.name: InputWindowsManagerTest_OnSessionLost
2964 * @tc.desc: Test OnSessionLost
2965 * @tc.type: FUNC
2966 * @tc.require:
2967 */
2968 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_OnSessionLost, TestSize.Level1)
2969 {
2970 CALL_TEST_DEBUG;
2971 InputWindowsManager inputWindowsManager;
2972 int32_t pointerStylePid = 10;
2973 int32_t uidRoot = 0;
2974 std::string programName = "uds_sesion_test";
2975 int32_t moduleType = 3;
2976 int32_t pid = 9;
2977 int32_t fd = -1;
2978 SessionPtr sess = std::make_shared<UDSSession>(programName, moduleType, fd, uidRoot, pid);
2979 int32_t windowId = 1;
2980 PointerStyle pointerStyle;
2981 pointerStyle.size = 1;
2982 pointerStyle.color = 2;
2983 pointerStyle.id = 3;
2984 std::map<int32_t, PointerStyle> pointerStyleMap;
2985 pointerStyleMap.insert(std::make_pair(windowId, pointerStyle));
2986 inputWindowsManager.pointerStyle_.insert(std::make_pair(pointerStylePid, pointerStyleMap));
2987 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.OnSessionLost(sess));
2988
2989 pid = 10;
2990 SessionPtr session = std::make_shared<UDSSession>(programName, moduleType, fd, uidRoot, pid);
2991 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.OnSessionLost(session));
2992 }
2993
2994 /**
2995 * @tc.name: InputWindowsManagerTest_UpdatePoinerStyle
2996 * @tc.desc: Test UpdatePoinerStyle
2997 * @tc.type: FUNC
2998 * @tc.require:
2999 */
3000 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePoinerStyle, TestSize.Level1)
3001 {
3002 CALL_TEST_DEBUG;
3003 InputWindowsManager inputWindowsManager;
3004 int32_t pid = 1;
3005 int32_t windowId = 1;
3006 PointerStyle pointerStyle;
3007 pointerStyle.size = 1;
3008 pointerStyle.color = 2;
3009 pointerStyle.id = 3;
3010 std::map<int32_t, PointerStyle> pointerStyleMap;
3011 pointerStyleMap.insert(std::make_pair(windowId, pointerStyle));
3012 inputWindowsManager.pointerStyle_.insert(std::make_pair(pid, pointerStyleMap));
3013 windowId = 2;
3014 WindowInfo windowInfo;
3015 windowInfo.id = 3;
3016 windowInfo.pid = 6;
3017 inputWindowsManager.displayGroupInfo_.windowsInfo.push_back(windowInfo);
3018 windowInfo.id = 2;
3019 windowInfo.pid = 1;
3020 inputWindowsManager.displayGroupInfo_.windowsInfo.push_back(windowInfo);
3021 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePoinerStyle(pid, windowId, pointerStyle));
3022 }
3023
3024 /**
3025 * @tc.name: InputWindowsManagerTest_UpdateSceneBoardPointerStyle
3026 * @tc.desc: Test UpdateSceneBoardPointerStyle
3027 * @tc.type: FUNC
3028 * @tc.require:
3029 */
3030 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateSceneBoardPointerStyle, TestSize.Level1)
3031 {
3032 CALL_TEST_DEBUG;
3033 InputWindowsManager inputWindowsManager;
3034 int32_t pid = 1000;
3035 int32_t windowId = 987654321;
3036 bool isUiExtension = true;
3037 PointerStyle style;
3038 style.id = 0;
3039 std::map<int32_t, PointerStyle> pointerStyleMap;
3040 pointerStyleMap.insert(std::make_pair(windowId, style));
3041 inputWindowsManager.uiExtensionPointerStyle_.insert(std::make_pair(pid, pointerStyleMap));
3042 pid = 1001;
3043 EXPECT_EQ(inputWindowsManager.UpdateSceneBoardPointerStyle(pid, windowId, style, isUiExtension), RET_OK);
3044 pid = 1000;
3045 windowId = 123456789;
3046 EXPECT_EQ(inputWindowsManager.UpdateSceneBoardPointerStyle(pid, windowId, style, isUiExtension), RET_OK);
3047 }
3048
3049 /**
3050 * @tc.name: InputWindowsManagerTest_SetGlobalDefaultPointerStyle
3051 * @tc.desc: Test SetGlobalDefaultPointerStyle
3052 * @tc.type: FUNC
3053 * @tc.require:
3054 */
3055 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetGlobalDefaultPointerStyle, TestSize.Level1)
3056 {
3057 CALL_TEST_DEBUG;
3058 InputWindowsManager inputWindowsManager;
3059 int32_t defaultPointerStyle = 0;
3060 int32_t cursorCircleStyle = 41;
3061 int32_t pid = 100;
3062 int32_t windowId = 1000;
3063 PointerStyle pointerStyle;
3064 pointerStyle.id = defaultPointerStyle;
3065 std::map<int32_t, PointerStyle> pointerStyleMap;
3066 pointerStyleMap.insert(std::make_pair(windowId, pointerStyle));
3067 inputWindowsManager.pointerStyle_.insert(std::make_pair(pid, pointerStyleMap));
3068 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SetGlobalDefaultPointerStyle());
3069
3070 pointerStyle.id = cursorCircleStyle;
3071 inputWindowsManager.pointerStyle_[pid][windowId] = pointerStyle;
3072 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SetGlobalDefaultPointerStyle());
3073 }
3074
3075 /**
3076 * @tc.name: InputWindowsManagerTest_SetPointerStyle
3077 * @tc.desc: Test SetPointerStyle
3078 * @tc.type: FUNC
3079 * @tc.require:
3080 */
3081 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetPointerStyle, TestSize.Level1)
3082 {
3083 CALL_TEST_DEBUG;
3084 InputWindowsManager inputWindowsManager;
3085 bool isUiExtension = false;
3086 int32_t pid = 100;
3087 int32_t windowId = 1000;
3088 PointerStyle pointerStyle;
3089 pointerStyle.id = 0;
3090 std::map<int32_t, PointerStyle> pointerStyleMap;
3091 pointerStyleMap.insert(std::make_pair(windowId, pointerStyle));
3092 inputWindowsManager.uiExtensionPointerStyle_.insert(std::make_pair(pid, pointerStyleMap));
3093 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SetPointerStyle(pid, windowId, pointerStyle, isUiExtension));
3094 }
3095
3096 /**
3097 * @tc.name: InputWindowsManagerTest_ClearWindowPointerStyle
3098 * @tc.desc: Test ClearWindowPointerStyle
3099 * @tc.type: FUNC
3100 * @tc.require:
3101 */
3102 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ClearWindowPointerStyle, TestSize.Level1)
3103 {
3104 CALL_TEST_DEBUG;
3105 InputWindowsManager inputWindowsManager;
3106 int32_t pid = 100;
3107 int32_t windowId = 1000;
3108 PointerStyle pointerStyle;
3109 pointerStyle.id = 0;
3110 std::map<int32_t, PointerStyle> pointerStyleMap;
3111 pointerStyleMap.insert(std::make_pair(windowId, pointerStyle));
3112 inputWindowsManager.pointerStyle_.insert(std::make_pair(pid, pointerStyleMap));
3113 windowId = 1001;
3114 EXPECT_EQ(inputWindowsManager.ClearWindowPointerStyle(pid, windowId), RET_OK);
3115 windowId = 1000;
3116 EXPECT_EQ(inputWindowsManager.ClearWindowPointerStyle(pid, windowId), RET_OK);
3117 }
3118
3119 /**
3120 * @tc.name: InputWindowsManagerTest_GetPointerStyle
3121 * @tc.desc: Test GetPointerStyle
3122 * @tc.type: FUNC
3123 * @tc.require:
3124 */
3125 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPointerStyle, TestSize.Level1)
3126 {
3127 CALL_TEST_DEBUG;
3128 InputWindowsManager inputWindowsManager;
3129 bool isUiExtension = true;
3130 int32_t pid = 100;
3131 int32_t windowId = 1000;
3132 PointerStyle pointerStyle;
3133 pointerStyle.id = 0;
3134 std::map<int32_t, PointerStyle> pointerStyleMap;
3135 pointerStyleMap.insert(std::make_pair(windowId, pointerStyle));
3136 inputWindowsManager.uiExtensionPointerStyle_.insert(std::make_pair(pid, pointerStyleMap));
3137 pid = 101;
3138 EXPECT_EQ(inputWindowsManager.GetPointerStyle(pid, windowId, pointerStyle, isUiExtension), RET_OK);
3139 pid = 100;
3140 windowId = 100;
3141 EXPECT_EQ(inputWindowsManager.GetPointerStyle(pid, windowId, pointerStyle, isUiExtension), RET_OK);
3142 windowId = 1000;
3143 EXPECT_EQ(inputWindowsManager.GetPointerStyle(pid, windowId, pointerStyle, isUiExtension), RET_OK);
3144 }
3145
3146 /**
3147 * @tc.name: InputWindowsManagerTest_UpdateDisplayId
3148 * @tc.desc: Test UpdateDisplayId
3149 * @tc.type: FUNC
3150 * @tc.require:
3151 */
3152 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayId, TestSize.Level1)
3153 {
3154 CALL_TEST_DEBUG;
3155 InputWindowsManager inputWindowsManager;
3156 int32_t displayId = -1;
3157 DisplayInfo displayInfo;
3158 displayInfo.id = 10;
3159 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displayInfo);
3160 EXPECT_TRUE(inputWindowsManager.UpdateDisplayId(displayId));
3161 EXPECT_TRUE(inputWindowsManager.UpdateDisplayId(displayId));
3162 displayId = 15;
3163 EXPECT_FALSE(inputWindowsManager.UpdateDisplayId(displayId));
3164 }
3165
3166 /**
3167 * @tc.name: InputWindowsManagerTest_SelectWindowInfo
3168 * @tc.desc: Test SelectWindowInfo
3169 * @tc.type: FUNC
3170 * @tc.require:
3171 */
3172 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectWindowInfo, TestSize.Level1)
3173 {
3174 CALL_TEST_DEBUG;
3175 InputWindowsManager inputWindowsManager;
3176 int32_t desplayId = 10;
3177 int32_t logicalX = 200;
3178 int32_t logicalY = 200;
3179 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
3180 EXPECT_NE(pointerEvent, nullptr);
3181 pointerEvent->SetTargetDisplayId(10);
3182 WindowInfo windowInfo;
3183 windowInfo.id = 10;
3184 WindowGroupInfo windowGroupInfo;
3185 windowGroupInfo.windowsInfo.push_back(windowInfo);
3186 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(desplayId, windowGroupInfo));
3187 inputWindowsManager.firstBtnDownWindowId_ = 10;
3188 inputWindowsManager.extraData_.appended = false;
3189 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_UNKNOWN;
3190 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_ROTATE_BEGIN);
3191 pointerEvent->SetButtonPressed(1);
3192 pointerEvent->SetButtonPressed(2);
3193 EXPECT_NE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent), std::nullopt);
3194 }
3195
3196 /**
3197 * @tc.name: InputWindowsManagerTest_GetWindowInfo
3198 * @tc.desc: Test GetWindowInfo
3199 * @tc.type: FUNC
3200 * @tc.require:
3201 */
3202 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowInfo, TestSize.Level1)
3203 {
3204 CALL_TEST_DEBUG;
3205 InputWindowsManager inputWindowsManager;
3206 int32_t logicalX = 200;
3207 int32_t logicalY = 200;
3208 WindowInfo windowInfo;
3209 windowInfo.flags = 1;
3210 inputWindowsManager.displayGroupInfo_.windowsInfo.push_back(windowInfo);
3211 EXPECT_EQ(inputWindowsManager.GetWindowInfo(logicalX, logicalY), std::nullopt);
3212 }
3213
3214 /**
3215 * @tc.name: InputWindowsManagerTest_UpdateLeftRightArea
3216 * @tc.desc: Test UpdateLeftRightArea
3217 * @tc.type: FUNC
3218 * @tc.require:
3219 */
3220 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateLeftRightArea, TestSize.Level1)
3221 {
3222 CALL_TEST_DEBUG;
3223 InputWindowsManager inputWindowsManager;
3224 Rect windowArea;
3225 std::vector<int32_t> pointerChangeAreas {5, 0, 5, 0, 5, 0, 5, 0};
3226 std::vector<Rect> windowHotAreas;
3227 windowArea.x = 200;
3228 windowArea.y = 200;
3229 windowArea.height = 400;
3230 windowArea.width = 400;
3231 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateLeftRightArea(windowArea, pointerChangeAreas, windowHotAreas));
3232 }
3233
3234 /**
3235 * @tc.name: InputWindowsManagerTest_UpdateInnerAngleArea
3236 * @tc.desc: Test UpdateInnerAngleArea
3237 * @tc.type: FUNC
3238 * @tc.require:
3239 */
3240 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateInnerAngleArea, TestSize.Level1)
3241 {
3242 CALL_TEST_DEBUG;
3243 InputWindowsManager inputWindowsManager;
3244 Rect windowArea;
3245 std::vector<int32_t> pointerChangeAreas {0, 16, 0, 16, 0, 16, 0, 16};
3246 std::vector<Rect> windowHotAreas;
3247 windowArea.x = 200;
3248 windowArea.y = 200;
3249 windowArea.height = 400;
3250 windowArea.width = 400;
3251 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateInnerAngleArea(windowArea, pointerChangeAreas, windowHotAreas));
3252 }
3253
3254 /**
3255 * @tc.name: InputWindowsManagerTest_UpdatePointerEvent
3256 * @tc.desc: Test UpdatePointerEvent
3257 * @tc.type: FUNC
3258 * @tc.require:
3259 */
3260 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerEvent, TestSize.Level1)
3261 {
3262 CALL_TEST_DEBUG;
3263 InputWindowsManager inputWindowsManager;
3264 int32_t logicalX = 200;
3265 int32_t logicalY = 200;
3266 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
3267 ASSERT_NE(pointerEvent, nullptr);
3268 WindowInfo touchWindow;
3269 touchWindow.id = 1;
3270 inputWindowsManager.lastWindowInfo_.id = 1;
3271 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePointerEvent(logicalX, logicalY, pointerEvent, touchWindow));
3272 }
3273
3274 /**
3275 * @tc.name: InputWindowsManagerTest_UpdateMouseTarget
3276 * @tc.desc: Test UpdateMouseTarget
3277 * @tc.type: FUNC
3278 * @tc.require:
3279 */
3280 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateMouseTarget, TestSize.Level1)
3281 {
3282 CALL_TEST_DEBUG;
3283 InputWindowsManager inputWindowsManager;
3284 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
3285 ASSERT_NE(pointerEvent, nullptr);
3286 pointerEvent->SetTargetDisplayId(-1);
3287 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
3288
3289 DisplayInfo displayInfo;
3290 displayInfo.id = 1;
3291 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displayInfo);
3292 pointerEvent->SetPointerId(5);
3293 PointerEvent::PointerItem item;
3294 item.SetPointerId(10);
3295 pointerEvent->AddPointerItem(item);
3296 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
3297 }
3298
3299 /**
3300 * @tc.name: InputWindowsManagerTest_JudgMouseIsDownOrUp
3301 * @tc.desc: Test JudgMouseIsDownOrUp
3302 * @tc.type: FUNC
3303 * @tc.require:
3304 */
3305 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_JudgMouseIsDownOrUp, TestSize.Level1)
3306 {
3307 CALL_TEST_DEBUG;
3308 InputWindowsManager inputWindowsManager;
3309 bool dragState = false;
3310 inputWindowsManager.lastPointerEvent_ = PointerEvent::Create();
3311 ASSERT_NE(inputWindowsManager.lastPointerEvent_, nullptr);
3312 inputWindowsManager.lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_UP);
3313 inputWindowsManager.pointerActionFlag_ = PointerEvent::POINTER_ACTION_BUTTON_UP;
3314 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.JudgMouseIsDownOrUp(dragState));
3315
3316 dragState = true;
3317 inputWindowsManager.lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
3318 inputWindowsManager.pointerActionFlag_ = PointerEvent::POINTER_ACTION_BUTTON_DOWN;
3319 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.JudgMouseIsDownOrUp(dragState));
3320 }
3321
3322 /**
3323 * @tc.name: InputWindowsManagerTest_UpdateJoystickTarget
3324 * @tc.desc: Test UpdateJoystickTarget
3325 * @tc.type: FUNC
3326 * @tc.require:
3327 */
3328 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateJoystickTarget, TestSize.Level1)
3329 {
3330 CALL_TEST_DEBUG;
3331 InputWindowsManager inputWindowsManager;
3332 inputWindowsManager.displayGroupInfo_.focusWindowId = 150;
3333 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
3334 ASSERT_NE(pointerEvent, nullptr);
3335 pointerEvent->SetTargetDisplayId(-1);
3336 WindowInfo windowInfo;
3337 windowInfo.id = 150;
3338 windowInfo.agentWindowId = 200;
3339 inputWindowsManager.displayGroupInfo_.windowsInfo.push_back(windowInfo);
3340 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateJoystickTarget(pointerEvent));
3341 }
3342
3343 /**
3344 * @tc.name: InputWindowsManagerTest_UpdateAndAdjustMouseLocation
3345 * @tc.desc: Test UpdateAndAdjustMouseLocation
3346 * @tc.type: FUNC
3347 * @tc.require:
3348 */
3349 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateAndAdjustMouseLocation, TestSize.Level1)
3350 {
3351 CALL_TEST_DEBUG;
3352 InputWindowsManager inputWindowsManager;
3353 int32_t displayId = 1;
3354 double x = 200;
3355 double y = 200;
3356 bool isRealData = true;
3357 DisplayInfo displayInfo;
3358 displayInfo.id = 1;
3359 displayInfo.width = 500;
3360 displayInfo.height = 500;
3361 displayInfo.displayDirection = DIRECTION0;
3362 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displayInfo);
3363 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateAndAdjustMouseLocation(displayId, x, y, isRealData));
3364 isRealData = false;
3365 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateAndAdjustMouseLocation(displayId, x, y, isRealData));
3366 }
3367
3368 /**
3369 * @tc.name: InputWindowsManagerTest_GetMouseInfo
3370 * @tc.desc: Test GetMouseInfo
3371 * @tc.type: FUNC
3372 * @tc.require:
3373 */
3374 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetMouseInfo, TestSize.Level1)
3375 {
3376 CALL_TEST_DEBUG;
3377 InputWindowsManager inputWindowsManager;
3378 inputWindowsManager.mouseLocation_.displayId = -1;
3379 DisplayInfo displayInfo;
3380 displayInfo.id = 1;
3381 displayInfo.width = 600;
3382 displayInfo.height = 600;
3383 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displayInfo);
3384 EXPECT_EQ(inputWindowsManager.GetMouseInfo().displayId, displayInfo.id);
3385 }
3386
3387 /**
3388 * @tc.name: InputWindowsManagerTest_GetCursorPos
3389 * @tc.desc: Test GetCursorPos
3390 * @tc.type: FUNC
3391 * @tc.require:
3392 */
3393 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetCursorPos, TestSize.Level1)
3394 {
3395 CALL_TEST_DEBUG;
3396 InputWindowsManager inputWindowsManager;
3397 inputWindowsManager.cursorPos_.displayId = -1;
3398 DisplayInfo displayInfo;
3399 displayInfo.id = 1;
3400 displayInfo.width = 300;
3401 displayInfo.height = 300;
3402 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displayInfo);
3403 EXPECT_EQ(inputWindowsManager.GetCursorPos().displayId, displayInfo.id);
3404 }
3405
3406 /**
3407 * @tc.name: InputWindowsManagerTest_ResetCursorPos
3408 * @tc.desc: Test ResetCursorPos
3409 * @tc.type: FUNC
3410 * @tc.require:
3411 */
3412 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ResetCursorPos, TestSize.Level1)
3413 {
3414 CALL_TEST_DEBUG;
3415 InputWindowsManager inputWindowsManager;
3416 DisplayInfo displayInfo;
3417 displayInfo.id = 1;
3418 displayInfo.width = 300;
3419 displayInfo.height = 300;
3420 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displayInfo);
3421 EXPECT_EQ(inputWindowsManager.ResetCursorPos().displayId, displayInfo.id);
3422 }
3423
3424 /**
3425 * @tc.name: InputWindowsManagerTest_GetTargetWindowIds
3426 * @tc.desc: Test GetTargetWindowIds
3427 * @tc.type: FUNC
3428 * @tc.require:
3429 */
3430 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetTargetWindowIds, TestSize.Level1)
3431 {
3432 CALL_TEST_DEBUG;
3433 InputWindowsManager inputWindowsManager;
3434 int32_t pointerItemId = 1;
3435 int32_t sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
3436 std::vector<int32_t> windowIds { 1, 2, 3 };
3437 inputWindowsManager.targetTouchWinIds_.insert(std::make_pair(pointerItemId, windowIds));
3438 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
3439 }
3440
3441 /**
3442 * @tc.name: InputWindowsManagerTest_CheckWindowIdPermissionByPid_001
3443 * @tc.desc: Test CheckWindowIdPermissionByPid
3444 * @tc.type: FUNC
3445 * @tc.require:
3446 */
3447 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckWindowIdPermissionByPid_001, TestSize.Level1)
3448 {
3449 CALL_TEST_DEBUG;
3450 InputWindowsManager inputWindowsManager;
3451 int32_t windowId = 300;
3452 int32_t pid = 500;
3453 WindowInfo windowInfo;
3454 windowInfo.id = 300;
3455 windowInfo.pid = 500;
3456 inputWindowsManager.displayGroupInfo_.windowsInfo.push_back(windowInfo);
3457 EXPECT_EQ(inputWindowsManager.CheckWindowIdPermissionByPid(windowId, pid), RET_OK);
3458 }
3459
3460 /**
3461 * @tc.name: InputWindowsManagerTest_PointerDrawingManagerOnDisplayInfo
3462 * @tc.desc: Test PointerDrawingManagerOnDisplayInfo
3463 * @tc.type: FUNC
3464 * @tc.require:
3465 */
3466 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PointerDrawingManagerOnDisplayInfo, TestSize.Level1)
3467 {
3468 CALL_TEST_DEBUG;
3469 std::shared_ptr<PointerDrawingManager> pointerDrawingMgr =
3470 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
3471 pointerDrawingMgr->displayInfo_.id = 521;
3472 DisplayGroupInfo displayGroupInfo;
3473 DisplayInfo displayInfo;
3474 displayInfo.id = 521;
3475 displayInfo.uniq = "uniq_test";
3476 displayInfo.dpi = 1000;
3477 displayGroupInfo.displaysInfo.push_back(displayInfo);
3478 int32_t deviceId = 1;
3479 InputDeviceManager::InputDeviceInfo inputDeviceInfo;
3480 inputDeviceInfo.isPointerDevice = true;
3481 INPUT_DEV_MGR->inputDevice_.insert(std::make_pair(deviceId, inputDeviceInfo));
3482 WIN_MGR->mouseLocation_.displayId = 10;
3483 WIN_MGR->mouseLocation_.physicalX = 500;
3484 WIN_MGR->mouseLocation_.physicalY = 500;
3485 WIN_MGR->cursorPos_.displayId = 10;
3486 WIN_MGR->cursorPos_.cursorPos.x = 300;
3487 WIN_MGR->cursorPos_.cursorPos.y = 300;
3488 displayInfo.id = 10;
3489 displayInfo.x = 300;
3490 displayInfo.y = 300;
3491 WIN_MGR->displayGroupInfo_.displaysInfo.push_back(displayInfo);
3492 WIN_MGR->lastPointerEvent_ = nullptr;
3493 EXPECT_NO_FATAL_FAILURE(WIN_MGR->PointerDrawingManagerOnDisplayInfo(displayGroupInfo));
3494 WIN_MGR->lastPointerEvent_ = PointerEvent::Create();
3495 EXPECT_NE(WIN_MGR->lastPointerEvent_, nullptr);
3496 WIN_MGR->lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
3497 EXPECT_NO_FATAL_FAILURE(WIN_MGR->PointerDrawingManagerOnDisplayInfo(displayGroupInfo));
3498 WIN_MGR->lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_UP);
3499 EXPECT_NO_FATAL_FAILURE(WIN_MGR->PointerDrawingManagerOnDisplayInfo(displayGroupInfo));
3500 }
3501
3502 /**
3503 * @tc.name: InputWindowsManagerTest_PointerDrawingManagerOnDisplayInfo_001
3504 * @tc.desc: Test PointerDrawingManagerOnDisplayInfo
3505 * @tc.type: FUNC
3506 * @tc.require:
3507 */
3508 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PointerDrawingManagerOnDisplayInfo_001, TestSize.Level1)
3509 {
3510 CALL_TEST_DEBUG;
3511 std::shared_ptr<PointerDrawingManager> pointerDrawingMgr =
3512 std::static_pointer_cast<PointerDrawingManager>(IPointerDrawingManager::GetInstance());
3513 pointerDrawingMgr->displayInfo_.id = 521;
3514 DisplayGroupInfo displayGroupInfo;
3515 DisplayInfo displayInfo;
3516 displayInfo.id = 521;
3517 displayInfo.uniq = "uniq_test";
3518 displayInfo.dpi = 1000;
3519 displayGroupInfo.displaysInfo.push_back(displayInfo);
3520 int32_t deviceId = 1;
3521 InputDeviceManager::InputDeviceInfo inputDeviceInfo;
3522 inputDeviceInfo.isPointerDevice = true;
3523 INPUT_DEV_MGR->inputDevice_.insert(std::make_pair(deviceId, inputDeviceInfo));
3524 WIN_MGR->mouseLocation_.displayId = 10;
3525 WIN_MGR->mouseLocation_.physicalX = 500;
3526 WIN_MGR->mouseLocation_.physicalY = 500;
3527 WIN_MGR->cursorPos_.displayId = 10;
3528 WIN_MGR->cursorPos_.cursorPos.x = 300;
3529 WIN_MGR->cursorPos_.cursorPos.y = 300;
3530 displayInfo.id = 10;
3531 displayInfo.x = 300;
3532 displayInfo.y = 300;
3533 WIN_MGR->displayGroupInfo_.displaysInfo.push_back(displayInfo);
3534 WIN_MGR->lastPointerEvent_ = PointerEvent::Create();
3535 EXPECT_NE(WIN_MGR->lastPointerEvent_, nullptr);
3536 WIN_MGR->lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_ENTER_WINDOW);
3537 WIN_MGR->lastPointerEvent_->SetTargetDisplayId(-1);
3538 WIN_MGR->firstBtnDownWindowId_ = -1;
3539 WIN_MGR->extraData_.appended = false;
3540 WIN_MGR->extraData_.sourceType = PointerEvent::SOURCE_TYPE_JOYSTICK;
3541 WindowInfo windowInfo;
3542 windowInfo.id = -1;
3543 windowInfo.pid = 1;
3544 WIN_MGR->displayGroupInfo_.windowsInfo.push_back(windowInfo);
3545 WIN_MGR->isDragBorder_ = true;
3546 WIN_MGR->dragFlag_ = true;
3547 EXPECT_NO_FATAL_FAILURE(WIN_MGR->PointerDrawingManagerOnDisplayInfo(displayGroupInfo));
3548 WIN_MGR->isDragBorder_ = false;
3549 WIN_MGR->dragFlag_ = false;
3550 WIN_MGR->lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
3551 EXPECT_NO_FATAL_FAILURE(WIN_MGR->PointerDrawingManagerOnDisplayInfo(displayGroupInfo));
3552 WIN_MGR->lastPointerEvent_->SetButtonPressed(1);
3553 WIN_MGR->lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_UP);
3554 EXPECT_NO_FATAL_FAILURE(WIN_MGR->PointerDrawingManagerOnDisplayInfo(displayGroupInfo));
3555 }
3556
3557 /**
3558 * @tc.name: InputWindowsManagerTest_IsInHotArea
3559 * @tc.desc: Test IsInHotArea
3560 * @tc.type: FUNC
3561 * @tc.require:
3562 */
3563 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsInHotArea, TestSize.Level1)
3564 {
3565 CALL_TEST_DEBUG;
3566 InputWindowsManager inputWindowsManager;
3567 int32_t x = 200;
3568 int32_t y = 300;
3569 std::vector<Rect> rects;
3570 WindowInfo window;
3571 Rect rect;
3572 rect.x = 100;
3573 rect.width = INT32_MAX;
3574 rects.push_back(rect);
3575 EXPECT_FALSE(inputWindowsManager.IsInHotArea(x, y, rects, window));
3576 rects.clear();
3577 rects = { {150, 100, 300, INT32_MAX} };
3578 EXPECT_FALSE(inputWindowsManager.IsInHotArea(x, y, rects, window));
3579 rects.clear();
3580 rects = { {150, 250, 300, 500} };
3581 EXPECT_TRUE(inputWindowsManager.IsInHotArea(x, y, rects, window));
3582 x = 100;
3583 y = 200;
3584 EXPECT_FALSE(inputWindowsManager.IsInHotArea(x, y, rects, window));
3585 }
3586
3587 /**
3588 * @tc.name: InputWindowsManagerTest_FindPhysicalDisplay_002
3589 * @tc.desc: This test verifies the functionality of finding physical displays
3590 * @tc.type: FUNC
3591 * @tc.require:
3592 */
3593 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_FindPhysicalDisplay_002, TestSize.Level1)
3594 {
3595 CALL_TEST_DEBUG;
3596 InputWindowsManager inputWindowsManager;
3597 DisplayInfo displayInfo;
3598 DisplayInfo displaysInfo;
3599 int32_t logicalX = 300;
3600 int32_t logicalY = 400;
3601 int32_t physicalX = 100;
3602 int32_t physicalY = 200;
3603 int32_t displayId = -1;
3604 displayInfo.x = INT32_MAX;
3605 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId));
3606 displayInfo.x = 200;
3607 inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
3608 EXPECT_EQ(logicalX, physicalX + displayInfo.x);
3609 displayInfo.y = INT32_MAX ;
3610 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId));
3611 displayInfo.y = 200;
3612 inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
3613 EXPECT_EQ(logicalY, physicalY + displayInfo.y);
3614 displaysInfo.x = 100;
3615 displaysInfo.width = INT32_MAX;
3616 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displaysInfo);
3617 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId));
3618 }
3619
3620 /**
3621 * @tc.name: InputWindowsManagerTest_FindPhysicalDisplay_003
3622 * @tc.desc: This test verifies the functionality of finding physical displays
3623 * @tc.type: FUNC
3624 * @tc.require:
3625 */
3626 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_FindPhysicalDisplay_003, TestSize.Level1)
3627 {
3628 CALL_TEST_DEBUG;
3629 InputWindowsManager inputWindowsManager;
3630 DisplayInfo displayInfo;
3631 DisplayInfo displaysInfo;
3632 int32_t logicalX = 300;
3633 int32_t logicalY = 400;
3634 int32_t physicalX = 100;
3635 int32_t physicalY = 200;
3636 int32_t displayMaxX = 300;
3637 int32_t displayMaxY = 400;
3638 int32_t displayId = -1;
3639 displayInfo.x = 200;
3640 inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
3641 EXPECT_EQ(logicalX, physicalX + displayInfo.x);
3642 displayInfo.y = 200;
3643 inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
3644 EXPECT_EQ(logicalY, physicalY + displayInfo.y);
3645 displaysInfo.x = 200;
3646 displaysInfo.width = 100;
3647 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displaysInfo);
3648 inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
3649 EXPECT_EQ(displayMaxX, displaysInfo.x + displaysInfo.width);
3650 displaysInfo.y = 100;
3651 displaysInfo.height = INT32_MAX;
3652 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displaysInfo);
3653 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId));
3654 displaysInfo.y = 200;
3655 displaysInfo.height = 200;
3656 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displaysInfo);
3657 inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
3658 EXPECT_EQ(displayMaxY, displaysInfo.y + displaysInfo.height);
3659 }
3660
3661 /**
3662 * @tc.name: InputWindowsManagerTest_UpdateDisplayIdAndName_002
3663 * @tc.desc: Test updating display ID and name
3664 * @tc.type: FUNC
3665 * @tc.require:
3666 */
3667 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayIdAndName_002, TestSize.Level1)
3668 {
3669 CALL_TEST_DEBUG;
3670 InputWindowsManager inputWindowsManager;
3671 DisplayInfo displaysInfo;
3672 displaysInfo.id = 1;
3673 displaysInfo.uniq = "abc";
3674 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displaysInfo);
3675 inputWindowsManager.bindInfo_.AddDisplay(2, "cde");
3676 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayIdAndName());
3677 }
3678
3679 /**
3680 * @tc.name: InputWindowsManagerTest_UpdateDisplayIdAndName_003
3681 * @tc.desc: Test updating display ID and name
3682 * @tc.type: FUNC
3683 * @tc.require:
3684 */
3685 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayIdAndName_003, TestSize.Level1)
3686 {
3687 CALL_TEST_DEBUG;
3688 InputWindowsManager inputWindowsManager;
3689 DisplayInfo displaysInfo;
3690 displaysInfo.id = 1;
3691 displaysInfo.uniq = "abc";
3692 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displaysInfo);
3693 inputWindowsManager.bindInfo_.AddDisplay(1, "abc");
3694 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayIdAndName());
3695 }
3696
3697 /**
3698 * @tc.name: InputWindowsManagerTest_InWhichHotArea
3699 * @tc.desc: Test InWhichHotArea
3700 * @tc.type: FUNC
3701 * @tc.require:
3702 */
3703 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_InWhichHotArea, TestSize.Level1)
3704 {
3705 CALL_TEST_DEBUG;
3706 InputWindowsManager inputWindowsManager;
3707 int32_t x = 500;
3708 int32_t y = 800;
3709 std::vector<Rect> rects;
3710 PointerStyle pointerStyle;
3711 rects = { { 100, 0, INT32_MAX, 0 } };
3712 EXPECT_FALSE(inputWindowsManager.InWhichHotArea(x, y, rects, pointerStyle));
3713 rects.clear();
3714 rects = { { 150, 100, 300, INT32_MAX } };
3715 EXPECT_FALSE(inputWindowsManager.InWhichHotArea(x, y, rects, pointerStyle));
3716 rects.clear();
3717 rects = { { 150, 250, 300, 500 } };
3718 EXPECT_FALSE(inputWindowsManager.InWhichHotArea(x, y, rects, pointerStyle));
3719 x = 200;
3720 y = 300;
3721 EXPECT_TRUE(inputWindowsManager.InWhichHotArea(x, y, rects, pointerStyle));
3722 int32_t cycleNum = 7;
3723 for (int32_t i = 0; i < cycleNum; ++i) {
3724 rects.insert(rects.begin(), { 1000, 1000, 1500, 1500 });
3725 EXPECT_TRUE(inputWindowsManager.InWhichHotArea(x, y, rects, pointerStyle));
3726 }
3727 }
3728
3729 /**
3730 * @tc.name: InputWindowsManagerTest_DispatchPointer
3731 * @tc.desc: Test DispatchPointer
3732 * @tc.type: FUNC
3733 * @tc.require:
3734 */
3735 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DispatchPointer, TestSize.Level1)
3736 {
3737 CALL_TEST_DEBUG;
3738 InputWindowsManager inputWindowsManager;
3739 int32_t pointerAction = PointerEvent::POINTER_ACTION_ENTER_WINDOW;
3740 UDSServer udsServer;
3741 inputWindowsManager.udsServer_ = &udsServer;
3742 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointer(pointerAction));
3743 IPointerDrawingManager::GetInstance()->SetMouseDisplayState(true);
3744 inputWindowsManager.lastPointerEvent_ = nullptr;
3745 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointer(pointerAction));
3746 inputWindowsManager.lastPointerEvent_ = PointerEvent::Create();
3747 EXPECT_NE(inputWindowsManager.lastPointerEvent_, nullptr);
3748 PointerEvent::PointerItem item;
3749 item.SetPointerId(0);
3750 inputWindowsManager.lastPointerEvent_->AddPointerItem(item);
3751 inputWindowsManager.lastPointerEvent_->SetPointerId(1);
3752 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointer(pointerAction));
3753 inputWindowsManager.lastPointerEvent_->SetPointerId(0);
3754 inputWindowsManager.lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
3755 WindowInfo windowInfo;
3756 windowInfo.flags = WindowInfo::FLAG_BIT_HANDWRITING;
3757 windowInfo.pointerHotAreas.push_back({ 100, 0, INT32_MAX, 0 });
3758 inputWindowsManager.displayGroupInfo_.windowsInfo.push_back(windowInfo);
3759 inputWindowsManager.lastLogicX_ = 200;
3760 inputWindowsManager.lastLogicY_ = 200;
3761 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointer(pointerAction));
3762 }
3763
3764 /**
3765 * @tc.name: InputWindowsManagerTest_DispatchPointer_002
3766 * @tc.desc: Test DispatchPointer
3767 * @tc.type: FUNC
3768 * @tc.require:
3769 */
3770 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DispatchPointer_002, TestSize.Level1)
3771 {
3772 CALL_TEST_DEBUG;
3773 InputWindowsManager inputWindowsManager;
3774 int32_t pointerAction = PointerEvent::POINTER_ACTION_ENTER_WINDOW;
3775 UDSServer udsServer;
3776 inputWindowsManager.udsServer_ = &udsServer;
3777 inputWindowsManager.lastPointerEvent_ = PointerEvent::Create();
3778 EXPECT_NE(inputWindowsManager.lastPointerEvent_, nullptr);
3779 PointerEvent::PointerItem item;
3780 item.SetPointerId(0);
3781 item.SetDisplayX(100);
3782 item.SetDisplayY(100);
3783 inputWindowsManager.lastPointerEvent_->AddPointerItem(item);
3784 inputWindowsManager.lastPointerEvent_->SetPointerId(0);
3785 inputWindowsManager.firstBtnDownWindowId_ = 1;
3786 inputWindowsManager.lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_UP);
3787 inputWindowsManager.lastPointerEvent_->SetTargetDisplayId(-1);
3788 WindowInfo windowInfo;
3789 windowInfo.id = 1;
3790 inputWindowsManager.displayGroupInfo_.windowsInfo.push_back(windowInfo);
3791 inputWindowsManager.lastWindowInfo_.id = 2;
3792 inputWindowsManager.lastWindowInfo_.agentWindowId = 2;
3793 inputWindowsManager.lastWindowInfo_.area.x = 100;
3794 inputWindowsManager.lastWindowInfo_.area.y = 100;
3795 inputWindowsManager.lastPointerEvent_->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
3796 inputWindowsManager.lastPointerEvent_->SetDeviceId(5);
3797 inputWindowsManager.extraData_.appended = true;
3798 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
3799 InputHandler->eventFilterHandler_ = std::make_shared<EventFilterHandler>();
3800 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointer(pointerAction));
3801 inputWindowsManager.lastWindowInfo_.id = 1;
3802 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointer(pointerAction));
3803 inputWindowsManager.extraData_.appended = false;
3804 pointerAction = PointerEvent::POINTER_ACTION_LEAVE_WINDOW;
3805 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointer(pointerAction));
3806 }
3807
3808 /**
3809 * @tc.name: InputWindowsManagerTest_NotifyPointerToWindow
3810 * @tc.desc: Test NotifyPointerToWindow
3811 * @tc.type: FUNC
3812 * @tc.require:
3813 */
3814 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_NotifyPointerToWindow, TestSize.Level1)
3815 {
3816 CALL_TEST_DEBUG;
3817 InputWindowsManager inputWindowsManager;
3818 UDSServer udsServer;
3819 inputWindowsManager.lastPointerEvent_ = PointerEvent::Create();
3820 ASSERT_NE(inputWindowsManager.lastPointerEvent_, nullptr);
3821 inputWindowsManager.lastLogicX_ = 200;
3822 inputWindowsManager.lastLogicY_ = 300;
3823 WindowInfo windowInfo;
3824 windowInfo.flags = WindowInfo::FLAG_BIT_HANDWRITING;
3825 windowInfo.pointerHotAreas.push_back({ 100, 100, INT32_MAX, 100 });
3826 inputWindowsManager.displayGroupInfo_.windowsInfo.push_back(windowInfo);
3827 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.NotifyPointerToWindow());
3828 windowInfo.id = 10;
3829 windowInfo.pointerHotAreas.clear();
3830 windowInfo.pointerHotAreas.push_back({ 150, 250, 300, 500 });
3831 inputWindowsManager.displayGroupInfo_.windowsInfo.insert(
3832 inputWindowsManager.displayGroupInfo_.windowsInfo.begin(), windowInfo);
3833 inputWindowsManager.lastWindowInfo_.id = 10;
3834 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.NotifyPointerToWindow());
3835 inputWindowsManager.lastWindowInfo_.id = 20;
3836 inputWindowsManager.lastWindowInfo_.pid = 50;
3837 int32_t udsFd = 100;
3838 udsServer.idxPidMap_.insert(std::make_pair(inputWindowsManager.lastWindowInfo_.pid, udsFd));
3839 inputWindowsManager.udsServer_ = &udsServer;
3840 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.NotifyPointerToWindow());
3841 inputWindowsManager.udsServer_ = nullptr;
3842 inputWindowsManager.lastWindowInfo_.id = 30;
3843 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.NotifyPointerToWindow());
3844 windowInfo.id = 50;
3845 inputWindowsManager.displayGroupInfo_.windowsInfo.push_back(windowInfo);
3846 inputWindowsManager.lastWindowInfo_.id = 50;
3847 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.NotifyPointerToWindow());
3848 }
3849
3850 /**
3851 * @tc.name: InputWindowsManagerTest_GetMouseInfo_002
3852 * @tc.desc: Test the function GetMouseInfo
3853 * @tc.type: FUNC
3854 * @tc.require:
3855 */
3856 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetMouseInfo_002, TestSize.Level1)
3857 {
3858 CALL_TEST_DEBUG;
3859 InputWindowsManager inputWindowsManager;
3860 inputWindowsManager.mouseLocation_.displayId = -1;
3861 DisplayInfo displaysInfo;
3862 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetMouseInfo());
3863 displaysInfo.id = 2;
3864 displaysInfo.width = 20;
3865 displaysInfo.height = 30;
3866 displaysInfo.name = "name1";
3867 displaysInfo.uniq = "uniq1";
3868 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displaysInfo);
3869 MouseLocation result = inputWindowsManager.GetMouseInfo();
3870 EXPECT_EQ(result.displayId, 2);
3871 EXPECT_EQ(result.physicalX, 10);
3872 EXPECT_EQ(result.physicalY, 15);
3873 }
3874
3875 /**
3876 * @tc.name: InputWindowsManagerTest_GetCursorPos_002
3877 * @tc.desc: Test the function GetCursorPos
3878 * @tc.type: FUNC
3879 * @tc.require:
3880 */
3881 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetCursorPos_002, TestSize.Level1)
3882 {
3883 CALL_TEST_DEBUG;
3884 InputWindowsManager inputWindowsManager;
3885 inputWindowsManager.cursorPos_.displayId = -1;
3886 DisplayInfo displaysInfo;
3887 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetCursorPos());
3888 displaysInfo.id = 2;
3889 displaysInfo.width = 30;
3890 displaysInfo.height = 40;
3891 displaysInfo.name = "name2";
3892 displaysInfo.uniq = "uniq2";
3893 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displaysInfo);
3894 CursorPosition result = inputWindowsManager.GetCursorPos();
3895 EXPECT_EQ(result.displayId, 2);
3896 EXPECT_EQ(result.cursorPos.x, 15);
3897 EXPECT_EQ(result.cursorPos.y, 20);
3898 }
3899
3900 /**
3901 * @tc.name: InputWindowsManagerTest_ResetCursorPos_002
3902 * @tc.desc: Test the function ResetCursorPos
3903 * @tc.type: FUNC
3904 * @tc.require:
3905 */
3906 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ResetCursorPos_002, TestSize.Level1)
3907 {
3908 CALL_TEST_DEBUG;
3909 InputWindowsManager inputWindowsManager;
3910 DisplayInfo displaysInfo;
3911 CursorPosition result = inputWindowsManager.ResetCursorPos();
3912 EXPECT_EQ(result.displayId, -1);
3913 displaysInfo.id = 3;
3914 displaysInfo.width = 40;
3915 displaysInfo.height = 50;
3916 displaysInfo.name = "name3";
3917 displaysInfo.uniq = "uniq3";
3918 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displaysInfo);
3919 result = inputWindowsManager.ResetCursorPos();
3920 EXPECT_EQ(result.displayId, 3);
3921 EXPECT_EQ(result.cursorPos.x, 20);
3922 EXPECT_EQ(result.cursorPos.y, 25);
3923 }
3924
3925 /**
3926 * @tc.name: InputWindowsManagerTest_SendPointerEvent
3927 * @tc.desc: Test SendPointerEvent
3928 * @tc.type: FUNC
3929 * @tc.require:
3930 */
3931 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SendPointerEvent, TestSize.Level1)
3932 {
3933 CALL_TEST_DEBUG;
3934 InputWindowsManager inputWindowsManager;
3935 int32_t pointerAction = PointerEvent::POINTER_ACTION_ENTER_WINDOW;
3936 UDSServer udsServer;
3937 WindowInfo windowInfo;
3938 inputWindowsManager.udsServer_ = &udsServer;
3939 windowInfo.pointerHotAreas.push_back({ 100, 100, INT32_MAX, 100 });
3940 inputWindowsManager.displayGroupInfo_.windowsInfo.push_back(windowInfo);
3941 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SendPointerEvent(pointerAction));
3942 windowInfo.pointerHotAreas.clear();
3943 windowInfo.pointerHotAreas.push_back({ 150, 250, 300, 500 });
3944 windowInfo.area.x = 50;
3945 windowInfo.area.y = 50;
3946 windowInfo.id = 10;
3947 windowInfo.pid = 30;
3948 windowInfo.agentWindowId = 10;
3949 inputWindowsManager.displayGroupInfo_.windowsInfo.insert(
3950 inputWindowsManager.displayGroupInfo_.windowsInfo.begin(), windowInfo);
3951 inputWindowsManager.mouseLocation_.displayId = 1;
3952 inputWindowsManager.mouseLocation_.physicalX = 200;
3953 inputWindowsManager.mouseLocation_.physicalY = 300;
3954 inputWindowsManager.lastLogicX_ = 150;
3955 inputWindowsManager.lastLogicY_ = 150;
3956 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SendPointerEvent(pointerAction));
3957 }
3958
3959 /**
3960 * @tc.name: InputWindowsManagerTest_UpdateMouseTarget001
3961 * @tc.desc: Test UpdateMouseTarget
3962 * @tc.type: FUNC
3963 * @tc.require:
3964 */
3965 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateMouseTarget001, TestSize.Level1)
3966 {
3967 CALL_TEST_DEBUG;
3968 InputWindowsManager inputWindowsManager;
3969 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
3970 ASSERT_NE(pointerEvent, nullptr);
3971 pointerEvent->SetTargetDisplayId(1);
3972 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
3973 DisplayInfo displayInfo;
3974 displayInfo.id = 1;
3975 displayInfo.x = 300;
3976 displayInfo.y = 500;
3977 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displayInfo);
3978 PointerEvent::PointerItem item;
3979 item.SetPointerId(1);
3980 item.SetDisplayX(INT32_MAX);
3981 pointerEvent->AddPointerItem(item);
3982 pointerEvent->SetPointerId(0);
3983 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
3984
3985 pointerEvent->SetPointerId(1);
3986 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
3987
3988 item.SetDisplayX(150);
3989 item.SetDisplayY(INT32_MAX);
3990 pointerEvent->UpdatePointerItem(pointerEvent->GetPointerId(), item);
3991 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
3992 item.SetDisplayX(150);
3993 item.SetDisplayY(300);
3994 pointerEvent->UpdatePointerItem(pointerEvent->GetPointerId(), item);
3995
3996 inputWindowsManager.firstBtnDownWindowId_ = 5;
3997 WindowGroupInfo windowGroupInfo;
3998 WindowInfo windowInfo;
3999 windowInfo.id = 10;
4000 windowGroupInfo.windowsInfo.push_back(windowInfo);
4001 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(pointerEvent->GetTargetDisplayId(), windowGroupInfo));
4002 inputWindowsManager.mouseDownInfo_.id = -1;
4003 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
4004
4005 inputWindowsManager.firstBtnDownWindowId_ = 10;
4006 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_AXIS_UPDATE);
4007 inputWindowsManager.SetHoverScrollState(false);
4008 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_OK);
4009 }
4010
4011 /**
4012 * @tc.name: InputWindowsManagerTest_UpdateMouseTarget_002
4013 * @tc.desc: Test UpdateMouseTarget
4014 * @tc.type: FUNC
4015 * @tc.require:
4016 */
4017 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateMouseTarget_002, TestSize.Level1)
4018 {
4019 CALL_TEST_DEBUG;
4020 InputWindowsManager inputWindowsManager;
4021 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
4022 ASSERT_NE(pointerEvent, nullptr);
4023 pointerEvent->SetTargetDisplayId(1);
4024 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
4025 DisplayInfo displayInfo;
4026 displayInfo.id = 1;
4027 displayInfo.x = 300;
4028 displayInfo.y = 500;
4029 displayInfo.width = 100;
4030 displayInfo.height = 100;
4031 displayInfo.displayDirection = DIRECTION0;
4032 displayInfo.direction = DIRECTION180;
4033 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displayInfo);
4034 PointerEvent::PointerItem item;
4035 item.SetPointerId(1);
4036 item.SetDisplayX(150);
4037 item.SetDisplayY(300);
4038 pointerEvent->AddPointerItem(item);
4039 pointerEvent->SetPointerId(1);
4040 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
4041 inputWindowsManager.firstBtnDownWindowId_ = 10;
4042 WindowGroupInfo windowGroupInfo;
4043 WindowInfo windowInfo;
4044 windowInfo.id = 10;
4045 windowInfo.pid = 50;
4046 windowInfo.agentWindowId = 60;
4047 windowGroupInfo.windowsInfo.push_back(windowInfo);
4048 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(pointerEvent->GetTargetDisplayId(), windowGroupInfo));
4049 inputWindowsManager.mouseDownInfo_.id = -1;
4050 inputWindowsManager.SetHoverScrollState(true);
4051 std::map<int32_t, PointerStyle> styleMap;
4052 PointerStyle pointerStyle;
4053 IPointerDrawingManager::GetInstance()->SetMouseDisplayState(false);
4054 styleMap.insert(std::make_pair(windowInfo.id, pointerStyle));
4055 inputWindowsManager.uiExtensionPointerStyle_.insert(std::make_pair(windowInfo.pid, styleMap));
4056 UDSServer udsServer;
4057 inputWindowsManager.udsServer_ = &udsServer;
4058 inputWindowsManager.SetUiExtensionInfo(true, 50, 10);
4059 inputWindowsManager.isDragBorder_ = true;
4060 inputWindowsManager.dragFlag_ = false;
4061 inputWindowsManager.captureModeInfo_.isCaptureMode = true;
4062 inputWindowsManager.captureModeInfo_.windowId = 1;
4063 inputWindowsManager.extraData_.appended = true;
4064 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
4065 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), ERR_OK);
4066 }
4067
4068 /**
4069 * @tc.name: InputWindowsManagerTest_UpdateMouseTarget_003
4070 * @tc.desc: Test UpdateMouseTarget
4071 * @tc.type: FUNC
4072 * @tc.require:
4073 */
4074 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateMouseTarget_003, TestSize.Level1)
4075 {
4076 CALL_TEST_DEBUG;
4077 InputWindowsManager inputWindowsManager;
4078 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
4079 ASSERT_NE(pointerEvent, nullptr);
4080 pointerEvent->SetTargetDisplayId(1);
4081 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_UP);
4082 DisplayInfo displayInfo;
4083 displayInfo.id = 1;
4084 displayInfo.x = 300;
4085 displayInfo.y = 500;
4086 displayInfo.width = 100;
4087 displayInfo.height = 100;
4088 displayInfo.displayDirection = DIRECTION180;
4089 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displayInfo);
4090 PointerEvent::PointerItem item;
4091 item.SetPointerId(1);
4092 item.SetDisplayX(150);
4093 item.SetDisplayY(300);
4094 pointerEvent->AddPointerItem(item);
4095 pointerEvent->SetPointerId(1);
4096 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
4097 inputWindowsManager.firstBtnDownWindowId_ = 10;
4098 WindowGroupInfo windowGroupInfo;
4099 WindowInfo windowInfo;
4100 windowInfo.id = 10;
4101 windowInfo.pid = 50;
4102 windowInfo.agentWindowId = 60;
4103 windowGroupInfo.windowsInfo.push_back(windowInfo);
4104 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(pointerEvent->GetTargetDisplayId(), windowGroupInfo));
4105 inputWindowsManager.mouseDownInfo_.id = -1;
4106 inputWindowsManager.SetHoverScrollState(true);
4107 std::map<int32_t, PointerStyle> styleMap;
4108 PointerStyle pointerStyle;
4109 IPointerDrawingManager::GetInstance()->SetMouseDisplayState(true);
4110 styleMap.insert(std::make_pair(windowInfo.id, pointerStyle));
4111 inputWindowsManager.uiExtensionPointerStyle_.insert(std::make_pair(windowInfo.pid, styleMap));
4112 UDSServer udsServer;
4113 inputWindowsManager.udsServer_ = &udsServer;
4114 inputWindowsManager.SetUiExtensionInfo(false, 50, 10);
4115 inputWindowsManager.isDragBorder_ = false;
4116 inputWindowsManager.dragFlag_ = true;
4117 inputWindowsManager.captureModeInfo_.isCaptureMode = false;
4118 inputWindowsManager.captureModeInfo_.windowId = 10;
4119 inputWindowsManager.extraData_.appended = false;
4120 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), ERR_OK);
4121 }
4122
4123 /**
4124 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget
4125 * @tc.desc: Test UpdateTouchScreenTarget
4126 * @tc.type: FUNC
4127 * @tc.require:
4128 */
4129 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget, TestSize.Level1)
4130 {
4131 CALL_TEST_DEBUG;
4132 InputWindowsManager inputWindowsManager;
4133 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
4134 ASSERT_NE(pointerEvent, nullptr);
4135 pointerEvent->SetTargetDisplayId(1);
4136 pointerEvent->SetPointerId(0);
4137 DisplayInfo displayInfo;
4138 displayInfo.id = 1;
4139 displayInfo.width = 300;
4140 displayInfo.height = 300;
4141 displayInfo.displayDirection = DIRECTION0;
4142 displayInfo.x = INT32_MAX;
4143 displayInfo.y = 300;
4144 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displayInfo);
4145 PointerEvent::PointerItem item;
4146 item.SetPointerId(1);
4147 item.SetDisplayX(100);
4148 item.SetDisplayY(100);
4149 item.SetDisplayXPos(100);
4150 item.SetDisplayYPos(100);
4151 item.SetTargetWindowId(-1);
4152 pointerEvent->AddPointerItem(item);
4153 EXPECT_EQ(inputWindowsManager.UpdateTouchScreenTarget(pointerEvent), RET_ERR);
4154
4155 pointerEvent->SetPointerId(1);
4156 pointerEvent->bitwise_ = InputEvent::EVENT_FLAG_SIMULATE;
4157 EXPECT_EQ(inputWindowsManager.UpdateTouchScreenTarget(pointerEvent), RET_ERR);
4158
4159 pointerEvent->bitwise_ = InputEvent::EVENT_FLAG_NONE;
4160 inputWindowsManager.displayGroupInfo_.displaysInfo[0].x = 300;
4161 inputWindowsManager.displayGroupInfo_.displaysInfo[0].y = INT32_MAX;
4162 EXPECT_EQ(inputWindowsManager.UpdateTouchScreenTarget(pointerEvent), RET_ERR);
4163 }
4164
4165 /**
4166 * @tc.name: InputWindowsManagerTest_GetPidAndUpdateTarget_002
4167 * @tc.desc: Test getting PID and updating the target
4168 * @tc.type: FUNC
4169 * @tc.require:
4170 */
4171 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPidAndUpdateTarget_002, TestSize.Level1)
4172 {
4173 CALL_TEST_DEBUG;
4174 InputWindowsManager inputWindowsManager;
4175 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
4176 ASSERT_NE(keyEvent, nullptr);
4177 keyEvent->SetTargetDisplayId(10);
4178 inputWindowsManager.displayGroupInfo_.focusWindowId = 52;
4179 WindowGroupInfo windowGroupInfo;
4180 WindowInfo windowInfo;
4181 windowInfo.id = 2;
4182 windowGroupInfo.windowsInfo.push_back(windowInfo);
4183 windowInfo.id = 52;
4184 windowInfo.pid = 100;
4185 windowInfo.agentWindowId = 65;
4186 windowGroupInfo.windowsInfo.push_back(windowInfo);
4187 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(keyEvent->GetTargetDisplayId(), windowGroupInfo));
4188 ASSERT_NO_FATAL_FAILURE(inputWindowsManager.GetPidAndUpdateTarget(keyEvent));
4189 }
4190
4191 /**
4192 * @tc.name: InputWindowsManagerTest_UpdateAndAdjustMouseLocation_002
4193 * @tc.desc: Test UpdateAndAdjustMouseLocation
4194 * @tc.type: FUNC
4195 * @tc.require:
4196 */
4197 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateAndAdjustMouseLocation_002, TestSize.Level1)
4198 {
4199 CALL_TEST_DEBUG;
4200 InputWindowsManager inputWindowsManager;
4201 int32_t displayId = 1;
4202 double x = 350;
4203 double y = 350;
4204 bool isRealData = true;
4205 DisplayInfo displayInfo;
4206 displayInfo.id = 1;
4207 displayInfo.x = 600;
4208 displayInfo.y = 600;
4209 displayInfo.width = 300;
4210 displayInfo.height = 300;
4211 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displayInfo);
4212 displayInfo.id = 2;
4213 displayInfo.x = 500;
4214 displayInfo.y = 500;
4215 displayInfo.width = 600;
4216 displayInfo.height = 600;
4217 displayInfo.displayDirection = DIRECTION0;
4218 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displayInfo);
4219 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateAndAdjustMouseLocation(displayId, x, y, isRealData));
4220 }
4221
4222 /**
4223 * @tc.name: InputWindowsManagerTest_UpdateAndAdjustMouseLocation_003
4224 * @tc.desc: Test UpdateAndAdjustMouseLocation
4225 * @tc.type: FUNC
4226 * @tc.require:
4227 */
4228 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateAndAdjustMouseLocation_003, TestSize.Level1)
4229 {
4230 CALL_TEST_DEBUG;
4231 InputWindowsManager inputWindowsManager;
4232 int32_t displayId = 1;
4233 double x = 200;
4234 double y = 200;
4235 bool isRealData = false;
4236 DisplayInfo displayInfo;
4237 displayInfo.id = 1;
4238 displayInfo.x = 600;
4239 displayInfo.y = 600;
4240 displayInfo.width = 400;
4241 displayInfo.height = 400;
4242 displayInfo.displayDirection = DIRECTION90;
4243 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displayInfo);
4244 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateAndAdjustMouseLocation(displayId, x, y, isRealData));
4245 inputWindowsManager.displayGroupInfo_.displaysInfo[0].displayDirection = DIRECTION0;
4246 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateAndAdjustMouseLocation(displayId, x, y, isRealData));
4247 }
4248
4249 /**
4250 * @tc.name: InputWindowsManagerTest_SetWindowPointerStyle_002
4251 * @tc.desc: Test SetWindowPointerStyle
4252 * @tc.type: FUNC
4253 * @tc.require:
4254 */
4255 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetWindowPointerStyle_002, TestSize.Level1)
4256 {
4257 CALL_TEST_DEBUG;
4258 InputWindowsManager inputWindowsManager;
4259 int32_t pid = 10;
4260 int32_t windowId = 50;
4261 WindowArea area = WindowArea::FOCUS_ON_BOTTOM_RIGHT;
4262 inputWindowsManager.lastPointerStyle_.id = MOUSE_ICON::NORTH_WEST_SOUTH_EAST;
4263 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SetWindowPointerStyle(area, pid, windowId));
4264
4265 windowId = -1;
4266 inputWindowsManager.lastPointerStyle_.id = MOUSE_ICON::EAST;
4267 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SetWindowPointerStyle(area, pid, windowId));
4268 }
4269
4270 /**
4271 * @tc.name: InputWindowsManagerTest_SkipNavigationWindow_006
4272 * @tc.desc: Test updating window information for each display
4273 * @tc.type: FUNC
4274 * @tc.require:
4275 */
4276 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SkipNavigationWindow_006, TestSize.Level1)
4277 {
4278 CALL_TEST_DEBUG;
4279 InputWindowsManager inputWindowsMgr;
4280 inputWindowsMgr.isOpenAntiMisTakeObserver_ = false;
4281 inputWindowsMgr.antiMistake_.isOpen = true;
4282 ASSERT_TRUE(inputWindowsMgr.SkipNavigationWindow(WindowInputType::MIX_BUTTOM_ANTI_AXIS_MOVE,
4283 PointerEvent::TOOL_TYPE_PEN));
4284
4285 inputWindowsMgr.isOpenAntiMisTakeObserver_ = true;
4286 inputWindowsMgr.antiMistake_.isOpen = false;
4287 ASSERT_FALSE(inputWindowsMgr.SkipNavigationWindow(WindowInputType::MIX_BUTTOM_ANTI_AXIS_MOVE,
4288 PointerEvent::TOOL_TYPE_PEN));
4289 }
4290
4291 /**
4292 * @tc.name: InputWindowsManagerTest_HandleWindowInputType_005
4293 * @tc.desc: Test HandleWindowInputType
4294 * @tc.type: FUNC
4295 * @tc.require:
4296 */
4297 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandleWindowInputType_005, TestSize.Level1)
4298 {
4299 CALL_TEST_DEBUG;
4300 InputWindowsManager inputWindowsMgr;
4301 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
4302 ASSERT_NE(pointerEvent, nullptr);
4303 PointerEvent::PointerItem item;
4304 item.SetPointerId(1);
4305 item.SetToolType(PointerEvent::TOOL_TYPE_MOUSE);
4306 pointerEvent->SetPointerId(1);
4307 pointerEvent->AddPointerItem(item);
4308 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
4309 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
4310 WindowInfo window;
4311 window.windowInputType = WindowInputType::NORMAL;
4312 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4313 window.windowInputType = WindowInputType::TRANSMIT_ALL;
4314 EXPECT_TRUE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4315 window.windowInputType = WindowInputType::TRANSMIT_EXCEPT_MOVE;
4316 EXPECT_TRUE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4317 window.windowInputType = WindowInputType::ANTI_MISTAKE_TOUCH;
4318 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4319 window.windowInputType = WindowInputType::TRANSMIT_AXIS_MOVE;
4320 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4321 window.windowInputType = WindowInputType::TRANSMIT_MOUSE_MOVE;
4322 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4323 window.windowInputType = WindowInputType::TRANSMIT_LEFT_RIGHT;
4324 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4325 window.windowInputType = WindowInputType::TRANSMIT_BUTTOM;
4326 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4327 window.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
4328 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4329 window.windowInputType = WindowInputType::MIX_BUTTOM_ANTI_AXIS_MOVE;
4330 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4331 window.windowInputType = static_cast<WindowInputType>(100);
4332 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4333 }
4334
4335 /**
4336 * @tc.name: InputWindowsManagerTest_AddTargetWindowIds_003
4337 * @tc.desc: Test AddTargetWindowIds
4338 * @tc.type: FUNC
4339 * @tc.require:
4340 */
4341 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_AddTargetWindowIds_003, TestSize.Level1)
4342 {
4343 CALL_TEST_DEBUG;
4344 InputWindowsManager inputWindowsMgr;
4345 int32_t pointerItemId = 1;
4346 int32_t sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
4347 int32_t windowId = 50;
4348 std::vector<int32_t> winIds;
4349 inputWindowsMgr.targetMouseWinIds_.insert(std::make_pair(pointerItemId, winIds));
4350 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.AddTargetWindowIds(pointerItemId, sourceType, windowId));
4351
4352 pointerItemId = 2;
4353 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.AddTargetWindowIds(pointerItemId, sourceType, windowId));
4354
4355 sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
4356 inputWindowsMgr.targetTouchWinIds_.insert(std::make_pair(pointerItemId, winIds));
4357 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.AddTargetWindowIds(pointerItemId, sourceType, windowId));
4358 }
4359
4360 /**
4361 * @tc.name: InputWindowsManagerTest_ReverseXY
4362 * @tc.desc: Test ReverseXY
4363 * @tc.type: FUNC
4364 * @tc.require:
4365 */
4366 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ReverseXY, TestSize.Level1)
4367 {
4368 CALL_TEST_DEBUG;
4369 InputWindowsManager inputWindowsMgr;
4370 int32_t x = 100;
4371 int32_t y = 100;
4372 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.ReverseXY(x, y));
4373
4374 DisplayInfo displayInfo;
4375 displayInfo.direction = DIRECTION0;
4376 displayInfo.width = 200;
4377 displayInfo.height = 300;
4378 inputWindowsMgr.displayGroupInfo_.displaysInfo.push_back(displayInfo);
4379 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.ReverseXY(x, y));
4380 }
4381
4382 /**
4383 * @tc.name: InputWindowsManagerTest_SendCancelEventWhenLock
4384 * @tc.desc: Test SendCancelEventWhenLock
4385 * @tc.type: FUNC
4386 * @tc.require:
4387 */
4388 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SendCancelEventWhenLock, TestSize.Level1)
4389 {
4390 CALL_TEST_DEBUG;
4391 InputWindowsManager inputWindowsMgr;
4392 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
4393 }
4394
4395 /**
4396 * @tc.name: InputWindowsManagerTest_PrintChangedWindowBySync
4397 * @tc.desc: Test PrintChangedWindowBySync
4398 * @tc.type: FUNC
4399 * @tc.require:
4400 */
4401 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintChangedWindowBySync, TestSize.Level1)
4402 {
4403 CALL_TEST_DEBUG;
4404 InputWindowsManager inputWindowsMgr;
4405 DisplayGroupInfo newDisplayInfo;
4406 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.PrintChangedWindowBySync(newDisplayInfo));
4407 WindowInfo windowInfo;
4408 windowInfo.id = 1;
4409 windowInfo.pid = 50;
4410 windowInfo.zOrder = 60;
4411 inputWindowsMgr.displayGroupInfo_.windowsInfo.push_back(windowInfo);
4412 windowInfo.id = 2;
4413 newDisplayInfo.windowsInfo.push_back(windowInfo);
4414 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.PrintChangedWindowBySync(newDisplayInfo));
4415 }
4416
4417 /**
4418 * @tc.name: InputWindowsManagerTest_GetClientFd_003
4419 * @tc.desc: Test the funcation GetClientFd
4420 * @tc.type: FUNC
4421 * @tc.require:
4422 */
4423 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetClientFd_003, TestSize.Level1)
4424 {
4425 InputWindowsManager inputWindowsManager;
4426 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
4427 EXPECT_NE(pointerEvent, nullptr);
4428 WindowInfoEX windowInfoEX;
4429 WindowInfo windowInfo;
4430 windowInfo.id = 1;
4431 windowInfo.pid = 5;
4432 std::vector<WindowInfo> windows;
4433 windows.push_back(windowInfo);
4434 windowInfoEX.window = windows [0];
4435 windowInfoEX.flag = false;
4436 pointerEvent->pointerId_ = 1;
4437 inputWindowsManager.touchItemDownInfos_.insert(std::make_pair(1, windowInfoEX));
4438 int32_t ret = inputWindowsManager.GetClientFd(pointerEvent);
4439 EXPECT_EQ(ret, -1);
4440 windowInfoEX.flag = true;
4441 std::shared_ptr<InputEvent> inputEvent = InputEvent::Create();
4442 EXPECT_NE(inputEvent, nullptr);
4443 inputEvent->targetDisplayId_ = 5;
4444 inputWindowsManager.touchItemDownInfos_.insert(std::make_pair(10, windowInfoEX));
4445 ret = inputWindowsManager.GetClientFd(pointerEvent);
4446 EXPECT_EQ(ret, -1);
4447 }
4448
4449 /**
4450 * @tc.name: InputWindowsManagerTest_GetPidAndUpdateTarget_003
4451 * @tc.desc: Test the funcation GetPidAndUpdateTarget
4452 * @tc.type: FUNC
4453 * @tc.require:
4454 */
4455 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPidAndUpdateTarget_003, TestSize.Level1)
4456 {
4457 CALL_TEST_DEBUG;
4458 InputWindowsManager inputWindowsManager;
4459 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
4460 ASSERT_NE(keyEvent, nullptr);
4461 inputWindowsManager.displayGroupInfo_.focusWindowId = 10;
4462 std::shared_ptr<InputEvent> inputEvent = InputEvent::Create();
4463 EXPECT_NE(inputEvent, nullptr);
4464 inputEvent->targetDisplayId_ = 10;
4465 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetPidAndUpdateTarget(keyEvent));
4466 inputEvent->targetDisplayId_ = 18;
4467 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetPidAndUpdateTarget(keyEvent));
4468 WindowGroupInfo windowGroupInfo;
4469 WindowInfo windowInfo;
4470 windowInfo.id = 10;
4471 windowInfo.pid = 11;
4472 windowGroupInfo.windowsInfo.push_back(windowInfo);
4473 windowInfo.id = 10;
4474 windowInfo.pid = 11;
4475 windowInfo.agentWindowId = 12;
4476 windowGroupInfo.windowsInfo.push_back(windowInfo);
4477 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(10, windowGroupInfo));
4478 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetPidAndUpdateTarget(keyEvent));
4479 }
4480
4481 /**
4482 * @tc.name: InputWindowsManagerTest_IsNeedRefreshLayer_002
4483 * @tc.desc: Test the funcation IsNeedRefreshLayer
4484 * @tc.type: FUNC
4485 * @tc.require:
4486 */
4487 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsNeedRefreshLayer_002, TestSize.Level1)
4488 {
4489 CALL_TEST_DEBUG;
4490 InputWindowsManager inputWindowsManager;
4491 int32_t windowId = 1;
4492 std::shared_ptr<InputEvent> inputEvent = InputEvent::Create();
4493 EXPECT_NE(inputEvent, nullptr);
4494 inputEvent->targetDisplayId_ = -11;
4495 bool ret = inputWindowsManager.IsNeedRefreshLayer(windowId);
4496 EXPECT_FALSE(ret);
4497 inputEvent->targetDisplayId_ = 11;
4498 EXPECT_FALSE(ret);
4499 }
4500
4501 /**
4502 * @tc.name: InputWindowsManagerTest_SelectWindowInfo_003
4503 * @tc.desc: Test the funcation SelectWindowInfo
4504 * @tc.type: FUNC
4505 * @tc.require:
4506 */
4507 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectWindowInfo_003, TestSize.Level1)
4508 {
4509 CALL_TEST_DEBUG;
4510 InputWindowsManager inputWindowsManager;
4511 int32_t logicalX = 200;
4512 int32_t logicalY = 200;
4513 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
4514 EXPECT_NE(pointerEvent, nullptr);
4515 inputWindowsManager.firstBtnDownWindowId_ = -1;
4516 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_BUTTON_DOWN;
4517 PointerEvent::PointerItem pointerItem;
4518 pointerItem.targetWindowId_ = 0;
4519 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4520 pointerItem.targetWindowId_ = 2;
4521 WindowInfo windowInfo;
4522 windowInfo.flags = WindowInfo::FLAG_BIT_UNTOUCHABLE;
4523 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4524 windowInfo.flags = WindowInfo::FLAG_BIT_HANDWRITING;
4525 pointerEvent->HasFlag(InputEvent::EVENT_FLAG_SIMULATE);
4526 inputWindowsManager.extraData_.appended = true;
4527 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
4528 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_PULL_UP;
4529 windowInfo.pointerHotAreas.push_back({ 150, 250, 300, 500 });
4530 windowInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
4531 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4532 inputWindowsManager.extraData_.appended = false;
4533 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
4534 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_PULL_IN_WINDOW;
4535 pointerItem.targetWindowId_ = -2;
4536 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4537 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_PULL_UP;
4538 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4539 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_AXIS_BEGIN;
4540 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4541 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_AXIS_UPDATE;
4542 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4543 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_PULL_OUT_WINDOW;
4544 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4545 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_AXIS_END;
4546 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4547 pointerItem.targetWindowId_ = 10;
4548 std::shared_ptr<InputEvent> inputEvent = InputEvent::Create();
4549 EXPECT_NE(inputEvent, nullptr);
4550 inputEvent->targetDisplayId_ = 11;
4551 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4552 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_BUTTON_DOWN;
4553 inputWindowsManager.firstBtnDownWindowId_ = 1;
4554 inputEvent->targetDisplayId_ = 1;
4555 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4556 }
4557
4558 /**
4559 * @tc.name: InputWindowsManagerTest_UpdateCrownTarget_001
4560 * @tc.desc: Test the funcation UpdateCrownTarget
4561 * @tc.type: FUNC
4562 * @tc.require:
4563 */
4564 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateCrownTarget_001, TestSize.Level1)
4565 {
4566 CALL_TEST_DEBUG;
4567 InputWindowsManager inputWindowsManager;
4568 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
4569 EXPECT_NE(pointerEvent, nullptr);
4570 std::shared_ptr<InputEvent> inputEvent = InputEvent::Create();
4571 EXPECT_NE(inputEvent, nullptr);
4572 inputEvent->targetDisplayId_ = -1;
4573 inputWindowsManager.displayGroupInfo_.focusWindowId = -1;
4574 int32_t ret = inputWindowsManager.UpdateCrownTarget(pointerEvent);
4575 EXPECT_NE(ret, RET_OK);
4576 inputEvent->targetDisplayId_ = 5;
4577 ret = inputWindowsManager.UpdateCrownTarget(pointerEvent);
4578 EXPECT_NE(ret, RET_OK);
4579 inputWindowsManager.displayGroupInfo_.focusWindowId = 5;
4580 ret = inputWindowsManager.UpdateCrownTarget(pointerEvent);
4581 EXPECT_NE(ret, RET_OK);
4582 }
4583
4584 /**
4585 * @tc.name: InputWindowsManagerTest_PrintChangedWindowByEvent_001
4586 * @tc.desc: Test the funcation PrintChangedWindowByEvent
4587 * @tc.type: FUNC
4588 * @tc.require:
4589 */
4590 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintChangedWindowByEvent_001, TestSize.Level1)
4591 {
4592 CALL_TEST_DEBUG;
4593 InputWindowsManager inputWindowsManager;
4594 int32_t eventType = 1;
4595 WindowInfo newWindowInfo;
4596 newWindowInfo.id = 6;
4597 WindowInfo windowInfo;
4598 windowInfo.id = 1;
4599 windowInfo.pid = 5;
4600 windowInfo.uid = 1;
4601 inputWindowsManager.lastMatchedWindow_.insert(std::make_pair(1, windowInfo));
4602 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.PrintChangedWindowByEvent(eventType, newWindowInfo));
4603 eventType = 10;
4604 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.PrintChangedWindowByEvent(eventType, newWindowInfo));
4605 newWindowInfo.id = 1;
4606 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.PrintChangedWindowByEvent(eventType, newWindowInfo));
4607 }
4608
4609 /**
4610 * @tc.name: InputWindowsManagerTest_IsOnTheWhitelist_001
4611 * @tc.desc: Test IsOnTheWhitelist
4612 * @tc.type: FUNC
4613 * @tc.require:
4614 */
4615 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsOnTheWhitelist_001, TestSize.Level1)
4616 {
4617 CALL_TEST_DEBUG;
4618 WIN_MGR->vecWhiteList_ = {{1}, {2}, {3}};
4619 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
4620 ASSERT_NE(keyEvent, nullptr);
4621 keyEvent->SetKeyCode(4);
4622 bool ret = WIN_MGR->IsOnTheWhitelist(keyEvent);
4623 ASSERT_FALSE(ret);
4624 }
4625
4626 /**
4627 * @tc.name: InputWindowsManagerTest_IsOnTheWhitelist_002
4628 * @tc.desc: Test IsOnTheWhitelist
4629 * @tc.type: FUNC
4630 * @tc.require:
4631 */
4632 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsOnTheWhitelist_002, TestSize.Level1)
4633 {
4634 CALL_TEST_DEBUG;
4635 InputWindowsManager inputManager;
4636 SwitchFocusKey whitelistItem;
4637 whitelistItem.keyCode = 1;
4638 whitelistItem.pressedKey = -1;
4639 inputManager.vecWhiteList_.push_back(whitelistItem);
4640 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
4641 ASSERT_NE(keyEvent, nullptr);
4642 keyEvent->SetKeyCode(1);
4643 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
4644 KeyEvent::KeyItem item;
4645 item.SetKeyCode(KeyEvent::KEYCODE_HOME);
4646 keyEvent->AddKeyItem(item);
4647 bool ret = inputManager.IsOnTheWhitelist(keyEvent);
4648 ASSERT_TRUE(ret);
4649 whitelistItem.pressedKey = 2;
4650 ret = inputManager.IsOnTheWhitelist(keyEvent);
4651 ASSERT_TRUE(ret);
4652 whitelistItem.pressedKey = -1;
4653 item.SetDeviceId(100);
4654 item.SetKeyCode(KeyEvent::KEYCODE_PAGE_DOWN);
4655 item.SetDownTime(100);
4656 keyEvent->AddKeyItem(item);
4657 ret = inputManager.IsOnTheWhitelist(keyEvent);
4658 ASSERT_FALSE(ret);
4659 }
4660
4661 /**
4662 * @tc.name: InputWindowsManagerTest_IsOnTheWhitelist_003
4663 * @tc.desc: Test IsOnTheWhitelist
4664 * @tc.type: FUNC
4665 * @tc.require:
4666 */
4667 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsOnTheWhitelist_003, TestSize.Level1)
4668 {
4669 CALL_TEST_DEBUG;
4670 InputWindowsManager inputManager;
4671 SwitchFocusKey whitelistItem;
4672 whitelistItem.keyCode = 1;
4673 whitelistItem.pressedKey = 1;
4674 inputManager.vecWhiteList_.push_back(whitelistItem);
4675 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
4676 ASSERT_NE(keyEvent, nullptr);
4677 keyEvent->SetKeyCode(1);
4678 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
4679 KeyEvent::KeyItem item;
4680 item.SetDeviceId(100);
4681 item.SetDownTime(100);
4682 keyEvent->AddKeyItem(item);
4683 item.pressed_ = true;
4684 bool ret = WIN_MGR->IsOnTheWhitelist(keyEvent);
4685 ASSERT_TRUE(ret);
4686 }
4687
4688 /**
4689 * @tc.name: InputWindowsManagerTest_IsKeyPressed_002
4690 * @tc.desc: Test IsKeyPressed
4691 * @tc.type: FUNC
4692 * @tc.require:
4693 */
4694 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsKeyPressed_002, TestSize.Level1)
4695 {
4696 CALL_TEST_DEBUG;
4697 KeyEvent::KeyItem item;
4698 item.SetKeyCode(1);
4699 std::vector<KeyEvent::KeyItem> keyItems;
4700 keyItems.push_back(item);
4701 bool ret = WIN_MGR->IsKeyPressed(1, keyItems);
4702 ASSERT_FALSE(ret);
4703 ret = WIN_MGR->IsKeyPressed(2, keyItems);
4704 ASSERT_FALSE(ret);
4705 item.pressed_ = true;
4706 keyItems.push_back(item);
4707 ret = WIN_MGR->IsKeyPressed(1, keyItems);
4708 ASSERT_TRUE(ret);
4709 }
4710
4711 /**
4712 * @tc.name: InputWindowsManagerTest_CheckUIExtentionWindowPointerHotArea_001
4713 * @tc.desc: Test CheckUIExtentionWindowPointerHotArea
4714 * @tc.type: FUNC
4715 * @tc.require:
4716 */
4717 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckUIExtentionWindowPointerHotArea_001, TestSize.Level1)
4718 {
4719 CALL_TEST_DEBUG;
4720 WindowInfo windowInfo;
4721 windowInfo.windowType = 2105;
4722 windowInfo.area.x = 10;
4723 windowInfo.area.y = 80;
4724 windowInfo.area.height = 90;
4725 std::vector<WindowInfo> windows;
4726 windows.push_back(windowInfo);
4727 int32_t windowId = 1;
4728 EXPECT_NO_FATAL_FAILURE(WIN_MGR->CheckUIExtentionWindowPointerHotArea(15, 20, windows, windowId));
4729 EXPECT_NO_FATAL_FAILURE(WIN_MGR->CheckUIExtentionWindowPointerHotArea(100, 200, windows, windowId));
4730 EXPECT_NO_FATAL_FAILURE(WIN_MGR->CheckUIExtentionWindowPointerHotArea(100, 200, {}, windowId));
4731 }
4732
4733 /**
4734 * @tc.name: InputWindowsManagerTest_GetUIExtentionWindowInfo_001
4735 * @tc.desc: Test GetUIExtentionWindowInfo
4736 * @tc.type: FUNC
4737 * @tc.require:
4738 */
4739 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetUIExtentionWindowInfo_001, TestSize.Level1)
4740 {
4741 CALL_TEST_DEBUG;
4742 InputWindowsManager manager;
4743 std::vector<WindowInfo> windows = {{1}, {2}, {3}};
4744 WindowInfo *touchWindow = nullptr;
4745 bool isUiExtentionWindow = false;
4746 EXPECT_NO_FATAL_FAILURE(WIN_MGR->GetUIExtentionWindowInfo(windows, 2, &touchWindow, isUiExtentionWindow));
4747 EXPECT_NO_FATAL_FAILURE(WIN_MGR->GetUIExtentionWindowInfo(windows, 4, &touchWindow, isUiExtentionWindow));
4748 std::vector<WindowInfo> emptyWindows;
4749 EXPECT_NO_FATAL_FAILURE(WIN_MGR->GetUIExtentionWindowInfo(emptyWindows, 1, &touchWindow, isUiExtentionWindow));
4750 }
4751
4752 /**
4753 * @tc.name: InputWindowsManagerTest_TransformDisplayXY_001
4754 * @tc.desc: Test the TransformDisplayXY function of the input window manager
4755 * @tc.type: FUNC
4756 * @tc.require:
4757 */
4758 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_TransformDisplayXY_001, TestSize.Level1)
4759 {
4760 CALL_TEST_DEBUG;
4761 DisplayInfo info;
4762 double logicX = 10.0;
4763 double logicY = 20.0;
4764 std::pair<double, double> result =WIN_MGR->TransformDisplayXY(info, logicX, logicY);
4765 double ret = result.first;
4766 EXPECT_EQ(ret, logicX);
4767 double ret1 = result.second;
4768 EXPECT_EQ(ret1, logicY);
4769 }
4770
4771 /**
4772 * @tc.name: InputWindowsManagerTest_TransformDisplayXY_002
4773 * @tc.desc: Test the TransformDisplayXY function of the input window manager
4774 * @tc.type: FUNC
4775 * @tc.require:
4776 */
4777 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_TransformDisplayXY_002, TestSize.Level1)
4778 {
4779 CALL_TEST_DEBUG;
4780 DisplayInfo info;
4781 std::vector<float> transform = { 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
4782 info.transform = transform;
4783 double logicX = 10.0;
4784 double logicY = 20.0;
4785 std::pair<double, double> result =WIN_MGR->TransformDisplayXY(info, logicX, logicY);
4786 double ret = result.first;
4787 EXPECT_EQ(ret, logicX);
4788 double ret1 = result.second;
4789 EXPECT_EQ(ret1, logicY);
4790 }
4791
4792 /**
4793 * @tc.name: InputWindowsManagerTest_TransformDisplayXY_003
4794 * @tc.desc: Test the TransformDisplayXY function of the input window manager
4795 * @tc.type: FUNC
4796 * @tc.require:
4797 */
4798 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_TransformDisplayXY_003, TestSize.Level1)
4799 {
4800 CALL_TEST_DEBUG;
4801 DisplayInfo info;
4802 std::vector<float> transform = { 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 315.0, 690.0, 1.0};
4803 info.transform = transform;
4804 double logicX = 10.0;
4805 double logicY = 20.0;
4806 std::pair<double, double> result =WIN_MGR->TransformDisplayXY(info, logicX, logicY);
4807 double ret = result.first;
4808 EXPECT_EQ(ret, 320);
4809 double ret1 = result.second;
4810 EXPECT_EQ(ret1, 700);
4811 }
4812
4813 /**
4814 * @tc.name: InputWindowsManagerTest_IsValidNavigationWindow_001
4815 * @tc.desc: Test IsValidNavigationWindow
4816 * @tc.type: FUNC
4817 * @tc.require:
4818 */
4819 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsValidNavigationWindow_001, TestSize.Level1)
4820 {
4821 CALL_TEST_DEBUG;
4822 WindowInfo windowInfo;
4823 windowInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
4824 double x = 10.0;
4825 double y = 20.0;
4826 Rect rect = {0, 0, 30, 40};
4827 windowInfo.defaultHotAreas.push_back(rect);
4828 EXPECT_TRUE(WIN_MGR->IsValidNavigationWindow(windowInfo, x, y));
4829 }
4830
4831 /**
4832 * @tc.name: InputWindowsManagerTest_IsValidNavigationWindow_002
4833 * @tc.desc: Test IsValidNavigationWindow
4834 * @tc.type: FUNC
4835 * @tc.require:
4836 */
4837 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsValidNavigationWindow_002, TestSize.Level1)
4838 {
4839 CALL_TEST_DEBUG;
4840 WindowInfo windowInfo;
4841 windowInfo.windowInputType = WindowInputType::MIX_BUTTOM_ANTI_AXIS_MOVE;
4842 double x = 10.0;
4843 double y = 20.0;
4844 Rect rect = {0, 0, 30, 40};
4845 windowInfo.defaultHotAreas.push_back(rect);
4846 EXPECT_TRUE(WIN_MGR->IsValidNavigationWindow(windowInfo, x, y));
4847 }
4848
4849 /**
4850 * @tc.name: InputWindowsManagerTest_IsValidNavigationWindow_003
4851 * @tc.desc: Test IsValidNavigationWindow
4852 * @tc.type: FUNC
4853 * @tc.require:
4854 */
4855 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsValidNavigationWindow_003, TestSize.Level1)
4856 {
4857 CALL_TEST_DEBUG;
4858 WindowInfo windowInfo;
4859 windowInfo.windowInputType = WindowInputType::NORMAL;
4860 double x = 10.0;
4861 double y = 20.0;
4862 Rect rect = {0, 0, 30, 40};
4863 windowInfo.defaultHotAreas.push_back(rect);
4864 EXPECT_FALSE(WIN_MGR->IsValidNavigationWindow(windowInfo, x, y));
4865 }
4866
4867 /**
4868 * @tc.name: InputWindowsManagerTest_IsValidNavigationWindow_004
4869 * @tc.desc: Test IsValidNavigationWindow
4870 * @tc.type: FUNC
4871 * @tc.require:
4872 */
4873 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsValidNavigationWindow_004, TestSize.Level1)
4874 {
4875 CALL_TEST_DEBUG;
4876 WindowInfo windowInfo;
4877 windowInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
4878 double x = -10.0;
4879 double y = 20.0;
4880 Rect rect = {0, 0, 30, 40};
4881 windowInfo.defaultHotAreas.push_back(rect);
4882 EXPECT_FALSE(WIN_MGR->IsValidNavigationWindow(windowInfo, x, y));
4883 }
4884
4885 /**
4886 * @tc.name: InputWindowsManagerTest_IsValidNavigationWindow_005
4887 * @tc.desc: Test IsValidNavigationWindow
4888 * @tc.type: FUNC
4889 * @tc.require:
4890 */
4891 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsValidNavigationWindow_005, TestSize.Level1)
4892 {
4893 CALL_TEST_DEBUG;
4894 WindowInfo windowInfo;
4895 windowInfo.windowInputType = WindowInputType::TRANSMIT_ALL;
4896 double x = 10.0;
4897 double y = -20.0;
4898 Rect rect = {0, 0, 30, 40};
4899 windowInfo.defaultHotAreas.push_back(rect);
4900 EXPECT_FALSE(WIN_MGR->IsValidNavigationWindow(windowInfo, x, y));
4901 }
4902
4903 /**
4904 * @tc.name: InputWindowsManagerTest_UpdateTransformDisplayXY_001
4905 * @tc.desc: Test UpdateTransformDisplayXY
4906 * @tc.type: FUNC
4907 * @tc.require:
4908 */
4909 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTransformDisplayXY_001, TestSize.Level1)
4910 {
4911 CALL_TEST_DEBUG;
4912 auto pointerEvent = PointerEvent::Create();
4913 EXPECT_NE(pointerEvent, nullptr);
4914 PointerEvent::PointerItem item;
4915 item.SetPointerId(0);
4916 item.SetDisplayXPos(10);
4917 item.SetDisplayYPos(20);
4918 pointerEvent->UpdatePointerItem(0, item);
4919 std::vector<WindowInfo> windowsInfo;
4920 DisplayInfo info;
4921 WIN_MGR->UpdateTransformDisplayXY(pointerEvent, windowsInfo, info);
4922 int32_t pointerId = pointerEvent->GetPointerId();
4923 PointerEvent::PointerItem pointerItem;
4924 if (!pointerEvent->GetPointerItem(pointerId, pointerItem)) {
4925 MMI_HILOG_DISPATCHE("Can't find pointer item, pointer:%{public}d", pointerId);
4926 return;
4927 }
4928 int32_t physicalX = pointerItem.GetDisplayX();
4929 int32_t physicalY = pointerItem.GetDisplayX();
4930 EXPECT_EQ(physicalX, 10);
4931 EXPECT_EQ(physicalY, 20);
4932 }
4933
4934 /**
4935 * @tc.name: InputWindowsManagerTest_UpdateTransformDisplayXY_002
4936 * @tc.desc: Test UpdateTransformDisplayXY
4937 * @tc.type: FUNC
4938 * @tc.require:
4939 */
4940 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTransformDisplayXY_002, TestSize.Level1)
4941 {
4942 CALL_TEST_DEBUG;
4943 auto pointerEvent = PointerEvent::Create();
4944 EXPECT_NE(pointerEvent, nullptr);
4945 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
4946 PointerEvent::PointerItem item;
4947 item.SetPointerId(0);
4948 item.SetDisplayXPos(10);
4949 item.SetDisplayYPos(20);
4950 pointerEvent->UpdatePointerItem(0, item);
4951 std::vector<WindowInfo> windowsInfo;
4952 WindowInfo windowInfo;
4953 DisplayInfo info;
4954 std::vector<float> transform = { 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 315.0, 690.0, 1.0};
4955 info.transform = transform;
4956 windowInfo.windowInputType = WindowInputType::MIX_BUTTOM_ANTI_AXIS_MOVE;
4957 Rect rect = {0, 0, 30, 40};
4958 windowInfo.defaultHotAreas.push_back(rect);
4959 windowsInfo.push_back(windowInfo);
4960 WIN_MGR->UpdateTransformDisplayXY(pointerEvent, windowsInfo, info);
4961 int32_t pointerId = pointerEvent->GetPointerId();
4962 PointerEvent::PointerItem pointerItem;
4963 if (!pointerEvent->GetPointerItem(pointerId, pointerItem)) {
4964 MMI_HILOG_DISPATCHE("Can't find pointer item, pointer:%{public}d", pointerId);
4965 return;
4966 }
4967 int32_t physicalX = pointerItem.GetDisplayX();
4968 int32_t physicalY = pointerItem.GetDisplayX();
4969 EXPECT_EQ(physicalX, 10);
4970 EXPECT_EQ(physicalY, 20);
4971 }
4972
4973 /**
4974 * @tc.name: InputWindowsManagerTest_UpdateTransformDisplayXY_003
4975 * @tc.desc: Test UpdateTransformDisplayXY
4976 * @tc.type: FUNC
4977 * @tc.require:
4978 */
4979 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTransformDisplayXY_003, TestSize.Level1)
4980 {
4981 CALL_TEST_DEBUG;
4982 auto pointerEvent = PointerEvent::Create();
4983 EXPECT_NE(pointerEvent, nullptr);
4984 PointerEvent::PointerItem item;
4985 item.SetPointerId(0);
4986 item.SetDisplayXPos(10);
4987 item.SetDisplayYPos(20);
4988 pointerEvent->UpdatePointerItem(0, item);
4989 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
4990 std::vector<WindowInfo> windowsInfo;
4991 WindowInfo windowInfo;
4992 DisplayInfo info;
4993 std::vector<float> transform = { 0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 315.0, 690.0, 1.0};
4994 info.transform = transform;
4995 windowInfo.windowInputType = WindowInputType::TRANSMIT_ALL;
4996 Rect rect = {0, 0, 30, 40};
4997 windowInfo.defaultHotAreas.push_back(rect);
4998 windowsInfo.push_back(windowInfo);
4999 WIN_MGR->UpdateTransformDisplayXY(pointerEvent, windowsInfo, info);
5000 int32_t pointerId = pointerEvent->GetPointerId();
5001 PointerEvent::PointerItem pointerItem;
5002 if (!pointerEvent->GetPointerItem(pointerId, pointerItem)) {
5003 MMI_HILOG_DISPATCHE("Can't find pointer item, pointer:%{public}d", pointerId);
5004 return;
5005 }
5006 int32_t physicalX = pointerItem.GetDisplayX();
5007 int32_t physicalY = pointerItem.GetDisplayX();
5008 EXPECT_EQ(physicalX, 320);
5009 EXPECT_EQ(physicalY, 700);
5010 }
5011
5012 /**
5013 * @tc.name: InputWindowsManagerTest_GetUIExtentionWindowInfo
5014 * @tc.desc: Test the funcation GetUIExtentionWindowInfo
5015 * @tc.type: FUNC
5016 * @tc.require:
5017 */
5018 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetUIExtentionWindowInfo, TestSize.Level1)
5019 {
5020 CALL_TEST_DEBUG;
5021 InputWindowsManager inputWinMgr;
5022 WindowInfo windowInfo;
5023 windowInfo.id = 5;
5024 std::vector<WindowInfo> uiExtentionWindowInfo;
5025 int32_t windowId = 10;
5026 WindowInfo *touchWindow;
5027 bool isUiExtentionWindow = false;
5028 uiExtentionWindowInfo.push_back(windowInfo);
5029 windowInfo.id = 10;
5030 uiExtentionWindowInfo.push_back(windowInfo);
5031 EXPECT_NO_FATAL_FAILURE(inputWinMgr.GetUIExtentionWindowInfo(uiExtentionWindowInfo, windowId,
5032 &touchWindow, isUiExtentionWindow));
5033 }
5034
5035 /**
5036 * @tc.name: InputWindowsManagerTest_IsKeyPressed
5037 * @tc.desc: Test the funcation IsKeyPressed
5038 * @tc.type: FUNC
5039 * @tc.require:
5040 */
5041 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsKeyPressed, TestSize.Level1)
5042 {
5043 CALL_TEST_DEBUG;
5044 InputWindowsManager inputWinMgr;
5045 KeyEvent::KeyItem item;
5046 int32_t pressedKey = 2024;
5047 std::vector<KeyEvent::KeyItem> keyItems;
5048 item.SetKeyCode(2018);
5049 item.SetPressed(false);
5050 keyItems.push_back(item);
5051 EXPECT_FALSE(inputWinMgr.IsKeyPressed(pressedKey, keyItems));
5052 }
5053
5054 /**
5055 * @tc.name: InputWindowsManagerTest_IsKeyPressed_001
5056 * @tc.desc: Test the funcation IsKeyPressed
5057 * @tc.type: FUNC
5058 * @tc.require:
5059 */
5060 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsKeyPressed_001, TestSize.Level1)
5061 {
5062 CALL_TEST_DEBUG;
5063 InputWindowsManager inputWinMgr;
5064 KeyEvent::KeyItem item;
5065 int32_t pressedKey = 2024;
5066 std::vector<KeyEvent::KeyItem> keyItems;
5067 item.SetKeyCode(2024);
5068 item.SetPressed(true);
5069 keyItems.push_back(item);
5070 EXPECT_TRUE(inputWinMgr.IsKeyPressed(pressedKey, keyItems));
5071 }
5072
5073 /**
5074 * @tc.name: InputWindowsManagerTest_IsOnTheWhitelist
5075 * @tc.desc: Test the funcation IsOnTheWhitelist
5076 * @tc.type: FUNC
5077 * @tc.require:
5078 */
5079 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsOnTheWhitelist, TestSize.Level1)
5080 {
5081 CALL_TEST_DEBUG;
5082 InputWindowsManager inputWinMgr;
5083 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
5084 ASSERT_NE(keyEvent, nullptr);
5085 KeyEvent::KeyItem item;
5086 SwitchFocusKey switchFocusKey;
5087 switchFocusKey.keyCode = 2024;
5088 switchFocusKey.pressedKey = -1;
5089 inputWinMgr.vecWhiteList_.push_back(switchFocusKey);
5090 keyEvent->SetKeyCode(2024);
5091 item.SetPressed(true);
5092 item.SetKeyCode(2024);
5093 keyEvent->AddKeyItem(item);
5094 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
5095 EXPECT_TRUE(inputWinMgr.IsOnTheWhitelist(keyEvent));
5096
5097 inputWinMgr.vecWhiteList_[0].pressedKey = 2024;
5098 keyEvent->AddKeyItem(item);
5099 EXPECT_TRUE(inputWinMgr.IsOnTheWhitelist(keyEvent));
5100
5101 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_UP);
5102 EXPECT_FALSE(inputWinMgr.IsOnTheWhitelist(keyEvent));
5103
5104 keyEvent->SetKeyCode(2018);
5105 EXPECT_FALSE(inputWinMgr.IsOnTheWhitelist(keyEvent));
5106 }
5107
5108 /**
5109 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_003
5110 * @tc.desc: Test UpdateTouchScreenTarget
5111 * @tc.type: FUNC
5112 * @tc.require:
5113 */
5114 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_003, TestSize.Level1)
5115 {
5116 CALL_TEST_DEBUG;
5117 InputWindowsManager inputWindowsMgr;
5118 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5119 ASSERT_NE(pointerEvent, nullptr);
5120 DisplayInfo displayInfo;
5121 WindowGroupInfo winGroupInfo;
5122 WindowInfo winInfo;
5123 Rect rect;
5124 PointerEvent::PointerItem item;
5125 displayInfo.id = 100;
5126 displayInfo.x = 500;
5127 displayInfo.y = 500;
5128 pointerEvent->SetTargetDisplayId(-1);
5129 pointerEvent->SetPointerId(150);
5130 item.SetPointerId(150);
5131 item.SetDisplayXPos(500);
5132 item.SetDisplayYPos(500);
5133 item.SetTargetWindowId(200);
5134 item.SetToolType(PointerEvent::TOOL_TYPE_FINGER);
5135 pointerEvent->AddPointerItem(item);
5136 pointerEvent->SetZOrder(15.5f);
5137 pointerEvent->bitwise_ = 0x00000000;
5138 rect.x = 300;
5139 rect.width = 1200;
5140 rect.y = 300;
5141 rect.height = 1200;
5142 for (int32_t i = 0; i < 4; ++i) {
5143 winInfo.defaultHotAreas.push_back(rect);
5144 }
5145 winInfo.id = 0;
5146 winInfo.flags = 6;
5147 winInfo.pixelMap = nullptr;
5148 winGroupInfo.windowsInfo.push_back(winInfo);
5149 winInfo.id = 1;
5150 winInfo.flags = 0;
5151 winInfo.pixelMap = nullptr;
5152 winInfo.windowInputType = WindowInputType::NORMAL;
5153 winInfo.transform.push_back(100.5f);
5154 winInfo.defaultHotAreas.push_back(rect);
5155 winGroupInfo.windowsInfo.push_back(winInfo);
5156 inputWindowsMgr.extraData_.appended = true;
5157 inputWindowsMgr.extraData_.pointerId = 150;
5158 inputWindowsMgr.extraData_.sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
5159 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
5160 inputWindowsMgr.displayGroupInfo_.displaysInfo.push_back(displayInfo);
5161 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5162 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5163 }
5164
5165 /**
5166 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_004
5167 * @tc.desc: Test UpdateTouchScreenTarget
5168 * @tc.type: FUNC
5169 * @tc.require:
5170 */
5171 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_004, TestSize.Level1)
5172 {
5173 CALL_TEST_DEBUG;
5174 InputWindowsManager inputWindowsMgr;
5175 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5176 ASSERT_NE(pointerEvent, nullptr);
5177 DisplayInfo displayInfo;
5178 WindowGroupInfo winGroupInfo;
5179 WindowInfo winInfo;
5180 Rect rect;
5181 PointerEvent::PointerItem item;
5182 displayInfo.id = 100;
5183 displayInfo.x = 500;
5184 displayInfo.y = 500;
5185 pointerEvent->SetTargetDisplayId(-1);
5186 pointerEvent->SetPointerId(150);
5187 item.SetPointerId(150);
5188 item.SetDisplayXPos(500);
5189 item.SetDisplayYPos(500);
5190 item.SetTargetWindowId(-1);
5191 item.SetToolType(PointerEvent::TOOL_TYPE_RUBBER);
5192 pointerEvent->AddPointerItem(item);
5193 pointerEvent->SetZOrder(15.5f);
5194 pointerEvent->bitwise_ = 0x00000000;
5195 rect.x = 300;
5196 rect.width = INT32_MAX;
5197 winInfo.id = 50;
5198 winInfo.defaultHotAreas.push_back(rect);
5199 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5200 rect.x = 300;
5201 rect.width = 1200;
5202 rect.y = 300;
5203 rect.height = 1200;
5204 winInfo.id = 1;
5205 winInfo.flags = 0;
5206 winInfo.pixelMap = nullptr;
5207 winInfo.windowInputType = WindowInputType::TRANSMIT_ALL;
5208 winInfo.defaultHotAreas.clear();
5209 winInfo.defaultHotAreas.push_back(rect);
5210 winGroupInfo.windowsInfo.push_back(winInfo);
5211 inputWindowsMgr.extraData_.appended = false;
5212 inputWindowsMgr.extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
5213 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5214 inputWindowsMgr.displayGroupInfo_.displaysInfo.push_back(displayInfo);
5215 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5216 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5217 }
5218
5219 /**
5220 * @tc.name: InputWindowsManagerTest_IgnoreTouchEvent_001
5221 * @tc.desc: Test IgnoreTouchEvent
5222 * @tc.type: FUNC
5223 * @tc.require:
5224 */
5225 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IgnoreTouchEvent_001, TestSize.Level1)
5226 {
5227 CALL_TEST_DEBUG;
5228 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5229 ASSERT_NE(pointerEvent, nullptr);
5230 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
5231 EXPECT_NO_FATAL_FAILURE(WIN_MGR->IgnoreTouchEvent(pointerEvent));
5232 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
5233 EXPECT_NO_FATAL_FAILURE(WIN_MGR->IgnoreTouchEvent(pointerEvent));
5234 }
5235
5236 /**
5237 * @tc.name: InputWindowsManagerTest_ReissueCancelTouchEvent_001
5238 * @tc.desc: Test ReissueCancelTouchEvent
5239 * @tc.type: FUNC
5240 * @tc.require:
5241 */
5242 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ReissueCancelTouchEvent_001, TestSize.Level1)
5243 {
5244 CALL_TEST_DEBUG;
5245 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5246 ASSERT_NE(pointerEvent, nullptr);
5247 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
5248 EXPECT_NO_FATAL_FAILURE(WIN_MGR->ReissueCancelTouchEvent(pointerEvent));
5249 }
5250
5251 /**
5252 * @tc.name: InputWindowsManagerTest_SendCancelEventWhenLock_001
5253 * @tc.desc: Test the funcation SendCancelEventWhenLock
5254 * @tc.type: FUNC
5255 * @tc.require:
5256 */
5257 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SendCancelEventWhenLock_001, TestSize.Level1)
5258 {
5259 CALL_TEST_DEBUG;
5260 InputWindowsManager inputWindowsMgr;
5261 inputWindowsMgr.lastTouchEventOnBackGesture_ = PointerEvent::Create();
5262 ASSERT_NE(inputWindowsMgr.lastTouchEventOnBackGesture_, nullptr);
5263 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
5264 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_UP);
5265 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
5266 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
5267 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
5268 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
5269 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
5270 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5271 ASSERT_NE(pointerEvent, nullptr);
5272 WindowInfoEX windowInfoEX;
5273 windowInfoEX.flag = true;
5274 pointerEvent->SetPointerId(1);
5275 inputWindowsMgr.touchItemDownInfos_.insert(std::make_pair(pointerEvent->GetPointerId(), windowInfoEX));
5276 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerId(2);
5277 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
5278 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerId(1);
5279 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
5280 }
5281
5282 /**
5283 * @tc.name: InputWindowsManagerTest_IsMouseDrawing_001
5284 * @tc.desc: Test the funcation IsMouseDrawing
5285 * @tc.type: FUNC
5286 * @tc.require:
5287 */
5288 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsMouseDrawing_001, TestSize.Level1)
5289 {
5290 CALL_TEST_DEBUG;
5291 InputWindowsManager inputWindowsMgr;
5292 int32_t currentAction = 10;
5293 bool ret = inputWindowsMgr.IsMouseDrawing(currentAction);
5294 ASSERT_FALSE(ret);
5295 currentAction = 11;
5296 ret = inputWindowsMgr.IsMouseDrawing(currentAction);
5297 ASSERT_FALSE(ret);
5298 currentAction = 15;
5299 ret = inputWindowsMgr.IsMouseDrawing(currentAction);
5300 ASSERT_FALSE(ret);
5301 currentAction = 16;
5302 ret = inputWindowsMgr.IsMouseDrawing(currentAction);
5303 ASSERT_FALSE(ret);
5304 currentAction = 1;
5305 ret = inputWindowsMgr.IsMouseDrawing(currentAction);
5306 ASSERT_TRUE(ret);
5307 }
5308
5309 /**
5310 * @tc.name: InputWindowsManagerTest_GetTargetWindowIds_002
5311 * @tc.desc: Test the funcation GetTargetWindowIds
5312 * @tc.type: FUNC
5313 * @tc.require:
5314 */
5315 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetTargetWindowIds_002, TestSize.Level1)
5316 {
5317 CALL_TEST_DEBUG;
5318 InputWindowsManager inputWindowsMgr;
5319 int32_t pointerItemId = 1;
5320 int32_t sourceType = 1;
5321 std::vector<int32_t> windowIds { 1, 2, 3 };
5322 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
5323 inputWindowsMgr.targetMouseWinIds_.insert(std::make_pair(1, windowIds));
5324 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
5325 sourceType = 2;
5326 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
5327 pointerItemId = 5;
5328 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
5329 inputWindowsMgr.targetMouseWinIds_.insert(std::make_pair(5, windowIds));
5330 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
5331 }
5332
5333 /**
5334 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_002
5335 * @tc.desc: Test UpdateTouchScreenTarget
5336 * @tc.type: FUNC
5337 * @tc.require:
5338 */
5339 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_002, TestSize.Level1)
5340 {
5341 CALL_TEST_DEBUG;
5342 InputWindowsManager inputWindowsMgr;
5343 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5344 ASSERT_NE(pointerEvent, nullptr);
5345 DisplayInfo displayInfo;
5346 WindowGroupInfo winGroupInfo;
5347 WindowInfo winInfo;
5348 PointerEvent::PointerItem item;
5349 displayInfo.id = 100;
5350 displayInfo.x = 500;
5351 displayInfo.y = 500;
5352 pointerEvent->SetTargetDisplayId(-1);
5353 pointerEvent->SetPointerId(150);
5354 item.SetPointerId(150);
5355 item.SetDisplayXPos(500);
5356 item.SetDisplayYPos(500);
5357 item.SetTargetWindowId(200);
5358 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5359 pointerEvent->AddPointerItem(item);
5360 pointerEvent->SetZOrder(15.5f);
5361 pointerEvent->bitwise_ = 0x00000000;
5362 winInfo.flags = 1;
5363 winGroupInfo.windowsInfo.push_back(winInfo);
5364 winInfo.flags = 0;
5365 winInfo.pixelMap = nullptr;
5366 winInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
5367 winGroupInfo.windowsInfo.push_back(winInfo);
5368 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5369 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
5370 inputWindowsMgr.isOpenAntiMisTakeObserver_ = false;
5371 inputWindowsMgr.antiMistake_.isOpen = true;
5372 inputWindowsMgr.displayGroupInfo_.displaysInfo.push_back(displayInfo);
5373 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5374 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5375 }
5376
5377 /**
5378 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_005
5379 * @tc.desc: Test UpdateTouchScreenTarget
5380 * @tc.type: FUNC
5381 * @tc.require:
5382 */
5383 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_005, TestSize.Level1)
5384 {
5385 CALL_TEST_DEBUG;
5386 InputWindowsManager inputWindowsMgr;
5387 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5388 ASSERT_NE(pointerEvent, nullptr);
5389 DisplayInfo displayInfo;
5390 WindowGroupInfo winGroupInfo;
5391 WindowInfo winInfo;
5392 PointerEvent::PointerItem item;
5393 displayInfo.id = 100;
5394 displayInfo.x = 500;
5395 displayInfo.y = 500;
5396 pointerEvent->SetTargetDisplayId(-1);
5397 pointerEvent->SetPointerId(150);
5398 item.SetPointerId(150);
5399 item.SetDisplayXPos(500);
5400 item.SetDisplayYPos(500);
5401 item.SetTargetWindowId(200);
5402 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5403 pointerEvent->AddPointerItem(item);
5404 pointerEvent->SetZOrder(15.5f);
5405 pointerEvent->bitwise_ = 0x00000000;
5406 winInfo.flags = 0;
5407 winInfo.pixelMap = nullptr;
5408 winInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
5409 winInfo.defaultHotAreas = { { 300, 300, 1000, 1000 } };
5410 winGroupInfo.windowsInfo.push_back(winInfo);
5411 winInfo.defaultHotAreas.clear();
5412 winInfo.defaultHotAreas = { { 300, 300, INT32_MAX, INT32_MAX } };
5413 winGroupInfo.windowsInfo.push_back(winInfo);
5414 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
5415 inputWindowsMgr.extraData_.appended = true;
5416 inputWindowsMgr.extraData_.sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
5417 inputWindowsMgr.isOpenAntiMisTakeObserver_ = true;
5418 inputWindowsMgr.antiMistake_.isOpen = false;
5419 inputWindowsMgr.displayGroupInfo_.displaysInfo.push_back(displayInfo);
5420 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5421 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5422 }
5423
5424 /**
5425 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_006
5426 * @tc.desc: Test UpdateTouchScreenTarget
5427 * @tc.type: FUNC
5428 * @tc.require:
5429 */
5430 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_006, TestSize.Level1)
5431 {
5432 CALL_TEST_DEBUG;
5433 InputWindowsManager inputWindowsMgr;
5434 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5435 ASSERT_NE(pointerEvent, nullptr);
5436 DisplayInfo displayInfo;
5437 WindowGroupInfo winGroupInfo;
5438 WindowInfo winInfo;
5439 PointerEvent::PointerItem item;
5440 displayInfo.id = 100;
5441 displayInfo.x = 500;
5442 displayInfo.y = 500;
5443 pointerEvent->SetTargetDisplayId(-1);
5444 pointerEvent->SetPointerId(150);
5445 item.SetPointerId(150);
5446 item.SetDisplayXPos(500);
5447 item.SetDisplayYPos(500);
5448 item.SetTargetWindowId(200);
5449 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5450 pointerEvent->AddPointerItem(item);
5451 pointerEvent->SetZOrder(15.5f);
5452 pointerEvent->bitwise_ = 0x00000000;
5453 winInfo.flags = 0;
5454 winInfo.pixelMap = nullptr;
5455 winInfo.windowInputType = WindowInputType::NORMAL;
5456 winInfo.id = 200;
5457 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5458 winGroupInfo.windowsInfo.push_back(winInfo);
5459 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5460 inputWindowsMgr.extraData_.appended = false;
5461 inputWindowsMgr.displayGroupInfo_.displaysInfo.push_back(displayInfo);
5462 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5463 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5464 }
5465
5466 /**
5467 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_007
5468 * @tc.desc: Test UpdateTouchScreenTarget
5469 * @tc.type: FUNC
5470 * @tc.require:
5471 */
5472 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_007, TestSize.Level1)
5473 {
5474 CALL_TEST_DEBUG;
5475 InputWindowsManager inputWindowsMgr;
5476 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5477 ASSERT_NE(pointerEvent, nullptr);
5478 DisplayInfo displayInfo;
5479 WindowGroupInfo winGroupInfo;
5480 WindowInfo winInfo;
5481 PointerEvent::PointerItem item;
5482 displayInfo.id = 100;
5483 displayInfo.x = 500;
5484 displayInfo.y = 500;
5485 pointerEvent->SetTargetDisplayId(-1);
5486 pointerEvent->SetPointerId(150);
5487 item.SetPointerId(150);
5488 item.SetDisplayXPos(500);
5489 item.SetDisplayYPos(500);
5490 item.SetTargetWindowId(200);
5491 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5492 pointerEvent->AddPointerItem(item);
5493 pointerEvent->SetZOrder(15.5f);
5494 pointerEvent->bitwise_ = 0x00000000;
5495 winInfo.flags = 0;
5496 winInfo.pixelMap = nullptr;
5497 winInfo.windowInputType = WindowInputType::NORMAL;
5498 winInfo.id = 110;
5499 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5500 winInfo.id = 200;
5501 winGroupInfo.windowsInfo.push_back(winInfo);
5502 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5503 inputWindowsMgr.extraData_.appended = false;
5504 inputWindowsMgr.displayGroupInfo_.displaysInfo.push_back(displayInfo);
5505 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5506 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5507 }
5508
5509 /**
5510 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_008
5511 * @tc.desc: Test UpdateTouchScreenTarget
5512 * @tc.type: FUNC
5513 * @tc.require:
5514 */
5515 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_008, TestSize.Level1)
5516 {
5517 CALL_TEST_DEBUG;
5518 InputWindowsManager inputWindowsMgr;
5519 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5520 ASSERT_NE(pointerEvent, nullptr);
5521 DisplayInfo displayInfo;
5522 WindowGroupInfo winGroupInfo;
5523 WindowInfo winInfo;
5524 PointerEvent::PointerItem item;
5525 displayInfo.id = 100;
5526 displayInfo.x = 500;
5527 displayInfo.y = 500;
5528 pointerEvent->SetTargetDisplayId(-1);
5529 pointerEvent->SetPointerId(150);
5530 item.SetPointerId(150);
5531 item.SetDisplayXPos(500);
5532 item.SetDisplayYPos(500);
5533 item.SetTargetWindowId(-1);
5534 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5535 pointerEvent->AddPointerItem(item);
5536 pointerEvent->SetZOrder(15.5f);
5537 pointerEvent->bitwise_ = 0x00000000;
5538 winInfo.flags = 0;
5539 winInfo.pixelMap = nullptr;
5540 winInfo.windowInputType = WindowInputType::NORMAL;
5541 winInfo.defaultHotAreas = { { 300, 300, 1000, 1000 } };
5542 winInfo.id = 100;
5543 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5544 winGroupInfo.windowsInfo.push_back(winInfo);
5545 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5546 inputWindowsMgr.extraData_.appended = false;
5547 inputWindowsMgr.displayGroupInfo_.displaysInfo.push_back(displayInfo);
5548 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5549 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5550 }
5551
5552 /**
5553 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_009
5554 * @tc.desc: Test UpdateTouchScreenTarget
5555 * @tc.type: FUNC
5556 * @tc.require:
5557 */
5558 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_009, TestSize.Level1)
5559 {
5560 CALL_TEST_DEBUG;
5561 InputWindowsManager inputWindowsMgr;
5562 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5563 ASSERT_NE(pointerEvent, nullptr);
5564 DisplayInfo displayInfo;
5565 WindowGroupInfo winGroupInfo;
5566 WindowInfo winInfo;
5567 PointerEvent::PointerItem item;
5568 displayInfo.id = 100;
5569 displayInfo.x = 500;
5570 displayInfo.y = 500;
5571 pointerEvent->SetTargetDisplayId(-1);
5572 pointerEvent->SetPointerId(150);
5573 item.SetPointerId(150);
5574 item.SetDisplayXPos(500);
5575 item.SetDisplayYPos(500);
5576 item.SetTargetWindowId(-1);
5577 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5578 pointerEvent->AddPointerItem(item);
5579 pointerEvent->SetZOrder(15.5f);
5580 pointerEvent->bitwise_ = 0x00000000;
5581 winInfo.flags = 0;
5582 winInfo.pixelMap = nullptr;
5583 winInfo.windowInputType = WindowInputType::TRANSMIT_ALL;
5584 winInfo.defaultHotAreas = { { 300, 300, 1000, 1000 } };
5585 winInfo.id = -1;
5586 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5587 winGroupInfo.windowsInfo.push_back(winInfo);
5588 winInfo.windowInputType = WindowInputType::NORMAL;
5589 winGroupInfo.windowsInfo.push_back(winInfo);
5590 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5591 inputWindowsMgr.extraData_.appended = false;
5592 inputWindowsMgr.displayGroupInfo_.displaysInfo.push_back(displayInfo);
5593 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5594 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5595 }
5596
5597 /**
5598 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_010
5599 * @tc.desc: Test UpdateTouchScreenTarget
5600 * @tc.type: FUNC
5601 * @tc.require:
5602 */
5603 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_010, TestSize.Level1)
5604 {
5605 CALL_TEST_DEBUG;
5606 InputWindowsManager inputWindowsMgr;
5607 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5608 ASSERT_NE(pointerEvent, nullptr);
5609 DisplayInfo displayInfo;
5610 WindowGroupInfo winGroupInfo;
5611 WindowInfo winInfo;
5612 PointerEvent::PointerItem item;
5613 displayInfo.id = 100;
5614 displayInfo.x = 500;
5615 displayInfo.y = 500;
5616 pointerEvent->SetTargetDisplayId(-1);
5617 pointerEvent->SetPointerId(150);
5618 item.SetPointerId(150);
5619 item.SetDisplayXPos(500);
5620 item.SetDisplayYPos(500);
5621 item.SetTargetWindowId(-1);
5622 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5623 pointerEvent->AddPointerItem(item);
5624 pointerEvent->SetZOrder(15.5f);
5625 pointerEvent->bitwise_ = 0x00000000;
5626 winInfo.flags = 0;
5627 winInfo.pixelMap = nullptr;
5628 winInfo.windowInputType = WindowInputType::NORMAL;
5629 winInfo.defaultHotAreas = { { 300, 300, 1000, 1000 } };
5630 winInfo.id = -1;
5631 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5632 winGroupInfo.windowsInfo.push_back(winInfo);
5633 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5634 inputWindowsMgr.extraData_.appended = false;
5635 inputWindowsMgr.displayGroupInfo_.displaysInfo.push_back(displayInfo);
5636 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5637 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5638 }
5639
5640 /**
5641 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_011
5642 * @tc.desc: Test UpdateTouchScreenTarget
5643 * @tc.type: FUNC
5644 * @tc.require:
5645 */
5646 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_011, TestSize.Level1)
5647 {
5648 CALL_TEST_DEBUG;
5649 InputWindowsManager inputWindowsMgr;
5650 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5651 ASSERT_NE(pointerEvent, nullptr);
5652 inputWindowsMgr.lastTouchEventOnBackGesture_ = PointerEvent::Create();
5653 ASSERT_NE(inputWindowsMgr.lastTouchEventOnBackGesture_, nullptr);
5654 DisplayInfo displayInfo;
5655 WindowGroupInfo winGroupInfo;
5656 WindowInfo winInfo;
5657 PointerEvent::PointerItem item;
5658 displayInfo.id = 100;
5659 displayInfo.x = 500;
5660 displayInfo.y = 500;
5661 pointerEvent->SetTargetDisplayId(-1);
5662 pointerEvent->SetPointerId(150);
5663 item.SetPointerId(150);
5664 item.SetDisplayXPos(500);
5665 item.SetDisplayYPos(500);
5666 item.SetTargetWindowId(200);
5667 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5668 pointerEvent->AddPointerItem(item);
5669 pointerEvent->SetZOrder(15.5f);
5670 pointerEvent->bitwise_ = 0x00000000;
5671 winInfo.flags = 0;
5672 winInfo.pixelMap = nullptr;
5673 winInfo.id = 200;
5674 winInfo.defaultHotAreas = { { 300, 300, 1000, 1000 } };
5675 winInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
5676 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5677 winGroupInfo.windowsInfo.push_back(winInfo);
5678 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
5679 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
5680 inputWindowsMgr.extraData_.appended = false;
5681 inputWindowsMgr.displayGroupInfo_.displaysInfo.push_back(displayInfo);
5682 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5683 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5684 }
5685
5686 /**
5687 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_012
5688 * @tc.desc: Test UpdateTouchScreenTarget
5689 * @tc.type: FUNC
5690 * @tc.require:
5691 */
5692 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_012, TestSize.Level1)
5693 {
5694 CALL_TEST_DEBUG;
5695 InputWindowsManager inputWindowsMgr;
5696 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5697 ASSERT_NE(pointerEvent, nullptr);
5698 inputWindowsMgr.lastTouchEventOnBackGesture_ = PointerEvent::Create();
5699 ASSERT_NE(inputWindowsMgr.lastTouchEventOnBackGesture_, nullptr);
5700 DisplayInfo displayInfo;
5701 WindowGroupInfo winGroupInfo;
5702 WindowInfo winInfo;
5703 PointerEvent::PointerItem item;
5704 displayInfo.id = 100;
5705 displayInfo.x = 500;
5706 displayInfo.y = 500;
5707 pointerEvent->SetTargetDisplayId(-1);
5708 pointerEvent->SetPointerId(150);
5709 item.SetPointerId(150);
5710 item.SetDisplayXPos(500);
5711 item.SetDisplayYPos(500);
5712 item.SetTargetWindowId(200);
5713 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5714 pointerEvent->AddPointerItem(item);
5715 pointerEvent->SetZOrder(15.5f);
5716 pointerEvent->bitwise_ = 0x00000000;
5717 winInfo.flags = 0;
5718 winInfo.pixelMap = nullptr;
5719 winInfo.id = 200;
5720 winInfo.defaultHotAreas = { { 300, 300, 1000, 1000 } };
5721 winInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
5722 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5723 winGroupInfo.windowsInfo.push_back(winInfo);
5724 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5725 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
5726 inputWindowsMgr.extraData_.appended = false;
5727 inputWindowsMgr.displayGroupInfo_.displaysInfo.push_back(displayInfo);
5728 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5729 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5730 }
5731
5732 /**
5733 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_013
5734 * @tc.desc: Test UpdateTouchScreenTarget
5735 * @tc.type: FUNC
5736 * @tc.require:
5737 */
5738 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_013, TestSize.Level1)
5739 {
5740 CALL_TEST_DEBUG;
5741 InputWindowsManager inputWindowsMgr;
5742 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5743 ASSERT_NE(pointerEvent, nullptr);
5744 inputWindowsMgr.lastTouchEventOnBackGesture_ = PointerEvent::Create();
5745 ASSERT_NE(inputWindowsMgr.lastTouchEventOnBackGesture_, nullptr);
5746 DisplayInfo displayInfo;
5747 WindowGroupInfo winGroupInfo;
5748 WindowInfo winInfo;
5749 PointerEvent::PointerItem item;
5750 displayInfo.id = 100;
5751 displayInfo.x = 500;
5752 displayInfo.y = 500;
5753 pointerEvent->SetTargetDisplayId(-1);
5754 pointerEvent->SetPointerId(150);
5755 item.SetPointerId(150);
5756 item.SetDisplayXPos(500);
5757 item.SetDisplayYPos(500);
5758 item.SetTargetWindowId(200);
5759 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5760 pointerEvent->AddPointerItem(item);
5761 pointerEvent->SetZOrder(15.5f);
5762 pointerEvent->bitwise_ = 0x00000000;
5763 winInfo.flags = 0;
5764 winInfo.pixelMap = nullptr;
5765 winInfo.id = 200;
5766 winInfo.defaultHotAreas = { { 300, 300, 1000, 1000 } };
5767 winInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
5768 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5769 winGroupInfo.windowsInfo.push_back(winInfo);
5770 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5771 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
5772 inputWindowsMgr.extraData_.appended = false;
5773 inputWindowsMgr.displayGroupInfo_.displaysInfo.push_back(displayInfo);
5774 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5775 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5776 }
5777
5778 /**
5779 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_014
5780 * @tc.desc: Test UpdateTouchScreenTarget
5781 * @tc.type: FUNC
5782 * @tc.require:
5783 */
5784 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_014, TestSize.Level1)
5785 {
5786 CALL_TEST_DEBUG;
5787 InputWindowsManager inputWindowsMgr;
5788 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5789 ASSERT_NE(pointerEvent, nullptr);
5790 inputWindowsMgr.lastTouchEventOnBackGesture_ = PointerEvent::Create();
5791 ASSERT_NE(inputWindowsMgr.lastTouchEventOnBackGesture_, nullptr);
5792 DisplayInfo displayInfo;
5793 WindowGroupInfo winGroupInfo;
5794 WindowInfo winInfo;
5795 PointerEvent::PointerItem item;
5796 displayInfo.id = 100;
5797 displayInfo.x = 500;
5798 displayInfo.y = 500;
5799 pointerEvent->SetTargetDisplayId(-1);
5800 pointerEvent->SetPointerId(150);
5801 item.SetPointerId(150);
5802 item.SetDisplayXPos(500);
5803 item.SetDisplayYPos(500);
5804 item.SetTargetWindowId(200);
5805 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5806 pointerEvent->AddPointerItem(item);
5807 pointerEvent->SetZOrder(15.5f);
5808 pointerEvent->bitwise_ = 0x00000000;
5809 winInfo.flags = 0;
5810 winInfo.pixelMap = nullptr;
5811 winInfo.id = 200;
5812 winInfo.defaultHotAreas = { { 300, 300, 1000, 1000 } };
5813 winInfo.windowInputType = WindowInputType::NORMAL;
5814 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5815 winGroupInfo.windowsInfo.push_back(winInfo);
5816 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5817 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
5818 inputWindowsMgr.extraData_.appended = false;
5819 inputWindowsMgr.displayGroupInfo_.displaysInfo.push_back(displayInfo);
5820 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5821 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5822 }
5823
5824 /**
5825 * @tc.name: InputWindowsManagerTest_UpdateTarget
5826 * @tc.desc: Test UpdateTouchScreenTarget
5827 * @tc.type: FUNC
5828 * @tc.require:
5829 */
5830 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTarget, TestSize.Level1)
5831 {
5832 CALL_TEST_DEBUG;
5833 InputWindowsManager inputWindowsMgr;
5834 std::shared_ptr<KeyEvent> keyEvent = nullptr;
5835 inputWindowsMgr.isParseConfig_ = true;
5836 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTarget(keyEvent));
5837 }
5838
5839 /**
5840 * @tc.name: InputWindowsManagerTest_HandleKeyEventWindowId
5841 * @tc.desc: Test HandleKeyEventWindowId
5842 * @tc.type: FUNC
5843 * @tc.require:
5844 */
5845 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandleKeyEventWindowId, TestSize.Level1)
5846 {
5847 CALL_TEST_DEBUG;
5848 InputWindowsManager inputWindowsMgr;
5849 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
5850 ASSERT_NE(keyEvent, nullptr);
5851 WindowInfo winInfo;
5852 keyEvent->SetTargetDisplayId(-1);
5853 inputWindowsMgr.displayGroupInfo_.focusWindowId = 50;
5854 winInfo.id = 50;
5855 winInfo.agentWindowId = 100;
5856 winInfo.privacyMode = SecureFlag::PRIVACY_MODE;
5857 inputWindowsMgr.displayGroupInfo_.windowsInfo.push_back(winInfo);
5858 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.HandleKeyEventWindowId(keyEvent));
5859
5860 inputWindowsMgr.displayGroupInfo_.windowsInfo[0].privacyMode = SecureFlag::DEFAULT_MODE;
5861 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.HandleKeyEventWindowId(keyEvent));
5862
5863 inputWindowsMgr.displayGroupInfo_.focusWindowId = 80;
5864 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.HandleKeyEventWindowId(keyEvent));
5865 }
5866
5867 /**
5868 * @tc.name: InputWindowsManagerTest_GetDisplayId
5869 * @tc.desc: Test GetDisplayId
5870 * @tc.type: FUNC
5871 * @tc.require:
5872 */
5873 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetDisplayId, TestSize.Level1)
5874 {
5875 CALL_TEST_DEBUG;
5876 InputWindowsManager inputWindowsMgr;
5877 std::shared_ptr<InputEvent> inputEvent = InputEvent::Create();
5878 ASSERT_NE(inputEvent, nullptr);
5879 DisplayInfo displayInfo;
5880 displayInfo.id = 100;
5881 inputEvent->SetTargetDisplayId(-1);
5882 inputWindowsMgr.displayGroupInfo_.displaysInfo.push_back(displayInfo);
5883 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetDisplayId(inputEvent));
5884 }
5885
5886 /**
5887 * @tc.name: InputWindowsManagerTest_GetClientFd_004
5888 * @tc.desc: Test GetClientFd
5889 * @tc.type: FUNC
5890 * @tc.require:
5891 */
5892 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetClientFd_004, TestSize.Level1)
5893 {
5894 CALL_TEST_DEBUG;
5895 InputWindowsManager inputWindowsMgr;
5896 int32_t windowId = 10;
5897 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5898 ASSERT_NE(pointerEvent, nullptr);
5899 WindowInfo winInfo;
5900 UDSServer udsServer;
5901 inputWindowsMgr.udsServer_ = &udsServer;
5902 pointerEvent->SetTargetDisplayId(-1);
5903 winInfo.id = 20;
5904 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5905 winInfo.id = 10;
5906 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5907 winInfo.pid = 50;
5908 winInfo.flags = 15;
5909 inputWindowsMgr.displayGroupInfo_.windowsInfo.push_back(winInfo);
5910 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetClientFd(pointerEvent, windowId));
5911 windowId = 100;
5912 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetClientFd(pointerEvent, windowId));
5913 }
5914
5915 /**
5916 * @tc.name: InputWindowsManagerTest_GetPidAndUpdateTarget
5917 * @tc.desc: Test GetPidAndUpdateTarget
5918 * @tc.type: FUNC
5919 * @tc.require:
5920 */
5921 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPidAndUpdateTarget, TestSize.Level1)
5922 {
5923 CALL_TEST_DEBUG;
5924 InputWindowsManager inputWindowsMgr;
5925 std::shared_ptr<KeyEvent> keyEvent = nullptr;
5926 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetPidAndUpdateTarget(keyEvent));
5927
5928 keyEvent = KeyEvent::Create();
5929 ASSERT_NE(keyEvent, nullptr);
5930 WindowInfo winInfo;
5931 winInfo.id = 10;
5932 winInfo.privacyUIFlag = true;
5933 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5934 keyEvent->SetTargetDisplayId(-1);
5935 inputWindowsMgr.displayGroupInfo_.focusWindowId = 10;
5936 inputWindowsMgr.displayGroupInfo_.windowsInfo.push_back(winInfo);
5937 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetPidAndUpdateTarget(keyEvent));
5938
5939 inputWindowsMgr.displayGroupInfo_.windowsInfo[0].uiExtentionWindowInfo[0].privacyUIFlag = false;
5940 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetPidAndUpdateTarget(keyEvent));
5941 }
5942
5943 /**
5944 * @tc.name: InputWindowsManagerTest_UpdateDisplayInfoExtIfNeed
5945 * @tc.desc: Test UpdateDisplayInfoExtIfNeed
5946 * @tc.type: FUNC
5947 * @tc.require:
5948 */
5949 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayInfoExtIfNeed, TestSize.Level1)
5950 {
5951 CALL_TEST_DEBUG;
5952 InputWindowsManager inputWindowsMgr;
5953 DisplayGroupInfo displayGroupInfo;
5954 bool needUpdateDisplayExt = true;
5955 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateDisplayInfoExtIfNeed(displayGroupInfo, needUpdateDisplayExt));
5956 }
5957
5958 /**
5959 * @tc.name: InputWindowsManagerTest_GetPointerStyle_002
5960 * @tc.desc: Test GetPointerStyle
5961 * @tc.type: FUNC
5962 * @tc.require:
5963 */
5964 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPointerStyle_002, TestSize.Level1)
5965 {
5966 CALL_TEST_DEBUG;
5967 InputWindowsManager inputWindowsMgr;
5968 int32_t pid = 100;
5969 int32_t windowId = 200;
5970 PointerStyle pointerStyle;
5971 bool isUiExtension = false;
5972 std::map<int32_t, PointerStyle> pointerStyleMap;
5973 pointerStyleMap.insert(std::make_pair(windowId, pointerStyle));
5974 inputWindowsMgr.pointerStyle_.insert(std::make_pair(pid, pointerStyleMap));
5975 EXPECT_EQ(inputWindowsMgr.GetPointerStyle(pid, windowId, pointerStyle, isUiExtension), RET_OK);
5976 }
5977
5978 /**
5979 * @tc.name: InputWindowsManagerTest_SelectPointerChangeArea
5980 * @tc.desc: Test SelectPointerChangeArea
5981 * @tc.type: FUNC
5982 * @tc.require:
5983 */
5984 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectPointerChangeArea, TestSize.Level1)
5985 {
5986 CALL_TEST_DEBUG;
5987 InputWindowsManager inputWindowsMgr;
5988 WindowInfo windowInfo;
5989 PointerStyle pointerStyle;
5990 int32_t logicalX = 300;
5991 int32_t logicalY = 300;
5992 std::vector<Rect> areas;
5993 Rect rect {
5994 .x = 100,
5995 .y = 100,
5996 .width = 1000,
5997 .height = 1000,
5998 };
5999 areas.push_back(rect);
6000 windowInfo.id = 100;
6001 inputWindowsMgr.windowsHotAreas_.insert(std::make_pair(100, areas));
6002 EXPECT_TRUE(inputWindowsMgr.SelectPointerChangeArea(windowInfo, pointerStyle, logicalX, logicalY));
6003 }
6004
6005 /**
6006 * @tc.name: InputWindowsManagerTest_DispatchUIExtentionPointerEvent
6007 * @tc.desc: Test DispatchUIExtentionPointerEvent
6008 * @tc.type: FUNC
6009 * @tc.require:
6010 */
6011 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DispatchUIExtentionPointerEvent, TestSize.Level1)
6012 {
6013 CALL_TEST_DEBUG;
6014 InputWindowsManager inputWindowsMgr;
6015 int32_t logicalX = 300;
6016 int32_t logicalY = 300;
6017 WindowInfo winInfo;
6018 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
6019 ASSERT_NE(pointerEvent, nullptr);
6020 pointerEvent->SetTargetDisplayId(-1);
6021 pointerEvent->SetTargetWindowId(100);
6022 winInfo.id = 10;
6023 winInfo.uiExtentionWindowInfo.push_back(winInfo);
6024 winInfo.id = 100;
6025 winInfo.agentWindowId = 200;
6026 winInfo.uiExtentionWindowInfo.push_back(winInfo);
6027 winInfo.id = 300;
6028 inputWindowsMgr.displayGroupInfo_.windowsInfo.push_back(winInfo);
6029 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.DispatchUIExtentionPointerEvent(logicalX, logicalY, pointerEvent));
6030 }
6031
6032 /**
6033 * @tc.name: InputWindowsManagerTest_PullEnterLeaveEvent
6034 * @tc.desc: Test PullEnterLeaveEvent
6035 * @tc.type: FUNC
6036 * @tc.require:
6037 */
6038 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PullEnterLeaveEvent, TestSize.Level1)
6039 {
6040 CALL_TEST_DEBUG;
6041 InputWindowsManager inputWindowsMgr;
6042 int32_t logicalX = 100;
6043 int32_t logicalY = 100;
6044 WindowInfo touchWindow;
6045 UDSServer udsServer;
6046 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
6047 ASSERT_NE(pointerEvent, nullptr);
6048 inputWindowsMgr.lastTouchEvent_ = PointerEvent::Create();
6049 ASSERT_NE(inputWindowsMgr.lastTouchEvent_, nullptr);
6050 PointerEvent::PointerItem lastPointerItem;
6051 touchWindow.id = 200;
6052 inputWindowsMgr.udsServer_ = &udsServer;
6053 inputWindowsMgr.lastTouchWindowInfo_.id = 100;
6054 inputWindowsMgr.lastTouchEvent_->SetPointerId(10);
6055 lastPointerItem.SetPointerId(10);
6056 inputWindowsMgr.lastTouchEvent_->AddPointerItem(lastPointerItem);
6057 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.PullEnterLeaveEvent(logicalX, logicalY, pointerEvent, &touchWindow));
6058 }
6059
6060 /**
6061 * @tc.name: InputWindowsManagerTest_UpdateCrownTarget
6062 * @tc.desc: Test UpdateCrownTarget
6063 * @tc.type: FUNC
6064 * @tc.require:
6065 */
6066 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateCrownTarget, TestSize.Level1)
6067 {
6068 CALL_TEST_DEBUG;
6069 InputWindowsManager inputWindowsMgr;
6070 WindowInfo winInfo;
6071 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
6072 ASSERT_NE(pointerEvent, nullptr);
6073 pointerEvent->SetTargetDisplayId(-1);
6074 inputWindowsMgr.displayGroupInfo_.focusWindowId = 100;
6075 winInfo.id = 200;
6076 inputWindowsMgr.displayGroupInfo_.windowsInfo.push_back(winInfo);
6077 winInfo.id = 100;
6078 winInfo.agentWindowId = 500;
6079 winInfo.privacyMode = SecureFlag::DEFAULT_MODE;
6080 inputWindowsMgr.displayGroupInfo_.windowsInfo.push_back(winInfo);
6081 EXPECT_EQ(inputWindowsMgr.UpdateCrownTarget(pointerEvent), RET_OK);
6082 }
6083
6084 /**
6085 * @tc.name: InputWindowsManagerTest_DrawTouchGraphic
6086 * @tc.desc: Test DrawTouchGraphic
6087 * @tc.type: FUNC
6088 * @tc.require:
6089 */
6090 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DrawTouchGraphic, TestSize.Level1)
6091 {
6092 CALL_TEST_DEBUG;
6093 InputWindowsManager inputWindowsMgr;
6094 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
6095 ASSERT_NE(pointerEvent, nullptr);
6096 inputWindowsMgr.knuckleDrawMgr_ = std::make_shared<KnuckleDrawingManager>();
6097 inputWindowsMgr.knuckleDynamicDrawingManager_ = std::make_shared<KnuckleDynamicDrawingManager>();
6098 pointerEvent->SetTargetDisplayId(100);
6099 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.DrawTouchGraphic(pointerEvent));
6100 }
6101
6102 /**
6103 * @tc.name: InputWindowsManagerTest_ReverseRotateScreen
6104 * @tc.desc: Test ReverseRotateScreen
6105 * @tc.type: FUNC
6106 * @tc.require:
6107 */
6108 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ReverseRotateScreen, TestSize.Level1)
6109 {
6110 CALL_TEST_DEBUG;
6111 InputWindowsManager inputWindowsMgr;
6112 DisplayInfo info;
6113 double x = 100.5;
6114 double y = 100.5;
6115 Coordinate2D cursorPos;
6116 info.direction = static_cast<Direction>(10);
6117 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.ReverseRotateScreen(info, x, y, cursorPos));
6118 }
6119
6120 /**
6121 * @tc.name: InputWindowsManagerTest_GetTargetWindowIds_003
6122 * @tc.desc: Test GetTargetWindowIds
6123 * @tc.type: FUNC
6124 * @tc.require:
6125 */
6126 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetTargetWindowIds_003, TestSize.Level1)
6127 {
6128 CALL_TEST_DEBUG;
6129 InputWindowsManager inputWindowsMgr;
6130 int32_t pointerItemId = 100;
6131 int32_t sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
6132 std::vector<int32_t> windowIds;
6133 inputWindowsMgr.targetMouseWinIds_.insert(std::make_pair(10, windowIds));
6134 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
6135 inputWindowsMgr.targetMouseWinIds_.insert(std::make_pair(pointerItemId, windowIds));
6136 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
6137 sourceType = PointerEvent::PointerEvent::SOURCE_TYPE_UNKNOWN;
6138 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
6139 }
6140
6141 /**
6142 * @tc.name: InputWindowsManagerTest_SetPrivacyModeFlag
6143 * @tc.desc: Test SetPrivacyModeFlag
6144 * @tc.type: FUNC
6145 * @tc.require:
6146 */
6147 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetPrivacyModeFlag, TestSize.Level1)
6148 {
6149 CALL_TEST_DEBUG;
6150 InputWindowsManager inputWindowsMgr;
6151 SecureFlag privacyMode = SecureFlag::PRIVACY_MODE;
6152 std::shared_ptr<InputEvent> event = InputEvent::Create();
6153 ASSERT_NE(event, nullptr);
6154 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SetPrivacyModeFlag(privacyMode, event));
6155 }
6156
6157 /**
6158 * @tc.name: InputWindowsManagerTest_ReverseXY_001
6159 * @tc.desc: Test ReverseXY
6160 * @tc.type: FUNC
6161 * @tc.require:
6162 */
6163 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ReverseXY_001, TestSize.Level1)
6164 {
6165 CALL_TEST_DEBUG;
6166 InputWindowsManager inputWindowsMgr;
6167 int32_t x = 100;
6168 int32_t y = 100;
6169 DisplayInfo displayInfo;
6170 displayInfo.direction = static_cast<Direction>(-1);
6171 inputWindowsMgr.displayGroupInfo_.displaysInfo.push_back(displayInfo);
6172 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.ReverseXY(x, y));
6173 inputWindowsMgr.displayGroupInfo_.displaysInfo[0].direction = static_cast<Direction>(10);
6174 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.ReverseXY(x, y));
6175 }
6176
6177 /**
6178 * @tc.name: InputWindowsManagerTest_SendCancelEventWhenLock_002
6179 * @tc.desc: Test SendCancelEventWhenLock
6180 * @tc.type: FUNC
6181 * @tc.require:
6182 */
6183 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SendCancelEventWhenLock_002, TestSize.Level1)
6184 {
6185 CALL_TEST_DEBUG;
6186 InputWindowsManager inputWindowsMgr;
6187 inputWindowsMgr.lastTouchEventOnBackGesture_ = PointerEvent::Create();
6188 ASSERT_NE(inputWindowsMgr.lastTouchEventOnBackGesture_, nullptr);
6189 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
6190 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
6191 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
6192 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
6193 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
6194 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
6195 }
6196
6197 /**
6198 * @tc.name: InputWindowsManagerTest_DispatchPointerCancel
6199 * @tc.desc: Test DispatchPointerCancel
6200 * @tc.type: FUNC
6201 * @tc.require:
6202 */
6203 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DispatchPointerCancel, TestSize.Level1)
6204 {
6205 CALL_TEST_DEBUG;
6206 InputWindowsManager inputWindowsMgr;
6207 int32_t displayId = -1;
6208 WindowInfo winInfo;
6209 inputWindowsMgr.mouseDownInfo_.id = -1;
6210 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.DispatchPointerCancel(displayId));
6211 inputWindowsMgr.mouseDownInfo_.id = 10;
6212 inputWindowsMgr.extraData_.appended = true;
6213 inputWindowsMgr.extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
6214 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.DispatchPointerCancel(displayId));
6215 inputWindowsMgr.lastPointerEvent_ = nullptr;
6216 inputWindowsMgr.extraData_.appended = false;
6217 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.DispatchPointerCancel(displayId));
6218 inputWindowsMgr.extraData_.appended = true;
6219 inputWindowsMgr.extraData_.sourceType = PointerEvent::SOURCE_TYPE_UNKNOWN;
6220 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.DispatchPointerCancel(displayId));
6221 inputWindowsMgr.lastPointerEvent_ = PointerEvent::Create();
6222 ASSERT_NE(inputWindowsMgr.lastPointerEvent_, nullptr);
6223 winInfo.id = 10;
6224 inputWindowsMgr.displayGroupInfo_.windowsInfo.push_back(winInfo);
6225 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.DispatchPointerCancel(displayId));
6226 inputWindowsMgr.displayGroupInfo_.windowsInfo.clear();
6227 winInfo.id = 100;
6228 inputWindowsMgr.displayGroupInfo_.windowsInfo.push_back(winInfo);
6229 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.DispatchPointerCancel(displayId));
6230 }
6231
6232 /**
6233 * @tc.name: InputWindowsManagerTest_GetPidByWindowId
6234 * @tc.desc: Test GetPidByWindowId
6235 * @tc.type: FUNC
6236 * @tc.require:
6237 */
6238 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPidByWindowId, TestSize.Level1)
6239 {
6240 CALL_TEST_DEBUG;
6241 InputWindowsManager inputWindowsMgr;
6242 int32_t id = 100;
6243 WindowInfo winInfo;
6244 winInfo.id = 100;
6245 winInfo.pid = 150;
6246 inputWindowsMgr.displayGroupInfo_.windowsInfo.push_back(winInfo);
6247 EXPECT_EQ(inputWindowsMgr.GetPidByWindowId(id), winInfo.pid);
6248 id = 300;
6249 EXPECT_EQ(inputWindowsMgr.GetPidByWindowId(id), RET_ERR);
6250 }
6251
6252 /**
6253 * @tc.name: InputWindowsManagerTest_SetPixelMapData
6254 * @tc.desc: Test SetPixelMapData
6255 * @tc.type: FUNC
6256 * @tc.require:
6257 */
6258 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetPixelMapData, TestSize.Level1)
6259 {
6260 CALL_TEST_DEBUG;
6261 InputWindowsManager inputWindowsMgr;
6262 int32_t infoId = -1;
6263 void *pixelMap = nullptr;
6264 EXPECT_EQ(inputWindowsMgr.SetPixelMapData(infoId, pixelMap), ERR_INVALID_VALUE);
6265 infoId = 100;
6266 EXPECT_EQ(inputWindowsMgr.SetPixelMapData(infoId, pixelMap), ERR_INVALID_VALUE);
6267 std::shared_ptr<Media::PixelMap> sharedPixelMap = CreatePixelMap(MIDDLE_PIXEL_MAP_WIDTH, MIDDLE_PIXEL_MAP_HEIGHT);
6268 ASSERT_NE(sharedPixelMap, nullptr);
6269 EXPECT_EQ(inputWindowsMgr.SetPixelMapData(infoId, (void *)sharedPixelMap.get()), RET_OK);
6270 }
6271
6272 #ifdef OHOS_BUILD_ENABLE_ANCO
6273 /**
6274 * @tc.name: InputWindowsManagerTest_IsKnuckleOnAncoWindow
6275 * @tc.desc: Test IsKnuckleOnAncoWindow
6276 * @tc.type: FUNC
6277 * @tc.require:
6278 */
6279 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsKnuckleOnAncoWindow, TestSize.Level1)
6280 {
6281 CALL_TEST_DEBUG;
6282 InputWindowsManager inputWindowsMgr;
6283 WindowInfo winInfo;
6284 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
6285 ASSERT_NE(pointerEvent, nullptr);
6286 PointerEvent::PointerItem item;
6287 item.SetPointerId(10);
6288 item.SetToolType(PointerEvent::TOOL_TYPE_KNUCKLE);
6289 pointerEvent->SetPointerId(0);
6290 pointerEvent->AddPointerItem(item);
6291 EXPECT_FALSE(inputWindowsMgr.IsKnuckleOnAncoWindow(pointerEvent));
6292 pointerEvent->SetPointerId(10);
6293 EXPECT_FALSE(inputWindowsMgr.IsKnuckleOnAncoWindow(pointerEvent));
6294 item.SetToolType(PointerEvent::TOOL_TYPE_MOUSE);
6295 pointerEvent->UpdatePointerItem(10, item);
6296 pointerEvent->SetTargetDisplayId(-1);
6297 winInfo.id = 50;
6298 inputWindowsMgr.displayGroupInfo_.focusWindowId = 100;
6299 inputWindowsMgr.displayGroupInfo_.windowsInfo.push_back(winInfo);
6300 EXPECT_FALSE(inputWindowsMgr.IsKnuckleOnAncoWindow(pointerEvent));
6301 inputWindowsMgr.displayGroupInfo_.focusWindowId = 50;
6302 EXPECT_FALSE(inputWindowsMgr.IsKnuckleOnAncoWindow(pointerEvent));
6303 }
6304 #endif // OHOS_BUILD_ENABLE_ANCO
6305 } // namespace MMI
6306 } // namespace OHOS
6307