1 /*
2 * Copyright (c) 2021-2025 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 <gmock/gmock.h>
19
20 #include "cursor_drawing_component.h"
21 #include "event_filter_handler.h"
22 #include "fingersense_wrapper.h"
23 #include "i_pointer_drawing_manager.h"
24 #include "input_device_manager.h"
25 #include "input_event_handler.h"
26 #include "input_windows_manager.h"
27 #include "mmi_log.h"
28 #include "mock_input_windows_manager.h"
29 #include "pointer_drawing_manager.h"
30 #include "proto.h"
31 #include "scene_board_judgement.h"
32 #include "struct_multimodal.h"
33 #include "uds_server.h"
34 #include "old_display_info.h"
35
36 #undef MMI_LOG_TAG
37 #define MMI_LOG_TAG "InputWindowsManagerTest"
38
39 namespace OHOS {
40 namespace MMI {
41 using namespace testing;
42 using namespace testing::ext;
43 namespace {
44 InputWindowsManager *g_instance;
45 constexpr uint32_t DEFAULT_ICON_COLOR {0xFF};
46 constexpr int32_t MAX_PIXEL_MAP_WIDTH {600};
47 constexpr int32_t MAX_PIXEL_MAP_HEIGHT {600};
48 constexpr int32_t INT32_BYTE {4};
49 constexpr int32_t NUMBER_TWO {2};
50 #ifdef OHOS_BUILD_ENABLE_VKEYBOARD
51 constexpr uint32_t WINDOW_NAME_TYPE_SCREENSHOT {1};
52 constexpr float SCREEN_CAPTURE_WINDOW_ZORDER {8000.0};
53 constexpr uint32_t CAST_WINDOW_TYPE {2106};
54 constexpr uint32_t GUIDE_WINDOW_TYPE {2500};
55 constexpr uint32_t TEST_WINDOW_START {-100};
56 constexpr uint32_t TEST_WINDOW_END {100000};
57 #define SCREEN_RECORD_WINDOW_WIDTH 400
58 #define SCREEN_RECORD_WINDOW_HEIGHT 200
59 #endif // OHOS_BUILD_ENABLE_VKEYBOARD
60 } // namespace
61
62 #ifdef WIN_MGR
63 #undef WIN_MGR
64 #endif
65 #define WIN_MGR g_instance
66
67 class InputWindowsManagerTest : public testing::Test {
68 public:
69 static void SetUpTestCase(void);
TearDownTestCase(void)70 static void TearDownTestCase(void) {};
71 static std::shared_ptr<Media::PixelMap> CreatePixelMap(int32_t width, int32_t height);
72 static SessionPtr CreateSessionPtr();
SetUp(void)73 void SetUp(void)
74 {
75 // 创建displayGroupInfo_
76 OLD::DisplayGroupInfo displayGroupInfo;
77 displayGroupInfo.focusWindowId = 1;
78 uint32_t num = 1;
79 for (uint32_t i = 0; i < num; i++) {
80 WindowInfo info;
81 info.id = 1;
82 info.pid = 1;
83 info.uid = 1;
84 info.area = {1, 1, 1, 1};
85 info.defaultHotAreas = {info.area};
86 info.pointerHotAreas = {info.area};
87 info.agentWindowId = 1;
88 info.flags = 1;
89 info.transform = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};
90 info.pointerChangeAreas = {1, 2, 1, 2, 1, 2, 1, 2, 1};
91 displayGroupInfo.windowsInfo.push_back(info);
92 }
93 for (uint32_t i = 0; i < num; i++) {
94 OLD::DisplayInfo info;
95 info.id = 1;
96 info.x = 1;
97 info.y = 1;
98 info.width = NUMBER_TWO;
99 info.height = NUMBER_TWO;
100 info.dpi = 240;
101 info.name = "pp";
102 info.uniq = "pp";
103 info.direction = DIRECTION0;
104 displayGroupInfo.displaysInfo.push_back(info);
105 }
106 WIN_MGR->UpdateDisplayInfo(displayGroupInfo);
107 preHoverScrollState_ = WIN_MGR->GetHoverScrollState();
108 } // void SetUp(void)
109
TearDown(void)110 void TearDown(void)
111 {
112 WIN_MGR->SetHoverScrollState(preHoverScrollState_);
113 }
114
115 private:
116 bool preHoverScrollState_ {true};
117 };
118
SetUpTestCase(void)119 void InputWindowsManagerTest::SetUpTestCase(void)
120 {
121 g_instance = static_cast<InputWindowsManager *>(IInputWindowsManager::GetInstance().get());
122 }
123
FingersenseWrapperTest(int32_t num)124 void FingersenseWrapperTest(int32_t num) {}
125
CreatePixelMap(int32_t width,int32_t height)126 std::shared_ptr<Media::PixelMap> InputWindowsManagerTest::CreatePixelMap(int32_t width, int32_t height)
127 {
128 CALL_DEBUG_ENTER;
129 if (width <= 0 || width > MAX_PIXEL_MAP_WIDTH || height <= 0 || height > MAX_PIXEL_MAP_HEIGHT) {
130 return nullptr;
131 }
132 Media::InitializationOptions opts;
133 opts.size.height = height;
134 opts.size.width = width;
135 opts.pixelFormat = Media::PixelFormat::BGRA_8888;
136 opts.alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_OPAQUE;
137 opts.scaleMode = Media::ScaleMode::FIT_TARGET_SIZE;
138
139 int32_t colorLen = width * height;
140 uint32_t *pixelColors = new (std::nothrow) uint32_t[colorLen];
141 CHKPP(pixelColors);
142 int32_t colorByteCount = colorLen * INT32_BYTE;
143 errno_t ret = memset_s(pixelColors, colorByteCount, DEFAULT_ICON_COLOR, colorByteCount);
144 if (ret != EOK) {
145 delete[] pixelColors;
146 return nullptr;
147 }
148 std::shared_ptr<Media::PixelMap> pixelMap = Media::PixelMap::Create(pixelColors, colorLen, opts);
149 if (pixelMap == nullptr) {
150 delete[] pixelColors;
151 return nullptr;
152 }
153 delete[] pixelColors;
154 return pixelMap;
155 }
156
CreateSessionPtr()157 SessionPtr InputWindowsManagerTest::CreateSessionPtr()
158 {
159 CALL_DEBUG_ENTER;
160 std::string programName = "uds_sesion_test";
161 int32_t moduleType = 3;
162 int32_t fd = -1;
163 int32_t uidRoot = 0;
164 int32_t pid = 9;
165 return std::make_shared<UDSSession>(programName, moduleType, fd, uidRoot, pid);
166 }
167
168 /**
169 * @tc.name: InputWindowsManagerTest_GetClientFd_001
170 * @tc.desc: Test GetClientFd
171 * @tc.type: FUNC
172 * @tc.require:
173 */
174 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetClientFd_001, TestSize.Level1)
175 {
176 CALL_TEST_DEBUG;
177 auto pointerEvent = PointerEvent::Create();
178 UDSServer udsServer;
179 WIN_MGR->Init(udsServer);
180 int32_t idNames = -1;
181 ASSERT_EQ(WIN_MGR->GetClientFd(pointerEvent), idNames);
182 }
183
184 /**
185 * @tc.name: InputWindowsManagerTest_GetDisplayGroupInfo_001
186 * @tc.desc: Test GetDisplayGroupInfo
187 * @tc.type: FUNC
188 * @tc.require:
189 */
190 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetDisplayGroupInfo_001, TestSize.Level1)
191 {
192 CALL_TEST_DEBUG;
193 auto pointerEvent = PointerEvent::Create();
194 UDSServer udsServer;
195 WIN_MGR->Init(udsServer);
196 OLD::DisplayGroupInfo displayGroupInfo;
197 displayGroupInfo.focusWindowId = 1;
198 int32_t groupId = 1;
199 EXPECT_NO_FATAL_FAILURE(WIN_MGR->GetDisplayGroupInfo(groupId));
200 }
201
202 /**
203 * @tc.name: InputWindowsManagerTest_UpdateTarget_003
204 * @tc.desc: Test UpdateTarget
205 * @tc.type: FUNC
206 * @tc.require:
207 */
208 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTarget_003, TestSize.Level1)
209 {
210 CALL_TEST_DEBUG;
211 UDSServer udsServer;
212 WIN_MGR->Init(udsServer);
213 auto keyEvent = KeyEvent::Create();
214 ASSERT_NE(keyEvent, nullptr);
215 keyEvent->SetDeviceId(1);
216 keyEvent->SetTargetWindowId(1);
217 keyEvent->SetAgentWindowId(1);
218 EXPECT_NO_FATAL_FAILURE(WIN_MGR->UpdateTarget(keyEvent));
219 }
220
221 /**
222 * @tc.name: InputWindowsManagerTest_HandleKeyEventWindowId_003
223 * @tc.desc: Test HandleKeyEventWindowId
224 * @tc.type: FUNC
225 * @tc.require:
226 */
227 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandleKeyEventWindowId_001, TestSize.Level1)
228 {
229 CALL_TEST_DEBUG;
230 UDSServer udsServer;
231 WIN_MGR->Init(udsServer);
232 auto keyEvent = KeyEvent::Create();
233 ASSERT_NE(keyEvent, nullptr);
234 keyEvent->SetDeviceId(1);
235 keyEvent->SetTargetWindowId(1);
236 keyEvent->SetAgentWindowId(1);
237 EXPECT_NO_FATAL_FAILURE(WIN_MGR->HandleKeyEventWindowId(keyEvent));
238 }
239
240 /**
241 * @tc.name: InputWindowsManagerTest_UpdateWindow_002
242 * @tc.desc: Test UpdateWindow
243 * @tc.type: FUNC
244 * @tc.require:
245 */
246 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateWindow_002, TestSize.Level1)
247 {
248 CALL_TEST_DEBUG;
249 WindowInfo window;
250 window.id = 11;
251 window.pid = 1221;
252 window.uid = 1;
253 window.area = {1, 1, 1, 1};
254 window.defaultHotAreas = {window.area};
255 window.pointerHotAreas = {window.area};
256 window.pointerChangeAreas = {1, 2, 1, 2};
257 window.displayId = 0;
258 window.agentWindowId = 1;
259 window.flags = 1;
260 window.action = WINDOW_UPDATE_ACTION::UNKNOWN;
261 WIN_MGR->UpdateWindowInfo({0, 11, {window}});
262 ASSERT_EQ(WIN_MGR->GetWindowPid(11), -1);
263 window.groupId = 2;
264 EXPECT_NO_FATAL_FAILURE(WIN_MGR->GetWindowInfoVector(2));
265 }
266
267 /**
268 * @tc.name: InputWindowsManagerTest_UpdateTargetPointer_005
269 * @tc.desc: Test UpdateTargetPointer
270 * @tc.type: FUNC
271 * @tc.require:
272 */
273 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTargetPointer_005, TestSize.Level1)
274 {
275 CALL_TEST_DEBUG;
276 UDSServer udsServer;
277 WIN_MGR->Init(udsServer);
278 auto pointerEvent = PointerEvent::Create();
279 ASSERT_EQ(WIN_MGR->UpdateTargetPointer(pointerEvent), -1);
280 WIN_MGR->IsFoldable_ = true;
281 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
282 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
283 PointerEvent::PointerItem pointerItem;
284 pointerEvent->UpdatePointerItem(2, pointerItem);
285 WIN_MGR->cancelTouchStatus_ = true;
286 int32_t longAxis = 1U << 27U;
287 pointerItem.SetLongAxis(longAxis);
288 ASSERT_EQ(WIN_MGR->UpdateTargetPointer(pointerEvent), RET_ERR);
289 }
290
291 /**
292 * @tc.name: InputWindowsManagerTest_IsNeedRefreshLayer_006
293 * @tc.desc: Test IsNeedRefreshLayer
294 * @tc.type: FUNC
295 * @tc.require:
296 */
297 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsNeedRefreshLayer_006, TestSize.Level1)
298 {
299 CALL_TEST_DEBUG;
300 UDSServer udsServer;
301 WIN_MGR->Init(udsServer);
302 if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
303 ASSERT_EQ(WIN_MGR->IsNeedRefreshLayer(-2), true);
304 ASSERT_EQ(WIN_MGR->IsNeedRefreshLayer(-1), true);
305 ASSERT_EQ(WIN_MGR->IsNeedRefreshLayer(0), true);
306 ASSERT_EQ(WIN_MGR->IsNeedRefreshLayer(1), true);
307 ASSERT_EQ(WIN_MGR->IsNeedRefreshLayer(-2), true);
308 } else {
309 ASSERT_EQ(WIN_MGR->IsNeedRefreshLayer(-2), false);
310 ASSERT_EQ(WIN_MGR->IsNeedRefreshLayer(-1), false);
311 ASSERT_EQ(WIN_MGR->IsNeedRefreshLayer(0), false);
312 ASSERT_EQ(WIN_MGR->IsNeedRefreshLayer(1), false);
313 ASSERT_EQ(WIN_MGR->IsNeedRefreshLayer(-2), false);
314 }
315 }
316
317 /**
318 * @tc.name: InputWindowsManagerTest_SetMouseCaptureMode_008
319 * @tc.desc: Test SetMouseCaptureMode
320 * @tc.type: FUNC
321 * @tc.require:
322 */
323 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetMouseCaptureMode_008, TestSize.Level1)
324 {
325 CALL_TEST_DEBUG;
326 UDSServer udsServer;
327 WIN_MGR->Init(udsServer);
328 bool isCaptureMode = false;
329 ASSERT_EQ(WIN_MGR->SetMouseCaptureMode(-1, isCaptureMode), -1);
330 ASSERT_EQ(WIN_MGR->SetMouseCaptureMode(1, isCaptureMode), 0);
331 isCaptureMode = true;
332 ASSERT_EQ(WIN_MGR->SetMouseCaptureMode(1, isCaptureMode), 0);
333 }
334
335 /**
336 * @tc.name: InputWindowsManagerTest_DeviceStatusChanged_002
337 * @tc.desc: Test DeviceStatusChanged
338 * @tc.type: FUNC
339 * @tc.require:
340 */
341 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DeviceStatusChanged_002, TestSize.Level1)
342 {
343 CALL_TEST_DEBUG;
344 UDSServer udsServer;
345 WIN_MGR->Init(udsServer);
346 std::string name = "mouse";
347 std::string sysUid = "james";
348 std::string devStatus = "add";
349 EXPECT_NO_FATAL_FAILURE(WIN_MGR->DeviceStatusChanged(2, name, sysUid, devStatus));
350 devStatus = "remove";
351 EXPECT_NO_FATAL_FAILURE(WIN_MGR->DeviceStatusChanged(2, name, sysUid, devStatus));
352 }
353
354 /**
355 * @tc.name: InputWindowsManagerTest_SetDisplayBind_009
356 * @tc.desc: Test SetDisplayBind
357 * @tc.type: FUNC
358 * @tc.require:
359 */
360 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetDisplayBind_009, TestSize.Level1)
361 {
362 CALL_TEST_DEBUG;
363 UDSServer udsServer;
364 WIN_MGR->Init(udsServer);
365 std::string msg = "There is in InputWindowsManagerTest_GetDisplayIdNames_009";
366 ASSERT_EQ(WIN_MGR->SetDisplayBind(-1, 1, msg), -1);
367 }
368
369 /**
370 * @tc.name: InputWindowsManagerTest_SetDisplayBind_010
371 * @tc.desc: Test SetDisplayBind
372 * @tc.type: FUNC
373 * @tc.require:
374 */
375 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetDisplayBind_010, TestSize.Level1)
376 {
377 CALL_TEST_DEBUG;
378 UDSServer udsServer;
379 WIN_MGR->Init(udsServer);
380 std::string msg = "There is in InputWindowsManagerTest_GetDisplayIdNames_009";
381 //std::shared_ptr<BindInfos> infos_ = std::make_shared<BindInfos>();
382 int32_t deviceId = 2;
383 int32_t displayId = 3;
384 BindInfo infos_;
385 infos_.inputDeviceId_ = 3;
386 infos_.inputNodeName_ = 4;
387 infos_.inputDeviceName_ = 5;
388 infos_.displayId_ = 6;
389 infos_.displayName_= "abc";
390 ASSERT_EQ(WIN_MGR->SetDisplayBind(deviceId, displayId, msg), RET_ERR);
391 }
392
393 /**
394 * @tc.name: InputWindowsManagerTest_SetHoverScrollState_010
395 * @tc.desc: Test SetHoverScrollState
396 * @tc.type: FUNC
397 * @tc.require:
398 */
399 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetHoverScrollState_010, TestSize.Level1)
400 {
401 CALL_TEST_DEBUG;
402 ASSERT_TRUE(WIN_MGR->SetHoverScrollState(false) == RET_OK);
403 WIN_MGR->SetHoverScrollState(true);
404 ASSERT_TRUE(WIN_MGR->GetHoverScrollState());
405 }
406
407 /**
408 * @tc.name: InputWindowsManagerTest_GetHoverScrollState_011
409 * @tc.desc: Test GetHoverScrollState
410 * @tc.type: FUNC
411 * @tc.require:
412 */
413 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetHoverScrollState_011, TestSize.Level1)
414 {
415 CALL_TEST_DEBUG;
416 WIN_MGR->SetHoverScrollState(true);
417 ASSERT_TRUE(WIN_MGR->GetHoverScrollState());
418 }
419
420 /**
421 * @tc.name: InputWindowsManagerTest_InitMouseDownInfo_001
422 * @tc.desc: Test initializing mouse down information
423 * @tc.type: FUNC
424 * @tc.require:
425 */
426 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_InitMouseDownInfo_001, TestSize.Level1)
427 {
428 CALL_TEST_DEBUG;
429 WIN_MGR->InitMouseDownInfo();
430 EXPECT_EQ(WIN_MGR->mouseDownInfo_.id, -1);
431 EXPECT_EQ(WIN_MGR->mouseDownInfo_.pid, -1);
432 EXPECT_TRUE(WIN_MGR->mouseDownInfo_.defaultHotAreas.empty());
433 EXPECT_TRUE(WIN_MGR->mouseDownInfo_.pointerHotAreas.empty());
434 }
435
436 /**
437 * @tc.name: InputWindowsManagerTest_InitMouseDownInfo_002
438 * @tc.desc: Test initializing mouse down information
439 * @tc.type: FUNC
440 * @tc.require:
441 */
442 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_InitMouseDownInfo_002, TestSize.Level1)
443 {
444 CALL_TEST_DEBUG;
445 WIN_MGR->mouseDownInfo_.id = 1;
446 WIN_MGR->mouseDownInfo_.pid = 123;
447 WIN_MGR->mouseDownInfo_.defaultHotAreas.push_back({0, 0, 100, 100});
448 WIN_MGR->InitMouseDownInfo();
449 EXPECT_EQ(WIN_MGR->mouseDownInfo_.id, -1);
450 EXPECT_EQ(WIN_MGR->mouseDownInfo_.pid, -1);
451 EXPECT_TRUE(WIN_MGR->mouseDownInfo_.defaultHotAreas.empty());
452 EXPECT_TRUE(WIN_MGR->mouseDownInfo_.pointerHotAreas.empty());
453 }
454
455 /**
456 * @tc.name: InputWindowsManagerTest_GetWindowGroupInfoByDisplayId_001
457 * @tc.desc: Test getting window group information by display ID
458 * @tc.type: FUNC
459 * @tc.require:
460 */
461 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowGroupInfoByDisplayId_001, TestSize.Level1)
462 {
463 CALL_TEST_DEBUG;
464 int32_t displayId = -1;
465 const std::vector<WindowInfo> &windowGroupInfo = WIN_MGR->GetWindowGroupInfoByDisplayId(displayId);
466 EXPECT_EQ(windowGroupInfo.size(), 1);
467 }
468
469 /**
470 * @tc.name: InputWindowsManagerTest_GetDisplayId_001
471 * @tc.desc: Test getting the display ID
472 * @tc.type: FUNC
473 * @tc.require:
474 */
475 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetDisplayId_001, TestSize.Level1)
476 {
477 CALL_TEST_DEBUG;
478 int32_t expectedDisplayId = 1;
479 std::shared_ptr<InputEvent> inputEvent = InputEvent::Create();
480 EXPECT_NE(inputEvent, nullptr);
481 inputEvent->SetTargetDisplayId(expectedDisplayId);
482 int32_t ret = WIN_MGR->GetDisplayId(inputEvent);
483 EXPECT_EQ(ret, expectedDisplayId);
484 }
485
486 /**
487 * @tc.name: InputWindowsManagerTest_GetPidAndUpdateTarget_001
488 * @tc.desc: Test getting PID and updating the target
489 * @tc.type: FUNC
490 * @tc.require:
491 */
492 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPidAndUpdateTarget_001, TestSize.Level1)
493 {
494 CALL_TEST_DEBUG;
495 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
496 EXPECT_NE(keyEvent, nullptr);
497 int32_t targetDisplayId = 0;
498 keyEvent->SetTargetDisplayId(targetDisplayId);
499 ASSERT_NO_FATAL_FAILURE(WIN_MGR->GetPidAndUpdateTarget(keyEvent));
500 }
501
502 /**
503 * @tc.name: InputWindowsManagerTest_GetWindowPid_001
504 * @tc.desc: Test getting the process ID of a window
505 * @tc.type: FUNC
506 * @tc.require:
507 */
508 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowPid_001, TestSize.Level1)
509 {
510 CALL_TEST_DEBUG;
511 int32_t windowId = 100;
512 std::vector<WindowInfo> windowsInfo;
513 int32_t ret = WIN_MGR->GetWindowPid(windowId, windowsInfo);
514 EXPECT_EQ(ret, -1);
515 }
516
517 /**
518 * @tc.name: InputWindowsManagerTest_GetWindowPid_002
519 * @tc.desc: Test getting the process ID of a window
520 * @tc.type: FUNC
521 * @tc.require:
522 */
523 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowPid_002, TestSize.Level1)
524 {
525 CALL_TEST_DEBUG;
526 int32_t windowId = 5;
527 std::vector<WindowInfo> windowsInfo(3);
528
529 windowsInfo[0].id = 5;
530 windowsInfo[0].pid = 6;
531
532 windowsInfo[1].id = 12;
533 windowsInfo[1].pid = 13;
534
535 windowsInfo[2].id = 123;
536 windowsInfo[2].pid = 124;
537 int32_t ret = WIN_MGR->GetWindowPid(windowId, windowsInfo);
538 EXPECT_EQ(ret, 6);
539 }
540
541 /**
542 * @tc.name: InputWindowsManagerTest_CheckFocusWindowChange_001
543 * @tc.desc: Test checking focus window changes
544 * @tc.type: FUNC
545 * @tc.require:
546 */
547 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckFocusWindowChange_001, TestSize.Level1)
548 {
549 CALL_TEST_DEBUG;
550 OLD::DisplayGroupInfo displayGroupInfo;
551 displayGroupInfo.focusWindowId = 123;
552 ASSERT_NO_FATAL_FAILURE(WIN_MGR->CheckFocusWindowChange(displayGroupInfo));
553 }
554
555 /**
556 * @tc.name: InputWindowsManagerTest_CheckFocusWindowChange_002
557 * @tc.desc: Test checking focus window changes
558 * @tc.type: FUNC
559 * @tc.require:
560 */
561 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckFocusWindowChange_002, TestSize.Level1)
562 {
563 CALL_TEST_DEBUG;
564 OLD::DisplayGroupInfo displayGroupInfo;
565 OLD::DisplayGroupInfo displayGroupInfo_;
566 displayGroupInfo.focusWindowId = 123;
567 displayGroupInfo_.focusWindowId = 456;
568 ASSERT_NO_FATAL_FAILURE(WIN_MGR->CheckFocusWindowChange(displayGroupInfo));
569 ASSERT_NO_FATAL_FAILURE(WIN_MGR->CheckFocusWindowChange(displayGroupInfo_));
570 }
571
572 /**
573 * @tc.name: InputWindowsManagerTest_CheckZorderWindowChange_001
574 * @tc.desc: Test checking Z-order window changes
575 * @tc.type: FUNC
576 * @tc.require:
577 */
578 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckZorderWindowChange_001, TestSize.Level1)
579 {
580 CALL_TEST_DEBUG;
581 std::vector<WindowInfo> oldWindowsInfo = {{1}};
582 std::vector<WindowInfo> newWindowsInfo = {{2}};
583 ASSERT_NO_FATAL_FAILURE(WIN_MGR->CheckZorderWindowChange(oldWindowsInfo, newWindowsInfo));
584 }
585
586 /**
587 * @tc.name: InputWindowsManagerTest_UpdateDisplayIdAndName_001
588 * @tc.desc: Test updating display ID and name
589 * @tc.type: FUNC
590 * @tc.require:
591 */
592 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayIdAndName_001, TestSize.Level1)
593 {
594 CALL_TEST_DEBUG;
595 ASSERT_NO_FATAL_FAILURE(WIN_MGR->UpdateDisplayIdAndName());
596 assert(WIN_MGR->GetDisplayIdNames().size() == 2);
597 assert(WIN_MGR->IsDisplayAdd(1, "A"));
598 assert(WIN_MGR->IsDisplayAdd(2, "B"));
599 ASSERT_NO_FATAL_FAILURE(WIN_MGR->UpdateDisplayIdAndName());
600 assert(WIN_MGR->GetDisplayIdNames().size() == 2);
601 assert(WIN_MGR->IsDisplayAdd(1, "A"));
602 assert(WIN_MGR->IsDisplayAdd(3, "C"));
603 assert(!WIN_MGR->IsDisplayAdd(2, "B"));
604 }
605
606 /**
607 * @tc.name: InputWindowsManagerTest_GetDisplayBindInfo_001
608 * @tc.desc: Test getting display binding information
609 * @tc.type: FUNC
610 * @tc.require:
611 */
612 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetDisplayBindInfo_001, TestSize.Level1)
613 {
614 CALL_TEST_DEBUG;
615 int32_t deviceId = 1;
616 int32_t displayId = 2;
617 DisplayBindInfos infos;
618 std::string msg;
619 int32_t ret = WIN_MGR->SetDisplayBind(deviceId, displayId, msg);
620 EXPECT_EQ(ret, -1);
621 ret = WIN_MGR->GetDisplayBindInfo(infos);
622 EXPECT_EQ(ret, 0);
623 }
624
625 /**
626 * @tc.name: InputWindowsManagerTest_UpdateCaptureMode_001
627 * @tc.desc: Test updating capture mode
628 * @tc.type: FUNC
629 * @tc.require:
630 */
631 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateCaptureMode_001, TestSize.Level1)
632 {
633 CALL_TEST_DEBUG;
634 OLD::DisplayGroupInfo displayGroupInfo;
635 displayGroupInfo.focusWindowId = 123;
636 WIN_MGR->UpdateCaptureMode(displayGroupInfo);
637 EXPECT_FALSE(WIN_MGR->captureModeInfo_.isCaptureMode);
638 }
639
640 /**
641 * @tc.name: InputWindowsManagerTest_UpdateDisplayInfoByIncrementalInfo_001
642 * @tc.desc: Test updating display information by incremental info
643 * @tc.type: FUNC
644 * @tc.require:
645 */
646 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayInfoByIncrementalInfo_001, TestSize.Level1)
647 {
648 CALL_TEST_DEBUG;
649 OLD::DisplayGroupInfo displayGroupInfo;
650 displayGroupInfo.focusWindowId = 1;
651 WindowInfo window;
652 WIN_MGR->UpdateDisplayInfoByIncrementalInfo(window, displayGroupInfo);
653 EXPECT_EQ(displayGroupInfo.windowsInfo.size(), 0);
654 }
655
656 /**
657 * @tc.name: InputWindowsManagerTest_UpdateWindowsInfoPerDisplay_001
658 * @tc.desc: Test updating window information for each display
659 * @tc.type: FUNC
660 * @tc.require:
661 */
662 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateWindowsInfoPerDisplay_001, TestSize.Level1)
663 {
664 CALL_TEST_DEBUG;
665 OLD::DisplayGroupInfo displayGroupInfo;
666 displayGroupInfo.focusWindowId = 2;
667 WIN_MGR->UpdateWindowsInfoPerDisplay(displayGroupInfo);
668 WindowInfo window1 {1};
669 WindowInfo window2 {2};
670 displayGroupInfo.windowsInfo.push_back(window1);
671 displayGroupInfo.windowsInfo.push_back(window2);
672 WIN_MGR->UpdateDisplayInfo(displayGroupInfo);
673 ASSERT_EQ(displayGroupInfo.windowsInfo.size(), 2);
674 ASSERT_EQ(displayGroupInfo.windowsInfo[0].zOrder, 0);
675 ASSERT_EQ(displayGroupInfo.windowsInfo[1].zOrder, 0);
676 }
677
678 /**
679 * @tc.name: InputWindowsManagerTest_UpdateDisplayInfo_001
680 * @tc.desc: Test updating display information
681 * @tc.type: FUNC
682 * @tc.require:
683 */
684 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayInfo_001, TestSize.Level1)
685 {
686 CALL_TEST_DEBUG;
687 OLD::DisplayGroupInfo displayGroupInfo;
688 WindowInfo windowInfo1;
689 windowInfo1.zOrder = 1;
690 windowInfo1.action = WINDOW_UPDATE_ACTION::ADD_END;
691 WindowInfo windowInfo2;
692 windowInfo2.zOrder = 2;
693 windowInfo2.action = WINDOW_UPDATE_ACTION::ADD_END;
694 displayGroupInfo.windowsInfo.push_back(windowInfo1);
695 displayGroupInfo.windowsInfo.push_back(windowInfo2);
696 ASSERT_NO_FATAL_FAILURE(WIN_MGR->UpdateDisplayInfo(displayGroupInfo));
697 }
698
699 /**
700 * @tc.name: InputWindowsManagerTest_NeedUpdatePointDrawFlag_001
701 * @tc.desc: Test whether the point draw flag needs to be updated
702 * @tc.type: FUNC
703 * @tc.require:
704 */
705 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_NeedUpdatePointDrawFlag_001, TestSize.Level1)
706 {
707 CALL_TEST_DEBUG;
708 std::vector<WindowInfo> windows1;
709 EXPECT_FALSE(WIN_MGR->NeedUpdatePointDrawFlag(windows1));
710 std::vector<WindowInfo> windows2;
711 windows2.push_back(WindowInfo());
712 windows2.back().action = OHOS::MMI::WINDOW_UPDATE_ACTION::ADD;
713 EXPECT_FALSE(WIN_MGR->NeedUpdatePointDrawFlag(windows2));
714 std::vector<WindowInfo> windows3;
715 windows3.push_back(WindowInfo());
716 windows3.back().action = OHOS::MMI::WINDOW_UPDATE_ACTION::ADD_END;
717 EXPECT_TRUE(WIN_MGR->NeedUpdatePointDrawFlag(windows3));
718 }
719
720 /**
721 * @tc.name: InputWindowsManagerTest_DispatchPointer_001
722 * @tc.desc: Test dispatching pointer events
723 * @tc.type: FUNC
724 * @tc.require:
725 */
726 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DispatchPointer_001, TestSize.Level1)
727 {
728 CALL_TEST_DEBUG;
729 int32_t pointerAction = PointerEvent::POINTER_ACTION_ENTER_WINDOW;
730 ASSERT_NO_FATAL_FAILURE(WIN_MGR->DispatchPointer(pointerAction));
731 pointerAction = PointerEvent::POINTER_ACTION_LEAVE_WINDOW;
732 ASSERT_NO_FATAL_FAILURE(WIN_MGR->DispatchPointer(pointerAction));
733 pointerAction = PointerEvent::POINTER_ACTION_MOVE;
734 ASSERT_NO_FATAL_FAILURE(WIN_MGR->DispatchPointer(pointerAction));
735 }
736
737 /**
738 * @tc.name: InputWindowsManagerTest_NotifyPointerToWindow_001
739 * @tc.desc: Test notifying pointer events to window
740 * @tc.type: FUNC
741 * @tc.require:
742 */
743 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_NotifyPointerToWindow_001, TestSize.Level1)
744 {
745 CALL_TEST_DEBUG;
746 InputWindowsManager inputWindowsManager;
747 inputWindowsManager.lastPointerEvent_ = nullptr;
748 inputWindowsManager.NotifyPointerToWindow();
749 EXPECT_EQ(inputWindowsManager.lastWindowInfo_.id, -1);
750 }
751
752 /**
753 * @tc.name: InputWindowsManagerTest_PrintWindowInfo_001
754 * @tc.desc: Test printing window information
755 * @tc.type: FUNC
756 * @tc.require:
757 */
758 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintWindowInfo_001, TestSize.Level1)
759 {
760 CALL_TEST_DEBUG;
761 WindowInfo windowInfo1;
762 windowInfo1.id = 1;
763 windowInfo1.pid = 100;
764 windowInfo1.uid = 200;
765 windowInfo1.area = {0, 0, 800, 600};
766 windowInfo1.defaultHotAreas = {
767 {10, 10, 100, 100},
768 {200, 200, 50, 50 }
769 };
770 windowInfo1.pointerHotAreas = {
771 {30, 30, 150, 150},
772 {400, 400, 70, 70 }
773 };
774 windowInfo1.agentWindowId = 10;
775 windowInfo1.flags = 1;
776 windowInfo1.displayId = 3;
777 windowInfo1.zOrder = 4.0f;
778 windowInfo1.pointerChangeAreas = {10, 20, 30};
779 windowInfo1.transform = {1.0f, 2.0f, 3.0f};
780 WindowInfo windowInfo2;
781 windowInfo2.id = 2;
782 windowInfo2.pid = 101;
783 windowInfo2.uid = 201;
784 windowInfo2.area = {800, 600, 1024, 768};
785 windowInfo2.defaultHotAreas = {
786 {50, 50, 200, 200},
787 {600, 600, 100, 100}
788 };
789 windowInfo2.pointerHotAreas = {
790 {70, 70, 250, 250},
791 {800, 800, 120, 120}
792 };
793 windowInfo2.agentWindowId = 20;
794 windowInfo2.flags = 2;
795 windowInfo2.displayId = 4;
796 windowInfo2.zOrder = 5.0f;
797 windowInfo2.pointerChangeAreas = {40, 50, 60};
798 windowInfo2.transform = {4.0f, 5.0f, 6.0f};
799 std::vector<WindowInfo> windowsInfo = {windowInfo1, windowInfo2};
800 ASSERT_NO_FATAL_FAILURE(WIN_MGR->PrintWindowInfo(windowsInfo));
801 }
802
803 /**
804 * @tc.name: InputWindowsManagerTest_PrintWindowGroupInfo_001
805 * @tc.desc: Test printing window group information
806 * @tc.type: FUNC
807 * @tc.require:
808 */
809 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintWindowGroupInfo_001, TestSize.Level1)
810 {
811 CALL_TEST_DEBUG;
812 WindowGroupInfo testData;
813 testData.focusWindowId = 1;
814 testData.displayId = 2;
815 ASSERT_NO_FATAL_FAILURE(WIN_MGR->PrintWindowGroupInfo(testData));
816 }
817
818 /**
819 * @tc.name: InputWindowsManagerTest_PrintDisplayInfo_001
820 * @tc.desc: Test printing display information
821 * @tc.type: FUNC
822 * @tc.require:
823 */
824 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintDisplayInfo_001, TestSize.Level1)
825 {
826 CALL_TEST_DEBUG;
827 InputWindowsManager manager;
828 auto it = manager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
829 if (it != manager.displayGroupInfoMap_.end()) {
830 it->second.focusWindowId = 1;
831 it->second.windowsInfo.push_back(WindowInfo());
832 it->second.displaysInfo.push_back(OLD::DisplayInfo());
833 }
834 ASSERT_NO_FATAL_FAILURE(WIN_MGR->PrintDisplayGroupInfo(it->second));
835 }
836
837 /**
838 * @tc.name: InputWindowsManagerTest_GetPhysicalDisplay_001
839 * @tc.desc: Test getting physical display information
840 * @tc.type: FUNC
841 * @tc.require:
842 */
843 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPhysicalDisplay_001, TestSize.Level1)
844 {
845 CALL_TEST_DEBUG;
846 int32_t id = 1;
847 const OLD::DisplayInfo *displayInfo = WIN_MGR->GetPhysicalDisplay(id);
848 EXPECT_NE(displayInfo, nullptr);
849 EXPECT_EQ(displayInfo->id, id);
850 }
851
852 /**
853 * @tc.name: InputWindowsManagerTest_GetPhysicalDisplay_002
854 * @tc.desc: Test getting physical display information
855 * @tc.type: FUNC
856 * @tc.require:
857 */
858 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPhysicalDisplay_002, TestSize.Level1)
859 {
860 CALL_TEST_DEBUG;
861 int32_t id = -1;
862 const OLD::DisplayInfo *displayInfo = WIN_MGR->GetPhysicalDisplay(id);
863 EXPECT_EQ(displayInfo, nullptr);
864 }
865
866 /**
867 * @tc.name: InputWindowsManagerTest_FindPhysicalDisplayInfo_001
868 * @tc.desc: Test finding physical display information
869 * @tc.type: FUNC
870 * @tc.require:
871 */
872 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_FindPhysicalDisplayInfo_001, TestSize.Level1)
873 {
874 CALL_TEST_DEBUG;
875 InputWindowsManager manager;
876 ASSERT_EQ(manager.FindPhysicalDisplayInfo("test"), nullptr);
877 OLD::DisplayInfo info1;
878 info1.id = 123;
879 auto it = manager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
880 if (it != manager.displayGroupInfoMap_.end()) {
881 it->second.displaysInfo.push_back(info1);
882 }
883 ASSERT_NE(manager.FindPhysicalDisplayInfo("test"), nullptr);
884 OLD::DisplayInfo info2;
885 info2.id = 456;
886 it->second.displaysInfo.push_back(info2);
887 ASSERT_NE(manager.FindPhysicalDisplayInfo("test"), nullptr);
888 ASSERT_NE(manager.FindPhysicalDisplayInfo("not_matching"), nullptr);
889 ASSERT_NE(manager.FindPhysicalDisplayInfo("nonexistent"), nullptr);
890 }
891
892 /**
893 * @tc.name: InputWindowsManagerTest_RotateScreen_001
894 * @tc.desc: Test rotating the screen
895 * @tc.type: FUNC
896 * @tc.require:
897 */
898 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_RotateScreen_001, TestSize.Level1)
899 {
900 CALL_TEST_DEBUG;
901 OLD::DisplayInfo info;
902 PhysicalCoordinate coord;
903 info.direction = DIRECTION0;
904 coord.x = 10;
905 coord.y = 20;
906 WIN_MGR->RotateScreen(info, coord);
907 EXPECT_EQ(coord.x, 10);
908 EXPECT_EQ(coord.y, 20);
909 }
910
911 /**
912 * @tc.name: InputWindowsManagerTest_RotateScreen_002
913 * @tc.desc: Test rotating the screen
914 * @tc.type: FUNC
915 * @tc.require:
916 */
917 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_RotateScreen_002, TestSize.Level1)
918 {
919 CALL_TEST_DEBUG;
920 OLD::DisplayInfo info;
921 PhysicalCoordinate coord;
922 info.direction = DIRECTION90;
923 info.width = 800;
924 info.height = 600;
925 info.validWidth = info.width;
926 info.validHeight = info.height;
927 coord.x = 10;
928 coord.y = 20;
929 ASSERT_NO_FATAL_FAILURE(WIN_MGR->RotateScreen(info, coord));
930 }
931
932 /**
933 * @tc.name: InputWindowsManagerTest_RotateScreen_003
934 * @tc.desc: Test rotating the screen
935 * @tc.type: FUNC
936 * @tc.require:
937 */
938 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_RotateScreen_003, TestSize.Level1)
939 {
940 CALL_TEST_DEBUG;
941 OLD::DisplayInfo info;
942 PhysicalCoordinate coord;
943 info.direction = DIRECTION180;
944 info.width = 800;
945 info.height = 600;
946 info.validWidth = info.width;
947 info.validHeight = info.height;
948 coord.x = 10;
949 coord.y = 20;
950 ASSERT_NO_FATAL_FAILURE(WIN_MGR->RotateScreen(info, coord));
951 }
952
953 /**
954 * @tc.name: InputWindowsManagerTest_RotateScreen_004
955 * @tc.desc: Test rotating the screen
956 * @tc.type: FUNC
957 * @tc.require:
958 */
959 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_RotateScreen_004, TestSize.Level1)
960 {
961 CALL_TEST_DEBUG;
962 OLD::DisplayInfo info;
963 PhysicalCoordinate coord;
964 info.direction = DIRECTION270;
965 info.width = 800;
966 info.height = 600;
967 info.validWidth = info.width;
968 info.validHeight = info.height;
969 coord.x = 10;
970 coord.y = 20;
971 ASSERT_NO_FATAL_FAILURE(WIN_MGR->RotateScreen(info, coord));
972 }
973
974 /**
975 * @tc.name: InputWindowsManagerTest_IsNeedRefreshLayer_001
976 * @tc.desc: Test whether layer refresh is needed
977 * @tc.type: FUNC
978 * @tc.require:
979 */
980 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsNeedRefreshLayer_001, TestSize.Level1)
981 {
982 CALL_TEST_DEBUG;
983 EXPECT_FALSE(WIN_MGR->IsNeedRefreshLayer(1));
984 WIN_MGR->GetWindowInfo(0, 0)->id = 2;
985 EXPECT_FALSE(WIN_MGR->IsNeedRefreshLayer(GLOBAL_WINDOW_ID));
986 WIN_MGR->GetWindowInfo(0, 0)->id = 3;
987 EXPECT_FALSE(WIN_MGR->IsNeedRefreshLayer(1));
988 }
989
990 /**
991 * @tc.name: InputWindowsManagerTest_OnSessionLost_001
992 * @tc.desc: Test handling when session is lost
993 * @tc.type: FUNC
994 * @tc.require:
995 */
996 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_OnSessionLost_001, TestSize.Level1)
997 {
998 CALL_TEST_DEBUG;
999 SessionPtr session = std::shared_ptr<UDSSession>();
1000 WIN_MGR->OnSessionLost(session);
1001 OLD::DisplayGroupInfo displayGroupInfo;
1002 displayGroupInfo.focusWindowId = 1;
1003 ASSERT_NO_FATAL_FAILURE(WIN_MGR->GetDisplayGroupInfo());
1004 }
1005
1006 /**
1007 * @tc.name: InputWindowsManagerTest_UpdatePoinerStyle_001
1008 * @tc.desc: Test updating pointer style
1009 * @tc.type: FUNC
1010 * @tc.require:
1011 */
1012 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePoinerStyle_001, TestSize.Level1)
1013 {
1014 CALL_TEST_DEBUG;
1015 int32_t pid = 1;
1016 int32_t windowId = 2;
1017 PointerStyle pointerStyle;
1018 int32_t ret = WIN_MGR->UpdatePoinerStyle(pid, windowId, pointerStyle);
1019 EXPECT_EQ(ret, RET_OK);
1020 pid = -1;
1021 windowId = -2;
1022 ret = WIN_MGR->UpdatePoinerStyle(pid, windowId, pointerStyle);
1023 EXPECT_EQ(ret, 401);
1024 pid = 1;
1025 windowId = -2;
1026 ret = WIN_MGR->UpdatePoinerStyle(pid, windowId, pointerStyle);
1027 EXPECT_EQ(ret, RET_OK);
1028 }
1029
1030 /**
1031 * @tc.name: InputWindowsManagerTest_UpdateSceneBoardPointerStyle_001
1032 * @tc.desc: Test updating scene board pointer style
1033 * @tc.type: FUNC
1034 * @tc.require:
1035 */
1036 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateSceneBoardPointerStyle_001, TestSize.Level1)
1037 {
1038 CALL_TEST_DEBUG;
1039 int32_t pid = 1;
1040 int32_t windowId = 2;
1041 PointerStyle pointerStyle;
1042 pointerStyle.id = 3;
1043 int32_t ret = WIN_MGR->UpdateSceneBoardPointerStyle(pid, windowId, pointerStyle);
1044 EXPECT_EQ(ret, RET_OK);
1045 pid = -1;
1046 windowId = -2;
1047 ret = WIN_MGR->UpdateSceneBoardPointerStyle(pid, windowId, pointerStyle);
1048 EXPECT_EQ(ret, RET_OK);
1049 }
1050
1051 /**
1052 * @tc.name: InputWindowsManagerTest_SetPointerStyle_001
1053 * @tc.desc: Test setting pointer style
1054 * @tc.type: FUNC
1055 * @tc.require:
1056 */
1057 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetPointerStyle_001, TestSize.Level1)
1058 {
1059 CALL_TEST_DEBUG;
1060 int32_t pid = 1;
1061 int32_t windowId = GLOBAL_WINDOW_ID;
1062 PointerStyle pointerStyle;
1063 pointerStyle.id = 1;
1064 int32_t ret = WIN_MGR->SetPointerStyle(pid, windowId, pointerStyle);
1065 EXPECT_EQ(ret, RET_OK);
1066 EXPECT_EQ(WIN_MGR->globalStyle_.id, pointerStyle.id);
1067 pid = 1;
1068 windowId = 2;
1069 ret = WIN_MGR->SetPointerStyle(pid, windowId, pointerStyle);
1070 EXPECT_EQ(ret, WIN_MGR->UpdatePoinerStyle(pid, windowId, pointerStyle));
1071 pid = 1;
1072 windowId = 2;
1073 ret = WIN_MGR->SetPointerStyle(pid, windowId, pointerStyle);
1074 EXPECT_EQ(ret, WIN_MGR->UpdateSceneBoardPointerStyle(pid, windowId, pointerStyle));
1075 }
1076
1077 /**
1078 * @tc.name: InputWindowsManagerTest_ClearWindowPointerStyle_001
1079 * @tc.desc: Test clearing window pointer style
1080 * @tc.type: FUNC
1081 * @tc.require:
1082 */
1083 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ClearWindowPointerStyle_001, TestSize.Level1)
1084 {
1085 CALL_TEST_DEBUG;
1086 int32_t pid = 123;
1087 int32_t windowId = 678;
1088 int32_t ret = WIN_MGR->ClearWindowPointerStyle(pid, windowId);
1089 EXPECT_EQ(ret, RET_OK);
1090 }
1091
1092 /**
1093 * @tc.name: InputWindowsManagerTest_GetPointerStyle_001
1094 * @tc.desc: Test getting pointer style
1095 * @tc.type: FUNC
1096 * @tc.require:
1097 */
1098 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPointerStyle_001, TestSize.Level1)
1099 {
1100 CALL_TEST_DEBUG;
1101 PointerStyle style;
1102 int32_t ret = WIN_MGR->GetPointerStyle(1, GLOBAL_WINDOW_ID, style);
1103 EXPECT_EQ(ret, RET_OK);
1104 EXPECT_EQ(style.id, 1);
1105 ret = WIN_MGR->GetPointerStyle(3, 1, style);
1106 EXPECT_EQ(ret, RET_OK);
1107 EXPECT_EQ(style.id, 1);
1108 ret = WIN_MGR->GetPointerStyle(1, 1, style);
1109 EXPECT_EQ(ret, RET_OK);
1110 EXPECT_EQ(style.id, 1);
1111 }
1112
1113 /**
1114 * @tc.name: InputWindowsManagerTest_IsInHotArea_001
1115 * @tc.desc: Test whether input is in the hot area
1116 * @tc.type: FUNC
1117 * @tc.require:
1118 */
1119 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsInHotArea_001, TestSize.Level1)
1120 {
1121 CALL_TEST_DEBUG;
1122 WIN_MGR->InitPointerStyle();
1123 int32_t x = 10;
1124 int32_t y = 20;
1125 std::vector<Rect> rects = {
1126 {0, 0, 30, 40}
1127 };
1128 WindowInfo window;
1129 bool ret = WIN_MGR->IsInHotArea(x, y, rects, window);
1130 EXPECT_TRUE(ret);
1131 x = -10;
1132 y = 20;
1133 ret = WIN_MGR->IsInHotArea(x, y, rects, window);
1134 EXPECT_FALSE(ret);
1135 x = 10;
1136 y = -10;
1137 ret = WIN_MGR->IsInHotArea(x, y, rects, window);
1138 EXPECT_FALSE(ret);
1139 }
1140
1141 /**
1142 * @tc.name: InputWindowsManagerTest_InWhichHotArea_001
1143 * @tc.desc: Test which hot area the input is in
1144 * @tc.type: FUNC
1145 * @tc.require:
1146 */
1147 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_InWhichHotArea_001, TestSize.Level1)
1148 {
1149 CALL_TEST_DEBUG;
1150 int32_t x = 50;
1151 int32_t y = 50;
1152 std::vector<Rect> rects = {
1153 {0, 0, 100, 100},
1154 {100, 100, 200, 200}
1155 };
1156 PointerStyle pointerStyle;
1157 WIN_MGR->InWhichHotArea(x, y, rects, pointerStyle);
1158 ASSERT_EQ(pointerStyle.id, 6);
1159 x = 250;
1160 y = 250;
1161 WIN_MGR->InWhichHotArea(x, y, rects, pointerStyle);
1162 ASSERT_EQ(pointerStyle.id, 6);
1163 }
1164
1165 /**
1166 * @tc.name: InputWindowsManagerTest_AdjustDisplayCoordinate_001
1167 * @tc.desc: Test adjusting display coordinates
1168 * @tc.type: FUNC
1169 * @tc.require:
1170 */
1171 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_AdjustDisplayCoordinate_001, TestSize.Level1)
1172 {
1173 CALL_TEST_DEBUG;
1174 OLD::DisplayInfo displayInfo;
1175 displayInfo.width = 10;
1176 displayInfo.height = 20;
1177 displayInfo.validWidth = displayInfo.width;
1178 displayInfo.validHeight = displayInfo.height;
1179 displayInfo.direction = DIRECTION90;
1180 double physicalX = -5;
1181 double physicalY = 15;
1182 WIN_MGR->AdjustDisplayCoordinate(displayInfo, physicalX, physicalY);
1183 EXPECT_EQ(physicalX, 0);
1184 EXPECT_EQ(physicalY, 9);
1185 displayInfo.width = 10;
1186 displayInfo.height = 20;
1187 displayInfo.validWidth = displayInfo.width;
1188 displayInfo.validHeight = displayInfo.height;
1189 displayInfo.direction = DIRECTION270;
1190 physicalX = 15;
1191 physicalY = 25;
1192 WIN_MGR->AdjustDisplayCoordinate(displayInfo, physicalX, physicalY);
1193 EXPECT_EQ(physicalX, 15);
1194 EXPECT_EQ(physicalY, 9);
1195 displayInfo.width = 10;
1196 displayInfo.height = 20;
1197 displayInfo.validWidth = displayInfo.width;
1198 displayInfo.validHeight = displayInfo.height;
1199 displayInfo.direction = DIRECTION270;
1200 physicalX = -5;
1201 physicalY = -15;
1202 WIN_MGR->AdjustDisplayCoordinate(displayInfo, physicalX, physicalY);
1203 EXPECT_EQ(physicalX, 0);
1204 EXPECT_EQ(physicalY, 0);
1205 }
1206
1207 /**
1208 * @tc.name: InputWindowsManagerTest_IsTransparentWin
1209 * @tc.desc: Test IsTransparentWin
1210 * @tc.type: FUNC
1211 * @tc.require:
1212 */
1213 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsTransparentWin, TestSize.Level1)
1214 {
1215 CALL_TEST_DEBUG;
1216 std::unique_ptr<Media::PixelMap> pixelMap = nullptr;
1217 int32_t logicalX = 0;
1218 int32_t logicalY = 0;
1219 bool result = WIN_MGR->IsTransparentWin(pixelMap, logicalX, logicalY);
1220 EXPECT_FALSE(result);
1221 }
1222
1223 /**
1224 * @tc.name: InputWindowsManagerTest_CheckWindowIdPermissionByPid
1225 * @tc.desc: Test CheckWindowIdPermissionByPid
1226 * @tc.type: FUNC
1227 * @tc.require:
1228 */
1229 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckWindowIdPermissionByPid, TestSize.Level1)
1230 {
1231 CALL_TEST_DEBUG;
1232 int32_t windowId = 12345;
1233 int32_t pid = 6789;
1234 int32_t result = WIN_MGR->CheckWindowIdPermissionByPid(windowId, pid);
1235 EXPECT_EQ(result, RET_ERR);
1236 }
1237
1238 /**
1239 * @tc.name: InputWindowsManagerTest_IsWindowVisible
1240 * @tc.desc: Test IsWindowVisible
1241 * @tc.type: FUNC
1242 * @tc.require:
1243 */
1244 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsWindowVisible, TestSize.Level1)
1245 {
1246 CALL_TEST_DEBUG;
1247 int32_t pid = -1;
1248 bool result = WIN_MGR->IsWindowVisible(pid);
1249 EXPECT_TRUE(result);
1250 }
1251
1252 /**
1253 * @tc.name: InputWindowsManagerTest_CoordinateCorrection_001
1254 * @tc.desc: Test CoordinateCorrection
1255 * @tc.type: FUNC
1256 * @tc.require:
1257 */
1258 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CoordinateCorrection_001, TestSize.Level1)
1259 {
1260 CALL_TEST_DEBUG;
1261 int32_t width = 100;
1262 int32_t height = 200;
1263 int32_t integerX = -1;
1264 int32_t integerY = 1;
1265 WIN_MGR->CoordinateCorrection(width, height, integerX, integerY);
1266 EXPECT_EQ(integerX, 0);
1267 }
1268
1269 /**
1270 * @tc.name: InputWindowsManagerTest_CoordinateCorrection_002
1271 * @tc.desc: Test CoordinateCorrection
1272 * @tc.type: FUNC
1273 * @tc.require:
1274 */
1275 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CoordinateCorrection_002, TestSize.Level1)
1276 {
1277 CALL_TEST_DEBUG;
1278 int32_t width = 100;
1279 int32_t height = 200;
1280 int32_t integerX = 150;
1281 int32_t integerY = 100;
1282 WIN_MGR->CoordinateCorrection(width, height, integerX, integerY);
1283 EXPECT_EQ(integerX, 99);
1284 }
1285
1286 /**
1287 * @tc.name: InputWindowsManagerTest_CoordinateCorrection_003
1288 * @tc.desc: Test CoordinateCorrection
1289 * @tc.type: FUNC
1290 * @tc.require:
1291 */
1292 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CoordinateCorrection_003, TestSize.Level1)
1293 {
1294 CALL_TEST_DEBUG;
1295 int32_t width = 100;
1296 int32_t height = 200;
1297 int32_t integerX = 1;
1298 int32_t integerY = -1;
1299 WIN_MGR->CoordinateCorrection(width, height, integerX, integerY);
1300 EXPECT_EQ(integerY, 0);
1301 }
1302
1303 /**
1304 * @tc.name: InputWindowsManagerTest_CoordinateCorrection_004
1305 * @tc.desc: Test CoordinateCorrection
1306 * @tc.type: FUNC
1307 * @tc.require:
1308 */
1309 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CoordinateCorrection_004, TestSize.Level1)
1310 {
1311 CALL_TEST_DEBUG;
1312 int32_t width = 100;
1313 int32_t height = 200;
1314 int32_t integerX = 100;
1315 int32_t integerY = 250;
1316 WIN_MGR->CoordinateCorrection(width, height, integerX, integerY);
1317 EXPECT_EQ(integerY, 199);
1318 }
1319
1320 /**
1321 * @tc.name: InputWindowsManagerTest_HandleWindowInputType_001
1322 * @tc.desc: Test HandleWindowInputType
1323 * @tc.type: FUNC
1324 * @tc.require:
1325 */
1326 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandleWindowInputType_001, TestSize.Level1)
1327 {
1328 CALL_TEST_DEBUG;
1329 UDSServer udsServer;
1330 WIN_MGR->Init(udsServer);
1331 auto pointerEvent = PointerEvent::Create();
1332 ASSERT_NE(pointerEvent, nullptr);
1333 WindowInfo window;
1334 window.windowInputType = WindowInputType::NORMAL;
1335 ASSERT_FALSE(WIN_MGR->HandleWindowInputType(window, pointerEvent));
1336 }
1337
1338 /**
1339 * @tc.name: InputWindowsManagerTest_HandleWindowInputType_002
1340 * @tc.desc: Test HandleWindowInputType
1341 * @tc.type: FUNC
1342 * @tc.require:
1343 */
1344 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandleWindowInputType_002, TestSize.Level1)
1345 {
1346 CALL_TEST_DEBUG;
1347 UDSServer udsServer;
1348 WIN_MGR->Init(udsServer);
1349 auto pointerEvent = PointerEvent::Create();
1350 ASSERT_NE(pointerEvent, nullptr);
1351 WindowInfo window;
1352 window.windowInputType = WindowInputType::TRANSMIT_ALL;
1353 ASSERT_FALSE(WIN_MGR->HandleWindowInputType(window, pointerEvent));
1354 }
1355
1356 /**
1357 * @tc.name: InputWindowsManagerTest_HandleWindowInputType_003
1358 * @tc.desc: Test HandleWindowInputType
1359 * @tc.type: FUNC
1360 * @tc.require:
1361 */
1362 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandleWindowInputType_003, TestSize.Level1)
1363 {
1364 CALL_TEST_DEBUG;
1365 UDSServer udsServer;
1366 WIN_MGR->Init(udsServer);
1367 auto pointerEvent = PointerEvent::Create();
1368 ASSERT_NE(pointerEvent, nullptr);
1369 WindowInfo window;
1370 window.windowInputType = WindowInputType::ANTI_MISTAKE_TOUCH;
1371 ASSERT_FALSE(WIN_MGR->HandleWindowInputType(window, pointerEvent));
1372 }
1373
1374 /**
1375 * @tc.name: InputWindowsManagerTest_UpdateDisplayId_001
1376 * @tc.desc: Test updating display ID
1377 * @tc.type: FUNC
1378 * @tc.require:
1379 */
1380 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayId_001, TestSize.Level1)
1381 {
1382 CALL_TEST_DEBUG;
1383 int32_t displayId = 1;
1384 bool ret = WIN_MGR->UpdateDisplayId(displayId);
1385 EXPECT_TRUE(ret);
1386 displayId = 0;
1387 ret = WIN_MGR->UpdateDisplayId(displayId);
1388 EXPECT_FALSE(ret);
1389 displayId = -1;
1390 ret = WIN_MGR->UpdateDisplayId(displayId);
1391 EXPECT_TRUE(ret);
1392 }
1393
1394 /**
1395 * @tc.name: InputWindowsManagerTest_SelectWindowInfo_001
1396 * @tc.desc: Test selecting window information
1397 * @tc.type: FUNC
1398 * @tc.require:
1399 */
1400 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectWindowInfo_001, TestSize.Level1)
1401 {
1402 CALL_TEST_DEBUG;
1403 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
1404 ASSERT_NE(pointerEvent, nullptr);
1405 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
1406 pointerEvent->SetPressedKeys({1});
1407 pointerEvent->SetTargetDisplayId(0);
1408 pointerEvent->SetTargetWindowId(1);
1409 std::optional<WindowInfo> result = WIN_MGR->SelectWindowInfo(400, 300, pointerEvent);
1410 EXPECT_FALSE(result.has_value());
1411 int32_t ret1 = result->id;
1412 EXPECT_EQ(ret1, 0);
1413 int32_t ret2 = result->flags;
1414 EXPECT_EQ(ret2, 0);
1415 int32_t ret3 = result->pid;
1416 EXPECT_EQ(ret3, 0);
1417 }
1418
1419 /**
1420 * @tc.name: InputWindowsManagerTest_SelectWindowInfo_002
1421 * @tc.desc: Test selecting window information
1422 * @tc.type: FUNC
1423 * @tc.require:
1424 */
1425 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectWindowInfo_002, TestSize.Level1)
1426 {
1427 CALL_TEST_DEBUG;
1428 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
1429 ASSERT_NE(pointerEvent, nullptr);
1430 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
1431 pointerEvent->SetPressedKeys({1});
1432 pointerEvent->SetTargetDisplayId(0);
1433 pointerEvent->SetTargetWindowId(1);
1434 std::optional<WindowInfo> result = WIN_MGR->SelectWindowInfo(-123, -456, pointerEvent);
1435 EXPECT_FALSE(result.has_value());
1436 int32_t ret1 = result->id;
1437 EXPECT_EQ(ret1, 0);
1438 int32_t ret2 = result->flags;
1439 EXPECT_EQ(ret2, 0);
1440 int32_t ret3 = result->pid;
1441 EXPECT_EQ(ret3, 0);
1442 }
1443
1444 /**
1445 * @tc.name: InputWindowsManagerTest_GetWindowInfo_001
1446 * @tc.desc: Test getting window information
1447 * @tc.type: FUNC
1448 * @tc.require:
1449 */
1450 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowInfo_001, TestSize.Level1)
1451 {
1452 CALL_TEST_DEBUG;
1453 WindowInfo windowInfo1 = {1, WindowInfo::FLAG_BIT_UNTOUCHABLE, {}};
1454 WindowInfo windowInfo2 = {2, 0, {}};
1455 WIN_MGR->displayGroupInfo_.windowsInfo = {windowInfo1, windowInfo2};
1456 auto result = WIN_MGR->GetWindowInfo(0, 0);
1457 EXPECT_FALSE(result.has_value());
1458 int32_t ret1 = result->id;
1459 EXPECT_EQ(ret1, 0);
1460 }
1461
1462 /**
1463 * @tc.name: InputWindowsManagerTest_SelectPointerChangeArea_001
1464 * @tc.desc: Test selecting pointer change area
1465 * @tc.type: FUNC
1466 * @tc.require:
1467 */
1468 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectPointerChangeArea_001, TestSize.Level1)
1469 {
1470 CALL_TEST_DEBUG;
1471 WindowInfo windowInfo;
1472 windowInfo.id = 1;
1473 PointerStyle pointerStyle;
1474 int32_t logicalX = 0;
1475 int32_t logicalY = 0;
1476 bool result = WIN_MGR->SelectPointerChangeArea(windowInfo, pointerStyle, logicalX, logicalY);
1477 EXPECT_FALSE(result);
1478 }
1479
1480 /**
1481 * @tc.name: InputWindowsManagerTest_SelectPointerChangeArea_002
1482 * @tc.desc: Test selecting pointer change area
1483 * @tc.type: FUNC
1484 * @tc.require:
1485 */
1486 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectPointerChangeArea_002, TestSize.Level1)
1487 {
1488 CALL_TEST_DEBUG;
1489 WindowInfo windowInfo;
1490 windowInfo.id = 1;
1491 PointerStyle pointerStyle;
1492 int32_t logicalX = -1;
1493 int32_t logicalY = -2;
1494 bool result = WIN_MGR->SelectPointerChangeArea(windowInfo, pointerStyle, logicalX, logicalY);
1495 EXPECT_FALSE(result);
1496 }
1497
1498 /**
1499 * @tc.name: InputWindowsManagerTest_UpdatePointerChangeAreas_001
1500 * @tc.desc: Test updating pointer change areas
1501 * @tc.type: FUNC
1502 * @tc.require:
1503 */
1504 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerChangeAreas_001, TestSize.Level1)
1505 {
1506 CALL_TEST_DEBUG;
1507 OLD::DisplayGroupInfo displayGroupInfo;
1508 WIN_MGR->UpdatePointerChangeAreas(displayGroupInfo);
1509 EXPECT_TRUE(WIN_MGR->windowsHotAreas_.empty());
1510 }
1511
1512 /**
1513 * @tc.name: InputWindowsManagerTest_UpdatePointerChangeAreas_002
1514 * @tc.desc: Test updating pointer change areas
1515 * @tc.type: FUNC
1516 * @tc.require:
1517 */
1518 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerChangeAreas_002, TestSize.Level1)
1519 {
1520 CALL_TEST_DEBUG;
1521 OLD::DisplayGroupInfo displayGroupInfo;
1522 WIN_MGR->UpdatePointerChangeAreas();
1523 WIN_MGR->UpdatePointerChangeAreas(displayGroupInfo);
1524 EXPECT_NE(WIN_MGR->windowsHotAreas_[1].size(), 8);
1525 }
1526
1527 /**
1528 * @tc.name: InputWindowsManagerTest_UpdateTopBottomArea_001
1529 * @tc.desc: Test updating top-bottom area
1530 * @tc.type: FUNC
1531 * @tc.require:
1532 */
1533 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTopBottomArea_001, TestSize.Level1)
1534 {
1535 CALL_TEST_DEBUG;
1536 Rect windowArea = {0, 0, 100, 100};
1537 std::vector<int32_t> pointerChangeAreas = {10, 20, 30, 40, 50, 60, 70, 80};
1538 std::vector<Rect> windowHotAreas;
1539 WIN_MGR->UpdateTopBottomArea(windowArea, pointerChangeAreas, windowHotAreas);
1540 int32_t ret1 = windowHotAreas.size();
1541 EXPECT_EQ(ret1, 2);
1542 int32_t ret2 = windowHotAreas[0].x;
1543 EXPECT_EQ(ret2, 10);
1544 int32_t ret3 = windowHotAreas[0].y;
1545 EXPECT_EQ(ret3, -20);
1546 int32_t ret4 = windowHotAreas[0].width;
1547 EXPECT_EQ(ret4, 60);
1548 int32_t ret5 = windowHotAreas[0].height;
1549 EXPECT_EQ(ret5, 40);
1550 int32_t ret6 = windowHotAreas[1].x;
1551 EXPECT_EQ(ret6, 70);
1552 int32_t ret7 = windowHotAreas[1].y;
1553 EXPECT_EQ(ret7, 40);
1554 int32_t ret8 = windowHotAreas[1].width;
1555 EXPECT_EQ(ret8, -20);
1556 int32_t ret9 = windowHotAreas[1].height;
1557 EXPECT_EQ(ret9, 80);
1558 }
1559
1560 /**
1561 * @tc.name: InputWindowsManagerTest_UpdateTopBottomArea_002
1562 * @tc.desc: Test updating top-bottom area
1563 * @tc.type: FUNC
1564 * @tc.require:
1565 */
1566 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTopBottomArea_002, TestSize.Level1)
1567 {
1568 CALL_TEST_DEBUG;
1569 Rect windowArea = {0, 0, 100, 100};
1570 std::vector<int32_t> pointerChangeAreas = {0, 0, 0, 0, 0, 0, 0, 0};
1571 std::vector<Rect> windowHotAreas;
1572 WIN_MGR->UpdateTopBottomArea(windowArea, pointerChangeAreas, windowHotAreas);
1573 int32_t ret1 = windowHotAreas.size();
1574 EXPECT_EQ(ret1, 2);
1575 int32_t ret2 = windowHotAreas[0].width;
1576 EXPECT_EQ(ret2, 0);
1577 int32_t ret3 = windowHotAreas[0].height;
1578 EXPECT_EQ(ret3, 0);
1579 int32_t ret4 = windowHotAreas[1].width;
1580 EXPECT_EQ(ret4, 0);
1581 int32_t ret5 = windowHotAreas[1].height;
1582 EXPECT_EQ(ret5, 0);
1583 }
1584
1585 /**
1586 * @tc.name: InputWindowsManagerTest_UpdateLeftRightArea_001
1587 * @tc.desc: Test updating left-right area
1588 * @tc.type: FUNC
1589 * @tc.require:
1590 */
1591 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateLeftRightArea_001, TestSize.Level1)
1592 {
1593 CALL_TEST_DEBUG;
1594 Rect windowArea = {0, 0, 100, 100};
1595 std::vector<int32_t> pointerChangeAreas = {10, 20, 30, 40, 50, 60, 70, 80};
1596 std::vector<Rect> windowHotAreas;
1597 WIN_MGR->UpdateLeftRightArea(windowArea, pointerChangeAreas, windowHotAreas);
1598 int32_t ret1 = windowHotAreas.size();
1599 EXPECT_EQ(ret1, 2);
1600 int32_t ret2 = windowHotAreas[0].x;
1601 EXPECT_EQ(ret2, -20);
1602 int32_t ret3 = windowHotAreas[0].y;
1603 EXPECT_EQ(ret3, 10);
1604 int32_t ret4 = windowHotAreas[0].width;
1605 EXPECT_EQ(ret4, 100);
1606 int32_t ret5 = windowHotAreas[0].height;
1607 EXPECT_EQ(ret5, 20);
1608 int32_t ret6 = windowHotAreas[1].x;
1609 EXPECT_EQ(ret6, 60);
1610 int32_t ret7 = windowHotAreas[1].y;
1611 EXPECT_EQ(ret7, 30);
1612 int32_t ret8 = windowHotAreas[1].width;
1613 EXPECT_EQ(ret8, 60);
1614 int32_t ret9 = windowHotAreas[1].height;
1615 EXPECT_EQ(ret9, 20);
1616 }
1617
1618 /**
1619 * @tc.name: InputWindowsManagerTest_UpdateLeftRightArea_002
1620 * @tc.desc: Test updating left-right area
1621 * @tc.type: FUNC
1622 * @tc.require:
1623 */
1624 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateLeftRightArea_002, TestSize.Level1)
1625 {
1626 CALL_TEST_DEBUG;
1627 Rect windowArea = {0, 0, 100, 100};
1628 std::vector<int32_t> pointerChangeAreas = {10, 0, 30, 40, 50, 60, 70, 80};
1629 std::vector<Rect> windowHotAreas;
1630 WIN_MGR->UpdateLeftRightArea(windowArea, pointerChangeAreas, windowHotAreas);
1631 int32_t ret1 = windowHotAreas.size();
1632 EXPECT_EQ(ret1, 2);
1633 int32_t ret2 = windowHotAreas[0].x;
1634 EXPECT_EQ(ret2, -20);
1635 int32_t ret3 = windowHotAreas[0].y;
1636 EXPECT_EQ(ret3, 10);
1637 int32_t ret4 = windowHotAreas[0].width;
1638 EXPECT_EQ(ret4, 100);
1639 int32_t ret5 = windowHotAreas[0].height;
1640 EXPECT_EQ(ret5, 20);
1641 int32_t ret6 = windowHotAreas[1].x;
1642 EXPECT_EQ(ret6, 60);
1643 int32_t ret7 = windowHotAreas[1].y;
1644 EXPECT_EQ(ret7, 30);
1645 int32_t ret8 = windowHotAreas[1].width;
1646 EXPECT_EQ(ret8, 60);
1647 int32_t ret9 = windowHotAreas[1].height;
1648 EXPECT_EQ(ret9, 20);
1649 }
1650
1651 /**
1652 * @tc.name: InputWindowsManagerTest_UpdateInnerAngleArea_001
1653 * @tc.desc: Test updating inner angle area
1654 * @tc.type: FUNC
1655 * @tc.require:
1656 */
1657 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateInnerAngleArea_001, TestSize.Level1)
1658 {
1659 CALL_TEST_DEBUG;
1660 Rect windowArea;
1661 windowArea.x = 10;
1662 windowArea.y = 20;
1663 windowArea.width = 100;
1664 windowArea.height = 200;
1665 std::vector<int32_t> pointerChangeAreas(4, 10);
1666 std::vector<Rect> windowHotAreas;
1667 WIN_MGR->UpdateInnerAngleArea(windowArea, pointerChangeAreas, windowHotAreas);
1668 int32_t ret1 = windowHotAreas.size();
1669 EXPECT_EQ(ret1, 4);
1670 int32_t ret2 = windowHotAreas[0].x;
1671 EXPECT_EQ(ret2, -10);
1672 int32_t ret3 = windowHotAreas[0].y;
1673 EXPECT_EQ(ret3, 0);
1674 int32_t ret4 = windowHotAreas[0].width;
1675 EXPECT_EQ(ret4, 30);
1676 int32_t ret5 = windowHotAreas[0].height;
1677 EXPECT_EQ(ret5, 30);
1678 int32_t ret6 = windowHotAreas[1].x;
1679 EXPECT_EQ(ret6, 100);
1680 int32_t ret7 = windowHotAreas[1].y;
1681 EXPECT_EQ(ret7, 0);
1682 int32_t ret8 = windowHotAreas[1].width;
1683 EXPECT_EQ(ret8, 30);
1684 int32_t ret9 = windowHotAreas[1].height;
1685 EXPECT_EQ(ret9, 30);
1686 int32_t ret10 = windowHotAreas[2].x;
1687 EXPECT_EQ(ret10, -10);
1688 int32_t ret11 = windowHotAreas[2].y;
1689 EXPECT_NE(ret11, 110);
1690 int32_t ret12 = windowHotAreas[2].width;
1691 EXPECT_NE(ret12, 21);
1692 int32_t ret13 = windowHotAreas[2].height;
1693 EXPECT_EQ(ret13, 32);
1694 }
1695
1696 /**
1697 * @tc.name: InputWindowsManagerTest_UpdatePointerEvent_001
1698 * @tc.desc: Test updating pointer event
1699 * @tc.type: FUNC
1700 * @tc.require:
1701 */
1702 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerEvent_001, TestSize.Level1)
1703 {
1704 CALL_TEST_DEBUG;
1705 InputWindowsManager inputWindowsManager;
1706 int32_t logicalX = 10;
1707 int32_t logicalY = 20;
1708 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
1709 ASSERT_NE(pointerEvent, nullptr);
1710 WindowInfo touchWindow;
1711 touchWindow.id = 2;
1712 WIN_MGR->UpdatePointerEvent(logicalX, logicalY, pointerEvent, touchWindow);
1713 EXPECT_EQ(inputWindowsManager.lastLogicX_, RET_ERR);
1714 EXPECT_EQ(inputWindowsManager.lastLogicY_, RET_ERR);
1715 }
1716
1717 /**
1718 * @tc.name: InputWindowsManagerTest_UpdatePointerEvent_002
1719 * @tc.desc: Test updating pointer event
1720 * @tc.type: FUNC
1721 * @tc.require:
1722 */
1723 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerEvent_002, TestSize.Level1)
1724 {
1725 CALL_TEST_DEBUG;
1726 InputWindowsManager inputWindowsManager;
1727 int32_t logicalX = 10;
1728 int32_t logicalY = 20;
1729 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
1730 ASSERT_NE(pointerEvent, nullptr);
1731 WindowInfo touchWindow;
1732 touchWindow.id = 0;
1733 WIN_MGR->UpdatePointerEvent(logicalX, logicalY, pointerEvent, touchWindow);
1734 EXPECT_EQ(inputWindowsManager.lastLogicX_, RET_ERR);
1735 EXPECT_EQ(inputWindowsManager.lastLogicY_, RET_ERR);
1736 }
1737
1738 /**
1739 * @tc.name: InputWindowsManagerTest_SetHoverScrollState_001
1740 * @tc.desc: Test setting hover scroll state
1741 * @tc.type: FUNC
1742 * @tc.require:
1743 */
1744 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetHoverScrollState_001, TestSize.Level1)
1745 {
1746 CALL_TEST_DEBUG;
1747 int32_t result = WIN_MGR->SetHoverScrollState(true);
1748 EXPECT_EQ(result, 0);
1749 result = WIN_MGR->SetHoverScrollState(false);
1750 EXPECT_EQ(result, 0);
1751 }
1752
1753 /**
1754 * @tc.name: InputWindowsManagerTest_GetHoverScrollState_001
1755 * @tc.desc: Test getting hover scroll state
1756 * @tc.type: FUNC
1757 * @tc.require:
1758 */
1759 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetHoverScrollState_001, TestSize.Level1)
1760 {
1761 CALL_TEST_DEBUG;
1762 bool result = WIN_MGR->GetHoverScrollState();
1763 EXPECT_TRUE(result);
1764 result = WIN_MGR->GetHoverScrollState();
1765 EXPECT_TRUE(result);
1766 }
1767
1768 /**
1769 * @tc.name: InputWindowsManagerTest_UpdateMouseTarget_001
1770 * @tc.desc: Test updating mouse target
1771 * @tc.type: FUNC
1772 * @tc.require:
1773 */
1774 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateMouseTarget_001, TestSize.Level1)
1775 {
1776 CALL_TEST_DEBUG;
1777 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
1778 ASSERT_NE(pointerEvent, nullptr);
1779 int32_t result = WIN_MGR->UpdateMouseTarget(pointerEvent);
1780 WIN_MGR->SetMouseFlag(true);
1781 WIN_MGR->SetMouseFlag(false);
1782 auto ret = WIN_MGR->GetMouseFlag();
1783 EXPECT_FALSE(ret);
1784 EXPECT_EQ(result, RET_ERR);
1785 }
1786
1787 /**
1788 * @tc.name: InputWindowsManagerTest_SkipNavigationWindow_001
1789 * @tc.desc: Test updating window information for each display
1790 * @tc.type: FUNC
1791 * @tc.require:
1792 */
1793 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SkipNavigationWindow_001, TestSize.Level1)
1794 {
1795 WIN_MGR->SetAntiMisTakeStatus(false);
1796 ASSERT_FALSE(WIN_MGR->SkipNavigationWindow(WindowInputType::ANTI_MISTAKE_TOUCH, PointerEvent::TOOL_TYPE_PEN));
1797 }
1798
1799 /**
1800 * @tc.name: InputWindowsManagerTest_SkipNavigationWindow_002
1801 * @tc.desc: Test updating window information for each display
1802 * @tc.type: FUNC
1803 * @tc.require:
1804 */
1805 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SkipNavigationWindow_002, TestSize.Level1)
1806 {
1807 WIN_MGR->SetAntiMisTakeStatus(false);
1808 ASSERT_FALSE(WIN_MGR->SkipNavigationWindow(WindowInputType::NORMAL, PointerEvent::TOOL_TYPE_RUBBER));
1809 }
1810
1811 /**
1812 * @tc.name: InputWindowsManagerTest_SkipNavigationWindow_003
1813 * @tc.desc: Test updating window information for each display
1814 * @tc.type: FUNC
1815 * @tc.require:
1816 */
1817 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SkipNavigationWindow_003, TestSize.Level1)
1818 {
1819 WIN_MGR->SetAntiMisTakeStatus(false);
1820 ASSERT_FALSE(WIN_MGR->SkipNavigationWindow(WindowInputType::NORMAL, PointerEvent::TOOL_TYPE_PEN));
1821 }
1822
1823 /**
1824 * @tc.name: InputWindowsManagerTest_SkipNavigationWindow_004
1825 * @tc.desc: Test updating window information for each display
1826 * @tc.type: FUNC
1827 * @tc.require:
1828 */
1829 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SkipNavigationWindow_004, TestSize.Level1)
1830 {
1831 WIN_MGR->SetAntiMisTakeStatus(false);
1832 ASSERT_FALSE(WIN_MGR->SkipNavigationWindow(WindowInputType::ANTI_MISTAKE_TOUCH, PointerEvent::TOOL_TYPE_RUBBER));
1833 }
1834
1835 /**
1836 * @tc.name: InputWindowsManagerTest_SkipNavigationWindow_005
1837 * @tc.desc: Test updating window information for each display
1838 * @tc.type: FUNC
1839 * @tc.require:
1840 */
1841 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SkipNavigationWindow_005, TestSize.Level1)
1842 {
1843 WIN_MGR->SetAntiMisTake(true);
1844 WIN_MGR->SetAntiMisTakeStatus(false);
1845 ASSERT_FALSE(WIN_MGR->SkipNavigationWindow(WindowInputType::ANTI_MISTAKE_TOUCH, PointerEvent::TOOL_TYPE_PEN));
1846 }
1847
1848 /**
1849 * @tc.name: InputWindowsManagerTest_JudgMouseIsDownOrUp_001
1850 * @tc.desc: This test verifies the functionality of judging whether the mouse button is down or up
1851 * @tc.type: FUNC
1852 * @tc.require:
1853 */
1854 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_JudgMouseIsDownOrUp_001, TestSize.Level1)
1855 {
1856 CALL_TEST_DEBUG;
1857 WIN_MGR->JudgMouseIsDownOrUp(false);
1858 EXPECT_FALSE(WIN_MGR->GetMouseFlag());
1859 WIN_MGR->JudgMouseIsDownOrUp(true);
1860 EXPECT_FALSE(WIN_MGR->GetMouseFlag());
1861 }
1862
1863 /**
1864 * @tc.name: InputWindowsManagerTest_SetMouseCaptureMode_001
1865 * @tc.desc: This test verifies the functionality of setting the mouse capture mode
1866 * @tc.type: FUNC
1867 * @tc.require:
1868 */
1869 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetMouseCaptureMode_001, TestSize.Level1)
1870 {
1871 CALL_TEST_DEBUG;
1872 int32_t windowId = -1;
1873 bool isCaptureMode = true;
1874 int32_t result = WIN_MGR->SetMouseCaptureMode(windowId, isCaptureMode);
1875 EXPECT_EQ(result, RET_ERR);
1876 windowId = 1;
1877 isCaptureMode = false;
1878 result = WIN_MGR->SetMouseCaptureMode(windowId, isCaptureMode);
1879 EXPECT_EQ(result, RET_OK);
1880 windowId = 1;
1881 isCaptureMode = true;
1882 result = WIN_MGR->SetMouseCaptureMode(windowId, isCaptureMode);
1883 EXPECT_EQ(result, RET_OK);
1884 EXPECT_TRUE(WIN_MGR->GetMouseIsCaptureMode());
1885 }
1886
1887 /**
1888 * @tc.name: InputWindowsManagerTest_IsNeedDrawPointer_001
1889 * @tc.desc: This test verifies the functionality of determining whether to draw the pointer
1890 * @tc.type: FUNC
1891 * @tc.require:
1892 */
1893 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsNeedDrawPointer_001, TestSize.Level1)
1894 {
1895 CALL_TEST_DEBUG;
1896 PointerEvent::PointerItem pointerItem;
1897 pointerItem.SetToolType(PointerEvent::TOOL_TYPE_PEN);
1898 pointerItem.SetDeviceId(1);
1899 bool result = WIN_MGR->IsNeedDrawPointer(pointerItem);
1900 EXPECT_FALSE(result);
1901 }
1902
1903 /**
1904 * @tc.name: InputWindowsManagerTest_SkipAnnotationWindow_001
1905 * @tc.desc: This test verifies the functionality of determining whether to draw the pointer
1906 * @tc.type: FUNC
1907 * @tc.require:
1908 */
1909 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SkipAnnotationWindow_001, TestSize.Level1)
1910 {
1911 CALL_TEST_DEBUG;
1912 uint32_t flag = WindowInfo::FLAG_BIT_HANDWRITING;
1913 int32_t toolType = PointerEvent::TOOL_TYPE_FINGER;
1914 bool result = WIN_MGR->SkipAnnotationWindow(flag, toolType);
1915 EXPECT_TRUE(result);
1916 flag = WindowInfo::FLAG_BIT_HANDWRITING;
1917 toolType = PointerEvent::TOOL_TYPE_PEN;
1918 result = WIN_MGR->SkipAnnotationWindow(flag, toolType);
1919 EXPECT_FALSE(result);
1920 flag = 0;
1921 toolType = PointerEvent::TOOL_TYPE_FINGER;
1922 result = WIN_MGR->SkipAnnotationWindow(flag, toolType);
1923 EXPECT_FALSE(result);
1924 flag = 0;
1925 toolType = PointerEvent::TOOL_TYPE_PEN;
1926 result = WIN_MGR->SkipAnnotationWindow(flag, toolType);
1927 EXPECT_FALSE(result);
1928 }
1929
1930 /**
1931 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_001
1932 * @tc.desc: This test verifies the functionality of updating the touch screen target
1933 * @tc.type: FUNC
1934 * @tc.require:
1935 */
1936 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_001, TestSize.Level1)
1937 {
1938 CALL_TEST_DEBUG;
1939 auto result = WIN_MGR->UpdateTouchScreenTarget(nullptr);
1940 EXPECT_NE(result, RET_ERR);
1941 auto pointerEvent = PointerEvent::Create();
1942 pointerEvent->SetTargetDisplayId(-1);
1943 result = WIN_MGR->UpdateTouchScreenTarget(pointerEvent);
1944 EXPECT_EQ(result, RET_ERR);
1945 pointerEvent->SetTargetDisplayId(1);
1946 pointerEvent->SetPointerId(1);
1947 result = WIN_MGR->UpdateTouchScreenTarget(pointerEvent);
1948 EXPECT_EQ(result, RET_ERR);
1949 }
1950
1951 /**
1952 * @tc.name: InputWindowsManagerTest_PullEnterLeaveEvent_001
1953 * @tc.desc: This test verifies the functionality of pulling enter and leave events
1954 * @tc.type: FUNC
1955 * @tc.require:
1956 */
1957 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PullEnterLeaveEvent_001, TestSize.Level1)
1958 {
1959 CALL_TEST_DEBUG;
1960 int32_t logicalX = 100;
1961 int32_t logicalY = 200;
1962 auto pointerEvent = PointerEvent::Create();
1963 WindowInfo touchWindow;
1964 WIN_MGR->PullEnterLeaveEvent(logicalX, logicalY, pointerEvent, &touchWindow);
1965 logicalX = -123;
1966 logicalY = -456;
1967 WIN_MGR->PullEnterLeaveEvent(logicalX, logicalY, pointerEvent, &touchWindow);
1968 }
1969
1970 /**
1971 * @tc.name: InputWindowsManagerTest_DispatchTouch_001
1972 * @tc.desc: This test verifies the functionality of touch event dispatching
1973 * @tc.type: FUNC
1974 * @tc.require:
1975 */
1976 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DispatchTouch_001, TestSize.Level1)
1977 {
1978 CALL_TEST_DEBUG;
1979 int32_t pointerAction = PointerEvent::POINTER_ACTION_PULL_IN_WINDOW;
1980 ASSERT_NO_FATAL_FAILURE(WIN_MGR->DispatchTouch(pointerAction));
1981 pointerAction = PointerEvent::POINTER_ACTION_DOWN;
1982 ASSERT_NO_FATAL_FAILURE(WIN_MGR->DispatchTouch(pointerAction));
1983 }
1984
1985 /**
1986 * @tc.name: InputWindowsManagerTest_UpdateTouchPadTarget_001
1987 * @tc.desc: This test verifies the functionality of updating the touchpad target
1988 * @tc.type: FUNC
1989 * @tc.require:
1990 */
1991 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchPadTarget_001, TestSize.Level1)
1992 {
1993 CALL_TEST_DEBUG;
1994 auto pointerEvent = PointerEvent::Create();
1995 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
1996 int32_t result = WIN_MGR->UpdateTouchPadTarget(pointerEvent);
1997 EXPECT_EQ(result, RET_ERR);
1998 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_UP);
1999 result = WIN_MGR->UpdateTouchPadTarget(pointerEvent);
2000 EXPECT_EQ(result, RET_ERR);
2001 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
2002 result = WIN_MGR->UpdateTouchPadTarget(pointerEvent);
2003 EXPECT_EQ(result, RET_ERR);
2004 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
2005 result = WIN_MGR->UpdateTouchPadTarget(pointerEvent);
2006 EXPECT_EQ(result, RET_ERR);
2007 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UP);
2008 result = WIN_MGR->UpdateTouchPadTarget(pointerEvent);
2009 EXPECT_EQ(result, RET_ERR);
2010 pointerEvent->SetPointerAction(9999);
2011 result = WIN_MGR->UpdateTouchPadTarget(pointerEvent);
2012 EXPECT_EQ(result, RET_ERR);
2013 }
2014
2015 /**
2016 * @tc.name: InputWindowsManagerTest_UpdateTargetPointer_001
2017 * @tc.desc: This test verifies the functionality of updating the target pointer
2018 * @tc.type: FUNC
2019 * @tc.require:
2020 */
2021 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTargetPointer_001, TestSize.Level1)
2022 {
2023 CALL_TEST_DEBUG;
2024 auto pointerEvent = PointerEvent::Create();
2025 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
2026 pointerEvent->SetPointerAction(1);
2027 int32_t result = WIN_MGR->UpdateTargetPointer(pointerEvent);
2028 EXPECT_EQ(result, RET_ERR);
2029 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
2030 pointerEvent->SetPointerAction(1);
2031 result = WIN_MGR->UpdateTargetPointer(pointerEvent);
2032 EXPECT_EQ(result, RET_ERR);
2033 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
2034 pointerEvent->SetPointerAction(1);
2035 result = WIN_MGR->UpdateTargetPointer(pointerEvent);
2036 EXPECT_EQ(result, RET_ERR);
2037 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_JOYSTICK);
2038 pointerEvent->SetPointerAction(1);
2039 result = WIN_MGR->UpdateTargetPointer(pointerEvent);
2040 EXPECT_EQ(result, RET_OK);
2041 pointerEvent->SetSourceType(999);
2042 pointerEvent->SetPointerAction(1);
2043 result = WIN_MGR->UpdateTargetPointer(pointerEvent);
2044 EXPECT_EQ(result, RET_ERR);
2045 }
2046
2047 /**
2048 * @tc.name: InputWindowsManagerTest_IsInsideDisplay_001
2049 * @tc.desc: This test verifies the functionality of determining whether it is inside the display area
2050 * @tc.type: FUNC
2051 * @tc.require:
2052 */
2053 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsInsideDisplay_001, TestSize.Level1)
2054 {
2055 CALL_TEST_DEBUG;
2056 OLD::DisplayInfo displayInfo;
2057 displayInfo.width = 1920;
2058 displayInfo.height = 1080;
2059 displayInfo.validWidth = displayInfo.width;
2060 displayInfo.validHeight = displayInfo.height;
2061 int32_t physicalX = 500;
2062 int32_t physicalY = 10;
2063 bool result = WIN_MGR->IsInsideDisplay(displayInfo, physicalX, physicalY);
2064 EXPECT_TRUE(result);
2065 physicalX = -10;
2066 physicalY = 500;
2067 result = WIN_MGR->IsInsideDisplay(displayInfo, physicalX, physicalY);
2068 EXPECT_FALSE(result);
2069 physicalX = 500;
2070 physicalY = -10;
2071 result = WIN_MGR->IsInsideDisplay(displayInfo, physicalX, physicalY);
2072 EXPECT_FALSE(result);
2073 physicalX = -500;
2074 physicalY = -10;
2075 result = WIN_MGR->IsInsideDisplay(displayInfo, physicalX, physicalY);
2076 EXPECT_FALSE(result);
2077 }
2078
2079 /**
2080 * @tc.name: InputWindowsManagerTest_FindPhysicalDisplay_001
2081 * @tc.desc: This test verifies the functionality of finding physical displays
2082 * @tc.type: FUNC
2083 * @tc.require:
2084 */
2085 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_FindPhysicalDisplay_001, TestSize.Level1)
2086 {
2087 CALL_TEST_DEBUG;
2088 OLD::DisplayInfo displayInfo = {10, 20};
2089 double physicalX, physicalY;
2090 int32_t displayId;
2091 WIN_MGR->FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
2092 EXPECT_EQ(physicalX, RET_OK);
2093 EXPECT_EQ(physicalY, RET_OK);
2094 EXPECT_EQ(displayId, RET_OK);
2095 displayInfo.x = INT32_MAX;
2096 displayInfo.y = INT32_MAX;
2097 WIN_MGR->FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
2098 EXPECT_EQ(physicalX, RET_OK);
2099 EXPECT_EQ(physicalY, RET_OK);
2100 EXPECT_EQ(displayId, RET_OK);
2101 displayInfo.x = 50;
2102 displayInfo.y = 60;
2103 WIN_MGR->FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
2104 EXPECT_EQ(physicalX, RET_OK);
2105 EXPECT_EQ(physicalY, RET_OK);
2106 EXPECT_EQ(displayId, RET_OK);
2107 }
2108
2109 /**
2110 * @tc.name: InputWindowsManagerTest_GetWidthAndHeight_001
2111 * @tc.desc: Test the method for retrieving width and height
2112 * @tc.type: FUNC
2113 * @tc.require:
2114 */
2115 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWidthAndHeight_001, TestSize.Level1)
2116 {
2117 CALL_TEST_DEBUG;
2118 OLD::DisplayInfo displayInfo;
2119 displayInfo.displayDirection = DIRECTION0;
2120 displayInfo.direction = DIRECTION0;
2121 int32_t width = 1920;
2122 int32_t height = 1080;
2123 WIN_MGR->GetWidthAndHeight(&displayInfo, width, height);
2124 EXPECT_EQ(width, RET_OK);
2125 EXPECT_EQ(height, RET_OK);
2126 displayInfo.direction = DIRECTION90;
2127 WIN_MGR->GetWidthAndHeight(&displayInfo, width, height);
2128 EXPECT_EQ(width, RET_OK);
2129 EXPECT_EQ(height, RET_OK);
2130 displayInfo.displayDirection = DIRECTION180;
2131 displayInfo.direction = DIRECTION0;
2132 WIN_MGR->GetWidthAndHeight(&displayInfo, width, height);
2133 EXPECT_EQ(width, RET_OK);
2134 EXPECT_EQ(height, RET_OK);
2135 }
2136
2137 /**
2138 * @tc.name: InputWindowsManagerTest_ReverseRotateScreen_001
2139 * @tc.desc: Test the method for reversing screen rotation
2140 * @tc.type: FUNC
2141 * @tc.require:
2142 */
2143 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ReverseRotateScreen_001, TestSize.Level1)
2144 {
2145 CALL_TEST_DEBUG;
2146 OLD::DisplayInfo info;
2147 Coordinate2D cursorPos;
2148 info.direction = DIRECTION0;
2149 info.width = 1920;
2150 info.height = 1080;
2151 info.validHeight = info.height;
2152 info.validWidth = info.width;
2153 WIN_MGR->ReverseRotateScreen(info, 100.0, 200.0, cursorPos);
2154 EXPECT_EQ(cursorPos.x, 100);
2155 EXPECT_EQ(cursorPos.y, 200);
2156 info.direction = DIRECTION90;
2157 WIN_MGR->ReverseRotateScreen(info, 100.0, 200.0, cursorPos);
2158 EXPECT_EQ(cursorPos.x, 200);
2159 EXPECT_EQ(cursorPos.y, 1819);
2160 info.direction = DIRECTION180;
2161 WIN_MGR->ReverseRotateScreen(info, 100.0, 200.0, cursorPos);
2162 EXPECT_EQ(cursorPos.x, 1819);
2163 EXPECT_EQ(cursorPos.y, 879);
2164 info.direction = DIRECTION270;
2165 WIN_MGR->ReverseRotateScreen(info, 100.0, 200.0, cursorPos);
2166 EXPECT_EQ(cursorPos.x, 879);
2167 EXPECT_EQ(cursorPos.y, 100);
2168 }
2169
2170 /**
2171 * @tc.name: InputWindowsManagerTest_UpdateAndAdjustMouseLocation_001
2172 * @tc.desc: Test the method for updating and adjusting mouse location
2173 * @tc.type: FUNC
2174 * @tc.require:
2175 */
2176 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateAndAdjustMouseLocation_001, TestSize.Level1)
2177 {
2178 CALL_TEST_DEBUG;
2179 int32_t displayId = 2;
2180 double x = 100.5;
2181 double y = 200.5;
2182 bool isRealData = true;
2183 std::shared_ptr<InputEvent> inputEvent = InputEvent::Create();
2184 ASSERT_NE(inputEvent, nullptr);
2185 WIN_MGR->UpdateAndAdjustMouseLocation(displayId, x, y, isRealData);
2186 auto ret = WIN_MGR->GetDisplayId(inputEvent);
2187 EXPECT_NE(displayId, ret);
2188 displayId = -1;
2189 x = 100.5;
2190 y = 200.5;
2191 isRealData = true;
2192 WIN_MGR->UpdateAndAdjustMouseLocation(displayId, x, y, isRealData);
2193 ret = WIN_MGR->GetDisplayId(inputEvent);
2194 EXPECT_NE(displayId, ret);
2195 displayId = 0;
2196 x = -100.5;
2197 y = -200.5;
2198 isRealData = true;
2199 WIN_MGR->UpdateAndAdjustMouseLocation(displayId, x, y, isRealData);
2200 ret = WIN_MGR->GetDisplayId(inputEvent);
2201 EXPECT_NE(displayId, ret);
2202 displayId = 0;
2203 x = 100.5;
2204 y = 200.5;
2205 isRealData = false;
2206 WIN_MGR->UpdateAndAdjustMouseLocation(displayId, x, y, isRealData);
2207 ret = WIN_MGR->GetDisplayId(inputEvent);
2208 EXPECT_NE(displayId, ret);
2209 }
2210
2211 /**
2212 * @tc.name: InputWindowsManagerTest_GetMouseInfo_001
2213 * @tc.desc: Test the GetMouseInfo method
2214 * @tc.type: FUNC
2215 * @tc.require:
2216 */
2217 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetMouseInfo_001, TestSize.Level1)
2218 {
2219 CALL_TEST_DEBUG;
2220 OLD::DisplayGroupInfo displayGroupInfo;
2221 MouseLocation mouseLocation;
2222 displayGroupInfo.displaysInfo.clear();
2223 MouseLocation result = WIN_MGR->GetMouseInfo();
2224 OLD::DisplayInfo displayInfo;
2225 displayInfo.id = 1;
2226 displayInfo.width = 1920;
2227 displayInfo.height = 1080;
2228 displayGroupInfo.displaysInfo.push_back(displayInfo);
2229 mouseLocation.displayId = 0;
2230 result = WIN_MGR->GetMouseInfo();
2231 displayGroupInfo.displaysInfo.push_back(displayInfo);
2232 mouseLocation.displayId = -1;
2233 MouseLocation expectedResult;
2234 expectedResult.displayId = 1;
2235 expectedResult.physicalX = 960;
2236 expectedResult.physicalY = 540;
2237 ASSERT_NO_FATAL_FAILURE(WIN_MGR->GetMouseInfo());
2238 }
2239
2240 /**
2241 * @tc.name: InputWindowsManagerTest_GetCursorPos_001
2242 * @tc.desc: Test the functionality of getting the cursor position
2243 * @tc.type: FUNC
2244 * @tc.require:
2245 */
2246 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetCursorPos_001, TestSize.Level1)
2247 {
2248 CALL_TEST_DEBUG;
2249 InputWindowsManager manager;
2250 manager.cursorPos_.displayId = -1;
2251 auto it = manager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
2252 if (it != manager.displayGroupInfoMap_.end()) {
2253 it->second.displaysInfo.push_back({0, 800, 600});
2254 }
2255 CursorPosition result = WIN_MGR->GetCursorPos();
2256 EXPECT_EQ(result.displayId, 1);
2257 manager.cursorPos_.displayId = 1;
2258 it->second.displaysInfo.push_back({1, 800, 600});
2259 result = WIN_MGR->GetCursorPos();
2260 EXPECT_EQ(result.displayId, 1);
2261 }
2262
2263 /**
2264 * @tc.name: InputWindowsManagerTest_ResetCursorPos_001
2265 * @tc.desc: Test the functionality of resetting cursor position
2266 * @tc.type: FUNC
2267 * @tc.require:
2268 */
2269 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ResetCursorPos_001, TestSize.Level1)
2270 {
2271 CALL_TEST_DEBUG;
2272 InputWindowsManager manager;
2273 auto it = manager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
2274 if (it != manager.displayGroupInfoMap_.end()) {
2275 it->second.displaysInfo.push_back({1, 800, 600});
2276 }
2277 CursorPosition result = WIN_MGR->ResetCursorPos();
2278 EXPECT_EQ(result.displayId, 1);
2279 it->second.displaysInfo.clear();
2280 result = WIN_MGR->ResetCursorPos();
2281 EXPECT_EQ(result.displayId, 1);
2282 }
2283
2284 /**
2285 * @tc.name: InputWindowsManagerTest_AppendExtraData_001
2286 * @tc.desc: Test the functionality of appending extra data in the input window manager
2287 * @tc.type: FUNC
2288 * @tc.require:
2289 */
2290 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_AppendExtraData_001, TestSize.Level1)
2291 {
2292 CALL_TEST_DEBUG;
2293 InputWindowsManager manager;
2294 ExtraData extraData;
2295 extraData.appended = true;
2296 extraData.buffer = std::vector<uint8_t> {1, 2, 3};
2297 extraData.pointerId = 12345;
2298 int32_t result = WIN_MGR->AppendExtraData(extraData);
2299 ASSERT_EQ(result, RET_OK);
2300 ASSERT_NE(manager.GetExtraData().appended, extraData.appended);
2301 ASSERT_NE(manager.GetExtraData().buffer, extraData.buffer);
2302 ASSERT_NE(manager.GetExtraData().pointerId, extraData.pointerId);
2303 }
2304
2305 /**
2306 * @tc.name: InputWindowsManagerTest_ClearExtraData_001
2307 * @tc.desc: Test the functionality of clearing extra data
2308 * @tc.type: FUNC
2309 * @tc.require:
2310 */
2311 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ClearExtraData_001, TestSize.Level1)
2312 {
2313 CALL_TEST_DEBUG;
2314 InputWindowsManager manager;
2315 manager.extraData_.appended = true;
2316 manager.extraData_.buffer.push_back(1);
2317 manager.extraData_.sourceType = 0;
2318 manager.extraData_.pointerId = 1;
2319 WIN_MGR->ClearExtraData();
2320 EXPECT_TRUE(manager.extraData_.appended);
2321 EXPECT_FALSE(manager.extraData_.buffer.empty());
2322 EXPECT_NE(-1, manager.extraData_.sourceType);
2323 EXPECT_NE(-1, manager.extraData_.pointerId);
2324 }
2325
2326 /**
2327 * @tc.name: InputWindowsManagerTest_GetExtraData_001
2328 * @tc.desc: Test the functionality of getting extra data in the input window manager
2329 * @tc.type: FUNC
2330 * @tc.require:
2331 */
2332 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetExtraData_001, TestSize.Level1)
2333 {
2334 CALL_TEST_DEBUG;
2335 ASSERT_NO_FATAL_FAILURE(WIN_MGR->GetExtraData());
2336 }
2337
2338 /**
2339 * @tc.name: InputWindowsManagerTest_IsWindowVisible_001
2340 * @tc.desc: Test the window visibility functionality of the input window manager
2341 * @tc.type: FUNC
2342 * @tc.require:
2343 */
2344 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsWindowVisible_001, TestSize.Level1)
2345 {
2346 CALL_TEST_DEBUG;
2347 int32_t invalidPid = -1;
2348 bool result = WIN_MGR->IsWindowVisible(invalidPid);
2349 EXPECT_TRUE(result);
2350 int32_t visiblePid = 0;
2351 result = WIN_MGR->IsWindowVisible(visiblePid);
2352 EXPECT_FALSE(result);
2353 int32_t invisiblePid = 1;
2354 result = WIN_MGR->IsWindowVisible(invisiblePid);
2355 EXPECT_FALSE(result);
2356 }
2357
2358 /**
2359 * @tc.name: InputWindowsManagerTest_UpdatePointerAction_001
2360 * @tc.desc: Test the update function of pointer action in Input Windows Manager
2361 * @tc.type: FUNC
2362 * @tc.require:
2363 */
2364 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerAction_001, TestSize.Level1)
2365 {
2366 CALL_TEST_DEBUG;
2367 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
2368 ASSERT_NE(pointerEvent, nullptr);
2369 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
2370 WIN_MGR->UpdatePointerAction(pointerEvent);
2371 EXPECT_EQ(pointerEvent->GetPointerAction(), PointerEvent::POINTER_ACTION_PULL_MOVE);
2372 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_UP);
2373 WIN_MGR->UpdatePointerAction(pointerEvent);
2374 EXPECT_EQ(pointerEvent->GetPointerAction(), PointerEvent::POINTER_ACTION_PULL_UP);
2375 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UP);
2376 WIN_MGR->UpdatePointerAction(pointerEvent);
2377 EXPECT_EQ(pointerEvent->GetPointerAction(), PointerEvent::POINTER_ACTION_PULL_UP);
2378 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_ENTER_WINDOW);
2379 WIN_MGR->UpdatePointerAction(pointerEvent);
2380 EXPECT_EQ(pointerEvent->GetPointerAction(), PointerEvent::POINTER_ACTION_PULL_IN_WINDOW);
2381 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_LEAVE_WINDOW);
2382 WIN_MGR->UpdatePointerAction(pointerEvent);
2383 EXPECT_EQ(pointerEvent->GetPointerAction(), PointerEvent::POINTER_ACTION_PULL_OUT_WINDOW);
2384 pointerEvent->SetPointerAction(100);
2385 WIN_MGR->UpdatePointerAction(pointerEvent);
2386 EXPECT_EQ(pointerEvent->GetPointerAction(), 100);
2387 }
2388
2389 /**
2390 * @tc.name: InputWindowsManagerTest_Dump_001
2391 * @tc.desc: Test the dump function of the input window manager
2392 * @tc.type: FUNC
2393 * @tc.require:
2394 */
2395 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_Dump_001, TestSize.Level1)
2396 {
2397 CALL_TEST_DEBUG;
2398 int32_t fd = 1;
2399 std::vector<std::string> args;
2400 ASSERT_NO_FATAL_FAILURE(WIN_MGR->Dump(fd, args));
2401 }
2402
2403 /**
2404 * @tc.name: InputWindowsManagerTest_TransformWindowXY_001
2405 * @tc.desc: Test the TransformWindowXY function of the input window manager
2406 * @tc.type: FUNC
2407 * @tc.require:
2408 */
2409 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_TransformWindowXY_001, TestSize.Level1)
2410 {
2411 CALL_TEST_DEBUG;
2412 WindowInfo window;
2413 double logicX = 10.0;
2414 double logicY = 20.0;
2415 std::pair<double, double> result = WIN_MGR->TransformWindowXY(window, logicX, logicY);
2416 double ret = result.first;
2417 EXPECT_EQ(ret, logicX);
2418 double ret1 = result.second;
2419 EXPECT_EQ(ret1, logicY);
2420 }
2421
2422 /**
2423 * @tc.name: InputWindowsManagerTest_IsValidZorderWindow_001
2424 * @tc.desc: Test the validity of the input window manager
2425 * @tc.type: FUNC
2426 * @tc.require:
2427 */
2428 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsValidZorderWindow_001, TestSize.Level1)
2429 {
2430 CALL_TEST_DEBUG;
2431 WindowInfo window;
2432 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
2433 ASSERT_NE(pointerEvent, nullptr);
2434 pointerEvent->HasFlag(InputEvent::EVENT_FLAG_SIMULATE);
2435 bool result = WIN_MGR->IsValidZorderWindow(window, pointerEvent);
2436 EXPECT_TRUE(result);
2437 }
2438
2439 /**
2440 * @tc.name: InputWindowsManagerTest_HandleWindowInputType_004
2441 * @tc.desc: Test the functionality of handling window input types in the Input Windows Manage
2442 * @tc.type: FUNC
2443 * @tc.require:
2444 */
2445 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandleWindowInputType_004, TestSize.Level1)
2446 {
2447 CALL_TEST_DEBUG;
2448 UDSServer udsServer;
2449 WIN_MGR->Init(udsServer);
2450 auto pointerEvent = PointerEvent::Create();
2451 ASSERT_NE(pointerEvent, nullptr);
2452 WindowInfo window;
2453 window.windowInputType = WindowInputType::TRANSMIT_EXCEPT_MOVE;
2454 ASSERT_FALSE(WIN_MGR->HandleWindowInputType(window, pointerEvent));
2455 }
2456
2457 /**
2458 * @tc.name: InputWindowsManagerTest_GetWindowAndDisplayInfo_001
2459 * @tc.desc: Test the function of getting window and display information
2460 * @tc.type: FUNC
2461 * @tc.require:
2462 */
2463 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowAndDisplayInfo_001, TestSize.Level1)
2464 {
2465 CALL_TEST_DEBUG;
2466 int32_t windowId = 1;
2467 int32_t displayId = 1;
2468 auto result = WIN_MGR->GetWindowAndDisplayInfo(windowId, displayId);
2469 ASSERT_TRUE(result.has_value());
2470 EXPECT_EQ(result->id, windowId);
2471 windowId = -1;
2472 displayId = 1;
2473 result = WIN_MGR->GetWindowAndDisplayInfo(windowId, displayId);
2474 ASSERT_FALSE(result.has_value());
2475 windowId = 1;
2476 displayId = -1;
2477 result = WIN_MGR->GetWindowAndDisplayInfo(windowId, displayId);
2478 ASSERT_TRUE(result.has_value());
2479 }
2480
2481 /**
2482 * @tc.name: InputWindowsManagerTest_GetTargetWindowIds_001
2483 * @tc.desc: Test the functionality of getting target window IDs
2484 * @tc.type: FUNC
2485 * @tc.require:
2486 */
2487 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetTargetWindowIds_001, TestSize.Level1)
2488 {
2489 CALL_TEST_DEBUG;
2490 std::vector<int32_t> windowIds;
2491 int32_t pointerItemId = 1;
2492 int32_t windowId = 100;
2493 int32_t sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
2494 WIN_MGR->AddTargetWindowIds(pointerItemId, sourceType, windowId);
2495 WIN_MGR->GetTargetWindowIds(pointerItemId, sourceType, windowIds);
2496 ASSERT_TRUE(!windowIds.empty());
2497 WIN_MGR->ClearTargetWindowId(pointerItemId);
2498 }
2499
2500 /**
2501 * @tc.name: InputWindowsManagerTest_AddTargetWindowIds_001
2502 * @tc.desc: Test the functionality of adding target window IDs
2503 * @tc.type: FUNC
2504 * @tc.require:
2505 */
2506 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_AddTargetWindowIds_001, TestSize.Level1)
2507 {
2508 CALL_TEST_DEBUG;
2509 InputWindowsManager manager;
2510 int32_t pointerItemId = 1;
2511 int32_t windowId = 100;
2512 int32_t sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
2513 WIN_MGR->AddTargetWindowIds(pointerItemId, sourceType, windowId);
2514 ASSERT_FALSE(manager.targetTouchWinIds_.find(pointerItemId) != manager.targetTouchWinIds_.end());
2515 ASSERT_EQ(manager.targetTouchWinIds_[pointerItemId].size(), 0);
2516 }
2517
2518 /**
2519 * @tc.name: InputWindowsManagerTest_AddTargetWindowIds_002
2520 * @tc.desc: Test the functionality of adding target window IDs
2521 * @tc.type: FUNC
2522 * @tc.require:
2523 */
2524 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_AddTargetWindowIds_002, TestSize.Level1)
2525 {
2526 CALL_TEST_DEBUG;
2527 InputWindowsManager manager;
2528 int32_t pointerItemId = 2;
2529 int32_t windowId1 = 200;
2530 int32_t windowId2 = 201;
2531 int32_t sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
2532 manager.targetTouchWinIds_[pointerItemId] = {windowId1};
2533 WIN_MGR->AddTargetWindowIds(pointerItemId, sourceType, windowId2);
2534 ASSERT_TRUE(manager.targetTouchWinIds_.find(pointerItemId) != manager.targetTouchWinIds_.end());
2535 ASSERT_EQ(manager.targetTouchWinIds_[pointerItemId].size(), 1);
2536 ASSERT_EQ(manager.targetTouchWinIds_[pointerItemId][0], windowId1);
2537 ASSERT_NE(manager.targetTouchWinIds_[pointerItemId][1], windowId2);
2538 }
2539
2540 /**
2541 * @tc.name: InputWindowsManagerTest_CheckWindowIdPermissionByPid_002
2542 * @tc.desc: Test the functionality of checking window ID permission by process ID
2543 * @tc.type: FUNC
2544 * @tc.require:
2545 */
2546 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckWindowIdPermissionByPid_002, TestSize.Level1)
2547 {
2548 CALL_TEST_DEBUG;
2549 int32_t windowId = -123;
2550 int32_t pid = -456;
2551 int32_t result = WIN_MGR->CheckWindowIdPermissionByPid(windowId, pid);
2552 EXPECT_EQ(result, RET_ERR);
2553 }
2554
2555 /**
2556 * @tc.name: InputWindowsManagerTest_IsTransparentWin_001
2557 * @tc.desc: Test the functionality of transparent windows
2558 * @tc.type: FUNC
2559 * @tc.require:
2560 */
2561 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsTransparentWin_001, TestSize.Level1)
2562 {
2563 CALL_TEST_DEBUG;
2564 std::unique_ptr<Media::PixelMap> pixelMap = nullptr;
2565 int32_t logicalX = 0;
2566 int32_t logicalY = 0;
2567 auto result = WIN_MGR->IsTransparentWin(pixelMap, logicalX, logicalY);
2568 EXPECT_FALSE(result);
2569 }
2570
2571 /**
2572 * @tc.name: InputWindowsManagerTest_SetCurrentUser_001
2573 * @tc.desc: Test the functionality of setting the current user
2574 * @tc.type: FUNC
2575 * @tc.require:
2576 */
2577 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetCurrentUser_001, TestSize.Level1)
2578 {
2579 CALL_TEST_DEBUG;
2580 int32_t userId = 123;
2581 auto ret = WIN_MGR->SetCurrentUser(userId);
2582 EXPECT_EQ(ret, RET_OK);
2583 userId = -456;
2584 ret = WIN_MGR->SetCurrentUser(userId);
2585 EXPECT_EQ(ret, RET_OK);
2586 }
2587
2588 /**
2589 * @tc.name: InputWindowsManagerTest_UpdatePointerAction_01
2590 * @tc.desc: Test UpdatePointerAction
2591 * @tc.type: FUNC
2592 * @tc.require:
2593 */
2594 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerAction_01, TestSize.Level1)
2595 {
2596 CALL_TEST_DEBUG;
2597 UDSServer udsServer;
2598 WIN_MGR->Init(udsServer);
2599 auto pointerEvent = PointerEvent::Create();
2600 ASSERT_NE(pointerEvent, nullptr);
2601 int32_t action = pointerEvent->GetPointerAction();
2602 action = PointerEvent::POINTER_ACTION_MOVE;
2603 WIN_MGR->UpdatePointerAction(pointerEvent);
2604 ASSERT_NO_FATAL_FAILURE(pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_MOVE));
2605 }
2606
2607 /**
2608 * @tc.name: InputWindowsManagerTest_UpdatePointerAction_02
2609 * @tc.desc: Test UpdatePointerAction
2610 * @tc.type: FUNC
2611 * @tc.require:
2612 */
2613 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerAction_02, TestSize.Level1)
2614 {
2615 CALL_TEST_DEBUG;
2616 UDSServer udsServer;
2617 WIN_MGR->Init(udsServer);
2618 auto pointerEvent = PointerEvent::Create();
2619 ASSERT_NE(pointerEvent, nullptr);
2620 int32_t action = pointerEvent->GetPointerAction();
2621 action = PointerEvent::POINTER_ACTION_UP;
2622 WIN_MGR->UpdatePointerAction(pointerEvent);
2623 ASSERT_NO_FATAL_FAILURE(pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_UP));
2624 }
2625
2626 /**
2627 * @tc.name: InputWindowsManagerTest_UpdatePointerAction_03
2628 * @tc.desc: Test UpdatePointerAction
2629 * @tc.type: FUNC
2630 * @tc.require:
2631 */
2632 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerAction_03, TestSize.Level1)
2633 {
2634 CALL_TEST_DEBUG;
2635 UDSServer udsServer;
2636 WIN_MGR->Init(udsServer);
2637 auto pointerEvent = PointerEvent::Create();
2638 ASSERT_NE(pointerEvent, nullptr);
2639 int32_t action = pointerEvent->GetPointerAction();
2640 action = PointerEvent::POINTER_ACTION_ENTER_WINDOW;
2641 WIN_MGR->UpdatePointerAction(pointerEvent);
2642 ASSERT_NO_FATAL_FAILURE(pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_IN_WINDOW));
2643 }
2644
2645 /**
2646 * @tc.name: InputWindowsManagerTest_UpdatePointerAction_04
2647 * @tc.desc: Test UpdatePointerAction
2648 * @tc.type: FUNC
2649 * @tc.require:
2650 */
2651 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerAction_04, TestSize.Level1)
2652 {
2653 CALL_TEST_DEBUG;
2654 UDSServer udsServer;
2655 WIN_MGR->Init(udsServer);
2656 auto pointerEvent = PointerEvent::Create();
2657 ASSERT_NE(pointerEvent, nullptr);
2658 int32_t action = pointerEvent->GetPointerAction();
2659 action = PointerEvent::POINTER_ACTION_LEAVE_WINDOW;
2660 WIN_MGR->UpdatePointerAction(pointerEvent);
2661 ASSERT_NO_FATAL_FAILURE(pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_OUT_WINDOW));
2662 }
2663
2664 /**
2665 * @tc.name: InputWindowsManagerTest_UpdateDisplayId_002
2666 * @tc.desc: Test UpdateDisplayId
2667 * @tc.type: FUNC
2668 * @tc.require:
2669 */
2670 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayId_002, TestSize.Level1)
2671 {
2672 auto pointerEvent = PointerEvent::Create();
2673 pointerEvent->SetTargetDisplayId(1);
2674 auto id = pointerEvent->GetTargetDisplayId();
2675 ASSERT_TRUE(WIN_MGR->UpdateDisplayId(id));
2676 }
2677
2678 /**
2679 * @tc.name: InputWindowsManagerTest_UpdateDisplayId_003
2680 * @tc.desc: Test UpdateDisplayId
2681 * @tc.type: FUNC
2682 * @tc.require:
2683 */
2684 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayId_003, TestSize.Level1)
2685 {
2686 auto pointerEvent = PointerEvent::Create();
2687 pointerEvent->SetTargetDisplayId(10);
2688 auto id = pointerEvent->GetTargetDisplayId();
2689 ASSERT_FALSE(WIN_MGR->UpdateDisplayId(id));
2690 }
2691
2692 /**
2693 * @tc.name: InputWindowsManagerTest_Init_001
2694 * @tc.desc: Test Init
2695 * @tc.type: FUNC
2696 * @tc.require:
2697 */
2698 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_Init_001, TestSize.Level1)
2699 {
2700 UDSServer udsServer;
2701 WIN_MGR->Init(udsServer);
2702 EXPECT_TRUE(true);
2703 }
2704
2705 /**
2706 * @tc.name: InputWindowsManagerTest_UpdateCaptureMode_002
2707 * @tc.desc: Test UpdateCaptureMode
2708 * @tc.type: FUNC
2709 * @tc.require:
2710 */
2711 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateCaptureMode_002, TestSize.Level1)
2712 {
2713 OLD::DisplayGroupInfo displayGroupInfo;
2714 OLD::DisplayInfo info;
2715 info.id = 1;
2716 info.x = 1;
2717 info.y = 1;
2718 info.width = 2;
2719 info.height = 2;
2720 info.dpi = 240;
2721 info.name = "pp";
2722 info.uniq = "pp";
2723 info.direction = DIRECTION0;
2724 displayGroupInfo.displaysInfo.push_back(info);
2725 WIN_MGR->UpdateCaptureMode(displayGroupInfo);
2726 ASSERT_FALSE(WIN_MGR->captureModeInfo_.isCaptureMode);
2727 }
2728
2729 /**
2730 * @tc.name: InputWindowsManagerTest_IsWindowVisible_002
2731 * @tc.desc: Test IsWindowVisible
2732 * @tc.type: FUNC
2733 * @tc.require:
2734 */
2735 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsWindowVisible_002, TestSize.Level1)
2736 {
2737 int32_t pid = 1000;
2738 auto ret = WIN_MGR->IsWindowVisible(pid);
2739 ASSERT_FALSE(ret);
2740 }
2741
2742 /**
2743 * @tc.name: InputWindowsManagerTest_IsWindowVisible_003
2744 * @tc.desc: Test IsWindowVisible
2745 * @tc.type: FUNC
2746 * @tc.require:
2747 */
2748 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsWindowVisible_003, TestSize.Level1)
2749 {
2750 int32_t pid = -1;
2751 auto ret = WIN_MGR->IsWindowVisible(pid);
2752 ASSERT_TRUE(ret);
2753 }
2754
2755 /**
2756 * @tc.name: InputWindowsManagerTest_GetWindowGroupInfoByDisplayId
2757 * @tc.desc: Test GetWindowGroupInfoByDisplayId
2758 * @tc.type: FUNC
2759 * @tc.require:
2760 */
2761 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowGroupInfoByDisplayId, TestSize.Level1)
2762 {
2763 CALL_TEST_DEBUG;
2764 InputWindowsManager inputWindowsManager;
2765 WindowGroupInfo windowGroupInfo;
2766 int32_t displayId = 1;
2767 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(displayId, windowGroupInfo));
2768 EXPECT_TRUE(inputWindowsManager.GetWindowGroupInfoByDisplayId(displayId).empty());
2769
2770 WindowInfo windowInfo;
2771 displayId = 2;
2772 windowInfo.id = 1;
2773 windowGroupInfo.windowsInfo.push_back(windowInfo);
2774 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(displayId, windowGroupInfo));
2775 EXPECT_FALSE(!inputWindowsManager.GetWindowGroupInfoByDisplayId(displayId).empty());
2776 }
2777
2778 /**
2779 * @tc.name: InputWindowsManagerTest_GetClientFd
2780 * @tc.desc: Test GetClientFd
2781 * @tc.type: FUNC
2782 * @tc.require:
2783 */
2784 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetClientFd, TestSize.Level1)
2785 {
2786 InputWindowsManager inputWindowsManager;
2787 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
2788 EXPECT_NE(pointerEvent, nullptr);
2789 WindowInfoEX windowInfoEX;
2790 windowInfoEX.flag = false;
2791 pointerEvent->SetPointerId(0);
2792 inputWindowsManager.touchItemDownInfos_.insert(std::make_pair(pointerEvent->GetPointerId(), windowInfoEX));
2793 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent), INVALID_FD);
2794 pointerEvent->SetPointerId(1);
2795 pointerEvent->SetTargetDisplayId(10);
2796 pointerEvent->SetTargetWindowId(15);
2797 WindowGroupInfo windowGroupInfo;
2798 WindowInfo windowInfo;
2799 windowInfo.id = 0;
2800 windowInfo.pid = 5;
2801 windowGroupInfo.windowsInfo.push_back(windowInfo);
2802 windowInfo.id = 15;
2803 windowInfo.pid = 6;
2804 windowGroupInfo.windowsInfo.push_back(windowInfo);
2805 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(pointerEvent->GetTargetDisplayId(), windowGroupInfo));
2806 UDSServer udsServer;
2807 udsServer.idxPidMap_.insert(std::make_pair(6, 15));
2808 inputWindowsManager.udsServer_ = &udsServer;
2809 EXPECT_NE(inputWindowsManager.udsServer_, nullptr);
2810 EXPECT_NE(inputWindowsManager.GetClientFd(pointerEvent), 15);
2811 pointerEvent->SetTargetWindowId(20);
2812 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_LEAVE_WINDOW);
2813 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent), INVALID_FD);
2814 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
2815 inputWindowsManager.touchItemDownInfos_.clear();
2816 windowInfoEX.flag = true;
2817 windowInfoEX.window.agentWindowId = 1;
2818 pointerEvent->SetPointerId(0);
2819 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
2820 inputWindowsManager.touchItemDownInfos_.insert(std::make_pair(pointerEvent->GetPointerId(), windowInfoEX));
2821 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent), INVALID_FD);
2822 pointerEvent->SetPointerId(7);
2823 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent), INVALID_FD);
2824 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
2825 inputWindowsManager.mouseDownInfo_.pid = 1;
2826 inputWindowsManager.mouseDownInfo_.agentWindowId = 6;
2827 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent), INVALID_FD);
2828 inputWindowsManager.mouseDownInfo_.pid = -1;
2829 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent), INVALID_FD);
2830 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_JOYSTICK);
2831 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent), INVALID_FD);
2832 }
2833
2834 /**
2835 * @tc.name: InputWindowsManagerTest_GetClientFd_002
2836 * @tc.desc: Test GetClientFd
2837 * @tc.type: FUNC
2838 * @tc.require:
2839 */
2840 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetClientFd_002, TestSize.Level1)
2841 {
2842 CALL_TEST_DEBUG;
2843 InputWindowsManager inputWindowsManager;
2844 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
2845 EXPECT_NE(pointerEvent, nullptr);
2846 UDSServer udsServer;
2847 int32_t udsPid = 20;
2848 int32_t udsFd = 15;
2849 udsServer.idxPidMap_.insert(std::make_pair(udsPid, udsFd));
2850 inputWindowsManager.udsServer_ = &udsServer;
2851 int32_t windowId = 15;
2852 EXPECT_NE(inputWindowsManager.udsServer_, nullptr);
2853 WindowGroupInfo widGroupInfo;
2854 WindowInfo windowInfo;
2855 pointerEvent->SetTargetDisplayId(15);
2856 windowInfo.id = 5;
2857 windowInfo.pid = 10;
2858 widGroupInfo.windowsInfo.push_back(windowInfo);
2859 windowInfo.id = 15;
2860 windowInfo.pid = 20;
2861 widGroupInfo.windowsInfo.push_back(windowInfo);
2862 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(pointerEvent->GetTargetDisplayId(), widGroupInfo));
2863 EXPECT_NE(inputWindowsManager.GetClientFd(pointerEvent, windowId), udsFd);
2864 windowId = 7;
2865 EXPECT_EQ(inputWindowsManager.GetClientFd(pointerEvent, windowId), INVALID_FD);
2866 }
2867
2868 /**
2869 * @tc.name: InputWindowsManagerTest_CheckFocusWindowChange
2870 * @tc.desc: Test CheckFocusWindowChange
2871 * @tc.type: FUNC
2872 * @tc.require:
2873 */
2874 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckFocusWindowChange, TestSize.Level1)
2875 {
2876 CALL_TEST_DEBUG;
2877 InputWindowsManager inputWindowsManager;
2878 OLD::DisplayGroupInfo displayGroupInfo;
2879 displayGroupInfo.focusWindowId = 1;
2880 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
2881 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
2882 it->second.focusWindowId = -1;
2883 }
2884 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CheckFocusWindowChange(displayGroupInfo));
2885 }
2886
2887 /**
2888 * @tc.name: InputWindowsManagerTest_CheckZorderWindowChange
2889 * @tc.desc: Test CheckZorderWindowChange
2890 * @tc.type: FUNC
2891 * @tc.require:
2892 */
2893 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckZorderWindowChange, TestSize.Level1)
2894 {
2895 CALL_TEST_DEBUG;
2896 InputWindowsManager inputWindowsManager;
2897 std::vector<WindowInfo> oldWindowsInfo;
2898 std::vector<WindowInfo> newWindowsInfo;
2899 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CheckZorderWindowChange(oldWindowsInfo, newWindowsInfo));
2900 }
2901
2902 /**
2903 * @tc.name: InputWindowsManagerTest_UpdateCaptureMode
2904 * @tc.desc: Test UpdateCaptureMode
2905 * @tc.type: FUNC
2906 * @tc.require:
2907 */
2908 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateCaptureMode, TestSize.Level1)
2909 {
2910 CALL_TEST_DEBUG;
2911 InputWindowsManager inputWindowsManager;
2912 OLD::DisplayGroupInfo displayGroupInfo;
2913 WindowInfo windowInfo;
2914 inputWindowsManager.captureModeInfo_.isCaptureMode = true;
2915 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
2916 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
2917 it->second.focusWindowId = 25;
2918 }
2919 displayGroupInfo.focusWindowId = 25;
2920 windowInfo.id = 10;
2921 it->second.windowsInfo.push_back(windowInfo);
2922 windowInfo.id = 11;
2923 displayGroupInfo.windowsInfo.push_back(windowInfo);
2924 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateCaptureMode(displayGroupInfo));
2925 }
2926
2927 /**
2928 * @tc.name: InputWindowsManagerTest_UpdateDisplayInfoByIncrementalInfo
2929 * @tc.desc: Test UpdateDisplayInfoByIncrementalInfo
2930 * @tc.type: FUNC
2931 * @tc.require:
2932 */
2933 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayInfoByIncrementalInfo, TestSize.Level1)
2934 {
2935 CALL_TEST_DEBUG;
2936 InputWindowsManager inputWindowsManager;
2937 WindowInfo window;
2938 OLD::DisplayGroupInfo displayGroupInfo;
2939 WindowInfo windowInfo;
2940 window.action = WINDOW_UPDATE_ACTION::ADD_END;
2941 window.id = 5;
2942 windowInfo.id = 10;
2943 displayGroupInfo.windowsInfo.push_back(windowInfo);
2944 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayInfoByIncrementalInfo(window, displayGroupInfo));
2945 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayInfoByIncrementalInfo(window, displayGroupInfo));
2946 window.id = 5;
2947 window.action = WINDOW_UPDATE_ACTION::DEL;
2948 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayInfoByIncrementalInfo(window, displayGroupInfo));
2949 window.action = WINDOW_UPDATE_ACTION::CHANGE;
2950 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayInfoByIncrementalInfo(window, displayGroupInfo));
2951 window.id = 10;
2952 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayInfoByIncrementalInfo(window, displayGroupInfo));
2953 window.action = WINDOW_UPDATE_ACTION::UNKNOWN;
2954 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayInfoByIncrementalInfo(window, displayGroupInfo));
2955 }
2956
2957 /**
2958 * @tc.name: InputWindowsManagerTest_UpdateDisplayMode
2959 * @tc.desc: Test UpdateDisplayMode
2960 * @tc.type: FUNC
2961 * @tc.require:
2962 */
2963 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayMode, TestSize.Level1)
2964 {
2965 CALL_TEST_DEBUG;
2966 InputWindowsManager inputWindowsManager;
2967 OLD::DisplayInfo displayInfo;
2968 displayInfo.displayMode = DisplayMode::FULL;
2969 inputWindowsManager.displayMode_ = DisplayMode::FULL;
2970 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
2971 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
2972 it->second.displaysInfo.push_back(displayInfo);
2973 }
2974 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayMode());
2975 inputWindowsManager.displayMode_ = DisplayMode::MAIN;
2976 FINGERSENSE_WRAPPER->sendFingerSenseDisplayMode_ = nullptr;
2977 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayMode());
2978 inputWindowsManager.displayMode_ = DisplayMode::MAIN;
2979 FINGERSENSE_WRAPPER->sendFingerSenseDisplayMode_ = FingersenseWrapperTest;
2980 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayMode());
2981 }
2982
2983 /**
2984 * @tc.name: InputWindowsManagerTest_GetPhysicalDisplay
2985 * @tc.desc: Test GetPhysicalDisplay
2986 * @tc.type: FUNC
2987 * @tc.require:
2988 */
2989 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPhysicalDisplay, TestSize.Level1)
2990 {
2991 CALL_TEST_DEBUG;
2992 InputWindowsManager inputWindowsManager;
2993 int32_t id = 1;
2994 OLD::DisplayInfo displayInfo;
2995 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
2996 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
2997 displayInfo.id = 0;
2998 it->second.displaysInfo.push_back(displayInfo);
2999 }
3000 displayInfo.id = 1;
3001 it->second.displaysInfo.push_back(displayInfo);
3002 EXPECT_NE(inputWindowsManager.GetPhysicalDisplay(id), nullptr);
3003 }
3004
3005 /**
3006 * @tc.name: InputWindowsManagerTest_FindPhysicalDisplayInfo
3007 * @tc.desc: Test FindPhysicalDisplayInfo
3008 * @tc.type: FUNC
3009 * @tc.require:
3010 */
3011 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_FindPhysicalDisplayInfo, TestSize.Level1)
3012 {
3013 CALL_TEST_DEBUG;
3014 InputWindowsManager inputWindowsManager;
3015 OLD::DisplayInfo displayInfo;
3016 std::string uniq = "uniq_test";
3017 displayInfo.uniq = "uniq_test";
3018 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3019 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3020 it->second.displaysInfo.push_back(displayInfo);
3021 }
3022 EXPECT_NE(inputWindowsManager.FindPhysicalDisplayInfo(uniq), nullptr);
3023 }
3024
3025 /**
3026 * @tc.name: InputWindowsManagerTest_OnSessionLost
3027 * @tc.desc: Test OnSessionLost
3028 * @tc.type: FUNC
3029 * @tc.require:
3030 */
3031 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_OnSessionLost, TestSize.Level1)
3032 {
3033 CALL_TEST_DEBUG;
3034 InputWindowsManager inputWindowsManager;
3035 int32_t pointerStylePid = 10;
3036 int32_t uidRoot = 0;
3037 std::string programName = "uds_sesion_test";
3038 int32_t moduleType = 3;
3039 int32_t pid = 9;
3040 int32_t fd = -1;
3041 SessionPtr sess = std::make_shared<UDSSession>(programName, moduleType, fd, uidRoot, pid);
3042 int32_t windowId = 1;
3043 PointerStyle pointerStyle;
3044 pointerStyle.size = 1;
3045 pointerStyle.color = 2;
3046 pointerStyle.id = 3;
3047 std::map<int32_t, PointerStyle> pointerStyleMap;
3048 pointerStyleMap.insert(std::make_pair(windowId, pointerStyle));
3049 inputWindowsManager.pointerStyle_.insert(std::make_pair(pointerStylePid, pointerStyleMap));
3050 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.OnSessionLost(sess));
3051
3052 pid = 10;
3053 SessionPtr session = std::make_shared<UDSSession>(programName, moduleType, fd, uidRoot, pid);
3054 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.OnSessionLost(session));
3055 }
3056
3057 /**
3058 * @tc.name: InputWindowsManagerTest_UpdatePoinerStyle
3059 * @tc.desc: Test UpdatePoinerStyle
3060 * @tc.type: FUNC
3061 * @tc.require:
3062 */
3063 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePoinerStyle, TestSize.Level1)
3064 {
3065 CALL_TEST_DEBUG;
3066 InputWindowsManager inputWindowsManager;
3067 int32_t pid = 1;
3068 int32_t windowId = 1;
3069 PointerStyle pointerStyle;
3070 pointerStyle.size = 1;
3071 pointerStyle.color = 2;
3072 pointerStyle.id = 3;
3073 std::map<int32_t, PointerStyle> pointerStyleMap;
3074 pointerStyleMap.insert(std::make_pair(windowId, pointerStyle));
3075 inputWindowsManager.pointerStyle_.insert(std::make_pair(pid, pointerStyleMap));
3076 windowId = 2;
3077 WindowInfo windowInfo;
3078 windowInfo.id = 3;
3079 windowInfo.pid = 6;
3080 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3081 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3082 it->second.windowsInfo.push_back(windowInfo);
3083 }
3084 windowInfo.id = 2;
3085 windowInfo.pid = 1;
3086 it->second.windowsInfo.push_back(windowInfo);
3087 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePoinerStyle(pid, windowId, pointerStyle));
3088 }
3089
3090 /**
3091 * @tc.name: InputWindowsManagerTest_UpdateSceneBoardPointerStyle
3092 * @tc.desc: Test UpdateSceneBoardPointerStyle
3093 * @tc.type: FUNC
3094 * @tc.require:
3095 */
3096 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateSceneBoardPointerStyle, TestSize.Level1)
3097 {
3098 CALL_TEST_DEBUG;
3099 InputWindowsManager inputWindowsManager;
3100 int32_t pid = 1000;
3101 int32_t windowId = 987654321;
3102 bool isUiExtension = true;
3103 PointerStyle style;
3104 style.id = 0;
3105 std::map<int32_t, PointerStyle> pointerStyleMap;
3106 pointerStyleMap.insert(std::make_pair(windowId, style));
3107 inputWindowsManager.uiExtensionPointerStyle_.insert(std::make_pair(pid, pointerStyleMap));
3108 pid = 1001;
3109 EXPECT_EQ(inputWindowsManager.UpdateSceneBoardPointerStyle(pid, windowId, style, isUiExtension), RET_OK);
3110 pid = 1000;
3111 windowId = 123456789;
3112 EXPECT_EQ(inputWindowsManager.UpdateSceneBoardPointerStyle(pid, windowId, style, isUiExtension), RET_OK);
3113 }
3114
3115 /**
3116 * @tc.name: InputWindowsManagerTest_SetGlobalDefaultPointerStyle
3117 * @tc.desc: Test SetGlobalDefaultPointerStyle
3118 * @tc.type: FUNC
3119 * @tc.require:
3120 */
3121 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetGlobalDefaultPointerStyle, TestSize.Level1)
3122 {
3123 CALL_TEST_DEBUG;
3124 InputWindowsManager inputWindowsManager;
3125 int32_t defaultPointerStyle = 0;
3126 int32_t cursorCircleStyle = 41;
3127 int32_t pid = 100;
3128 int32_t windowId = 1000;
3129 PointerStyle pointerStyle;
3130 pointerStyle.id = defaultPointerStyle;
3131 std::map<int32_t, PointerStyle> pointerStyleMap;
3132 pointerStyleMap.insert(std::make_pair(windowId, pointerStyle));
3133 inputWindowsManager.pointerStyle_.insert(std::make_pair(pid, pointerStyleMap));
3134 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SetGlobalDefaultPointerStyle());
3135
3136 pointerStyle.id = cursorCircleStyle;
3137 inputWindowsManager.pointerStyle_[pid][windowId] = pointerStyle;
3138 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SetGlobalDefaultPointerStyle());
3139 }
3140
3141 /**
3142 * @tc.name: InputWindowsManagerTest_SetPointerStyle
3143 * @tc.desc: Test SetPointerStyle
3144 * @tc.type: FUNC
3145 * @tc.require:
3146 */
3147 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetPointerStyle, TestSize.Level1)
3148 {
3149 CALL_TEST_DEBUG;
3150 InputWindowsManager inputWindowsManager;
3151 bool isUiExtension = false;
3152 int32_t pid = 100;
3153 int32_t windowId = 1000;
3154 PointerStyle pointerStyle;
3155 pointerStyle.id = 0;
3156 std::map<int32_t, PointerStyle> pointerStyleMap;
3157 pointerStyleMap.insert(std::make_pair(windowId, pointerStyle));
3158 inputWindowsManager.uiExtensionPointerStyle_.insert(std::make_pair(pid, pointerStyleMap));
3159 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SetPointerStyle(pid, windowId, pointerStyle, isUiExtension));
3160 }
3161
3162 /**
3163 * @tc.name: InputWindowsManagerTest_ClearWindowPointerStyle
3164 * @tc.desc: Test ClearWindowPointerStyle
3165 * @tc.type: FUNC
3166 * @tc.require:
3167 */
3168 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ClearWindowPointerStyle, TestSize.Level1)
3169 {
3170 CALL_TEST_DEBUG;
3171 InputWindowsManager inputWindowsManager;
3172 int32_t pid = 100;
3173 int32_t windowId = 1000;
3174 PointerStyle pointerStyle;
3175 pointerStyle.id = 0;
3176 std::map<int32_t, PointerStyle> pointerStyleMap;
3177 pointerStyleMap.insert(std::make_pair(windowId, pointerStyle));
3178 inputWindowsManager.pointerStyle_.insert(std::make_pair(pid, pointerStyleMap));
3179 windowId = 1001;
3180 EXPECT_EQ(inputWindowsManager.ClearWindowPointerStyle(pid, windowId), RET_OK);
3181 windowId = 1000;
3182 EXPECT_EQ(inputWindowsManager.ClearWindowPointerStyle(pid, windowId), RET_OK);
3183 }
3184
3185 /**
3186 * @tc.name: InputWindowsManagerTest_GetPointerStyle
3187 * @tc.desc: Test GetPointerStyle
3188 * @tc.type: FUNC
3189 * @tc.require:
3190 */
3191 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPointerStyle, TestSize.Level1)
3192 {
3193 CALL_TEST_DEBUG;
3194 InputWindowsManager inputWindowsManager;
3195 bool isUiExtension = true;
3196 int32_t pid = 100;
3197 int32_t windowId = 1000;
3198 PointerStyle pointerStyle;
3199 pointerStyle.id = 0;
3200 std::map<int32_t, PointerStyle> pointerStyleMap;
3201 pointerStyleMap.insert(std::make_pair(windowId, pointerStyle));
3202 inputWindowsManager.uiExtensionPointerStyle_.insert(std::make_pair(pid, pointerStyleMap));
3203 pid = 101;
3204 EXPECT_EQ(inputWindowsManager.GetPointerStyle(pid, windowId, pointerStyle, isUiExtension), RET_OK);
3205 pid = 100;
3206 windowId = 100;
3207 EXPECT_EQ(inputWindowsManager.GetPointerStyle(pid, windowId, pointerStyle, isUiExtension), RET_OK);
3208 windowId = 1000;
3209 EXPECT_EQ(inputWindowsManager.GetPointerStyle(pid, windowId, pointerStyle, isUiExtension), RET_OK);
3210 }
3211
3212 /**
3213 * @tc.name: InputWindowsManagerTest_UpdateDisplayId
3214 * @tc.desc: Test UpdateDisplayId
3215 * @tc.type: FUNC
3216 * @tc.require:
3217 */
3218 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayId, TestSize.Level1)
3219 {
3220 CALL_TEST_DEBUG;
3221 InputWindowsManager inputWindowsManager;
3222 int32_t displayId = -1;
3223 OLD::DisplayInfo displayInfo;
3224 displayInfo.id = 10;
3225 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3226 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3227 it->second.displaysInfo.push_back(displayInfo);
3228 }
3229 EXPECT_TRUE(inputWindowsManager.UpdateDisplayId(displayId));
3230 EXPECT_TRUE(inputWindowsManager.UpdateDisplayId(displayId));
3231 displayId = 15;
3232 EXPECT_FALSE(inputWindowsManager.UpdateDisplayId(displayId));
3233 }
3234
3235 /**
3236 * @tc.name: InputWindowsManagerTest_SelectWindowInfo
3237 * @tc.desc: Test SelectWindowInfo
3238 * @tc.type: FUNC
3239 * @tc.require:
3240 */
3241 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectWindowInfo, TestSize.Level1)
3242 {
3243 CALL_TEST_DEBUG;
3244 InputWindowsManager inputWindowsManager;
3245 int32_t desplayId = 10;
3246 int32_t logicalX = 200;
3247 int32_t logicalY = 200;
3248 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
3249 EXPECT_NE(pointerEvent, nullptr);
3250 pointerEvent->SetTargetDisplayId(10);
3251 WindowInfo windowInfo;
3252 windowInfo.id = 10;
3253 WindowGroupInfo windowGroupInfo;
3254 windowGroupInfo.windowsInfo.push_back(windowInfo);
3255 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(desplayId, windowGroupInfo));
3256 inputWindowsManager.firstBtnDownWindowInfo_.first = 10;
3257 inputWindowsManager.extraData_.appended = false;
3258 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_UNKNOWN;
3259 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_ROTATE_BEGIN);
3260 pointerEvent->SetButtonPressed(1);
3261 pointerEvent->SetButtonPressed(2);
3262 EXPECT_EQ(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent), std::nullopt);
3263 }
3264
3265 /**
3266 * @tc.name: InputWindowsManagerTest_GetWindowInfo
3267 * @tc.desc: Test GetWindowInfo
3268 * @tc.type: FUNC
3269 * @tc.require:
3270 */
3271 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowInfo, TestSize.Level1)
3272 {
3273 CALL_TEST_DEBUG;
3274 InputWindowsManager inputWindowsManager;
3275 int32_t logicalX = 200;
3276 int32_t logicalY = 200;
3277 WindowInfo windowInfo;
3278 windowInfo.flags = 1;
3279 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3280 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3281 it->second.windowsInfo.push_back(windowInfo);
3282 }
3283 EXPECT_EQ(inputWindowsManager.GetWindowInfo(logicalX, logicalY), std::nullopt);
3284 }
3285
3286 /**
3287 * @tc.name: InputWindowsManagerTest_UpdateLeftRightArea
3288 * @tc.desc: Test UpdateLeftRightArea
3289 * @tc.type: FUNC
3290 * @tc.require:
3291 */
3292 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateLeftRightArea, TestSize.Level1)
3293 {
3294 CALL_TEST_DEBUG;
3295 InputWindowsManager inputWindowsManager;
3296 Rect windowArea;
3297 std::vector<int32_t> pointerChangeAreas {5, 0, 5, 0, 5, 0, 5, 0};
3298 std::vector<Rect> windowHotAreas;
3299 windowArea.x = 200;
3300 windowArea.y = 200;
3301 windowArea.height = 400;
3302 windowArea.width = 400;
3303 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateLeftRightArea(windowArea, pointerChangeAreas, windowHotAreas));
3304 }
3305
3306 /**
3307 * @tc.name: InputWindowsManagerTest_UpdateInnerAngleArea
3308 * @tc.desc: Test UpdateInnerAngleArea
3309 * @tc.type: FUNC
3310 * @tc.require:
3311 */
3312 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateInnerAngleArea, TestSize.Level1)
3313 {
3314 CALL_TEST_DEBUG;
3315 InputWindowsManager inputWindowsManager;
3316 Rect windowArea;
3317 std::vector<int32_t> pointerChangeAreas {0, 16, 0, 16, 0, 16, 0, 16};
3318 std::vector<Rect> windowHotAreas;
3319 windowArea.x = 200;
3320 windowArea.y = 200;
3321 windowArea.height = 400;
3322 windowArea.width = 400;
3323 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateInnerAngleArea(windowArea, pointerChangeAreas, windowHotAreas));
3324 }
3325
3326 /**
3327 * @tc.name: InputWindowsManagerTest_UpdatePointerEvent
3328 * @tc.desc: Test UpdatePointerEvent
3329 * @tc.type: FUNC
3330 * @tc.require:
3331 */
3332 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerEvent, TestSize.Level1)
3333 {
3334 CALL_TEST_DEBUG;
3335 InputWindowsManager inputWindowsManager;
3336 int32_t logicalX = 200;
3337 int32_t logicalY = 200;
3338 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
3339 ASSERT_NE(pointerEvent, nullptr);
3340 WindowInfo touchWindow;
3341 touchWindow.id = 1;
3342 inputWindowsManager.lastWindowInfo_.id = 1;
3343 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePointerEvent(logicalX, logicalY, pointerEvent, touchWindow));
3344 }
3345
3346 /**
3347 * @tc.name: InputWindowsManagerTest_UpdateMouseTarget
3348 * @tc.desc: Test UpdateMouseTarget
3349 * @tc.type: FUNC
3350 * @tc.require:
3351 */
3352 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateMouseTarget, TestSize.Level1)
3353 {
3354 CALL_TEST_DEBUG;
3355 InputWindowsManager inputWindowsManager;
3356 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
3357 ASSERT_NE(pointerEvent, nullptr);
3358 pointerEvent->SetTargetDisplayId(-1);
3359 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
3360
3361 OLD::DisplayInfo displayInfo;
3362 displayInfo.id = 1;
3363 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3364 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3365 it->second.displaysInfo.push_back(displayInfo);
3366 }
3367 pointerEvent->SetPointerId(5);
3368 PointerEvent::PointerItem item;
3369 item.SetPointerId(10);
3370 pointerEvent->AddPointerItem(item);
3371 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
3372 }
3373
3374 /**
3375 * @tc.name: InputWindowsManagerTest_JudgMouseIsDownOrUp
3376 * @tc.desc: Test JudgMouseIsDownOrUp
3377 * @tc.type: FUNC
3378 * @tc.require:
3379 */
3380 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_JudgMouseIsDownOrUp, TestSize.Level1)
3381 {
3382 CALL_TEST_DEBUG;
3383 InputWindowsManager inputWindowsManager;
3384 bool dragState = false;
3385 inputWindowsManager.lastPointerEvent_ = PointerEvent::Create();
3386 ASSERT_NE(inputWindowsManager.lastPointerEvent_, nullptr);
3387 inputWindowsManager.lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_UP);
3388 inputWindowsManager.pointerActionFlag_ = PointerEvent::POINTER_ACTION_BUTTON_UP;
3389 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.JudgMouseIsDownOrUp(dragState));
3390
3391 dragState = true;
3392 inputWindowsManager.lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
3393 inputWindowsManager.pointerActionFlag_ = PointerEvent::POINTER_ACTION_BUTTON_DOWN;
3394 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.JudgMouseIsDownOrUp(dragState));
3395 }
3396
3397 /**
3398 * @tc.name: InputWindowsManagerTest_UpdateJoystickTarget
3399 * @tc.desc: Test UpdateJoystickTarget
3400 * @tc.type: FUNC
3401 * @tc.require:
3402 */
3403 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateJoystickTarget, TestSize.Level1)
3404 {
3405 CALL_TEST_DEBUG;
3406 InputWindowsManager inputWindowsManager;
3407 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3408 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3409 it->second.focusWindowId = 150;
3410 }
3411 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
3412 ASSERT_NE(pointerEvent, nullptr);
3413 pointerEvent->SetTargetDisplayId(-1);
3414 WindowInfo windowInfo;
3415 windowInfo.id = 150;
3416 windowInfo.agentWindowId = 200;
3417 it->second.windowsInfo.push_back(windowInfo);
3418 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateJoystickTarget(pointerEvent));
3419 }
3420
3421 /**
3422 * @tc.name: InputWindowsManagerTest_UpdateAndAdjustMouseLocation
3423 * @tc.desc: Test UpdateAndAdjustMouseLocation
3424 * @tc.type: FUNC
3425 * @tc.require:
3426 */
3427 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateAndAdjustMouseLocation, TestSize.Level1)
3428 {
3429 CALL_TEST_DEBUG;
3430 InputWindowsManager inputWindowsManager;
3431 int32_t displayId = 1;
3432 double x = 200;
3433 double y = 200;
3434 bool isRealData = true;
3435 OLD::DisplayInfo displayInfo;
3436 displayInfo.id = 1;
3437 displayInfo.width = 500;
3438 displayInfo.height = 500;
3439 displayInfo.displayDirection = DIRECTION0;
3440 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3441 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3442 it->second.displaysInfo.push_back(displayInfo);
3443 }
3444 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateAndAdjustMouseLocation(displayId, x, y, isRealData));
3445 isRealData = false;
3446 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateAndAdjustMouseLocation(displayId, x, y, isRealData));
3447 }
3448
3449 /**
3450 * @tc.name: InputWindowsManagerTest_GetMouseInfo
3451 * @tc.desc: Test GetMouseInfo
3452 * @tc.type: FUNC
3453 * @tc.require:
3454 */
3455 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetMouseInfo, TestSize.Level1)
3456 {
3457 CALL_TEST_DEBUG;
3458 InputWindowsManager inputWindowsManager;
3459 inputWindowsManager.mouseLocation_.displayId = -1;
3460 OLD::DisplayInfo displayInfo;
3461 displayInfo.id = 1;
3462 displayInfo.width = 600;
3463 displayInfo.height = 600;
3464 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3465 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3466 it->second.displaysInfo.push_back(displayInfo);
3467 }
3468 EXPECT_EQ(inputWindowsManager.GetMouseInfo().displayId, displayInfo.id);
3469 }
3470
3471 /**
3472 * @tc.name: InputWindowsManagerTest_GetCursorPos
3473 * @tc.desc: Test GetCursorPos
3474 * @tc.type: FUNC
3475 * @tc.require:
3476 */
3477 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetCursorPos, TestSize.Level1)
3478 {
3479 CALL_TEST_DEBUG;
3480 InputWindowsManager inputWindowsManager;
3481 inputWindowsManager.cursorPos_.displayId = -1;
3482 OLD::DisplayInfo displayInfo;
3483 displayInfo.id = 1;
3484 displayInfo.width = 300;
3485 displayInfo.height = 300;
3486 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3487 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3488 it->second.displaysInfo.push_back(displayInfo);
3489 }
3490 EXPECT_NE(inputWindowsManager.GetCursorPos().displayId, displayInfo.id);
3491 }
3492
3493 /**
3494 * @tc.name: InputWindowsManagerTest_ResetCursorPos
3495 * @tc.desc: Test ResetCursorPos
3496 * @tc.type: FUNC
3497 * @tc.require:
3498 */
3499 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ResetCursorPos, TestSize.Level1)
3500 {
3501 CALL_TEST_DEBUG;
3502 InputWindowsManager inputWindowsManager;
3503 OLD::DisplayInfo displayInfo;
3504 displayInfo.id = 1;
3505 displayInfo.width = 300;
3506 displayInfo.height = 300;
3507 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3508 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3509 it->second.displaysInfo.push_back(displayInfo);
3510 }
3511 EXPECT_EQ(inputWindowsManager.ResetCursorPos().displayId, displayInfo.id);
3512 }
3513
3514 /**
3515 * @tc.name: InputWindowsManagerTest_GetTargetWindowIds
3516 * @tc.desc: Test GetTargetWindowIds
3517 * @tc.type: FUNC
3518 * @tc.require:
3519 */
3520 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetTargetWindowIds, TestSize.Level1)
3521 {
3522 CALL_TEST_DEBUG;
3523 InputWindowsManager inputWindowsManager;
3524 int32_t pointerItemId = 1;
3525 int32_t sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
3526 std::vector<int32_t> windowIds {1, 2, 3};
3527 inputWindowsManager.targetTouchWinIds_.insert(std::make_pair(pointerItemId, windowIds));
3528 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
3529 }
3530
3531 /**
3532 * @tc.name: InputWindowsManagerTest_CheckWindowIdPermissionByPid_001
3533 * @tc.desc: Test CheckWindowIdPermissionByPid
3534 * @tc.type: FUNC
3535 * @tc.require:
3536 */
3537 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckWindowIdPermissionByPid_001, TestSize.Level1)
3538 {
3539 CALL_TEST_DEBUG;
3540 InputWindowsManager inputWindowsManager;
3541 int32_t windowId = 300;
3542 int32_t pid = 500;
3543 WindowInfo windowInfo;
3544 windowInfo.id = 300;
3545 windowInfo.pid = 500;
3546 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3547 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3548 it->second.windowsInfo.push_back(windowInfo);
3549 }
3550 EXPECT_EQ(inputWindowsManager.CheckWindowIdPermissionByPid(windowId, pid), RET_OK);
3551 }
3552
3553 /**
3554 * @tc.name: InputWindowsManagerTest_FindPhysicalDisplay_002
3555 * @tc.desc: This test verifies the functionality of finding physical displays
3556 * @tc.type: FUNC
3557 * @tc.require:
3558 */
3559 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_FindPhysicalDisplay_002, TestSize.Level1)
3560 {
3561 CALL_TEST_DEBUG;
3562 InputWindowsManager inputWindowsManager;
3563 OLD::DisplayInfo displayInfo;
3564 OLD::DisplayInfo displaysInfo;
3565 double logicalX = 300;
3566 double logicalY = 400;
3567 double physicalX = 100;
3568 double physicalY = 200;
3569 int32_t displayId = -1;
3570 displayInfo.x = INT32_MAX;
3571 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId));
3572 displayInfo.x = 200;
3573 inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
3574 EXPECT_EQ(logicalX, physicalX + displayInfo.x);
3575 displayInfo.y = INT32_MAX;
3576 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId));
3577 displayInfo.y = 200;
3578 inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
3579 EXPECT_EQ(logicalY, physicalY + displayInfo.y);
3580 displaysInfo.x = 100;
3581 displaysInfo.width = INT32_MAX;
3582 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3583 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3584 it->second.displaysInfo.push_back(displaysInfo);
3585 }
3586 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId));
3587 }
3588
3589 /**
3590 * @tc.name: InputWindowsManagerTest_FindPhysicalDisplay_003
3591 * @tc.desc: This test verifies the functionality of finding physical displays
3592 * @tc.type: FUNC
3593 * @tc.require:
3594 */
3595 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_FindPhysicalDisplay_003, TestSize.Level1)
3596 {
3597 CALL_TEST_DEBUG;
3598 InputWindowsManager inputWindowsManager;
3599 OLD::DisplayInfo displayInfo;
3600 OLD::DisplayInfo displaysInfo;
3601 double logicalX = 300;
3602 double logicalY = 400;
3603 double physicalX = 100;
3604 double physicalY = 200;
3605 int32_t displayMaxX = 300;
3606 int32_t displayMaxY = 400;
3607 int32_t displayId = -1;
3608 displayInfo.x = 200;
3609 inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
3610 EXPECT_EQ(logicalX, physicalX + displayInfo.x);
3611 displayInfo.y = 200;
3612 inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
3613 EXPECT_EQ(logicalY, physicalY + displayInfo.y);
3614 displaysInfo.x = 200;
3615 displaysInfo.width = 100;
3616 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3617 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3618 it->second.displaysInfo.push_back(displaysInfo);
3619 }
3620 inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
3621 EXPECT_EQ(displayMaxX, displaysInfo.x + displaysInfo.width);
3622 displaysInfo.y = 100;
3623 displaysInfo.height = INT32_MAX;
3624 it->second.displaysInfo.push_back(displaysInfo);
3625 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId));
3626 displaysInfo.y = 200;
3627 displaysInfo.height = 200;
3628 it->second.displaysInfo.push_back(displaysInfo);
3629 inputWindowsManager.FindPhysicalDisplay(displayInfo, physicalX, physicalY, displayId);
3630 EXPECT_EQ(displayMaxY, displaysInfo.y + displaysInfo.height);
3631 }
3632
3633 /**
3634 * @tc.name: InputWindowsManagerTest_IsInHotArea
3635 * @tc.desc: Test IsInHotArea
3636 * @tc.type: FUNC
3637 * @tc.require:
3638 */
3639 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsInHotArea, TestSize.Level1)
3640 {
3641 CALL_TEST_DEBUG;
3642 InputWindowsManager inputWindowsManager;
3643 int32_t x = 200;
3644 int32_t y = 300;
3645 std::vector<Rect> rects;
3646 WindowInfo window;
3647 Rect rect;
3648 rect.x = 100;
3649 rect.width = INT32_MAX;
3650 rects.push_back(rect);
3651 EXPECT_FALSE(inputWindowsManager.IsInHotArea(x, y, rects, window));
3652 rects.clear();
3653 rects = {
3654 {150, 100, 300, INT32_MAX}
3655 };
3656 EXPECT_FALSE(inputWindowsManager.IsInHotArea(x, y, rects, window));
3657 rects.clear();
3658 rects = {
3659 {150, 250, 300, 500}
3660 };
3661 EXPECT_TRUE(inputWindowsManager.IsInHotArea(x, y, rects, window));
3662 x = 100;
3663 y = 200;
3664 EXPECT_FALSE(inputWindowsManager.IsInHotArea(x, y, rects, window));
3665 }
3666
3667 /**
3668 * @tc.name: InputWindowsManagerTest_InWhichHotArea
3669 * @tc.desc: Test InWhichHotArea
3670 * @tc.type: FUNC
3671 * @tc.require:
3672 */
3673 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_InWhichHotArea, TestSize.Level1)
3674 {
3675 CALL_TEST_DEBUG;
3676 InputWindowsManager inputWindowsManager;
3677 int32_t x = 500;
3678 int32_t y = 800;
3679 std::vector<Rect> rects;
3680 PointerStyle pointerStyle;
3681 rects = {
3682 {100, 0, INT32_MAX, 0}
3683 };
3684 EXPECT_FALSE(inputWindowsManager.InWhichHotArea(x, y, rects, pointerStyle));
3685 rects.clear();
3686 rects = {
3687 {150, 100, 300, INT32_MAX}
3688 };
3689 EXPECT_FALSE(inputWindowsManager.InWhichHotArea(x, y, rects, pointerStyle));
3690 rects.clear();
3691 rects = {
3692 {150, 250, 300, 500}
3693 };
3694 EXPECT_FALSE(inputWindowsManager.InWhichHotArea(x, y, rects, pointerStyle));
3695 x = 200;
3696 y = 300;
3697 EXPECT_TRUE(inputWindowsManager.InWhichHotArea(x, y, rects, pointerStyle));
3698 int32_t cycleNum = 7;
3699 for (int32_t i = 0; i < cycleNum; ++i) {
3700 rects.insert(rects.begin(), {1000, 1000, 1500, 1500});
3701 EXPECT_TRUE(inputWindowsManager.InWhichHotArea(x, y, rects, pointerStyle));
3702 }
3703 }
3704
3705 /**
3706 * @tc.name: InputWindowsManagerTest_DispatchPointer
3707 * @tc.desc: Test DispatchPointer
3708 * @tc.type: FUNC
3709 * @tc.require:
3710 */
3711 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DispatchPointer, TestSize.Level1)
3712 {
3713 CALL_TEST_DEBUG;
3714 InputWindowsManager inputWindowsManager;
3715 int32_t pointerAction = PointerEvent::POINTER_ACTION_ENTER_WINDOW;
3716 UDSServer udsServer;
3717 inputWindowsManager.udsServer_ = &udsServer;
3718 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointer(pointerAction));
3719 CursorDrawingComponent::GetInstance().SetMouseDisplayState(true);
3720 inputWindowsManager.lastPointerEvent_ = nullptr;
3721 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointer(pointerAction));
3722 inputWindowsManager.lastPointerEvent_ = PointerEvent::Create();
3723 EXPECT_NE(inputWindowsManager.lastPointerEvent_, nullptr);
3724 PointerEvent::PointerItem item;
3725 item.SetPointerId(0);
3726 inputWindowsManager.lastPointerEvent_->AddPointerItem(item);
3727 inputWindowsManager.lastPointerEvent_->SetPointerId(1);
3728 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointer(pointerAction));
3729 inputWindowsManager.lastPointerEvent_->SetPointerId(0);
3730 inputWindowsManager.lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
3731 WindowInfo windowInfo;
3732 windowInfo.flags = WindowInfo::FLAG_BIT_HANDWRITING;
3733 windowInfo.pointerHotAreas.push_back({100, 0, INT32_MAX, 0});
3734 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3735 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3736 it->second.windowsInfo.push_back(windowInfo);
3737 }
3738 inputWindowsManager.lastLogicX_ = 200;
3739 inputWindowsManager.lastLogicY_ = 200;
3740 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointer(pointerAction));
3741 }
3742
3743 /**
3744 * @tc.name: InputWindowsManagerTest_DispatchPointer_002
3745 * @tc.desc: Test DispatchPointer
3746 * @tc.type: FUNC
3747 * @tc.require:
3748 */
3749 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DispatchPointer_002, TestSize.Level1)
3750 {
3751 CALL_TEST_DEBUG;
3752 InputWindowsManager inputWindowsManager;
3753 int32_t pointerAction = PointerEvent::POINTER_ACTION_ENTER_WINDOW;
3754 UDSServer udsServer;
3755 inputWindowsManager.udsServer_ = &udsServer;
3756 inputWindowsManager.lastPointerEvent_ = PointerEvent::Create();
3757 EXPECT_NE(inputWindowsManager.lastPointerEvent_, nullptr);
3758 PointerEvent::PointerItem item;
3759 item.SetPointerId(0);
3760 item.SetDisplayX(100);
3761 item.SetDisplayY(100);
3762 inputWindowsManager.lastPointerEvent_->AddPointerItem(item);
3763 inputWindowsManager.lastPointerEvent_->SetPointerId(0);
3764 inputWindowsManager.firstBtnDownWindowInfo_.first = 1;
3765 inputWindowsManager.lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_UP);
3766 inputWindowsManager.lastPointerEvent_->SetTargetDisplayId(-1);
3767 WindowInfo windowInfo;
3768 windowInfo.id = 1;
3769 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3770 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3771 it->second.windowsInfo.push_back(windowInfo);
3772 }
3773 inputWindowsManager.lastWindowInfo_.id = 2;
3774 inputWindowsManager.lastWindowInfo_.agentWindowId = 2;
3775 inputWindowsManager.lastWindowInfo_.area.x = 100;
3776 inputWindowsManager.lastWindowInfo_.area.y = 100;
3777 inputWindowsManager.lastPointerEvent_->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
3778 inputWindowsManager.lastPointerEvent_->SetDeviceId(5);
3779 inputWindowsManager.extraData_.appended = true;
3780 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
3781 InputHandler->eventFilterHandler_ = std::make_shared<EventFilterHandler>();
3782 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointer(pointerAction));
3783 inputWindowsManager.lastWindowInfo_.id = 1;
3784 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointer(pointerAction));
3785 inputWindowsManager.extraData_.appended = false;
3786 pointerAction = PointerEvent::POINTER_ACTION_LEAVE_WINDOW;
3787 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointer(pointerAction));
3788 }
3789
3790 /**
3791 * @tc.name: InputWindowsManagerTest_NotifyPointerToWindow
3792 * @tc.desc: Test NotifyPointerToWindow
3793 * @tc.type: FUNC
3794 * @tc.require:
3795 */
3796 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_NotifyPointerToWindow, TestSize.Level1)
3797 {
3798 CALL_TEST_DEBUG;
3799 InputWindowsManager inputWindowsManager;
3800 UDSServer udsServer;
3801 inputWindowsManager.lastPointerEvent_ = PointerEvent::Create();
3802 ASSERT_NE(inputWindowsManager.lastPointerEvent_, nullptr);
3803 inputWindowsManager.lastLogicX_ = 200;
3804 inputWindowsManager.lastLogicY_ = 300;
3805 WindowInfo windowInfo;
3806 windowInfo.flags = WindowInfo::FLAG_BIT_HANDWRITING;
3807 windowInfo.pointerHotAreas.push_back({100, 100, INT32_MAX, 100});
3808 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3809 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3810 it->second.windowsInfo.push_back(windowInfo);
3811 }
3812 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.NotifyPointerToWindow());
3813 windowInfo.id = 10;
3814 windowInfo.pointerHotAreas.clear();
3815 windowInfo.pointerHotAreas.push_back({150, 250, 300, 500});
3816 it->second.windowsInfo.insert(it->second.windowsInfo.begin(), windowInfo);
3817 inputWindowsManager.lastWindowInfo_.id = 10;
3818 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.NotifyPointerToWindow());
3819 inputWindowsManager.lastWindowInfo_.id = 20;
3820 inputWindowsManager.lastWindowInfo_.pid = 50;
3821 int32_t udsFd = 100;
3822 udsServer.idxPidMap_.insert(std::make_pair(inputWindowsManager.lastWindowInfo_.pid, udsFd));
3823 inputWindowsManager.udsServer_ = &udsServer;
3824 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.NotifyPointerToWindow());
3825 inputWindowsManager.udsServer_ = nullptr;
3826 inputWindowsManager.lastWindowInfo_.id = 30;
3827 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.NotifyPointerToWindow());
3828 windowInfo.id = 50;
3829 it->second.windowsInfo.push_back(windowInfo);
3830 inputWindowsManager.lastWindowInfo_.id = 50;
3831 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.NotifyPointerToWindow());
3832 }
3833
3834 /**
3835 * @tc.name: InputWindowsManagerTest_GetMouseInfo_002
3836 * @tc.desc: Test the function GetMouseInfo
3837 * @tc.type: FUNC
3838 * @tc.require:
3839 */
3840 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetMouseInfo_002, TestSize.Level1)
3841 {
3842 CALL_TEST_DEBUG;
3843 InputWindowsManager inputWindowsManager;
3844 inputWindowsManager.mouseLocation_.displayId = -1;
3845 OLD::DisplayInfo displaysInfo;
3846 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetMouseInfo());
3847 displaysInfo.id = 2;
3848 displaysInfo.width = 20;
3849 displaysInfo.height = 30;
3850 displaysInfo.validWidth = displaysInfo.width;
3851 displaysInfo.validHeight = displaysInfo.height;
3852 displaysInfo.name = "name1";
3853 displaysInfo.uniq = "uniq1";
3854 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3855 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3856 it->second.displaysInfo.push_back(displaysInfo);
3857 }
3858 MouseLocation result = inputWindowsManager.GetMouseInfo();
3859 EXPECT_EQ(result.displayId, 2);
3860 EXPECT_EQ(result.physicalX, 10);
3861 EXPECT_EQ(result.physicalY, 15);
3862 }
3863
3864 /**
3865 * @tc.name: InputWindowsManagerTest_GetCursorPos_002
3866 * @tc.desc: Test the function GetCursorPos
3867 * @tc.type: FUNC
3868 * @tc.require:
3869 */
3870 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetCursorPos_002, TestSize.Level1)
3871 {
3872 CALL_TEST_DEBUG;
3873 InputWindowsManager inputWindowsManager;
3874 inputWindowsManager.cursorPos_.displayId = -1;
3875 OLD::DisplayInfo displaysInfo;
3876 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetCursorPos());
3877 displaysInfo.id = 2;
3878 displaysInfo.width = 30;
3879 displaysInfo.height = 40;
3880 displaysInfo.validWidth = displaysInfo.width;
3881 displaysInfo.validHeight = displaysInfo.height;
3882 displaysInfo.name = "name2";
3883 displaysInfo.uniq = "uniq2";
3884 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3885 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3886 it->second.displaysInfo.push_back(displaysInfo);
3887 }
3888 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetCursorPos());
3889 }
3890
3891 /**
3892 * @tc.name: InputWindowsManagerTest_ResetCursorPos_002
3893 * @tc.desc: Test the function ResetCursorPos
3894 * @tc.type: FUNC
3895 * @tc.require:
3896 */
3897 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ResetCursorPos_002, TestSize.Level1)
3898 {
3899 CALL_TEST_DEBUG;
3900 InputWindowsManager inputWindowsManager;
3901 OLD::DisplayInfo displaysInfo;
3902 CursorPosition result = inputWindowsManager.ResetCursorPos();
3903 EXPECT_EQ(result.displayId, -1);
3904 displaysInfo.id = 3;
3905 displaysInfo.width = 40;
3906 displaysInfo.height = 50;
3907 displaysInfo.validWidth = displaysInfo.width;
3908 displaysInfo.validHeight = displaysInfo.height;
3909 displaysInfo.name = "name3";
3910 displaysInfo.uniq = "uniq3";
3911 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3912 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3913 it->second.displaysInfo.push_back(displaysInfo);
3914 }
3915 result = inputWindowsManager.ResetCursorPos();
3916 EXPECT_EQ(result.displayId, 3);
3917 EXPECT_EQ(result.cursorPos.x, 20);
3918 EXPECT_EQ(result.cursorPos.y, 25);
3919 }
3920
3921 /**
3922 * @tc.name: InputWindowsManagerTest_UpdateDisplayIdAndName_002
3923 * @tc.desc: Test updating display ID and name
3924 * @tc.type: FUNC
3925 * @tc.require:
3926 */
3927 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayIdAndName_002, TestSize.Level1)
3928 {
3929 CALL_TEST_DEBUG;
3930 InputWindowsManager inputWindowsManager;
3931 OLD::DisplayInfo displaysInfo;
3932 displaysInfo.id = 1;
3933 displaysInfo.uniq = "abc";
3934 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3935 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3936 it->second.displaysInfo.push_back(displaysInfo);
3937 }
3938 inputWindowsManager.bindInfo_.AddDisplay(2, "cde");
3939 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayIdAndName());
3940 }
3941
3942 /**
3943 * @tc.name: InputWindowsManagerTest_UpdateDisplayIdAndName_003
3944 * @tc.desc: Test updating display ID and name
3945 * @tc.type: FUNC
3946 * @tc.require:
3947 */
3948 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayIdAndName_003, TestSize.Level1)
3949 {
3950 CALL_TEST_DEBUG;
3951 InputWindowsManager inputWindowsManager;
3952 OLD::DisplayInfo displaysInfo;
3953 displaysInfo.id = 1;
3954 displaysInfo.uniq = "abc";
3955 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3956 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3957 it->second.displaysInfo.push_back(displaysInfo);
3958 }
3959 inputWindowsManager.bindInfo_.AddDisplay(1, "abc");
3960 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayIdAndName());
3961 }
3962
3963 /**
3964 * @tc.name: InputWindowsManagerTest_SendPointerEvent
3965 * @tc.desc: Test SendPointerEvent
3966 * @tc.type: FUNC
3967 * @tc.require:
3968 */
3969 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SendPointerEvent, TestSize.Level1)
3970 {
3971 CALL_TEST_DEBUG;
3972 InputWindowsManager inputWindowsManager;
3973 int32_t pointerAction = PointerEvent::POINTER_ACTION_ENTER_WINDOW;
3974 UDSServer udsServer;
3975 WindowInfo windowInfo;
3976 inputWindowsManager.udsServer_ = &udsServer;
3977 windowInfo.pointerHotAreas.push_back({100, 100, INT32_MAX, 100});
3978 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
3979 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
3980 it->second.windowsInfo.push_back(windowInfo);
3981 }
3982 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SendPointerEvent(pointerAction));
3983 windowInfo.pointerHotAreas.clear();
3984 windowInfo.pointerHotAreas.push_back({150, 250, 300, 500});
3985 windowInfo.area.x = 50;
3986 windowInfo.area.y = 50;
3987 windowInfo.id = 10;
3988 windowInfo.pid = 30;
3989 windowInfo.agentWindowId = 10;
3990 it->second.windowsInfo.insert(it->second.windowsInfo.begin(), windowInfo);
3991 inputWindowsManager.mouseLocation_.displayId = 1;
3992 inputWindowsManager.mouseLocation_.physicalX = 200;
3993 inputWindowsManager.mouseLocation_.physicalY = 300;
3994 inputWindowsManager.lastLogicX_ = 150;
3995 inputWindowsManager.lastLogicY_ = 150;
3996 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SendPointerEvent(pointerAction));
3997 }
3998
3999 /**
4000 * @tc.name: InputWindowsManagerTest_UpdateMouseTarget001
4001 * @tc.desc: Test UpdateMouseTarget
4002 * @tc.type: FUNC
4003 * @tc.require:
4004 */
4005 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateMouseTarget001, TestSize.Level1)
4006 {
4007 CALL_TEST_DEBUG;
4008 InputWindowsManager inputWindowsManager;
4009 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
4010 ASSERT_NE(pointerEvent, nullptr);
4011 pointerEvent->SetTargetDisplayId(1);
4012 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
4013 OLD::DisplayInfo displayInfo;
4014 displayInfo.id = 1;
4015 displayInfo.x = 300;
4016 displayInfo.y = 500;
4017 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
4018 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
4019 it->second.displaysInfo.push_back(displayInfo);
4020 }
4021 PointerEvent::PointerItem item;
4022 item.SetPointerId(1);
4023 item.SetDisplayX(INT32_MAX);
4024 pointerEvent->AddPointerItem(item);
4025 pointerEvent->SetPointerId(0);
4026 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
4027
4028 pointerEvent->SetPointerId(1);
4029 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
4030
4031 item.SetDisplayX(150);
4032 item.SetDisplayY(INT32_MAX);
4033 pointerEvent->UpdatePointerItem(pointerEvent->GetPointerId(), item);
4034 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
4035 item.SetDisplayX(150);
4036 item.SetDisplayY(300);
4037 pointerEvent->UpdatePointerItem(pointerEvent->GetPointerId(), item);
4038
4039 inputWindowsManager.firstBtnDownWindowInfo_.first = 5;
4040 WindowGroupInfo windowGroupInfo;
4041 WindowInfo windowInfo;
4042 windowInfo.id = 10;
4043 windowGroupInfo.windowsInfo.push_back(windowInfo);
4044 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(pointerEvent->GetTargetDisplayId(), windowGroupInfo));
4045 inputWindowsManager.mouseDownInfo_.id = -1;
4046 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
4047
4048 inputWindowsManager.firstBtnDownWindowInfo_.first = 10;
4049 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_AXIS_UPDATE);
4050 inputWindowsManager.SetHoverScrollState(false);
4051 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
4052 }
4053
4054 /**
4055 * @tc.name: InputWindowsManagerTest_UpdateMouseTarget_002
4056 * @tc.desc: Test UpdateMouseTarget
4057 * @tc.type: FUNC
4058 * @tc.require:
4059 */
4060 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateMouseTarget_002, TestSize.Level1)
4061 {
4062 CALL_TEST_DEBUG;
4063 InputWindowsManager inputWindowsManager;
4064 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
4065 ASSERT_NE(pointerEvent, nullptr);
4066 pointerEvent->SetTargetDisplayId(1);
4067 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
4068 OLD::DisplayInfo displayInfo;
4069 displayInfo.id = 1;
4070 displayInfo.x = 300;
4071 displayInfo.y = 500;
4072 displayInfo.width = 100;
4073 displayInfo.height = 100;
4074 displayInfo.displayDirection = DIRECTION0;
4075 displayInfo.direction = DIRECTION180;
4076 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
4077 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
4078 it->second.displaysInfo.push_back(displayInfo);
4079 }
4080 PointerEvent::PointerItem item;
4081 item.SetPointerId(1);
4082 item.SetDisplayX(150);
4083 item.SetDisplayY(300);
4084 pointerEvent->AddPointerItem(item);
4085 pointerEvent->SetPointerId(1);
4086 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
4087 inputWindowsManager.firstBtnDownWindowInfo_.first = 10;
4088 WindowGroupInfo windowGroupInfo;
4089 WindowInfo windowInfo;
4090 windowInfo.id = 10;
4091 windowInfo.pid = 50;
4092 windowInfo.agentWindowId = 60;
4093 windowGroupInfo.windowsInfo.push_back(windowInfo);
4094 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(pointerEvent->GetTargetDisplayId(), windowGroupInfo));
4095 inputWindowsManager.mouseDownInfo_.id = -1;
4096 inputWindowsManager.SetHoverScrollState(true);
4097 std::map<int32_t, PointerStyle> styleMap;
4098 PointerStyle pointerStyle;
4099 CursorDrawingComponent::GetInstance().SetMouseDisplayState(false);
4100 styleMap.insert(std::make_pair(windowInfo.id, pointerStyle));
4101 inputWindowsManager.uiExtensionPointerStyle_.insert(std::make_pair(windowInfo.pid, styleMap));
4102 UDSServer udsServer;
4103 inputWindowsManager.udsServer_ = &udsServer;
4104 inputWindowsManager.SetUiExtensionInfo(true, 50, 10);
4105 inputWindowsManager.isDragBorder_ = true;
4106 inputWindowsManager.dragFlag_ = false;
4107 inputWindowsManager.captureModeInfo_.isCaptureMode = true;
4108 inputWindowsManager.captureModeInfo_.windowId = 1;
4109 inputWindowsManager.extraData_.appended = true;
4110 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
4111 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
4112 }
4113
4114 /**
4115 * @tc.name: InputWindowsManagerTest_UpdateMouseTarget_003
4116 * @tc.desc: Test UpdateMouseTarget
4117 * @tc.type: FUNC
4118 * @tc.require:
4119 */
4120 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateMouseTarget_003, TestSize.Level1)
4121 {
4122 CALL_TEST_DEBUG;
4123 InputWindowsManager inputWindowsManager;
4124 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
4125 ASSERT_NE(pointerEvent, nullptr);
4126 pointerEvent->SetTargetDisplayId(1);
4127 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_UP);
4128 OLD::DisplayInfo displayInfo;
4129 displayInfo.id = 1;
4130 displayInfo.x = 300;
4131 displayInfo.y = 500;
4132 displayInfo.width = 100;
4133 displayInfo.height = 100;
4134 displayInfo.displayDirection = DIRECTION180;
4135 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
4136 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
4137 it->second.displaysInfo.push_back(displayInfo);
4138 }
4139 PointerEvent::PointerItem item;
4140 item.SetPointerId(1);
4141 item.SetDisplayX(150);
4142 item.SetDisplayY(300);
4143 pointerEvent->AddPointerItem(item);
4144 pointerEvent->SetPointerId(1);
4145 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
4146 inputWindowsManager.firstBtnDownWindowInfo_.first = 10;
4147 WindowGroupInfo windowGroupInfo;
4148 WindowInfo windowInfo;
4149 windowInfo.id = 10;
4150 windowInfo.pid = 50;
4151 windowInfo.agentWindowId = 60;
4152 windowGroupInfo.windowsInfo.push_back(windowInfo);
4153 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(pointerEvent->GetTargetDisplayId(), windowGroupInfo));
4154 inputWindowsManager.mouseDownInfo_.id = -1;
4155 inputWindowsManager.SetHoverScrollState(true);
4156 std::map<int32_t, PointerStyle> styleMap;
4157 PointerStyle pointerStyle;
4158 CursorDrawingComponent::GetInstance().SetMouseDisplayState(true);
4159 styleMap.insert(std::make_pair(windowInfo.id, pointerStyle));
4160 inputWindowsManager.uiExtensionPointerStyle_.insert(std::make_pair(windowInfo.pid, styleMap));
4161 UDSServer udsServer;
4162 inputWindowsManager.udsServer_ = &udsServer;
4163 inputWindowsManager.SetUiExtensionInfo(false, 50, 10);
4164 inputWindowsManager.isDragBorder_ = false;
4165 inputWindowsManager.dragFlag_ = true;
4166 inputWindowsManager.captureModeInfo_.isCaptureMode = false;
4167 inputWindowsManager.captureModeInfo_.windowId = 10;
4168 inputWindowsManager.extraData_.appended = false;
4169 EXPECT_EQ(inputWindowsManager.UpdateMouseTarget(pointerEvent), RET_ERR);
4170 }
4171
4172 /**
4173 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget
4174 * @tc.desc: Test UpdateTouchScreenTarget
4175 * @tc.type: FUNC
4176 * @tc.require:
4177 */
4178 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget, TestSize.Level1)
4179 {
4180 CALL_TEST_DEBUG;
4181 InputWindowsManager inputWindowsManager;
4182 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
4183 ASSERT_NE(pointerEvent, nullptr);
4184 pointerEvent->SetTargetDisplayId(1);
4185 pointerEvent->SetPointerId(0);
4186 OLD::DisplayInfo displayInfo;
4187 displayInfo.id = 1;
4188 displayInfo.width = 300;
4189 displayInfo.height = 300;
4190 displayInfo.displayDirection = DIRECTION0;
4191 displayInfo.x = INT32_MAX;
4192 displayInfo.y = 300;
4193 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
4194 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
4195 it->second.displaysInfo.push_back(displayInfo);
4196 }
4197 PointerEvent::PointerItem item;
4198 item.SetPointerId(1);
4199 item.SetDisplayX(100);
4200 item.SetDisplayY(100);
4201 item.SetDisplayXPos(100);
4202 item.SetDisplayYPos(100);
4203 item.SetTargetWindowId(-1);
4204 pointerEvent->AddPointerItem(item);
4205 EXPECT_EQ(inputWindowsManager.UpdateTouchScreenTarget(pointerEvent), RET_ERR);
4206
4207 pointerEvent->SetPointerId(1);
4208 pointerEvent->bitwise_ = InputEvent::EVENT_FLAG_SIMULATE;
4209 EXPECT_EQ(inputWindowsManager.UpdateTouchScreenTarget(pointerEvent), RET_ERR);
4210
4211 pointerEvent->bitwise_ = InputEvent::EVENT_FLAG_NONE;
4212 it->second.displaysInfo[0].x = 300;
4213 it->second.displaysInfo[0].y = INT32_MAX;
4214 EXPECT_EQ(inputWindowsManager.UpdateTouchScreenTarget(pointerEvent), RET_ERR);
4215 }
4216
4217 /**
4218 * @tc.name: InputWindowsManagerTest_GetPidAndUpdateTarget_002
4219 * @tc.desc: Test getting PID and updating the target
4220 * @tc.type: FUNC
4221 * @tc.require:
4222 */
4223 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPidAndUpdateTarget_002, TestSize.Level1)
4224 {
4225 CALL_TEST_DEBUG;
4226 InputWindowsManager inputWindowsManager;
4227 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
4228 ASSERT_NE(keyEvent, nullptr);
4229 keyEvent->SetTargetDisplayId(10);
4230 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
4231 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
4232 it->second.focusWindowId = 52;
4233 }
4234 WindowGroupInfo windowGroupInfo;
4235 WindowInfo windowInfo;
4236 windowInfo.id = 2;
4237 windowGroupInfo.windowsInfo.push_back(windowInfo);
4238 windowInfo.id = 52;
4239 windowInfo.pid = 100;
4240 windowInfo.agentWindowId = 65;
4241 windowGroupInfo.windowsInfo.push_back(windowInfo);
4242 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(keyEvent->GetTargetDisplayId(), windowGroupInfo));
4243 ASSERT_NO_FATAL_FAILURE(inputWindowsManager.GetPidAndUpdateTarget(keyEvent));
4244 }
4245
4246 /**
4247 * @tc.name: InputWindowsManagerTest_UpdateAndAdjustMouseLocation_002
4248 * @tc.desc: Test UpdateAndAdjustMouseLocation
4249 * @tc.type: FUNC
4250 * @tc.require:
4251 */
4252 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateAndAdjustMouseLocation_002, TestSize.Level1)
4253 {
4254 CALL_TEST_DEBUG;
4255 InputWindowsManager inputWindowsManager;
4256 int32_t displayId = 1;
4257 double x = 350;
4258 double y = 350;
4259 bool isRealData = true;
4260 OLD::DisplayInfo displayInfo;
4261 displayInfo.id = 1;
4262 displayInfo.x = 600;
4263 displayInfo.y = 600;
4264 displayInfo.width = 300;
4265 displayInfo.height = 300;
4266 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
4267 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
4268 it->second.displaysInfo.push_back(displayInfo);
4269 }
4270 displayInfo.id = 2;
4271 displayInfo.x = 500;
4272 displayInfo.y = 500;
4273 displayInfo.width = 600;
4274 displayInfo.height = 600;
4275 displayInfo.displayDirection = DIRECTION0;
4276 it->second.displaysInfo.push_back(displayInfo);
4277 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateAndAdjustMouseLocation(displayId, x, y, isRealData));
4278 }
4279
4280 /**
4281 * @tc.name: InputWindowsManagerTest_UpdateAndAdjustMouseLocation_003
4282 * @tc.desc: Test UpdateAndAdjustMouseLocation
4283 * @tc.type: FUNC
4284 * @tc.require:
4285 */
4286 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateAndAdjustMouseLocation_003, TestSize.Level1)
4287 {
4288 CALL_TEST_DEBUG;
4289 InputWindowsManager inputWindowsManager;
4290 int32_t displayId = 1;
4291 double x = 200;
4292 double y = 200;
4293 bool isRealData = false;
4294 OLD::DisplayInfo displayInfo;
4295 displayInfo.id = 1;
4296 displayInfo.x = 600;
4297 displayInfo.y = 600;
4298 displayInfo.width = 400;
4299 displayInfo.height = 400;
4300 displayInfo.displayDirection = DIRECTION90;
4301 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
4302 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
4303 it->second.displaysInfo.push_back(displayInfo);
4304 }
4305 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateAndAdjustMouseLocation(displayId, x, y, isRealData));
4306 it->second.displaysInfo[0].displayDirection = DIRECTION0;
4307 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateAndAdjustMouseLocation(displayId, x, y, isRealData));
4308 }
4309
4310 /**
4311 * @tc.name: InputWindowsManagerTest_HandleWindowInputType_005
4312 * @tc.desc: Test HandleWindowInputType
4313 * @tc.type: FUNC
4314 * @tc.require:
4315 */
4316 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandleWindowInputType_005, TestSize.Level1)
4317 {
4318 CALL_TEST_DEBUG;
4319 InputWindowsManager inputWindowsMgr;
4320 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
4321 ASSERT_NE(pointerEvent, nullptr);
4322 PointerEvent::PointerItem item;
4323 item.SetPointerId(1);
4324 item.SetToolType(PointerEvent::TOOL_TYPE_MOUSE);
4325 pointerEvent->SetPointerId(1);
4326 pointerEvent->AddPointerItem(item);
4327 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
4328 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
4329 WindowInfo window;
4330 window.windowInputType = WindowInputType::NORMAL;
4331 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4332 window.windowInputType = WindowInputType::TRANSMIT_ALL;
4333 EXPECT_TRUE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4334 window.windowInputType = WindowInputType::TRANSMIT_EXCEPT_MOVE;
4335 EXPECT_TRUE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4336 window.windowInputType = WindowInputType::ANTI_MISTAKE_TOUCH;
4337 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4338 window.windowInputType = WindowInputType::TRANSMIT_AXIS_MOVE;
4339 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4340 window.windowInputType = WindowInputType::TRANSMIT_MOUSE_MOVE;
4341 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4342 window.windowInputType = WindowInputType::TRANSMIT_LEFT_RIGHT;
4343 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4344 window.windowInputType = WindowInputType::TRANSMIT_BUTTOM;
4345 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4346 window.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
4347 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4348 window.windowInputType = WindowInputType::MIX_BUTTOM_ANTI_AXIS_MOVE;
4349 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4350 window.windowInputType = static_cast<WindowInputType>(100);
4351 EXPECT_FALSE(inputWindowsMgr.HandleWindowInputType(window, pointerEvent));
4352 }
4353
4354 /**
4355 * @tc.name: InputWindowsManagerTest_AddTargetWindowIds_003
4356 * @tc.desc: Test AddTargetWindowIds
4357 * @tc.type: FUNC
4358 * @tc.require:
4359 */
4360 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_AddTargetWindowIds_003, TestSize.Level1)
4361 {
4362 CALL_TEST_DEBUG;
4363 InputWindowsManager inputWindowsMgr;
4364 int32_t pointerItemId = 1;
4365 int32_t sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
4366 int32_t windowId = 50;
4367 std::vector<int32_t> winIds;
4368 inputWindowsMgr.targetMouseWinIds_.insert(std::make_pair(pointerItemId, winIds));
4369 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.AddTargetWindowIds(pointerItemId, sourceType, windowId));
4370
4371 pointerItemId = 2;
4372 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.AddTargetWindowIds(pointerItemId, sourceType, windowId));
4373
4374 sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
4375 inputWindowsMgr.targetTouchWinIds_.insert(std::make_pair(pointerItemId, winIds));
4376 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.AddTargetWindowIds(pointerItemId, sourceType, windowId));
4377 }
4378
4379 /**
4380 * @tc.name: InputWindowsManagerTest_ReverseXY
4381 * @tc.desc: Test ReverseXY
4382 * @tc.type: FUNC
4383 * @tc.require:
4384 */
4385 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ReverseXY, TestSize.Level1)
4386 {
4387 CALL_TEST_DEBUG;
4388 InputWindowsManager inputWindowsMgr;
4389 int32_t x = 100;
4390 int32_t y = 100;
4391 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.ReverseXY(x, y));
4392
4393 OLD::DisplayInfo displayInfo;
4394 displayInfo.direction = DIRECTION0;
4395 displayInfo.width = 200;
4396 displayInfo.height = 300;
4397 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
4398 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
4399 it->second.displaysInfo.push_back(displayInfo);
4400 }
4401 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.ReverseXY(x, y));
4402 }
4403
4404 /**
4405 * @tc.name: InputWindowsManagerTest_SendCancelEventWhenLock
4406 * @tc.desc: Test SendCancelEventWhenLock
4407 * @tc.type: FUNC
4408 * @tc.require:
4409 */
4410 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SendCancelEventWhenLock, TestSize.Level1)
4411 {
4412 CALL_TEST_DEBUG;
4413 InputWindowsManager inputWindowsMgr;
4414 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
4415 }
4416
4417 /**
4418 * @tc.name: InputWindowsManagerTest_FoldScreenRotation
4419 * @tc.desc: Test FoldScreenRotation
4420 * @tc.type: FUNC
4421 * @tc.require:
4422 */
4423 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_FoldScreenRotation, TestSize.Level1)
4424 {
4425 CALL_TEST_DEBUG;
4426 InputWindowsManager inputWindowsMgr;
4427 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
4428 EXPECT_NE(pointerEvent, nullptr);
4429 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.FoldScreenRotation(pointerEvent));
4430 }
4431
4432 /**
4433 * @tc.name: InputWindowsManagerTest_PrintChangedWindowBySync_001
4434 * @tc.desc: Test PrintChangedWindowBySync
4435 * @tc.type: FUNC
4436 * @tc.require:
4437 */
4438 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintChangedWindowBySync_001, TestSize.Level1)
4439 {
4440 CALL_TEST_DEBUG;
4441 InputWindowsManager inputWindowsMgr;
4442 OLD::DisplayGroupInfo newDisplayInfo;
4443 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.PrintChangedWindowBySync(newDisplayInfo));
4444 WindowInfo windowInfo;
4445 windowInfo.id = 1;
4446 windowInfo.pid = 50;
4447 windowInfo.zOrder = 60;
4448 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
4449 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
4450 it->second.windowsInfo.push_back(windowInfo);
4451 }
4452 windowInfo.id = 2;
4453 newDisplayInfo.windowsInfo.push_back(windowInfo);
4454 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.PrintChangedWindowBySync(newDisplayInfo));
4455 }
4456
4457 /**
4458 * @tc.name: InputWindowsManagerTest_PrintChangedWindowBySync_002
4459 * @tc.desc: Test PrintChangedWindowBySync
4460 * @tc.type: FUNC
4461 * @tc.require:
4462 */
4463 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintChangedWindowBySync_002, TestSize.Level1)
4464 {
4465 CALL_TEST_DEBUG;
4466 InputWindowsManager inputWindowsMgr;
4467 OLD::DisplayGroupInfo newDisplayGroupInfo;
4468 OLD::DisplayInfo newDisplayInfo;
4469 newDisplayInfo.direction = DIRECTION0;
4470 newDisplayInfo.displayDirection = DIRECTION0;
4471 newDisplayInfo.width = 200;
4472 newDisplayInfo.height = 300;
4473 newDisplayGroupInfo.displaysInfo.push_back(newDisplayInfo);
4474 OLD::DisplayInfo displayInfo;
4475 displayInfo.direction = DIRECTION0;
4476 displayInfo.displayDirection = DIRECTION0;
4477 displayInfo.width = 200;
4478 displayInfo.height = 300;
4479 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
4480 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
4481 it->second.displaysInfo.push_back(displayInfo);
4482 }
4483 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.PrintChangedWindowBySync(newDisplayGroupInfo));
4484
4485 newDisplayInfo.direction = DIRECTION90;
4486 newDisplayGroupInfo.displaysInfo.clear();
4487 newDisplayGroupInfo.displaysInfo.push_back(newDisplayInfo);
4488 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.PrintChangedWindowBySync(newDisplayGroupInfo));
4489
4490 displayInfo.direction = DIRECTION90;
4491 auto iter = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
4492 if (iter != inputWindowsMgr.displayGroupInfoMap_.end()) {
4493 iter->second.displaysInfo.clear();
4494 iter->second.displaysInfo.push_back(displayInfo);
4495 }
4496 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.PrintChangedWindowBySync(newDisplayGroupInfo));
4497 }
4498
4499 /**
4500 * @tc.name: InputWindowsManagerTest_GetClientFd_003
4501 * @tc.desc: Test the funcation GetClientFd
4502 * @tc.type: FUNC
4503 * @tc.require:
4504 */
4505 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetClientFd_003, TestSize.Level1)
4506 {
4507 InputWindowsManager inputWindowsManager;
4508 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
4509 EXPECT_NE(pointerEvent, nullptr);
4510 WindowInfoEX windowInfoEX;
4511 WindowInfo windowInfo;
4512 windowInfo.id = 1;
4513 windowInfo.pid = 5;
4514 std::vector<WindowInfo> windows;
4515 windows.push_back(windowInfo);
4516 windowInfoEX.window = windows[0];
4517 windowInfoEX.flag = false;
4518 pointerEvent->pointerId_ = 1;
4519 inputWindowsManager.touchItemDownInfos_.insert(std::make_pair(1, windowInfoEX));
4520 int32_t ret = inputWindowsManager.GetClientFd(pointerEvent);
4521 EXPECT_EQ(ret, -1);
4522 windowInfoEX.flag = true;
4523 std::shared_ptr<InputEvent> inputEvent = InputEvent::Create();
4524 EXPECT_NE(inputEvent, nullptr);
4525 inputEvent->targetDisplayId_ = 5;
4526 inputWindowsManager.touchItemDownInfos_.insert(std::make_pair(10, windowInfoEX));
4527 ret = inputWindowsManager.GetClientFd(pointerEvent);
4528 EXPECT_EQ(ret, -1);
4529 }
4530
4531 /**
4532 * @tc.name: InputWindowsManagerTest_GetPidAndUpdateTarget_003
4533 * @tc.desc: Test the funcation GetPidAndUpdateTarget
4534 * @tc.type: FUNC
4535 * @tc.require:
4536 */
4537 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPidAndUpdateTarget_003, TestSize.Level1)
4538 {
4539 CALL_TEST_DEBUG;
4540 InputWindowsManager inputWindowsManager;
4541 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
4542 ASSERT_NE(keyEvent, nullptr);
4543 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
4544 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
4545 it->second.focusWindowId = 10;
4546 }
4547 std::shared_ptr<InputEvent> inputEvent = InputEvent::Create();
4548 EXPECT_NE(inputEvent, nullptr);
4549 inputEvent->targetDisplayId_ = 10;
4550 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetPidAndUpdateTarget(keyEvent));
4551 inputEvent->targetDisplayId_ = 18;
4552 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetPidAndUpdateTarget(keyEvent));
4553 WindowGroupInfo windowGroupInfo;
4554 WindowInfo windowInfo;
4555 windowInfo.id = 10;
4556 windowInfo.pid = 11;
4557 windowGroupInfo.windowsInfo.push_back(windowInfo);
4558 windowInfo.id = 10;
4559 windowInfo.pid = 11;
4560 windowInfo.agentWindowId = 12;
4561 windowGroupInfo.windowsInfo.push_back(windowInfo);
4562 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(10, windowGroupInfo));
4563 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetPidAndUpdateTarget(keyEvent));
4564 }
4565
4566 /**
4567 * @tc.name: InputWindowsManagerTest_IsNeedRefreshLayer_002
4568 * @tc.desc: Test the funcation IsNeedRefreshLayer
4569 * @tc.type: FUNC
4570 * @tc.require:
4571 */
4572 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsNeedRefreshLayer_002, TestSize.Level1)
4573 {
4574 CALL_TEST_DEBUG;
4575 InputWindowsManager inputWindowsManager;
4576 int32_t windowId = 1;
4577 std::shared_ptr<InputEvent> inputEvent = InputEvent::Create();
4578 EXPECT_NE(inputEvent, nullptr);
4579 inputEvent->targetDisplayId_ = -11;
4580 bool ret = inputWindowsManager.IsNeedRefreshLayer(windowId);
4581 EXPECT_FALSE(ret);
4582 inputEvent->targetDisplayId_ = 11;
4583 EXPECT_FALSE(ret);
4584 }
4585
4586 /**
4587 * @tc.name: InputWindowsManagerTest_SelectWindowInfo_003
4588 * @tc.desc: Test the funcation SelectWindowInfo
4589 * @tc.type: FUNC
4590 * @tc.require:
4591 */
4592 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectWindowInfo_003, TestSize.Level1)
4593 {
4594 CALL_TEST_DEBUG;
4595 InputWindowsManager inputWindowsManager;
4596 int32_t logicalX = 200;
4597 int32_t logicalY = 200;
4598 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
4599 EXPECT_NE(pointerEvent, nullptr);
4600 inputWindowsManager.firstBtnDownWindowInfo_.first = -1;
4601 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_BUTTON_DOWN;
4602 PointerEvent::PointerItem pointerItem;
4603 pointerItem.targetWindowId_ = 0;
4604 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4605 pointerItem.targetWindowId_ = 2;
4606 WindowInfo windowInfo;
4607 windowInfo.flags = WindowInfo::FLAG_BIT_UNTOUCHABLE;
4608 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4609 windowInfo.flags = WindowInfo::FLAG_BIT_HANDWRITING;
4610 pointerEvent->HasFlag(InputEvent::EVENT_FLAG_SIMULATE);
4611 inputWindowsManager.extraData_.appended = true;
4612 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
4613 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_PULL_UP;
4614 windowInfo.pointerHotAreas.push_back({150, 250, 300, 500});
4615 windowInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
4616 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4617 inputWindowsManager.extraData_.appended = false;
4618 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
4619 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_PULL_IN_WINDOW;
4620 pointerItem.targetWindowId_ = -2;
4621 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4622 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_PULL_UP;
4623 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4624 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_AXIS_BEGIN;
4625 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4626 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_AXIS_UPDATE;
4627 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4628 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_PULL_OUT_WINDOW;
4629 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4630 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_AXIS_END;
4631 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4632 pointerItem.targetWindowId_ = 10;
4633 std::shared_ptr<InputEvent> inputEvent = InputEvent::Create();
4634 EXPECT_NE(inputEvent, nullptr);
4635 inputEvent->targetDisplayId_ = 11;
4636 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4637 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_BUTTON_DOWN;
4638 inputWindowsManager.firstBtnDownWindowInfo_.first = 1;
4639 inputEvent->targetDisplayId_ = 1;
4640 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent));
4641 }
4642
4643 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_CROWN)
4644 /**
4645 * @tc.name: InputWindowsManagerTest_UpdateCrownTarget_001
4646 * @tc.desc: Test the funcation UpdateCrownTarget
4647 * @tc.type: FUNC
4648 * @tc.require:
4649 */
4650 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateCrownTarget_001, TestSize.Level1)
4651 {
4652 CALL_TEST_DEBUG;
4653 InputWindowsManager inputWindowsManager;
4654 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
4655 EXPECT_NE(pointerEvent, nullptr);
4656 std::shared_ptr<InputEvent> inputEvent = InputEvent::Create();
4657 EXPECT_NE(inputEvent, nullptr);
4658 inputEvent->targetDisplayId_ = -1;
4659 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
4660 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
4661 it->second.focusWindowId = -1;
4662 }
4663 int32_t ret = inputWindowsManager.UpdateCrownTarget(pointerEvent);
4664 EXPECT_NE(ret, RET_OK);
4665 inputEvent->targetDisplayId_ = 5;
4666 ret = inputWindowsManager.UpdateCrownTarget(pointerEvent);
4667 EXPECT_NE(ret, RET_OK);
4668 it->second.focusWindowId = 5;
4669 ret = inputWindowsManager.UpdateCrownTarget(pointerEvent);
4670 EXPECT_NE(ret, RET_OK);
4671 }
4672 #endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_CROWN
4673
4674 /**
4675 * @tc.name: InputWindowsManagerTest_PrintChangedWindowByEvent_001
4676 * @tc.desc: Test the funcation PrintChangedWindowByEvent
4677 * @tc.type: FUNC
4678 * @tc.require:
4679 */
4680 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintChangedWindowByEvent_001, TestSize.Level1)
4681 {
4682 CALL_TEST_DEBUG;
4683 InputWindowsManager inputWindowsManager;
4684 int32_t eventType = 1;
4685 WindowInfo newWindowInfo;
4686 newWindowInfo.id = 6;
4687 WindowInfo windowInfo;
4688 windowInfo.id = 1;
4689 windowInfo.pid = 5;
4690 windowInfo.uid = 1;
4691 inputWindowsManager.lastMatchedWindow_.insert(std::make_pair(1, windowInfo));
4692 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.PrintChangedWindowByEvent(eventType, newWindowInfo));
4693 eventType = 10;
4694 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.PrintChangedWindowByEvent(eventType, newWindowInfo));
4695 newWindowInfo.id = 1;
4696 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.PrintChangedWindowByEvent(eventType, newWindowInfo));
4697 }
4698
4699 /**
4700 * @tc.name: InputWindowsManagerTest_TransformDisplayXY_001
4701 * @tc.desc: Test the TransformDisplayXY function of the input window manager
4702 * @tc.type: FUNC
4703 * @tc.require:
4704 */
4705 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_TransformDisplayXY_001, TestSize.Level1)
4706 {
4707 CALL_TEST_DEBUG;
4708 OLD::DisplayInfo info;
4709 double logicX = 10.0;
4710 double logicY = 20.0;
4711 std::pair<double, double> result = WIN_MGR->TransformDisplayXY(info, logicX, logicY);
4712 double ret = result.first;
4713 EXPECT_EQ(ret, logicX);
4714 double ret1 = result.second;
4715 EXPECT_EQ(ret1, logicY);
4716 }
4717
4718 /**
4719 * @tc.name: InputWindowsManagerTest_TransformDisplayXY_002
4720 * @tc.desc: Test the TransformDisplayXY function of the input window manager
4721 * @tc.type: FUNC
4722 * @tc.require:
4723 */
4724 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_TransformDisplayXY_002, TestSize.Level1)
4725 {
4726 CALL_TEST_DEBUG;
4727 OLD::DisplayInfo info;
4728 std::vector<float> transform = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
4729 info.transform = transform;
4730 double logicX = 10.0;
4731 double logicY = 20.0;
4732 std::pair<double, double> result = WIN_MGR->TransformDisplayXY(info, logicX, logicY);
4733 double ret = result.first;
4734 EXPECT_EQ(ret, logicX);
4735 double ret1 = result.second;
4736 EXPECT_EQ(ret1, logicY);
4737 }
4738
4739 /**
4740 * @tc.name: InputWindowsManagerTest_TransformDisplayXY_003
4741 * @tc.desc: Test the TransformDisplayXY function of the input window manager
4742 * @tc.type: FUNC
4743 * @tc.require:
4744 */
4745 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_TransformDisplayXY_003, TestSize.Level1)
4746 {
4747 CALL_TEST_DEBUG;
4748 OLD::DisplayInfo info;
4749 std::vector<float> transform = {0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 315.0, 690.0, 1.0};
4750 info.transform = transform;
4751 double logicX = 10.0;
4752 double logicY = 20.0;
4753 std::pair<double, double> result = WIN_MGR->TransformDisplayXY(info, logicX, logicY);
4754 double ret = result.first;
4755 EXPECT_EQ(ret, 320);
4756 double ret1 = result.second;
4757 EXPECT_EQ(ret1, 700);
4758 }
4759
4760 /**
4761 * @tc.name: InputWindowsManagerTest_IsValidNavigationWindow_001
4762 * @tc.desc: Test IsValidNavigationWindow
4763 * @tc.type: FUNC
4764 * @tc.require:
4765 */
4766 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsValidNavigationWindow_001, TestSize.Level1)
4767 {
4768 CALL_TEST_DEBUG;
4769 WindowInfo windowInfo;
4770 windowInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
4771 double x = 10.0;
4772 double y = 20.0;
4773 Rect rect = {0, 0, 30, 40};
4774 windowInfo.defaultHotAreas.push_back(rect);
4775 EXPECT_TRUE(WIN_MGR->IsValidNavigationWindow(windowInfo, x, y));
4776 }
4777
4778 /**
4779 * @tc.name: InputWindowsManagerTest_IsValidNavigationWindow_002
4780 * @tc.desc: Test IsValidNavigationWindow
4781 * @tc.type: FUNC
4782 * @tc.require:
4783 */
4784 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsValidNavigationWindow_002, TestSize.Level1)
4785 {
4786 CALL_TEST_DEBUG;
4787 WindowInfo windowInfo;
4788 windowInfo.windowInputType = WindowInputType::MIX_BUTTOM_ANTI_AXIS_MOVE;
4789 double x = 10.0;
4790 double y = 20.0;
4791 Rect rect = {0, 0, 30, 40};
4792 windowInfo.defaultHotAreas.push_back(rect);
4793 EXPECT_TRUE(WIN_MGR->IsValidNavigationWindow(windowInfo, x, y));
4794 }
4795
4796 /**
4797 * @tc.name: InputWindowsManagerTest_IsValidNavigationWindow_003
4798 * @tc.desc: Test IsValidNavigationWindow
4799 * @tc.type: FUNC
4800 * @tc.require:
4801 */
4802 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsValidNavigationWindow_003, TestSize.Level1)
4803 {
4804 CALL_TEST_DEBUG;
4805 WindowInfo windowInfo;
4806 windowInfo.windowInputType = WindowInputType::NORMAL;
4807 double x = 10.0;
4808 double y = 20.0;
4809 Rect rect = {0, 0, 30, 40};
4810 windowInfo.defaultHotAreas.push_back(rect);
4811 EXPECT_FALSE(WIN_MGR->IsValidNavigationWindow(windowInfo, x, y));
4812 }
4813
4814 /**
4815 * @tc.name: InputWindowsManagerTest_IsValidNavigationWindow_004
4816 * @tc.desc: Test IsValidNavigationWindow
4817 * @tc.type: FUNC
4818 * @tc.require:
4819 */
4820 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsValidNavigationWindow_004, TestSize.Level1)
4821 {
4822 CALL_TEST_DEBUG;
4823 WindowInfo windowInfo;
4824 windowInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
4825 double x = -10.0;
4826 double y = 20.0;
4827 Rect rect = {0, 0, 30, 40};
4828 windowInfo.defaultHotAreas.push_back(rect);
4829 EXPECT_FALSE(WIN_MGR->IsValidNavigationWindow(windowInfo, x, y));
4830 }
4831
4832 /**
4833 * @tc.name: InputWindowsManagerTest_IsValidNavigationWindow_005
4834 * @tc.desc: Test IsValidNavigationWindow
4835 * @tc.type: FUNC
4836 * @tc.require:
4837 */
4838 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsValidNavigationWindow_005, TestSize.Level1)
4839 {
4840 CALL_TEST_DEBUG;
4841 WindowInfo windowInfo;
4842 windowInfo.windowInputType = WindowInputType::TRANSMIT_ALL;
4843 double x = 10.0;
4844 double y = -20.0;
4845 Rect rect = {0, 0, 30, 40};
4846 windowInfo.defaultHotAreas.push_back(rect);
4847 EXPECT_FALSE(WIN_MGR->IsValidNavigationWindow(windowInfo, x, y));
4848 }
4849
4850 /**
4851 * @tc.name: InputWindowsManagerTest_UpdateTransformDisplayXY_001
4852 * @tc.desc: Test UpdateTransformDisplayXY
4853 * @tc.type: FUNC
4854 * @tc.require:
4855 */
4856 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTransformDisplayXY_001, TestSize.Level1)
4857 {
4858 CALL_TEST_DEBUG;
4859 auto pointerEvent = PointerEvent::Create();
4860 EXPECT_NE(pointerEvent, nullptr);
4861 PointerEvent::PointerItem item;
4862 item.SetPointerId(0);
4863 item.SetDisplayXPos(10);
4864 item.SetDisplayYPos(20);
4865 pointerEvent->UpdatePointerItem(0, item);
4866 std::vector<WindowInfo> windowsInfo;
4867 OLD::DisplayInfo info;
4868 WIN_MGR->UpdateTransformDisplayXY(pointerEvent, windowsInfo, info);
4869 int32_t pointerId = pointerEvent->GetPointerId();
4870 PointerEvent::PointerItem pointerItem;
4871 if (!pointerEvent->GetPointerItem(pointerId, pointerItem)) {
4872 MMI_HILOG_DISPATCHE("Can't find pointer item, pointer:%{public}d", pointerId);
4873 return;
4874 }
4875 int32_t physicalX = pointerItem.GetDisplayX();
4876 int32_t physicalY = pointerItem.GetDisplayX();
4877 EXPECT_EQ(physicalX, 10);
4878 EXPECT_EQ(physicalY, 20);
4879 }
4880
4881 /**
4882 * @tc.name: InputWindowsManagerTest_UpdateTransformDisplayXY_002
4883 * @tc.desc: Test UpdateTransformDisplayXY
4884 * @tc.type: FUNC
4885 * @tc.require:
4886 */
4887 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTransformDisplayXY_002, TestSize.Level1)
4888 {
4889 CALL_TEST_DEBUG;
4890 auto pointerEvent = PointerEvent::Create();
4891 EXPECT_NE(pointerEvent, nullptr);
4892 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
4893 PointerEvent::PointerItem item;
4894 item.SetPointerId(0);
4895 item.SetDisplayXPos(10);
4896 item.SetDisplayYPos(20);
4897 pointerEvent->UpdatePointerItem(0, item);
4898 std::vector<WindowInfo> windowsInfo;
4899 WindowInfo windowInfo;
4900 OLD::DisplayInfo info;
4901 std::vector<float> transform = {0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 315.0, 690.0, 1.0};
4902 info.transform = transform;
4903 windowInfo.windowInputType = WindowInputType::MIX_BUTTOM_ANTI_AXIS_MOVE;
4904 Rect rect = {0, 0, 30, 40};
4905 windowInfo.defaultHotAreas.push_back(rect);
4906 windowsInfo.push_back(windowInfo);
4907 WIN_MGR->UpdateTransformDisplayXY(pointerEvent, windowsInfo, info);
4908 int32_t pointerId = pointerEvent->GetPointerId();
4909 PointerEvent::PointerItem pointerItem;
4910 if (!pointerEvent->GetPointerItem(pointerId, pointerItem)) {
4911 MMI_HILOG_DISPATCHE("Can't find pointer item, pointer:%{public}d", pointerId);
4912 return;
4913 }
4914 int32_t physicalX = pointerItem.GetDisplayX();
4915 int32_t physicalY = pointerItem.GetDisplayX();
4916 EXPECT_EQ(physicalX, 10);
4917 EXPECT_EQ(physicalY, 20);
4918 }
4919
4920 /**
4921 * @tc.name: InputWindowsManagerTest_UpdateTransformDisplayXY_003
4922 * @tc.desc: Test UpdateTransformDisplayXY
4923 * @tc.type: FUNC
4924 * @tc.require:
4925 */
4926 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTransformDisplayXY_003, TestSize.Level1)
4927 {
4928 CALL_TEST_DEBUG;
4929 auto pointerEvent = PointerEvent::Create();
4930 EXPECT_NE(pointerEvent, nullptr);
4931 PointerEvent::PointerItem item;
4932 item.SetPointerId(0);
4933 item.SetDisplayXPos(10);
4934 item.SetDisplayYPos(20);
4935 pointerEvent->UpdatePointerItem(0, item);
4936 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
4937 std::vector<WindowInfo> windowsInfo;
4938 WindowInfo windowInfo;
4939 OLD::DisplayInfo info;
4940 std::vector<float> transform = {0.5, 0.0, 0.0, 0.0, 0.5, 0.0, 315.0, 690.0, 1.0};
4941 info.transform = transform;
4942 windowInfo.windowInputType = WindowInputType::TRANSMIT_ALL;
4943 Rect rect = {0, 0, 30, 40};
4944 windowInfo.defaultHotAreas.push_back(rect);
4945 windowsInfo.push_back(windowInfo);
4946 WIN_MGR->UpdateTransformDisplayXY(pointerEvent, windowsInfo, info);
4947 int32_t pointerId = pointerEvent->GetPointerId();
4948 PointerEvent::PointerItem pointerItem;
4949 if (!pointerEvent->GetPointerItem(pointerId, pointerItem)) {
4950 MMI_HILOG_DISPATCHE("Can't find pointer item, pointer:%{public}d", pointerId);
4951 return;
4952 }
4953 int32_t physicalX = pointerItem.GetDisplayX();
4954 int32_t physicalY = pointerItem.GetDisplayX();
4955 EXPECT_EQ(physicalX, 320);
4956 EXPECT_EQ(physicalY, 700);
4957 }
4958
4959 /**
4960 * @tc.name: InputWindowsManagerTest_GetUIExtentionWindowInfo
4961 * @tc.desc: Test the funcation GetUIExtentionWindowInfo
4962 * @tc.type: FUNC
4963 * @tc.require:
4964 */
4965 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetUIExtentionWindowInfo, TestSize.Level1)
4966 {
4967 CALL_TEST_DEBUG;
4968 InputWindowsManager inputWinMgr;
4969 WindowInfo windowInfo;
4970 windowInfo.id = 5;
4971 std::vector<WindowInfo> uiExtentionWindowInfo;
4972 int32_t windowId = 10;
4973 WindowInfo *touchWindow;
4974 bool isUiExtentionWindow = false;
4975 uiExtentionWindowInfo.push_back(windowInfo);
4976 windowInfo.id = 10;
4977 uiExtentionWindowInfo.push_back(windowInfo);
4978 EXPECT_NO_FATAL_FAILURE(
4979 inputWinMgr.GetUIExtentionWindowInfo(uiExtentionWindowInfo, windowId, &touchWindow, isUiExtentionWindow));
4980 }
4981
4982 /**
4983 * @tc.name: InputWindowsManagerTest_CheckUIExtentionWindowDefaultHotArea
4984 * @tc.desc: Test the funcation CheckUIExtentionWindowDefaultHotArea
4985 * @tc.type: FUNC
4986 * @tc.require:
4987 */
4988 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckUIExtentionWindowDefaultHotArea, TestSize.Level1)
4989 {
4990 CALL_TEST_DEBUG;
4991 InputWindowsManager inputWinMgr;
4992 int32_t logicalX = 150;
4993 int32_t logicalY = 150;
4994 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
4995 ASSERT_NE(pointerEvent, nullptr);
4996 pointerEvent->SetPointerId(0);
4997 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
4998 std::vector<WindowInfo> windowInfos;
4999 bool isHotArea = true;
5000 std::pair<int32_t, int32_t> logicalXY(std::make_pair(logicalX, logicalY));
5001 WindowInfo windowInfo;
5002 Rect rect;
5003 rect.x = INT32_MAX;
5004 rect.width = 100;
5005 windowInfo.defaultHotAreas.push_back(rect);
5006 windowInfos.push_back(windowInfo);
5007 WindowInfo touchWindow;
5008 touchWindow.id = 100;
5009 const WindowInfo *touchWindowInfo = &touchWindow;
5010 EXPECT_NO_FATAL_FAILURE(inputWinMgr.CheckUIExtentionWindowDefaultHotArea(
5011 logicalXY, isHotArea, pointerEvent, windowInfos, &touchWindowInfo));
5012 }
5013
5014 /**
5015 * @tc.name: InputWindowsManagerTest_CheckUIExtentionWindowDefaultHotArea_001
5016 * @tc.desc: Test the funcation CheckUIExtentionWindowDefaultHotArea
5017 * @tc.type: FUNC
5018 * @tc.require:
5019 */
5020 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckUIExtentionWindowDefaultHotArea_001, TestSize.Level1)
5021 {
5022 CALL_TEST_DEBUG;
5023 InputWindowsManager inputWinMgr;
5024 int32_t logicalX = 150;
5025 int32_t logicalY = 150;
5026 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5027 ASSERT_NE(pointerEvent, nullptr);
5028 pointerEvent->SetPointerId(0);
5029 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
5030 std::vector<WindowInfo> windowInfos;
5031 bool isHotArea = true;
5032 std::pair<int32_t, int32_t> logicalXY(std::make_pair(logicalX, logicalY));
5033 WindowInfo windowInfo;
5034 Rect rect;
5035 rect.x = 100;
5036 rect.y = 100;
5037 rect.width = 200;
5038 rect.height = 200;
5039 windowInfo.defaultHotAreas.push_back(rect);
5040 windowInfos.push_back(windowInfo);
5041 WindowInfo touchWindow;
5042 touchWindow.id = 100;
5043 const WindowInfo *touchWindowInfo = &touchWindow;
5044 EXPECT_NO_FATAL_FAILURE(inputWinMgr.CheckUIExtentionWindowDefaultHotArea(
5045 logicalXY, isHotArea, pointerEvent, windowInfos, &touchWindowInfo));
5046 }
5047
5048 /**
5049 * @tc.name: InputWindowsManagerTest_IsKeyPressed
5050 * @tc.desc: Test the funcation IsKeyPressed
5051 * @tc.type: FUNC
5052 * @tc.require:
5053 */
5054 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsKeyPressed, TestSize.Level1)
5055 {
5056 CALL_TEST_DEBUG;
5057 InputWindowsManager inputWinMgr;
5058 KeyEvent::KeyItem item;
5059 int32_t pressedKey = 2024;
5060 std::vector<KeyEvent::KeyItem> keyItems;
5061 item.SetKeyCode(2018);
5062 item.SetPressed(false);
5063 keyItems.push_back(item);
5064 EXPECT_FALSE(inputWinMgr.IsKeyPressed(pressedKey, keyItems));
5065 }
5066
5067 /**
5068 * @tc.name: InputWindowsManagerTest_IsKeyPressed_001
5069 * @tc.desc: Test the funcation IsKeyPressed
5070 * @tc.type: FUNC
5071 * @tc.require:
5072 */
5073 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsKeyPressed_001, TestSize.Level1)
5074 {
5075 CALL_TEST_DEBUG;
5076 InputWindowsManager inputWinMgr;
5077 KeyEvent::KeyItem item;
5078 int32_t pressedKey = 2024;
5079 std::vector<KeyEvent::KeyItem> keyItems;
5080 item.SetKeyCode(2024);
5081 item.SetPressed(true);
5082 keyItems.push_back(item);
5083 EXPECT_TRUE(inputWinMgr.IsKeyPressed(pressedKey, keyItems));
5084 }
5085
5086 /**
5087 * @tc.name: InputWindowsManagerTest_IsOnTheWhitelist
5088 * @tc.desc: Test the funcation IsOnTheWhitelist
5089 * @tc.type: FUNC
5090 * @tc.require:
5091 */
5092 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsOnTheWhitelist, TestSize.Level1)
5093 {
5094 CALL_TEST_DEBUG;
5095 InputWindowsManager inputWinMgr;
5096 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
5097 ASSERT_NE(keyEvent, nullptr);
5098 KeyEvent::KeyItem item;
5099 SwitchFocusKey switchFocusKey;
5100 switchFocusKey.keyCode = 2024;
5101 switchFocusKey.pressedKey = -1;
5102 inputWinMgr.vecWhiteList_.push_back(switchFocusKey);
5103 keyEvent->SetKeyCode(2024);
5104 item.SetPressed(true);
5105 item.SetKeyCode(2024);
5106 keyEvent->AddKeyItem(item);
5107 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
5108 EXPECT_TRUE(inputWinMgr.IsOnTheWhitelist(keyEvent));
5109
5110 inputWinMgr.vecWhiteList_[0].pressedKey = 2024;
5111 keyEvent->AddKeyItem(item);
5112 EXPECT_TRUE(inputWinMgr.IsOnTheWhitelist(keyEvent));
5113
5114 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_UP);
5115 EXPECT_FALSE(inputWinMgr.IsOnTheWhitelist(keyEvent));
5116
5117 keyEvent->SetKeyCode(2018);
5118 EXPECT_FALSE(inputWinMgr.IsOnTheWhitelist(keyEvent));
5119 }
5120
5121 /**
5122 * @tc.name: InputWindowsManagerTest_IsOnTheWhitelist_001
5123 * @tc.desc: Test IsOnTheWhitelist
5124 * @tc.type: FUNC
5125 * @tc.require:
5126 */
5127 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsOnTheWhitelist_001, TestSize.Level1)
5128 {
5129 CALL_TEST_DEBUG;
5130 WIN_MGR->vecWhiteList_ = {{1}, {2}, {3}};
5131 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
5132 ASSERT_NE(keyEvent, nullptr);
5133 keyEvent->SetKeyCode(4);
5134 bool ret = WIN_MGR->IsOnTheWhitelist(keyEvent);
5135 ASSERT_FALSE(ret);
5136 }
5137
5138 /**
5139 * @tc.name: InputWindowsManagerTest_IsOnTheWhitelist_002
5140 * @tc.desc: Test IsOnTheWhitelist
5141 * @tc.type: FUNC
5142 * @tc.require:
5143 */
5144 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsOnTheWhitelist_002, TestSize.Level1)
5145 {
5146 CALL_TEST_DEBUG;
5147 InputWindowsManager inputManager;
5148 SwitchFocusKey whitelistItem;
5149 whitelistItem.keyCode = 1;
5150 whitelistItem.pressedKey = -1;
5151 inputManager.vecWhiteList_.push_back(whitelistItem);
5152 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
5153 ASSERT_NE(keyEvent, nullptr);
5154 keyEvent->SetKeyCode(1);
5155 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
5156 KeyEvent::KeyItem item;
5157 item.SetKeyCode(KeyEvent::KEYCODE_HOME);
5158 keyEvent->AddKeyItem(item);
5159 bool ret = inputManager.IsOnTheWhitelist(keyEvent);
5160 ASSERT_TRUE(ret);
5161 whitelistItem.pressedKey = 2;
5162 ret = inputManager.IsOnTheWhitelist(keyEvent);
5163 ASSERT_TRUE(ret);
5164 whitelistItem.pressedKey = -1;
5165 item.SetDeviceId(100);
5166 item.SetKeyCode(KeyEvent::KEYCODE_PAGE_DOWN);
5167 item.SetDownTime(100);
5168 keyEvent->AddKeyItem(item);
5169 ret = inputManager.IsOnTheWhitelist(keyEvent);
5170 ASSERT_FALSE(ret);
5171 }
5172
5173 /**
5174 * @tc.name: InputWindowsManagerTest_IsOnTheWhitelist_003
5175 * @tc.desc: Test IsOnTheWhitelist
5176 * @tc.type: FUNC
5177 * @tc.require:
5178 */
5179 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsOnTheWhitelist_003, TestSize.Level1)
5180 {
5181 CALL_TEST_DEBUG;
5182 InputWindowsManager inputManager;
5183 SwitchFocusKey whitelistItem;
5184 whitelistItem.keyCode = 1;
5185 whitelistItem.pressedKey = 1;
5186 inputManager.vecWhiteList_.push_back(whitelistItem);
5187 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
5188 ASSERT_NE(keyEvent, nullptr);
5189 keyEvent->SetKeyCode(1);
5190 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
5191 KeyEvent::KeyItem item;
5192 item.SetDeviceId(100);
5193 item.SetDownTime(100);
5194 keyEvent->AddKeyItem(item);
5195 item.pressed_ = true;
5196 bool ret = WIN_MGR->IsOnTheWhitelist(keyEvent);
5197 ASSERT_TRUE(ret);
5198 }
5199
5200 /**
5201 * @tc.name: InputWindowsManagerTest_IsKeyPressed_002
5202 * @tc.desc: Test IsKeyPressed
5203 * @tc.type: FUNC
5204 * @tc.require:
5205 */
5206 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsKeyPressed_002, TestSize.Level1)
5207 {
5208 CALL_TEST_DEBUG;
5209 KeyEvent::KeyItem item;
5210 item.SetKeyCode(1);
5211 std::vector<KeyEvent::KeyItem> keyItems;
5212 keyItems.push_back(item);
5213 bool ret = WIN_MGR->IsKeyPressed(1, keyItems);
5214 ASSERT_FALSE(ret);
5215 ret = WIN_MGR->IsKeyPressed(2, keyItems);
5216 ASSERT_FALSE(ret);
5217 item.pressed_ = true;
5218 keyItems.push_back(item);
5219 ret = WIN_MGR->IsKeyPressed(1, keyItems);
5220 ASSERT_TRUE(ret);
5221 }
5222
5223 /**
5224 * @tc.name: InputWindowsManagerTest_CheckUIExtentionWindowPointerHotArea_001
5225 * @tc.desc: Test CheckUIExtentionWindowPointerHotArea
5226 * @tc.type: FUNC
5227 * @tc.require:
5228 */
5229 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckUIExtentionWindowPointerHotArea_001, TestSize.Level1)
5230 {
5231 CALL_TEST_DEBUG;
5232 WindowInfo windowInfo;
5233 windowInfo.windowType = 2105;
5234 windowInfo.area.x = 10;
5235 windowInfo.area.y = 80;
5236 windowInfo.area.height = 90;
5237 std::vector<WindowInfo> windows;
5238 windows.push_back(windowInfo);
5239 int32_t windowId = 1;
5240 EXPECT_NO_FATAL_FAILURE(WIN_MGR->CheckUIExtentionWindowPointerHotArea(15, 20, windows, windowId));
5241 EXPECT_NO_FATAL_FAILURE(WIN_MGR->CheckUIExtentionWindowPointerHotArea(100, 200, windows, windowId));
5242 EXPECT_NO_FATAL_FAILURE(WIN_MGR->CheckUIExtentionWindowPointerHotArea(100, 200, {}, windowId));
5243 }
5244
5245 /**
5246 * @tc.name: InputWindowsManagerTest_GetUIExtentionWindowInfo_001
5247 * @tc.desc: Test GetUIExtentionWindowInfo
5248 * @tc.type: FUNC
5249 * @tc.require:
5250 */
5251 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetUIExtentionWindowInfo_001, TestSize.Level1)
5252 {
5253 CALL_TEST_DEBUG;
5254 InputWindowsManager manager;
5255 std::vector<WindowInfo> windows = {{1}, {2}, {3}};
5256 WindowInfo *touchWindow = nullptr;
5257 bool isUiExtentionWindow = false;
5258 EXPECT_NO_FATAL_FAILURE(WIN_MGR->GetUIExtentionWindowInfo(windows, 2, &touchWindow, isUiExtentionWindow));
5259 EXPECT_NO_FATAL_FAILURE(WIN_MGR->GetUIExtentionWindowInfo(windows, 4, &touchWindow, isUiExtentionWindow));
5260 std::vector<WindowInfo> emptyWindows;
5261 EXPECT_NO_FATAL_FAILURE(WIN_MGR->GetUIExtentionWindowInfo(emptyWindows, 1, &touchWindow, isUiExtentionWindow));
5262 }
5263
5264 /**
5265 * @tc.name: InputWindowsManagerTest_CheckUIExtentionWindowDefaultHotArea_002
5266 * @tc.desc: Test CheckUIExtentionWindowDefaultHotArea
5267 * @tc.type: FUNC
5268 * @tc.require:
5269 */
5270 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckUIExtentionWindowDefaultHotArea_002, TestSize.Level1)
5271 {
5272 CALL_TEST_DEBUG;
5273 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5274 ASSERT_NE(pointerEvent, nullptr);
5275 pointerEvent->SetPointerId(0);
5276 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
5277 bool isHotArea = true;
5278 InputWindowsManager manager;
5279 WindowInfo windowInfo;
5280 windowInfo.windowType = 2105;
5281 windowInfo.area.x = 10;
5282 windowInfo.area.y = 100;
5283 windowInfo.area.height = 200;
5284 std::vector<WindowInfo> windows;
5285 windows.push_back(windowInfo);
5286 WindowInfo touchWindow;
5287 touchWindow.id = 100;
5288 const WindowInfo *touchWindowInfo = &touchWindow;
5289 std::pair<int32_t, int32_t> logicalXY(std::make_pair(15, 25));
5290 EXPECT_NO_FATAL_FAILURE(
5291 WIN_MGR->CheckUIExtentionWindowDefaultHotArea(logicalXY, isHotArea, pointerEvent, windows, &touchWindowInfo));
5292 std::pair<int32_t, int32_t> secondXY(std::make_pair(300, 300));
5293 EXPECT_NO_FATAL_FAILURE(
5294 WIN_MGR->CheckUIExtentionWindowDefaultHotArea(secondXY, isHotArea, pointerEvent, windows, &touchWindowInfo));
5295 EXPECT_NO_FATAL_FAILURE(
5296 WIN_MGR->CheckUIExtentionWindowDefaultHotArea(logicalXY, isHotArea, pointerEvent, {}, &touchWindowInfo));
5297 }
5298
5299 /**
5300 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_003
5301 * @tc.desc: Test UpdateTouchScreenTarget
5302 * @tc.type: FUNC
5303 * @tc.require:
5304 */
5305 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_003, TestSize.Level1)
5306 {
5307 CALL_TEST_DEBUG;
5308 InputWindowsManager inputWindowsMgr;
5309 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5310 ASSERT_NE(pointerEvent, nullptr);
5311 OLD::DisplayInfo displayInfo;
5312 WindowGroupInfo winGroupInfo;
5313 WindowInfo winInfo;
5314 Rect rect;
5315 PointerEvent::PointerItem item;
5316 displayInfo.id = 100;
5317 displayInfo.x = 500;
5318 displayInfo.y = 500;
5319 pointerEvent->SetTargetDisplayId(-1);
5320 pointerEvent->SetPointerId(150);
5321 item.SetPointerId(150);
5322 item.SetDisplayXPos(500);
5323 item.SetDisplayYPos(500);
5324 item.SetTargetWindowId(200);
5325 item.SetToolType(PointerEvent::TOOL_TYPE_FINGER);
5326 pointerEvent->AddPointerItem(item);
5327 pointerEvent->SetZOrder(15.5f);
5328 pointerEvent->bitwise_ = 0x00000000;
5329 rect.x = 300;
5330 rect.width = 1200;
5331 rect.y = 300;
5332 rect.height = 1200;
5333 for (int32_t i = 0; i < 4; ++i) {
5334 winInfo.defaultHotAreas.push_back(rect);
5335 }
5336 winInfo.id = 0;
5337 winInfo.flags = 6;
5338 winInfo.pixelMap = nullptr;
5339 winGroupInfo.windowsInfo.push_back(winInfo);
5340 winInfo.id = 1;
5341 winInfo.flags = 0;
5342 winInfo.pixelMap = nullptr;
5343 winInfo.windowInputType = WindowInputType::NORMAL;
5344 winInfo.transform.clear();
5345 winInfo.transform = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};
5346 auto pointerId = 150;
5347 WindowInfoEX winEx;
5348 winEx.flag = true;
5349 winEx.window = winInfo;
5350 inputWindowsMgr.touchItemDownInfos_.insert(std::make_pair(pointerId, winEx));
5351 auto iter = inputWindowsMgr.touchItemDownInfos_.find(pointerId);
5352 if (iter != inputWindowsMgr.touchItemDownInfos_.end()) {
5353 iter->second.window.transform.clear();
5354 iter->second.window.transform = winInfo.transform;
5355 }
5356 winInfo.defaultHotAreas.push_back(rect);
5357 winGroupInfo.windowsInfo.push_back(winInfo);
5358 inputWindowsMgr.extraData_.appended = true;
5359 inputWindowsMgr.extraData_.pointerId = 150;
5360 inputWindowsMgr.extraData_.sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
5361 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
5362 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
5363 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
5364 it->second.displaysInfo.push_back(displayInfo);
5365 }
5366 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5367 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5368 }
5369
5370 /**
5371 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_004
5372 * @tc.desc: Test UpdateTouchScreenTarget
5373 * @tc.type: FUNC
5374 * @tc.require:
5375 */
5376 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_004, TestSize.Level1)
5377 {
5378 CALL_TEST_DEBUG;
5379 InputWindowsManager inputWindowsMgr;
5380 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5381 ASSERT_NE(pointerEvent, nullptr);
5382 OLD::DisplayInfo displayInfo;
5383 WindowGroupInfo winGroupInfo;
5384 WindowInfo winInfo;
5385 Rect rect;
5386 PointerEvent::PointerItem item;
5387 displayInfo.id = 100;
5388 displayInfo.x = 500;
5389 displayInfo.y = 500;
5390 pointerEvent->SetTargetDisplayId(-1);
5391 pointerEvent->SetPointerId(150);
5392 item.SetPointerId(150);
5393 item.SetDisplayXPos(500);
5394 item.SetDisplayYPos(500);
5395 item.SetTargetWindowId(-1);
5396 item.SetToolType(PointerEvent::TOOL_TYPE_RUBBER);
5397 pointerEvent->AddPointerItem(item);
5398 pointerEvent->SetZOrder(15.5f);
5399 pointerEvent->bitwise_ = 0x00000000;
5400 rect.x = 300;
5401 rect.width = INT32_MAX;
5402 winInfo.id = 50;
5403 winInfo.defaultHotAreas.push_back(rect);
5404 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5405 rect.x = 300;
5406 rect.width = 1200;
5407 rect.y = 300;
5408 rect.height = 1200;
5409 winInfo.id = 1;
5410 winInfo.flags = 0;
5411 winInfo.pixelMap = nullptr;
5412 winInfo.windowInputType = WindowInputType::TRANSMIT_ALL;
5413 winInfo.defaultHotAreas.clear();
5414 winInfo.defaultHotAreas.push_back(rect);
5415 winInfo.transform.clear();
5416 winInfo.transform = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};
5417 auto pointerId = 150;
5418 WindowInfoEX winEx;
5419 winEx.flag = true;
5420 winEx.window = winInfo;
5421 inputWindowsMgr.touchItemDownInfos_.insert(std::make_pair(pointerId, winEx));
5422 auto iter = inputWindowsMgr.touchItemDownInfos_.find(pointerId);
5423 if (iter != inputWindowsMgr.touchItemDownInfos_.end()) {
5424 iter->second.window.transform.clear();
5425 iter->second.window.transform = winInfo.transform;
5426 }
5427 winGroupInfo.windowsInfo.push_back(winInfo);
5428 inputWindowsMgr.extraData_.appended = false;
5429 inputWindowsMgr.extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
5430 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5431 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
5432 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
5433 it->second.displaysInfo.push_back(displayInfo);
5434 }
5435 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5436 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5437 }
5438
5439 /**
5440 * @tc.name: InputWindowsManagerTest_IgnoreTouchEvent_001
5441 * @tc.desc: Test IgnoreTouchEvent
5442 * @tc.type: FUNC
5443 * @tc.require:
5444 */
5445 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IgnoreTouchEvent_001, TestSize.Level1)
5446 {
5447 CALL_TEST_DEBUG;
5448 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5449 ASSERT_NE(pointerEvent, nullptr);
5450 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
5451 EXPECT_NO_FATAL_FAILURE(WIN_MGR->IgnoreTouchEvent(pointerEvent));
5452 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
5453 EXPECT_NO_FATAL_FAILURE(WIN_MGR->IgnoreTouchEvent(pointerEvent));
5454 }
5455
5456 /**
5457 * @tc.name: InputWindowsManagerTest_ReissueCancelTouchEvent_001
5458 * @tc.desc: Test ReissueCancelTouchEvent
5459 * @tc.type: FUNC
5460 * @tc.require:
5461 */
5462 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ReissueCancelTouchEvent_001, TestSize.Level1)
5463 {
5464 CALL_TEST_DEBUG;
5465 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5466 ASSERT_NE(pointerEvent, nullptr);
5467 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
5468 EXPECT_NO_FATAL_FAILURE(WIN_MGR->ReissueCancelTouchEvent(pointerEvent));
5469 }
5470
5471 /**
5472 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_002
5473 * @tc.desc: Test UpdateTouchScreenTarget
5474 * @tc.type: FUNC
5475 * @tc.require:
5476 */
5477 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_002, TestSize.Level1)
5478 {
5479 CALL_TEST_DEBUG;
5480 InputWindowsManager inputWindowsMgr;
5481 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5482 ASSERT_NE(pointerEvent, nullptr);
5483 OLD::DisplayInfo displayInfo;
5484 WindowGroupInfo winGroupInfo;
5485 WindowInfo winInfo;
5486 PointerEvent::PointerItem item;
5487 displayInfo.id = 100;
5488 displayInfo.x = 500;
5489 displayInfo.y = 500;
5490 pointerEvent->SetTargetDisplayId(-1);
5491 pointerEvent->SetPointerId(150);
5492 item.SetPointerId(150);
5493 item.SetDisplayXPos(500);
5494 item.SetDisplayYPos(500);
5495 item.SetTargetWindowId(200);
5496 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5497 pointerEvent->AddPointerItem(item);
5498 pointerEvent->SetZOrder(15.5f);
5499 pointerEvent->bitwise_ = 0x00000000;
5500 winInfo.flags = 1;
5501 winGroupInfo.windowsInfo.push_back(winInfo);
5502 winInfo.flags = 0;
5503 winInfo.pixelMap = nullptr;
5504 winInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
5505 winGroupInfo.windowsInfo.push_back(winInfo);
5506 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5507 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
5508 inputWindowsMgr.isOpenAntiMisTakeObserver_ = false;
5509 inputWindowsMgr.antiMistake_.isOpen = true;
5510 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
5511 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
5512 it->second.displaysInfo.push_back(displayInfo);
5513 }
5514 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5515 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5516 }
5517
5518 /**
5519 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_005
5520 * @tc.desc: Test UpdateTouchScreenTarget
5521 * @tc.type: FUNC
5522 * @tc.require:
5523 */
5524 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_005, TestSize.Level1)
5525 {
5526 CALL_TEST_DEBUG;
5527 InputWindowsManager inputWindowsMgr;
5528 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5529 ASSERT_NE(pointerEvent, nullptr);
5530 OLD::DisplayInfo displayInfo;
5531 WindowGroupInfo winGroupInfo;
5532 WindowInfo winInfo;
5533 PointerEvent::PointerItem item;
5534 displayInfo.id = 100;
5535 displayInfo.x = 500;
5536 displayInfo.y = 500;
5537 pointerEvent->SetTargetDisplayId(-1);
5538 pointerEvent->SetPointerId(150);
5539 item.SetPointerId(150);
5540 item.SetDisplayXPos(500);
5541 item.SetDisplayYPos(500);
5542 item.SetTargetWindowId(200);
5543 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5544 pointerEvent->AddPointerItem(item);
5545 pointerEvent->SetZOrder(15.5f);
5546 pointerEvent->bitwise_ = 0x00000000;
5547 winInfo.flags = 0;
5548 winInfo.pixelMap = nullptr;
5549 winInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
5550 winInfo.defaultHotAreas = {
5551 {300, 300, 1000, 1000}
5552 };
5553 winGroupInfo.windowsInfo.push_back(winInfo);
5554 winInfo.defaultHotAreas.clear();
5555 winInfo.defaultHotAreas = {
5556 {300, 300, INT32_MAX, INT32_MAX}
5557 };
5558 winGroupInfo.windowsInfo.push_back(winInfo);
5559 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
5560 inputWindowsMgr.extraData_.appended = true;
5561 inputWindowsMgr.extraData_.sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
5562 inputWindowsMgr.isOpenAntiMisTakeObserver_ = true;
5563 inputWindowsMgr.antiMistake_.isOpen = false;
5564 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
5565 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
5566 it->second.displaysInfo.push_back(displayInfo);
5567 }
5568 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5569 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5570 }
5571
5572 /**
5573 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_008
5574 * @tc.desc: Test UpdateTouchScreenTarget
5575 * @tc.type: FUNC
5576 * @tc.require:
5577 */
5578 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_008, TestSize.Level1)
5579 {
5580 CALL_TEST_DEBUG;
5581 InputWindowsManager inputWindowsMgr;
5582 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5583 ASSERT_NE(pointerEvent, nullptr);
5584 OLD::DisplayInfo displayInfo;
5585 WindowGroupInfo winGroupInfo;
5586 WindowInfo winInfo;
5587 PointerEvent::PointerItem item;
5588 displayInfo.id = 100;
5589 displayInfo.x = 500;
5590 displayInfo.y = 500;
5591 pointerEvent->SetTargetDisplayId(-1);
5592 pointerEvent->SetPointerId(150);
5593 item.SetPointerId(150);
5594 item.SetDisplayXPos(500);
5595 item.SetDisplayYPos(500);
5596 item.SetTargetWindowId(-1);
5597 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5598 pointerEvent->AddPointerItem(item);
5599 pointerEvent->SetZOrder(15.5f);
5600 pointerEvent->bitwise_ = 0x00000000;
5601 winInfo.flags = 0;
5602 winInfo.pixelMap = nullptr;
5603 winInfo.windowInputType = WindowInputType::NORMAL;
5604 winInfo.defaultHotAreas = { {300, 300, 1000, 1000} };
5605 winInfo.id = 100;
5606 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5607 winInfo.transform.clear();
5608 winInfo.transform = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};
5609 auto pointerId = 150;
5610 WindowInfoEX winEx;
5611 winEx.flag = true;
5612 winEx.window = winInfo;
5613 inputWindowsMgr.touchItemDownInfos_.insert(std::make_pair(pointerId, winEx));
5614 auto iter = inputWindowsMgr.touchItemDownInfos_.find(pointerId);
5615 if (iter != inputWindowsMgr.touchItemDownInfos_.end()) {
5616 iter->second.window.transform.clear();
5617 iter->second.window.transform = winInfo.transform;
5618 }
5619 winGroupInfo.windowsInfo.push_back(winInfo);
5620 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5621 inputWindowsMgr.extraData_.appended = false;
5622 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
5623 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
5624 it->second.displaysInfo.push_back(displayInfo);
5625 }
5626 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5627 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5628 }
5629
5630 /**
5631 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_009
5632 * @tc.desc: Test UpdateTouchScreenTarget
5633 * @tc.type: FUNC
5634 * @tc.require:
5635 */
5636 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_009, TestSize.Level1)
5637 {
5638 CALL_TEST_DEBUG;
5639 InputWindowsManager inputWindowsMgr;
5640 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5641 ASSERT_NE(pointerEvent, nullptr);
5642 OLD::DisplayInfo displayInfo;
5643 WindowGroupInfo winGroupInfo;
5644 WindowInfo winInfo;
5645 PointerEvent::PointerItem item;
5646 displayInfo.id = 100;
5647 displayInfo.x = 500;
5648 displayInfo.y = 500;
5649 pointerEvent->SetTargetDisplayId(-1);
5650 pointerEvent->SetPointerId(150);
5651 item.SetPointerId(150);
5652 item.SetDisplayXPos(500);
5653 item.SetDisplayYPos(500);
5654 item.SetTargetWindowId(-1);
5655 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5656 pointerEvent->AddPointerItem(item);
5657 pointerEvent->SetZOrder(15.5f);
5658 pointerEvent->bitwise_ = 0x00000000;
5659 winInfo.flags = 0;
5660 winInfo.pixelMap = nullptr;
5661 winInfo.windowInputType = WindowInputType::TRANSMIT_ALL;
5662 winInfo.defaultHotAreas = {
5663 {300, 300, 1000, 1000}
5664 };
5665 winInfo.id = -1;
5666 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5667 winInfo.transform.clear();
5668 winInfo.transform = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};
5669 auto pointerId = 150;
5670 WindowInfoEX winEx;
5671 winEx.flag = true;
5672 winEx.window = winInfo;
5673 inputWindowsMgr.touchItemDownInfos_.insert(std::make_pair(pointerId, winEx));
5674 auto iter = inputWindowsMgr.touchItemDownInfos_.find(pointerId);
5675 if (iter != inputWindowsMgr.touchItemDownInfos_.end()) {
5676 iter->second.window.transform.clear();
5677 iter->second.window.transform = winInfo.transform;
5678 }
5679 winGroupInfo.windowsInfo.push_back(winInfo);
5680 winInfo.windowInputType = WindowInputType::NORMAL;
5681 winGroupInfo.windowsInfo.push_back(winInfo);
5682 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5683 inputWindowsMgr.extraData_.appended = false;
5684 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
5685 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
5686 it->second.displaysInfo.push_back(displayInfo);
5687 }
5688 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5689 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5690 }
5691
5692 /**
5693 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_010
5694 * @tc.desc: Test UpdateTouchScreenTarget
5695 * @tc.type: FUNC
5696 * @tc.require:
5697 */
5698 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_010, TestSize.Level1)
5699 {
5700 CALL_TEST_DEBUG;
5701 InputWindowsManager inputWindowsMgr;
5702 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5703 ASSERT_NE(pointerEvent, nullptr);
5704 OLD::DisplayInfo displayInfo;
5705 WindowGroupInfo winGroupInfo;
5706 WindowInfo winInfo;
5707 PointerEvent::PointerItem item;
5708 displayInfo.id = 100;
5709 displayInfo.x = 500;
5710 displayInfo.y = 500;
5711 pointerEvent->SetTargetDisplayId(-1);
5712 pointerEvent->SetPointerId(150);
5713 item.SetPointerId(150);
5714 item.SetDisplayXPos(500);
5715 item.SetDisplayYPos(500);
5716 item.SetTargetWindowId(-1);
5717 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5718 pointerEvent->AddPointerItem(item);
5719 pointerEvent->SetZOrder(15.5f);
5720 pointerEvent->bitwise_ = 0x00000000;
5721 winInfo.flags = 0;
5722 winInfo.pixelMap = nullptr;
5723 winInfo.windowInputType = WindowInputType::NORMAL;
5724 winInfo.defaultHotAreas = {{300, 300, 1000, 1000}};
5725 winInfo.id = -1;
5726 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5727 winInfo.transform.clear();
5728 winInfo.transform = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};
5729 auto pointerId = 150;
5730 WindowInfoEX winEx;
5731 winEx.flag = true;
5732 winEx.window = winInfo;
5733 inputWindowsMgr.touchItemDownInfos_.insert(std::make_pair(pointerId, winEx));
5734 auto iter = inputWindowsMgr.touchItemDownInfos_.find(pointerId);
5735 if (iter != inputWindowsMgr.touchItemDownInfos_.end()) {
5736 iter->second.window.transform.clear();
5737 iter->second.window.transform = winInfo.transform;
5738 }
5739 winGroupInfo.windowsInfo.push_back(winInfo);
5740 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5741 inputWindowsMgr.extraData_.appended = false;
5742 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
5743 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
5744 it->second.displaysInfo.push_back(displayInfo);
5745 }
5746 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5747 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5748 }
5749
5750 /**
5751 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_011
5752 * @tc.desc: Test UpdateTouchScreenTarget
5753 * @tc.type: FUNC
5754 * @tc.require:
5755 */
5756 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_011, TestSize.Level1)
5757 {
5758 CALL_TEST_DEBUG;
5759 InputWindowsManager inputWindowsMgr;
5760 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5761 ASSERT_NE(pointerEvent, nullptr);
5762 inputWindowsMgr.lastTouchEventOnBackGesture_ = PointerEvent::Create();
5763 ASSERT_NE(inputWindowsMgr.lastTouchEventOnBackGesture_, nullptr);
5764 OLD::DisplayInfo displayInfo;
5765 WindowGroupInfo winGroupInfo;
5766 WindowInfo winInfo;
5767 PointerEvent::PointerItem item;
5768 displayInfo.id = 100;
5769 displayInfo.x = 500;
5770 displayInfo.y = 500;
5771 pointerEvent->SetTargetDisplayId(-1);
5772 pointerEvent->SetPointerId(150);
5773 item.SetPointerId(150);
5774 item.SetDisplayXPos(500);
5775 item.SetDisplayYPos(500);
5776 item.SetTargetWindowId(200);
5777 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5778 pointerEvent->AddPointerItem(item);
5779 pointerEvent->SetZOrder(15.5f);
5780 pointerEvent->bitwise_ = 0x00000000;
5781 winInfo.flags = 0;
5782 winInfo.pixelMap = nullptr;
5783 winInfo.id = 200;
5784 winInfo.defaultHotAreas = {
5785 {300, 300, 1000, 1000}
5786 };
5787 winInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
5788 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5789 winInfo.transform.clear();
5790 winInfo.transform = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};
5791 auto pointerId = 150;
5792 WindowInfoEX winEx;
5793 winEx.flag = true;
5794 winEx.window = winInfo;
5795 inputWindowsMgr.touchItemDownInfos_.insert(std::make_pair(pointerId, winEx));
5796 auto iter = inputWindowsMgr.touchItemDownInfos_.find(pointerId);
5797 if (iter != inputWindowsMgr.touchItemDownInfos_.end()) {
5798 iter->second.window.transform.clear();
5799 iter->second.window.transform = winInfo.transform;
5800 }
5801 winGroupInfo.windowsInfo.push_back(winInfo);
5802 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
5803 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
5804 inputWindowsMgr.extraData_.appended = false;
5805 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
5806 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
5807 it->second.displaysInfo.push_back(displayInfo);
5808 }
5809 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5810 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5811 }
5812
5813 /**
5814 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_012
5815 * @tc.desc: Test UpdateTouchScreenTarget
5816 * @tc.type: FUNC
5817 * @tc.require:
5818 */
5819 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_012, TestSize.Level1)
5820 {
5821 CALL_TEST_DEBUG;
5822 InputWindowsManager inputWindowsMgr;
5823 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5824 ASSERT_NE(pointerEvent, nullptr);
5825 inputWindowsMgr.lastTouchEventOnBackGesture_ = PointerEvent::Create();
5826 ASSERT_NE(inputWindowsMgr.lastTouchEventOnBackGesture_, nullptr);
5827 OLD::DisplayInfo displayInfo;
5828 WindowGroupInfo winGroupInfo;
5829 WindowInfo winInfo;
5830 PointerEvent::PointerItem item;
5831 displayInfo.id = 100;
5832 displayInfo.x = 500;
5833 displayInfo.y = 500;
5834 pointerEvent->SetTargetDisplayId(-1);
5835 pointerEvent->SetPointerId(150);
5836 item.SetPointerId(150);
5837 item.SetDisplayXPos(500);
5838 item.SetDisplayYPos(500);
5839 item.SetTargetWindowId(200);
5840 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5841 pointerEvent->AddPointerItem(item);
5842 pointerEvent->SetZOrder(15.5f);
5843 pointerEvent->bitwise_ = 0x00000000;
5844 winInfo.flags = 0;
5845 winInfo.pixelMap = nullptr;
5846 winInfo.id = 200;
5847 winInfo.defaultHotAreas = {
5848 {300, 300, 1000, 1000}
5849 };
5850 winInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
5851 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5852 winInfo.transform.clear();
5853 winInfo.transform = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};
5854 auto pointerId = 150;
5855 WindowInfoEX winEx;
5856 winEx.flag = true;
5857 winEx.window = winInfo;
5858 inputWindowsMgr.touchItemDownInfos_.insert(std::make_pair(pointerId, winEx));
5859 auto iter = inputWindowsMgr.touchItemDownInfos_.find(pointerId);
5860 if (iter != inputWindowsMgr.touchItemDownInfos_.end()) {
5861 iter->second.window.transform.clear();
5862 iter->second.window.transform = winInfo.transform;
5863 }
5864 winGroupInfo.windowsInfo.push_back(winInfo);
5865 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5866 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
5867 inputWindowsMgr.extraData_.appended = false;
5868 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
5869 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
5870 it->second.displaysInfo.push_back(displayInfo);
5871 }
5872 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5873 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5874 }
5875
5876 /**
5877 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_013
5878 * @tc.desc: Test UpdateTouchScreenTarget
5879 * @tc.type: FUNC
5880 * @tc.require:
5881 */
5882 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_013, TestSize.Level1)
5883 {
5884 CALL_TEST_DEBUG;
5885 InputWindowsManager inputWindowsMgr;
5886 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5887 ASSERT_NE(pointerEvent, nullptr);
5888 inputWindowsMgr.lastTouchEventOnBackGesture_ = PointerEvent::Create();
5889 ASSERT_NE(inputWindowsMgr.lastTouchEventOnBackGesture_, nullptr);
5890 OLD::DisplayInfo displayInfo;
5891 WindowGroupInfo winGroupInfo;
5892 WindowInfo winInfo;
5893 PointerEvent::PointerItem item;
5894 displayInfo.id = 100;
5895 displayInfo.x = 500;
5896 displayInfo.y = 500;
5897 pointerEvent->SetTargetDisplayId(-1);
5898 pointerEvent->SetPointerId(150);
5899 item.SetPointerId(150);
5900 item.SetDisplayXPos(500);
5901 item.SetDisplayYPos(500);
5902 item.SetTargetWindowId(200);
5903 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5904 pointerEvent->AddPointerItem(item);
5905 pointerEvent->SetZOrder(15.5f);
5906 pointerEvent->bitwise_ = 0x00000000;
5907 winInfo.flags = 0;
5908 winInfo.pixelMap = nullptr;
5909 winInfo.id = 200;
5910 winInfo.defaultHotAreas = {
5911 {300, 300, 1000, 1000}
5912 };
5913 winInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
5914 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5915 winInfo.transform.clear();
5916 winInfo.transform = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};
5917 auto pointerId = 150;
5918 WindowInfoEX winEx;
5919 winEx.flag = true;
5920 winEx.window = winInfo;
5921 inputWindowsMgr.touchItemDownInfos_.insert(std::make_pair(pointerId, winEx));
5922 auto iter = inputWindowsMgr.touchItemDownInfos_.find(pointerId);
5923 if (iter != inputWindowsMgr.touchItemDownInfos_.end()) {
5924 iter->second.window.transform.clear();
5925 iter->second.window.transform = winInfo.transform;
5926 }
5927 winGroupInfo.windowsInfo.push_back(winInfo);
5928 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5929 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
5930 inputWindowsMgr.extraData_.appended = false;
5931 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
5932 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
5933 it->second.displaysInfo.push_back(displayInfo);
5934 }
5935 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5936 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
5937 }
5938
5939 /**
5940 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_014
5941 * @tc.desc: Test UpdateTouchScreenTarget
5942 * @tc.type: FUNC
5943 * @tc.require:
5944 */
5945 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_014, TestSize.Level1)
5946 {
5947 CALL_TEST_DEBUG;
5948 InputWindowsManager inputWindowsMgr;
5949 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
5950 ASSERT_NE(pointerEvent, nullptr);
5951 inputWindowsMgr.lastTouchEventOnBackGesture_ = PointerEvent::Create();
5952 ASSERT_NE(inputWindowsMgr.lastTouchEventOnBackGesture_, nullptr);
5953 OLD::DisplayInfo displayInfo;
5954 WindowGroupInfo winGroupInfo;
5955 WindowInfo winInfo;
5956 PointerEvent::PointerItem item;
5957 displayInfo.id = 100;
5958 displayInfo.x = 500;
5959 displayInfo.y = 500;
5960 pointerEvent->SetTargetDisplayId(-1);
5961 pointerEvent->SetPointerId(150);
5962 item.SetPointerId(150);
5963 item.SetDisplayXPos(500);
5964 item.SetDisplayYPos(500);
5965 item.SetTargetWindowId(200);
5966 item.SetToolType(PointerEvent::TOOL_TYPE_PEN);
5967 pointerEvent->AddPointerItem(item);
5968 pointerEvent->SetZOrder(15.5f);
5969 pointerEvent->bitwise_ = 0x00000000;
5970 winInfo.flags = 0;
5971 winInfo.pixelMap = nullptr;
5972 winInfo.id = 200;
5973 winInfo.defaultHotAreas = {
5974 {300, 300, 1000, 1000}
5975 };
5976 winInfo.windowInputType = WindowInputType::NORMAL;
5977 winInfo.uiExtentionWindowInfo.push_back(winInfo);
5978 winInfo.transform.clear();
5979 winInfo.transform = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};
5980 auto pointerId = 150;
5981 WindowInfoEX winEx;
5982 winEx.flag = true;
5983 winEx.window = winInfo;
5984 inputWindowsMgr.touchItemDownInfos_.insert(std::make_pair(pointerId, winEx));
5985 auto iter = inputWindowsMgr.touchItemDownInfos_.find(pointerId);
5986 if (iter != inputWindowsMgr.touchItemDownInfos_.end()) {
5987 iter->second.window.transform.clear();
5988 iter->second.window.transform = winInfo.transform;
5989 }
5990 winGroupInfo.windowsInfo.push_back(winInfo);
5991 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
5992 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
5993 inputWindowsMgr.extraData_.appended = false;
5994 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
5995 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
5996 it->second.displaysInfo.push_back(displayInfo);
5997 }
5998 inputWindowsMgr.windowsPerDisplay_.insert(std::make_pair(100, winGroupInfo));
5999 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
6000 }
6001
6002 /**
6003 * @tc.name: InputWindowsManagerTest_UpdateTouchScreenTarget_015
6004 * @tc.desc: This test verifies the functionality of updating the touch screen target
6005 * @tc.type: FUNC
6006 * @tc.require:
6007 */
6008 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTouchScreenTarget_015, TestSize.Level1)
6009 {
6010 CALL_TEST_DEBUG;
6011 InputWindowsManager inputWindowsMgr;
6012 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
6013 ASSERT_NE(pointerEvent, nullptr);
6014 PointerEvent::PointerItem item;
6015 pointerEvent->AddPointerItem(item);
6016 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
6017
6018 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
6019
6020 pointerEvent->AddFlag(InputEvent::EVENT_FLAG_SIMULATE);
6021 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
6022
6023 pointerEvent->RemovePointerItem(item.GetPointerId());
6024 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTouchScreenTarget(pointerEvent));
6025 }
6026
6027 /**
6028 * @tc.name: InputWindowsManagerTest_SendCancelEventWhenLock_001
6029 * @tc.desc: Test the funcation SendCancelEventWhenLock
6030 * @tc.type: FUNC
6031 * @tc.require:
6032 */
6033 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SendCancelEventWhenLock_001, TestSize.Level1)
6034 {
6035 CALL_TEST_DEBUG;
6036 InputWindowsManager inputWindowsMgr;
6037 inputWindowsMgr.lastTouchEventOnBackGesture_ = PointerEvent::Create();
6038 ASSERT_NE(inputWindowsMgr.lastTouchEventOnBackGesture_, nullptr);
6039 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
6040 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_UP);
6041 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
6042 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
6043 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
6044 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
6045 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
6046 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
6047 ASSERT_NE(pointerEvent, nullptr);
6048 WindowInfoEX windowInfoEX;
6049 windowInfoEX.flag = true;
6050 pointerEvent->SetPointerId(1);
6051 inputWindowsMgr.touchItemDownInfos_.insert(std::make_pair(pointerEvent->GetPointerId(), windowInfoEX));
6052 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerId(2);
6053 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
6054 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerId(1);
6055 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
6056 }
6057
6058 /**
6059 * @tc.name: InputWindowsManagerTest_DrawTouchGraphic_001
6060 * @tc.desc: Test the funcation DrawTouchGraphic
6061 * @tc.type: FUNC
6062 * @tc.require:
6063 */
6064 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DrawTouchGraphic_001, TestSize.Level1)
6065 {
6066 CALL_TEST_DEBUG;
6067 InputWindowsManager inputWindowsMgr;
6068 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
6069 ASSERT_NE(pointerEvent, nullptr);
6070 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.DrawTouchGraphic(pointerEvent));
6071 }
6072
6073 /**
6074 * @tc.name: InputWindowsManagerTest_IsMouseDrawing_001
6075 * @tc.desc: Test the funcation IsMouseDrawing
6076 * @tc.type: FUNC
6077 * @tc.require:
6078 */
6079 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsMouseDrawing_001, TestSize.Level1)
6080 {
6081 CALL_TEST_DEBUG;
6082 InputWindowsManager inputWindowsMgr;
6083 int32_t currentAction = 10;
6084 bool ret = inputWindowsMgr.IsMouseDrawing(currentAction);
6085 ASSERT_FALSE(ret);
6086 currentAction = 11;
6087 ret = inputWindowsMgr.IsMouseDrawing(currentAction);
6088 ASSERT_FALSE(ret);
6089 currentAction = 15;
6090 ret = inputWindowsMgr.IsMouseDrawing(currentAction);
6091 ASSERT_FALSE(ret);
6092 currentAction = 16;
6093 ret = inputWindowsMgr.IsMouseDrawing(currentAction);
6094 ASSERT_FALSE(ret);
6095 currentAction = 1;
6096 ret = inputWindowsMgr.IsMouseDrawing(currentAction);
6097 ASSERT_TRUE(ret);
6098 }
6099
6100 /**
6101 * @tc.name: InputWindowsManagerTest_GetTargetWindowIds_002
6102 * @tc.desc: Test the funcation GetTargetWindowIds
6103 * @tc.type: FUNC
6104 * @tc.require:
6105 */
6106 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetTargetWindowIds_002, TestSize.Level1)
6107 {
6108 CALL_TEST_DEBUG;
6109 InputWindowsManager inputWindowsMgr;
6110 int32_t pointerItemId = 1;
6111 int32_t sourceType = 1;
6112 std::vector<int32_t> windowIds {1, 2, 3};
6113 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
6114 inputWindowsMgr.targetMouseWinIds_.insert(std::make_pair(1, windowIds));
6115 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
6116 sourceType = 2;
6117 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
6118 pointerItemId = 5;
6119 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
6120 inputWindowsMgr.targetMouseWinIds_.insert(std::make_pair(5, windowIds));
6121 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
6122 }
6123
6124 /**
6125 * @tc.name: InputWindowsManagerTest_UpdateTarget
6126 * @tc.desc: Test UpdateTouchScreenTarget
6127 * @tc.type: FUNC
6128 * @tc.require:
6129 */
6130 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTarget, TestSize.Level1)
6131 {
6132 CALL_TEST_DEBUG;
6133 InputWindowsManager inputWindowsMgr;
6134 std::shared_ptr<KeyEvent> keyEvent = nullptr;
6135 inputWindowsMgr.isParseConfig_ = true;
6136 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateTarget(keyEvent));
6137 }
6138
6139 /**
6140 * @tc.name: InputWindowsManagerTest_HandleKeyEventWindowId
6141 * @tc.desc: Test HandleKeyEventWindowId
6142 * @tc.type: FUNC
6143 * @tc.require:
6144 */
6145 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandleKeyEventWindowId, TestSize.Level1)
6146 {
6147 CALL_TEST_DEBUG;
6148 InputWindowsManager inputWindowsMgr;
6149 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
6150 ASSERT_NE(keyEvent, nullptr);
6151 WindowInfo winInfo;
6152 keyEvent->SetTargetDisplayId(-1);
6153 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
6154 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
6155 it->second.focusWindowId = 50;
6156 }
6157 winInfo.id = 50;
6158 winInfo.agentWindowId = 100;
6159 winInfo.privacyMode = SecureFlag::PRIVACY_MODE;
6160 it->second.windowsInfo.push_back(winInfo);
6161 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.HandleKeyEventWindowId(keyEvent));
6162
6163 it->second.windowsInfo[0].privacyMode = SecureFlag::DEFAULT_MODE;
6164 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.HandleKeyEventWindowId(keyEvent));
6165
6166 it->second.focusWindowId = 80;
6167 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.HandleKeyEventWindowId(keyEvent));
6168 }
6169
6170 /**
6171 * @tc.name: InputWindowsManagerTest_GetDisplayId
6172 * @tc.desc: Test GetDisplayId
6173 * @tc.type: FUNC
6174 * @tc.require:
6175 */
6176 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetDisplayId, TestSize.Level1)
6177 {
6178 CALL_TEST_DEBUG;
6179 InputWindowsManager inputWindowsMgr;
6180 std::shared_ptr<InputEvent> inputEvent = InputEvent::Create();
6181 ASSERT_NE(inputEvent, nullptr);
6182 OLD::DisplayInfo displayInfo;
6183 displayInfo.id = 100;
6184 inputEvent->SetTargetDisplayId(-1);
6185 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
6186 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
6187 it->second.displaysInfo.push_back(displayInfo);
6188 }
6189 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetDisplayId(inputEvent));
6190 }
6191
6192 /**
6193 * @tc.name: InputWindowsManagerTest_GetClientFd_004
6194 * @tc.desc: Test GetClientFd
6195 * @tc.type: FUNC
6196 * @tc.require:
6197 */
6198 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetClientFd_004, TestSize.Level1)
6199 {
6200 CALL_TEST_DEBUG;
6201 InputWindowsManager inputWindowsMgr;
6202 int32_t windowId = 10;
6203 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
6204 ASSERT_NE(pointerEvent, nullptr);
6205 WindowInfo winInfo;
6206 UDSServer udsServer;
6207 inputWindowsMgr.udsServer_ = &udsServer;
6208 pointerEvent->SetTargetDisplayId(-1);
6209 winInfo.id = 20;
6210 winInfo.uiExtentionWindowInfo.push_back(winInfo);
6211 winInfo.id = 10;
6212 winInfo.uiExtentionWindowInfo.push_back(winInfo);
6213 winInfo.pid = 50;
6214 winInfo.flags = 15;
6215 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
6216 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
6217 it->second.windowsInfo.push_back(winInfo);
6218 }
6219 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetClientFd(pointerEvent, windowId));
6220 windowId = 100;
6221 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetClientFd(pointerEvent, windowId));
6222 }
6223
6224 /**
6225 * @tc.name: InputWindowsManagerTest_GetPidAndUpdateTarget
6226 * @tc.desc: Test GetPidAndUpdateTarget
6227 * @tc.type: FUNC
6228 * @tc.require:
6229 */
6230 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPidAndUpdateTarget, TestSize.Level1)
6231 {
6232 CALL_TEST_DEBUG;
6233 InputWindowsManager inputWindowsMgr;
6234 std::shared_ptr<KeyEvent> keyEvent = nullptr;
6235 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetPidAndUpdateTarget(keyEvent));
6236
6237 keyEvent = KeyEvent::Create();
6238 ASSERT_NE(keyEvent, nullptr);
6239 WindowInfo winInfo;
6240 winInfo.id = 10;
6241 winInfo.privacyUIFlag = true;
6242 winInfo.uiExtentionWindowInfo.push_back(winInfo);
6243 keyEvent->SetTargetDisplayId(-1);
6244 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
6245 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
6246 it->second.focusWindowId = 10;
6247 it->second.windowsInfo.push_back(winInfo);
6248 }
6249 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetPidAndUpdateTarget(keyEvent));
6250
6251 it->second.windowsInfo[0].uiExtentionWindowInfo[0].privacyUIFlag = false;
6252 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetPidAndUpdateTarget(keyEvent));
6253 }
6254
6255 /**
6256 * @tc.name: InputWindowsManagerTest_UpdateDisplayInfoExtIfNeed
6257 * @tc.desc: Test UpdateDisplayInfoExtIfNeed
6258 * @tc.type: FUNC
6259 * @tc.require:
6260 */
6261 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayInfoExtIfNeed, TestSize.Level1)
6262 {
6263 CALL_TEST_DEBUG;
6264 InputWindowsManager inputWindowsMgr;
6265 OLD::DisplayGroupInfo displayGroupInfo;
6266 bool needUpdateDisplayExt = true;
6267 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.UpdateDisplayInfoExtIfNeed(displayGroupInfo, needUpdateDisplayExt));
6268 }
6269
6270 /**
6271 * @tc.name: InputWindowsManagerTest_GetPointerStyle_002
6272 * @tc.desc: Test GetPointerStyle
6273 * @tc.type: FUNC
6274 * @tc.require:
6275 */
6276 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPointerStyle_002, TestSize.Level1)
6277 {
6278 CALL_TEST_DEBUG;
6279 InputWindowsManager inputWindowsMgr;
6280 int32_t pid = 100;
6281 int32_t windowId = 200;
6282 PointerStyle pointerStyle;
6283 bool isUiExtension = false;
6284 std::map<int32_t, PointerStyle> pointerStyleMap;
6285 pointerStyleMap.insert(std::make_pair(windowId, pointerStyle));
6286 inputWindowsMgr.pointerStyle_.insert(std::make_pair(pid, pointerStyleMap));
6287 EXPECT_EQ(inputWindowsMgr.GetPointerStyle(pid, windowId, pointerStyle, isUiExtension), RET_OK);
6288 }
6289
6290 /**
6291 * @tc.name: InputWindowsManagerTest_SelectPointerChangeArea
6292 * @tc.desc: Test SelectPointerChangeArea
6293 * @tc.type: FUNC
6294 * @tc.require:
6295 */
6296 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectPointerChangeArea, TestSize.Level1)
6297 {
6298 CALL_TEST_DEBUG;
6299 InputWindowsManager inputWindowsMgr;
6300 WindowInfo windowInfo;
6301 PointerStyle pointerStyle;
6302 int32_t logicalX = 300;
6303 int32_t logicalY = 300;
6304 std::vector<Rect> areas;
6305 Rect rect {
6306 .x = 100,
6307 .y = 100,
6308 .width = 1000,
6309 .height = 1000,
6310 };
6311 areas.push_back(rect);
6312 windowInfo.id = 100;
6313 inputWindowsMgr.windowsHotAreas_.insert(std::make_pair(100, areas));
6314 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SelectPointerChangeArea(windowInfo, pointerStyle, logicalX, logicalY));
6315 }
6316
6317 /**
6318 * @tc.name: InputWindowsManagerTest_DispatchUIExtentionPointerEvent
6319 * @tc.desc: Test DispatchUIExtentionPointerEvent
6320 * @tc.type: FUNC
6321 * @tc.require:
6322 */
6323 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DispatchUIExtentionPointerEvent, TestSize.Level1)
6324 {
6325 CALL_TEST_DEBUG;
6326 InputWindowsManager inputWindowsMgr;
6327 int32_t logicalX = 300;
6328 int32_t logicalY = 300;
6329 WindowInfo winInfo;
6330 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
6331 ASSERT_NE(pointerEvent, nullptr);
6332 pointerEvent->SetTargetDisplayId(-1);
6333 pointerEvent->SetTargetWindowId(100);
6334 winInfo.id = 10;
6335 winInfo.uiExtentionWindowInfo.push_back(winInfo);
6336 winInfo.id = 100;
6337 winInfo.agentWindowId = 200;
6338 winInfo.uiExtentionWindowInfo.push_back(winInfo);
6339 winInfo.id = 300;
6340 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
6341 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
6342 it->second.windowsInfo.push_back(winInfo);
6343 }
6344 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.DispatchUIExtentionPointerEvent(logicalX, logicalY, pointerEvent));
6345 }
6346
6347 /**
6348 * @tc.name: InputWindowsManagerTest_PullEnterLeaveEvent
6349 * @tc.desc: Test PullEnterLeaveEvent
6350 * @tc.type: FUNC
6351 * @tc.require:
6352 */
6353 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PullEnterLeaveEvent, TestSize.Level1)
6354 {
6355 CALL_TEST_DEBUG;
6356 InputWindowsManager inputWindowsMgr;
6357 int32_t logicalX = 100;
6358 int32_t logicalY = 100;
6359 WindowInfo touchWindow;
6360 UDSServer udsServer;
6361 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
6362 ASSERT_NE(pointerEvent, nullptr);
6363 inputWindowsMgr.lastTouchEvent_ = PointerEvent::Create();
6364 ASSERT_NE(inputWindowsMgr.lastTouchEvent_, nullptr);
6365 PointerEvent::PointerItem lastPointerItem;
6366 touchWindow.id = 200;
6367 inputWindowsMgr.udsServer_ = &udsServer;
6368 inputWindowsMgr.lastTouchWindowInfo_.id = 100;
6369 inputWindowsMgr.lastTouchEvent_->SetPointerId(10);
6370 lastPointerItem.SetPointerId(10);
6371 inputWindowsMgr.lastTouchEvent_->AddPointerItem(lastPointerItem);
6372 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.PullEnterLeaveEvent(logicalX, logicalY, pointerEvent, &touchWindow));
6373 }
6374
6375 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_CROWN)
6376 /**
6377 * @tc.name: InputWindowsManagerTest_UpdateCrownTarget
6378 * @tc.desc: Test UpdateCrownTarget
6379 * @tc.type: FUNC
6380 * @tc.require:
6381 */
6382 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateCrownTarget, TestSize.Level1)
6383 {
6384 CALL_TEST_DEBUG;
6385 InputWindowsManager inputWindowsMgr;
6386 WindowInfo winInfo;
6387 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
6388 ASSERT_NE(pointerEvent, nullptr);
6389 pointerEvent->SetTargetDisplayId(-1);
6390 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
6391 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
6392 it->second.focusWindowId = 100;
6393 }
6394 winInfo.id = 200;
6395 it->second.windowsInfo.push_back(winInfo);
6396 winInfo.id = 100;
6397 winInfo.agentWindowId = 500;
6398 winInfo.privacyMode = SecureFlag::DEFAULT_MODE;
6399 it->second.windowsInfo.push_back(winInfo);
6400 EXPECT_EQ(inputWindowsMgr.UpdateCrownTarget(pointerEvent), RET_OK);
6401 }
6402 #endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_CROWN
6403
6404 /**
6405 * @tc.name: InputWindowsManagerTest_DrawTouchGraphic
6406 * @tc.desc: Test DrawTouchGraphic
6407 * @tc.type: FUNC
6408 * @tc.require:
6409 */
6410 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DrawTouchGraphic, TestSize.Level1)
6411 {
6412 CALL_TEST_DEBUG;
6413 InputWindowsManager inputWindowsMgr;
6414 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
6415 ASSERT_NE(pointerEvent, nullptr);
6416 pointerEvent->SetTargetDisplayId(100);
6417 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.DrawTouchGraphic(pointerEvent));
6418 }
6419
6420 /**
6421 * @tc.name: InputWindowsManagerTest_ReverseRotateScreen
6422 * @tc.desc: Test ReverseRotateScreen
6423 * @tc.type: FUNC
6424 * @tc.require:
6425 */
6426 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ReverseRotateScreen, TestSize.Level1)
6427 {
6428 CALL_TEST_DEBUG;
6429 InputWindowsManager inputWindowsMgr;
6430 OLD::DisplayInfo info;
6431 double x = 100.5;
6432 double y = 100.5;
6433 Coordinate2D cursorPos;
6434 info.direction = static_cast<Direction>(10);
6435 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.ReverseRotateScreen(info, x, y, cursorPos));
6436 }
6437
6438 /**
6439 * @tc.name: InputWindowsManagerTest_GetTargetWindowIds_003
6440 * @tc.desc: Test GetTargetWindowIds
6441 * @tc.type: FUNC
6442 * @tc.require:
6443 */
6444 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetTargetWindowIds_003, TestSize.Level1)
6445 {
6446 CALL_TEST_DEBUG;
6447 InputWindowsManager inputWindowsMgr;
6448 int32_t pointerItemId = 100;
6449 int32_t sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
6450 std::vector<int32_t> windowIds;
6451 inputWindowsMgr.targetMouseWinIds_.insert(std::make_pair(10, windowIds));
6452 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
6453 inputWindowsMgr.targetMouseWinIds_.insert(std::make_pair(pointerItemId, windowIds));
6454 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
6455 sourceType = PointerEvent::PointerEvent::SOURCE_TYPE_UNKNOWN;
6456 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.GetTargetWindowIds(pointerItemId, sourceType, windowIds));
6457 }
6458
6459 /**
6460 * @tc.name: InputWindowsManagerTest_SetPrivacyModeFlag
6461 * @tc.desc: Test SetPrivacyModeFlag
6462 * @tc.type: FUNC
6463 * @tc.require:
6464 */
6465 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetPrivacyModeFlag, TestSize.Level1)
6466 {
6467 CALL_TEST_DEBUG;
6468 InputWindowsManager inputWindowsMgr;
6469 SecureFlag privacyMode = SecureFlag::PRIVACY_MODE;
6470 std::shared_ptr<InputEvent> event = InputEvent::Create();
6471 ASSERT_NE(event, nullptr);
6472 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SetPrivacyModeFlag(privacyMode, event));
6473 }
6474
6475 /**
6476 * @tc.name: InputWindowsManagerTest_ReverseXY_001
6477 * @tc.desc: Test ReverseXY
6478 * @tc.type: FUNC
6479 * @tc.require:
6480 */
6481 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ReverseXY_001, TestSize.Level1)
6482 {
6483 CALL_TEST_DEBUG;
6484 InputWindowsManager inputWindowsMgr;
6485 int32_t x = 100;
6486 int32_t y = 100;
6487 OLD::DisplayInfo displayInfo;
6488 displayInfo.direction = static_cast<Direction>(-1);
6489 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
6490 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
6491 it->second.displaysInfo.push_back(displayInfo);
6492 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.ReverseXY(x, y));
6493 }
6494 it->second.displaysInfo[0].direction = static_cast<Direction>(10);
6495 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.ReverseXY(x, y));
6496 }
6497
6498 /**
6499 * @tc.name: InputWindowsManagerTest_SendCancelEventWhenLock_002
6500 * @tc.desc: Test SendCancelEventWhenLock
6501 * @tc.type: FUNC
6502 * @tc.require:
6503 */
6504 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SendCancelEventWhenLock_002, TestSize.Level1)
6505 {
6506 CALL_TEST_DEBUG;
6507 InputWindowsManager inputWindowsMgr;
6508 inputWindowsMgr.lastTouchEventOnBackGesture_ = PointerEvent::Create();
6509 ASSERT_NE(inputWindowsMgr.lastTouchEventOnBackGesture_, nullptr);
6510 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
6511 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
6512 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
6513 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
6514 inputWindowsMgr.lastTouchEventOnBackGesture_->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
6515 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SendCancelEventWhenLock());
6516 }
6517
6518 /**
6519 * @tc.name: InputWindowsManagerTest_DispatchPointerCancel
6520 * @tc.desc: Test DispatchPointerCancel
6521 * @tc.type: FUNC
6522 * @tc.require:
6523 */
6524 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DispatchPointerCancel, TestSize.Level1)
6525 {
6526 CALL_TEST_DEBUG;
6527 InputWindowsManager inputWindowsMgr;
6528 int32_t displayId = -1;
6529 WindowInfo winInfo;
6530 inputWindowsMgr.mouseDownInfo_.id = -1;
6531 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.DispatchPointerCancel(displayId));
6532 inputWindowsMgr.mouseDownInfo_.id = 10;
6533 inputWindowsMgr.extraData_.appended = true;
6534 inputWindowsMgr.extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
6535 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.DispatchPointerCancel(displayId));
6536 inputWindowsMgr.lastPointerEvent_ = nullptr;
6537 inputWindowsMgr.extraData_.appended = false;
6538 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.DispatchPointerCancel(displayId));
6539 inputWindowsMgr.extraData_.appended = true;
6540 inputWindowsMgr.extraData_.sourceType = PointerEvent::SOURCE_TYPE_UNKNOWN;
6541 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.DispatchPointerCancel(displayId));
6542 inputWindowsMgr.lastPointerEvent_ = PointerEvent::Create();
6543 ASSERT_NE(inputWindowsMgr.lastPointerEvent_, nullptr);
6544 winInfo.id = 10;
6545 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
6546 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
6547 it->second.windowsInfo.push_back(winInfo);
6548 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.DispatchPointerCancel(displayId));
6549 }
6550 it->second.windowsInfo.clear();
6551 winInfo.id = 100;
6552 it->second.windowsInfo.push_back(winInfo);
6553 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.DispatchPointerCancel(displayId));
6554 }
6555
6556 /**
6557 * @tc.name: InputWindowsManagerTest_GetPidByWindowId
6558 * @tc.desc: Test GetPidByWindowId
6559 * @tc.type: FUNC
6560 * @tc.require:
6561 */
6562 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPidByWindowId, TestSize.Level1)
6563 {
6564 CALL_TEST_DEBUG;
6565 InputWindowsManager inputWindowsMgr;
6566 int32_t id = 100;
6567 WindowInfo winInfo;
6568 winInfo.id = 100;
6569 winInfo.pid = 150;
6570 auto it = inputWindowsMgr.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
6571 if (it != inputWindowsMgr.displayGroupInfoMap_.end()) {
6572 it->second.windowsInfo.push_back(winInfo);
6573 }
6574 EXPECT_EQ(inputWindowsMgr.GetPidByWindowId(id), winInfo.pid);
6575 id = 300;
6576 EXPECT_EQ(inputWindowsMgr.GetPidByWindowId(id), RET_ERR);
6577 }
6578
6579 /**
6580 * @tc.name: InputWindowsManagerTest_SetPixelMapData
6581 * @tc.desc: Test SetPixelMapData
6582 * @tc.type: FUNC
6583 * @tc.require:
6584 */
6585 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetPixelMapData, TestSize.Level1)
6586 {
6587 CALL_TEST_DEBUG;
6588 InputWindowsManager inputWindowsMgr;
6589 int32_t infoId = -1;
6590 void *pixelMap = nullptr;
6591 EXPECT_EQ(inputWindowsMgr.SetPixelMapData(infoId, pixelMap), ERR_INVALID_VALUE);
6592 infoId = 100;
6593 EXPECT_EQ(inputWindowsMgr.SetPixelMapData(infoId, pixelMap), ERR_INVALID_VALUE);
6594 }
6595
6596 /**
6597 * @tc.name: InputWindowsManagerTest_UpdateDisplayInfo_002
6598 * @tc.desc: Test updating window & display information for each display in extended screen mode
6599 * @tc.type: FUNC
6600 * @tc.require:
6601 */
6602 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayInfo_002, TestSize.Level1)
6603 {
6604 CALL_TEST_DEBUG;
6605 OLD::DisplayGroupInfo displayGroupInfo;
6606 displayGroupInfo.focusWindowId = 1;
6607
6608 WindowInfo windowInfo;
6609 windowInfo.id = 1;
6610 windowInfo.pid = 1;
6611 windowInfo.uid = 1;
6612 windowInfo.area = {1, 1, 1, 1};
6613 windowInfo.defaultHotAreas = {windowInfo.area};
6614 windowInfo.pointerHotAreas = {windowInfo.area};
6615 windowInfo.agentWindowId = 1;
6616 windowInfo.flags = 1;
6617 windowInfo.transform = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};
6618 windowInfo.pointerChangeAreas = {1, 2, 1, 2, 1, 2, 1, 2, 1};
6619 displayGroupInfo.windowsInfo.push_back(windowInfo);
6620
6621 OLD::DisplayInfo displayInfo1;
6622 displayInfo1.id = 1;
6623 displayInfo1.x = 1;
6624 displayInfo1.y = 1;
6625 displayInfo1.width = 2;
6626 displayInfo1.height = 2;
6627 displayInfo1.dpi = 240;
6628 displayInfo1.name = "pp";
6629 displayInfo1.uniq = "pp";
6630 displayInfo1.direction = DIRECTION0;
6631 displayGroupInfo.displaysInfo.push_back(displayInfo1);
6632
6633 OLD::DisplayInfo displayInfo2;
6634 displayInfo2.id = 2;
6635 displayInfo2.x = 1;
6636 displayInfo2.y = 1;
6637 displayInfo2.width = 2;
6638 displayInfo2.height = 2;
6639 displayInfo2.dpi = 240;
6640 displayInfo2.name = "pp";
6641 displayInfo2.uniq = "pp";
6642 displayInfo2.direction = DIRECTION0;
6643 displayGroupInfo.displaysInfo.push_back(displayInfo2);
6644
6645 ASSERT_NO_FATAL_FAILURE(WIN_MGR->UpdateDisplayInfo(displayGroupInfo));
6646
6647 displayGroupInfo.displaysInfo.pop_back();
6648 ASSERT_NO_FATAL_FAILURE(WIN_MGR->UpdateDisplayInfo(displayGroupInfo));
6649 }
6650
6651 /**
6652 * @tc.name: InputWindowsManagerTest_UpdateDisplayInfo_003
6653 * @tc.desc: Test updating window & display information for each display in extended screen mode
6654 * @tc.type: FUNC
6655 * @tc.require:
6656 */
6657 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayInfo_003, TestSize.Level1)
6658 {
6659 CALL_TEST_DEBUG;
6660 OLD::DisplayGroupInfo displayGroupInfo;
6661 displayGroupInfo.focusWindowId = 1;
6662
6663 OLD::DisplayInfo displayInfo1;
6664 displayInfo1.id = 1;
6665 displayInfo1.x = 1;
6666 displayInfo1.y = 1;
6667 displayInfo1.width = 2;
6668 displayInfo1.height = 2;
6669 displayInfo1.dpi = 240;
6670 displayInfo1.name = "pp";
6671 displayInfo1.uniq = "pp";
6672 displayInfo1.direction = DIRECTION0;
6673 displayGroupInfo.displaysInfo.push_back(displayInfo1);
6674
6675 OLD::DisplayInfo displayInfo2;
6676 displayInfo2.id = 2;
6677 displayInfo2.x = 1;
6678 displayInfo2.y = 1;
6679 displayInfo2.width = 2;
6680 displayInfo2.height = 2;
6681 displayInfo2.dpi = 240;
6682 displayInfo2.name = "pp";
6683 displayInfo2.uniq = "pp";
6684 displayInfo2.direction = DIRECTION0;
6685 displayGroupInfo.displaysInfo.push_back(displayInfo2);
6686
6687 ASSERT_NO_FATAL_FAILURE(WIN_MGR->UpdateDisplayInfo(displayGroupInfo));
6688 }
6689
6690 /**
6691 * @tc.name: InputWindowsManagerTest_UpdateDisplayInfo_004
6692 * @tc.desc: Test updating window & display information for each display
6693 * @tc.type: FUNC
6694 * @tc.require:
6695 */
6696 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayInfo_004, TestSize.Level1)
6697 {
6698 CALL_TEST_DEBUG;
6699 OLD::DisplayGroupInfo displayGroupInfo;
6700 displayGroupInfo.focusWindowId = 1;
6701
6702 WindowInfo windowInfo;
6703 windowInfo.id = 1;
6704 windowInfo.pid = 1;
6705 windowInfo.uid = 1;
6706 windowInfo.area = {1, 1, 1, 1};
6707 windowInfo.defaultHotAreas = {windowInfo.area};
6708 windowInfo.pointerHotAreas = {windowInfo.area};
6709 windowInfo.agentWindowId = 1;
6710 windowInfo.flags = 1;
6711 windowInfo.transform = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};
6712 windowInfo.pointerChangeAreas = {1, 2, 1, 2, 1, 2, 1, 2, 1};
6713 displayGroupInfo.windowsInfo.push_back(windowInfo);
6714
6715 OLD::DisplayInfo displayInfo1;
6716 displayInfo1.id = 1;
6717 displayInfo1.x = 1;
6718 displayInfo1.y = 1;
6719 displayInfo1.width = 2;
6720 displayInfo1.height = 2;
6721 displayInfo1.dpi = 240;
6722 displayInfo1.name = "pp";
6723 displayInfo1.direction = DIRECTION0;
6724 displayGroupInfo.displaysInfo.push_back(displayInfo1);
6725
6726 OLD::DisplayInfo displayInfo2;
6727 displayInfo2.id = 2;
6728 displayInfo2.x = 1;
6729 displayInfo2.y = 1;
6730 displayInfo2.width = 2;
6731 displayInfo2.height = 2;
6732 displayInfo2.dpi = 240;
6733 displayInfo2.name = "pp";
6734 displayInfo2.uniq = "pp";
6735 displayInfo2.direction = DIRECTION0;
6736 displayGroupInfo.displaysInfo.push_back(displayInfo2);
6737
6738 ASSERT_NO_FATAL_FAILURE(WIN_MGR->UpdateDisplayInfo(displayGroupInfo));
6739
6740 displayGroupInfo.displaysInfo.erase(displayGroupInfo.displaysInfo.begin());
6741 ASSERT_NO_FATAL_FAILURE(WIN_MGR->UpdateDisplayInfo(displayGroupInfo));
6742 }
6743
6744 /**
6745 * @tc.name: InputWindowsManagerTest_UpdateDisplayInfo_005
6746 * @tc.desc: Test updating window & display information for each display
6747 * @tc.type: FUNC
6748 * @tc.require:
6749 */
6750 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayInfo_005, TestSize.Level1)
6751 {
6752 CALL_TEST_DEBUG;
6753 OLD::DisplayGroupInfo displayGroupInfo;
6754 displayGroupInfo.focusWindowId = 1;
6755
6756 ASSERT_NO_FATAL_FAILURE(WIN_MGR->UpdateDisplayInfo(displayGroupInfo));
6757 }
6758
6759 /**
6760 * @tc.name: InputWindowsManagerTest_UpdateKeyEventDisplayId_001
6761 * @tc.desc: Test the funcation UpdateKeyEventDisplayId
6762 * @tc.type: FUNC
6763 * @tc.require:
6764 */
6765 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateKeyEventDisplayId_001, TestSize.Level1)
6766 {
6767 CALL_TEST_DEBUG;
6768 InputWindowsManager inputWindowsManager;
6769 std::shared_ptr<KeyEvent> keyEvent = nullptr;
6770 int32_t focusWindowId = 1;
6771 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateKeyEventDisplayId(keyEvent, focusWindowId));
6772
6773 WindowInfo windowInfo = {.displayId = 1};
6774 WindowGroupInfo windowGroupInfo = {.focusWindowId = 1, .displayId = 1, .windowsInfo = {windowInfo}};
6775 inputWindowsManager.windowsPerDisplay_.emplace(std::make_pair(1, windowGroupInfo));
6776 keyEvent = KeyEvent::Create();
6777 ASSERT_NE(keyEvent, nullptr);
6778 inputWindowsManager.UpdateKeyEventDisplayId(keyEvent, focusWindowId);
6779 EXPECT_EQ(keyEvent->GetTargetDisplayId(), -1);
6780
6781 focusWindowId = 2;
6782 inputWindowsManager.UpdateKeyEventDisplayId(keyEvent, focusWindowId);
6783 EXPECT_EQ(keyEvent->GetTargetDisplayId(), -1);
6784
6785 OLD::DisplayInfo info1 = {.id = 0, .x = 0, .y = 0, .width = 100, .height = 200};
6786 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
6787 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
6788 it->second.displaysInfo.emplace_back(info1);
6789 }
6790 inputWindowsManager.UpdateKeyEventDisplayId(keyEvent, focusWindowId);
6791 EXPECT_EQ(keyEvent->GetTargetDisplayId(), 0);
6792 }
6793
6794 /**
6795 * @tc.name: InputWindowsManagerTest_OnDisplayRemovedOrCombinationChanged_003
6796 * @tc.desc: Test the funcation OnDisplayRemovedOrCombinationChanged
6797 * @tc.type: FUNC
6798 * @tc.require:
6799 */
6800 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_OnDisplayRemovedOrCombinationChanged_003, TestSize.Level1)
6801 {
6802 CALL_TEST_DEBUG;
6803 InputWindowsManager inputWindowsManager;
6804 OLD::DisplayGroupInfo displayGroupInfo {};
6805 bool ret = inputWindowsManager.OnDisplayRemovedOrCombinationChanged(displayGroupInfo);
6806 EXPECT_FALSE(ret);
6807
6808 OLD::DisplayInfo info1 = {.id = 0, .x = 0, .y = 0, .width = 100, .height = 200};
6809 OLD::DisplayInfo info2 = {.id = 1, .x = 100, .y = 0, .width = 100, .height = 200};
6810 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
6811 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
6812 it->second.displaysInfo = {info1, info2};
6813 }
6814 displayGroupInfo.displaysInfo = {info2};
6815 ret = inputWindowsManager.OnDisplayRemovedOrCombinationChanged(displayGroupInfo);
6816 EXPECT_TRUE(ret);
6817 }
6818
6819 /**
6820 * @tc.name: InputWindowsManagerTest_UpdateWindowInfo_001
6821 * @tc.desc: Test the funcation UpdateWindowInfo
6822 * @tc.type: FUNC
6823 * @tc.require:
6824 */
6825 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateWindowInfo_001, TestSize.Level1)
6826 {
6827 CALL_TEST_DEBUG;
6828 OLD::DisplayGroupInfo displayGroupInfo;
6829 displayGroupInfo.focusWindowId = 1;
6830
6831 WindowInfo windowInfo;
6832 windowInfo.id = 1;
6833 windowInfo.pid = 1;
6834 windowInfo.uid = 1;
6835 windowInfo.area = {1, 1, 1, 1};
6836 windowInfo.defaultHotAreas = {windowInfo.area};
6837 windowInfo.pointerHotAreas = {windowInfo.area};
6838 windowInfo.agentWindowId = 1;
6839 windowInfo.flags = 1;
6840 windowInfo.transform = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};
6841 windowInfo.pointerChangeAreas = {1, 2, 1, 2, 1, 2, 1, 2, 1};
6842 windowInfo.action = WINDOW_UPDATE_ACTION::ADD;
6843 displayGroupInfo.windowsInfo.push_back(windowInfo);
6844
6845 WINDOW_UPDATE_ACTION ret = WIN_MGR->UpdateWindowInfo(displayGroupInfo);
6846 ASSERT_EQ(ret, WINDOW_UPDATE_ACTION::ADD);
6847 }
6848
6849 /**
6850 * @tc.name: InputWindowsManagerTest_UpdateDisplayInfo_PointerBackCenter_001
6851 * @tc.desc: Test moved screen , pointer back screen center
6852 * @tc.type: FUNC
6853 * @tc.require:
6854 */
6855 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayInfo_PointerBackCenter_001, TestSize.Level1)
6856 {
6857 CALL_TEST_DEBUG;
6858 OLD::DisplayGroupInfo displayGroupInfo;
6859 displayGroupInfo.focusWindowId = 1;
6860
6861 OLD::DisplayInfo displayInfo1;
6862 displayInfo1.id = 1;
6863 displayInfo1.x = 1;
6864 displayInfo1.y = 1;
6865 displayInfo1.width = 2;
6866 displayInfo1.height = 2;
6867 displayInfo1.dpi = 240;
6868 displayInfo1.name = "pp";
6869 displayInfo1.direction = DIRECTION0;
6870 displayInfo1.displaySourceMode = OHOS::MMI::DisplaySourceMode::SCREEN_MAIN;
6871
6872 OLD::DisplayInfo displayInfo2;
6873 displayInfo2.id = 2;
6874 displayInfo2.x = 1;
6875 displayInfo2.y = 1;
6876 displayInfo2.width = 2;
6877 displayInfo2.height = 2;
6878 displayInfo2.dpi = 240;
6879 displayInfo2.name = "pp";
6880 displayInfo2.uniq = "pp";
6881 displayInfo2.direction = DIRECTION0;
6882 displayInfo2.displaySourceMode = OHOS::MMI::DisplaySourceMode::SCREEN_EXPAND;
6883 displayGroupInfo.displaysInfo.push_back(displayInfo2);
6884 displayGroupInfo.displaysInfo.push_back(displayInfo1);
6885
6886 ASSERT_NO_FATAL_FAILURE(WIN_MGR->UpdateDisplayInfo(displayGroupInfo));
6887
6888 displayGroupInfo.displaysInfo.erase(displayGroupInfo.displaysInfo.begin());
6889 ASSERT_NO_FATAL_FAILURE(WIN_MGR->UpdateDisplayInfo(displayGroupInfo));
6890 CursorPosition pointerPos = WIN_MGR->GetCursorPos();
6891 EXPECT_EQ(pointerPos.displayId, displayInfo1.id);
6892 }
6893
6894 /**
6895 * @tc.name: InputWindowsManagerTest_IgnoreTouchEvent_002
6896 * @tc.desc: Test the funcation IgnoreTouchEvent
6897 * @tc.type: FUNC
6898 * @tc.require:
6899 */
6900 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IgnoreTouchEvent_002, TestSize.Level1)
6901 {
6902 CALL_TEST_DEBUG;
6903 InputWindowsManager inputWindowsManager;
6904 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
6905 ASSERT_NE(pointerEvent, nullptr);
6906 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
6907 EXPECT_FALSE(inputWindowsManager.IgnoreTouchEvent(pointerEvent));
6908 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
6909 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
6910 EXPECT_FALSE(inputWindowsManager.IgnoreTouchEvent(pointerEvent));
6911 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
6912 PointerEvent::PointerItem item;
6913 item.SetPointerId(10);
6914 item.SetLongAxis(-1);
6915 pointerEvent->SetPointerId(0);
6916 pointerEvent->AddPointerItem(item);
6917 EXPECT_FALSE(inputWindowsManager.IgnoreTouchEvent(pointerEvent));
6918 pointerEvent->SetPointerId(10);
6919 inputWindowsManager.cancelTouchStatus_ = true;
6920 EXPECT_TRUE(inputWindowsManager.IgnoreTouchEvent(pointerEvent));
6921 item.SetLongAxis(100);
6922 pointerEvent->UpdatePointerItem(10, item);
6923 EXPECT_FALSE(inputWindowsManager.IgnoreTouchEvent(pointerEvent));
6924 EXPECT_FALSE(inputWindowsManager.IgnoreTouchEvent(pointerEvent));
6925 item.SetLongAxis(-1);
6926 pointerEvent->UpdatePointerItem(10, item);
6927 EXPECT_TRUE(inputWindowsManager.IgnoreTouchEvent(pointerEvent));
6928 }
6929
6930 /**
6931 * @tc.name: InputWindowsManagerTest_ReissueCancelTouchEvent
6932 * @tc.desc: Test the funcation ReissueCancelTouchEvent
6933 * @tc.type: FUNC
6934 * @tc.require:
6935 */
6936 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ReissueCancelTouchEvent, TestSize.Level1)
6937 {
6938 CALL_TEST_DEBUG;
6939 InputWindowsManager inputWindowsManager;
6940 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
6941 ASSERT_NE(pointerEvent, nullptr);
6942 PointerEvent::PointerItem item;
6943 item.SetPressed(false);
6944 pointerEvent->AddPointerItem(item);
6945 item.SetPointerId(100);
6946 item.SetPressed(true);
6947 pointerEvent->AddPointerItem(item);
6948 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.ReissueCancelTouchEvent(pointerEvent));
6949 }
6950
6951 /**
6952 * @tc.name: InputWindowsManagerTest_SetPointerEvent
6953 * @tc.desc: Test the funcation SetPointerEvent
6954 * @tc.type: FUNC
6955 * @tc.require:
6956 */
6957 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetPointerEvent, TestSize.Level1)
6958 {
6959 CALL_TEST_DEBUG;
6960 InputWindowsManager inputWindowsManager;
6961 int32_t pointerAction = PointerEvent::POINTER_ACTION_DOWN;
6962 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
6963 ASSERT_NE(pointerEvent, nullptr);
6964 inputWindowsManager.lastPointerEvent_ = PointerEvent::Create();
6965 ASSERT_NE(pointerEvent, nullptr);
6966 PointerEvent::PointerItem item;
6967 item.SetPointerId(100);
6968 item.SetPressed(true);
6969 item.SetDisplayX(50);
6970 item.SetDisplayY(50);
6971 inputWindowsManager.lastPointerEvent_->SetTargetDisplayId(150);
6972 inputWindowsManager.lastPointerEvent_->SetPointerId(100);
6973 inputWindowsManager.lastPointerEvent_->AddPointerItem(item);
6974 inputWindowsManager.lastWindowInfo_.id = 10;
6975 inputWindowsManager.mouseDownInfo_.id = 100;
6976 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SetPointerEvent(pointerAction, pointerEvent));
6977 item.SetPressed(false);
6978 inputWindowsManager.lastPointerEvent_->UpdatePointerItem(100, item);
6979 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.SetPointerEvent(pointerAction, pointerEvent));
6980 }
6981
6982 /**
6983 * @tc.name: InputWindowsManagerTest_CheckUIExtentionWindowPointerHotArea
6984 * @tc.desc: Test the funcation CheckUIExtentionWindowPointerHotArea
6985 * @tc.type: FUNC
6986 * @tc.require:
6987 */
6988 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckUIExtentionWindowPointerHotArea, TestSize.Level1)
6989 {
6990 CALL_TEST_DEBUG;
6991 InputWindowsManager inputWindowsManager;
6992 WindowInfo winInfo;
6993 Rect rect {
6994 .x = 100,
6995 .y = 100,
6996 .width = 1000,
6997 .height = 1000,
6998 };
6999 int32_t logicalX = 300;
7000 int32_t logicalY = 300;
7001 std::vector<WindowInfo> windowInfos;
7002 int32_t windowId = 10;
7003 winInfo.id = 20;
7004 winInfo.pointerHotAreas.push_back(rect);
7005 windowInfos.push_back(winInfo);
7006 EXPECT_NO_FATAL_FAILURE(
7007 inputWindowsManager.CheckUIExtentionWindowPointerHotArea(logicalX, logicalY, windowInfos, windowId));
7008 }
7009
7010 /**
7011 * @tc.name: InputWindowsManagerTest_UpdateTargetPointer
7012 * @tc.desc: Test the funcation UpdateTargetPointer
7013 * @tc.type: FUNC
7014 * @tc.require:
7015 */
7016 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateTargetPointer, TestSize.Level1)
7017 {
7018 CALL_TEST_DEBUG;
7019 InputWindowsManager inputWindowsManager;
7020 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
7021 ASSERT_NE(pointerEvent, nullptr);
7022 int32_t longAxis = 1U << 27U;
7023 inputWindowsManager.IsFoldable_ = true;
7024 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
7025 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
7026 PointerEvent::PointerItem item;
7027 item.SetPointerId(10);
7028 item.SetLongAxis(longAxis);
7029 pointerEvent->SetPointerId(10);
7030 pointerEvent->AddPointerItem(item);
7031 inputWindowsManager.cancelTouchStatus_ = true;
7032 EXPECT_EQ(inputWindowsManager.UpdateTargetPointer(pointerEvent), RET_OK);
7033 }
7034
7035 /**
7036 * @tc.name: InputWindowsManagerTest_CleanInvalidPiexMap
7037 * @tc.desc: Test the funcation CleanInvalidPiexMap
7038 * @tc.type: FUNC
7039 * @tc.require:
7040 */
7041 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CleanInvalidPiexMap, TestSize.Level1)
7042 {
7043 CALL_TEST_DEBUG;
7044 InputWindowsManager inputWindowsManager;
7045 int32_t windowId = 100;
7046 WindowInfo winInfo;
7047 winInfo.id = 10;
7048 std::unique_ptr<Media::PixelMap> pixelMap = nullptr;
7049 inputWindowsManager.transparentWins_.insert_or_assign(windowId, std::move(pixelMap));
7050 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
7051 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
7052 it->second.windowsInfo.push_back(winInfo);
7053 }
7054 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CleanInvalidPiexMap());
7055 }
7056
7057 /**
7058 * @tc.name: InputWindowsManagerTest_CleanInvalidPiexMap_001
7059 * @tc.desc: Test the funcation CleanInvalidPiexMap
7060 * @tc.type: FUNC
7061 * @tc.require:
7062 */
7063 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CleanInvalidPiexMap_001, TestSize.Level1)
7064 {
7065 CALL_TEST_DEBUG;
7066 InputWindowsManager inputWindowsManager;
7067 int32_t windowId = 10;
7068 WindowInfo winInfo;
7069 winInfo.id = 10;
7070 std::unique_ptr<Media::PixelMap> pixelMap = nullptr;
7071 inputWindowsManager.transparentWins_.insert_or_assign(windowId, std::move(pixelMap));
7072 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
7073 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
7074 it->second.windowsInfo.push_back(winInfo);
7075 }
7076 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CleanInvalidPiexMap());
7077 }
7078
7079 /**
7080 * @tc.name: InputWindowsManagerTest_GetCancelEventFlag
7081 * @tc.desc: Test the funcation GetCancelEventFlag
7082 * @tc.type: FUNC
7083 * @tc.require:
7084 */
7085 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetCancelEventFlag, TestSize.Level1)
7086 {
7087 CALL_TEST_DEBUG;
7088 InputWindowsManager inputWindowsManager;
7089 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
7090 ASSERT_NE(pointerEvent, nullptr);
7091 WindowInfoEX winInfoEx;
7092 winInfoEx.flag = true;
7093 int32_t pointerId = 100;
7094 pointerEvent->SetPointerId(100);
7095 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
7096 inputWindowsManager.touchItemDownInfos_.insert(std::make_pair(pointerId, winInfoEx));
7097 EXPECT_TRUE(inputWindowsManager.GetCancelEventFlag(pointerEvent));
7098
7099 pointerEvent->SetPointerId(200);
7100 EXPECT_TRUE(inputWindowsManager.GetCancelEventFlag(pointerEvent));
7101 }
7102
7103 /**
7104 * @tc.name: InputWindowsManagerTest_GetCancelEventFlag_001
7105 * @tc.desc: Test the funcation GetCancelEventFlag
7106 * @tc.type: FUNC
7107 * @tc.require:
7108 */
7109 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetCancelEventFlag_001, TestSize.Level1)
7110 {
7111 CALL_TEST_DEBUG;
7112 InputWindowsManager inputWindowsManager;
7113 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
7114 ASSERT_NE(pointerEvent, nullptr);
7115 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
7116 inputWindowsManager.mouseDownInfo_.pid = 100;
7117 EXPECT_FALSE(inputWindowsManager.GetCancelEventFlag(pointerEvent));
7118
7119 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
7120 inputWindowsManager.mouseDownInfo_.pid = -1;
7121 EXPECT_TRUE(inputWindowsManager.GetCancelEventFlag(pointerEvent));
7122
7123 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_UNKNOWN);
7124 EXPECT_FALSE(inputWindowsManager.GetCancelEventFlag(pointerEvent));
7125 }
7126
7127 /**
7128 * @tc.name: InputWindowsManagerTest_DispatchPointerCancel_001
7129 * @tc.desc: Test the funcation DispatchPointerCancel
7130 * @tc.type: FUNC
7131 * @tc.require:
7132 */
7133 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DispatchPointerCancel_001, TestSize.Level1)
7134 {
7135 CALL_TEST_DEBUG;
7136 InputWindowsManager inputWindowsManager;
7137 int32_t displayId = -1;
7138 WindowGroupInfo winGroupInfo;
7139 WindowInfo winInfo;
7140 inputWindowsManager.lastPointerEvent_ = PointerEvent::Create();
7141 ASSERT_NE(inputWindowsManager.lastPointerEvent_, nullptr);
7142 inputWindowsManager.mouseDownInfo_.id = 10;
7143 inputWindowsManager.extraData_.appended = false;
7144 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_UNKNOWN;
7145 inputWindowsManager.firstBtnDownWindowInfo_.first = -1;
7146 inputWindowsManager.firstBtnDownWindowInfo_.second = 10;
7147 winInfo.id = 10;
7148 winGroupInfo.windowsInfo.push_back(winInfo);
7149 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(10, winGroupInfo));
7150 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointerCancel(displayId));
7151 }
7152
7153 /**
7154 * @tc.name: InputWindowsManagerTest_DispatchPointerCancel_002
7155 * @tc.desc: Test the funcation DispatchPointerCancel
7156 * @tc.type: FUNC
7157 * @tc.require:
7158 */
7159 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DispatchPointerCancel_002, TestSize.Level1)
7160 {
7161 CALL_TEST_DEBUG;
7162 InputWindowsManager inputWindowsManager;
7163 int32_t displayId = -1;
7164 WindowGroupInfo winGroupInfo;
7165 WindowInfo winInfo;
7166 inputWindowsManager.lastPointerEvent_ = PointerEvent::Create();
7167 ASSERT_NE(inputWindowsManager.lastPointerEvent_, nullptr);
7168 inputWindowsManager.mouseDownInfo_.id = 50;
7169 inputWindowsManager.extraData_.appended = false;
7170 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_UNKNOWN;
7171 inputWindowsManager.firstBtnDownWindowInfo_.first = -1;
7172 inputWindowsManager.firstBtnDownWindowInfo_.second = 10;
7173 winInfo.id = 10;
7174 winGroupInfo.windowsInfo.push_back(winInfo);
7175 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(10, winGroupInfo));
7176 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointerCancel(displayId));
7177 }
7178
7179 /**
7180 * @tc.name: InputWindowsManagerTest_UpdateWindowsInfoPerDisplay
7181 * @tc.desc: Test the funcation UpdateWindowsInfoPerDisplay
7182 * @tc.type: FUNC
7183 * @tc.require:
7184 */
7185 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateWindowsInfoPerDisplay, TestSize.Level1)
7186 {
7187 CALL_TEST_DEBUG;
7188 InputWindowsManager inputWindowsManager;
7189 OLD::DisplayGroupInfo displayGroupInfo;
7190 WindowGroupInfo winGroupInfo;
7191 WindowInfo winInfo;
7192 int32_t displayId = 100;
7193 winInfo.displayId = 100;
7194 winInfo.id = 200;
7195 winInfo.windowType = -1;
7196 displayGroupInfo.focusWindowId = 300;
7197 displayGroupInfo.windowsInfo.push_back(winInfo);
7198 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(displayId, winGroupInfo));
7199 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateWindowsInfoPerDisplay(displayGroupInfo));
7200
7201 winInfo.windowType = static_cast<int32_t>(Rosen::WindowType::WINDOW_TYPE_TRANSPARENT_VIEW);
7202 displayGroupInfo.windowsInfo.push_back(winInfo);
7203 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateWindowsInfoPerDisplay(displayGroupInfo));
7204 }
7205
7206 /**
7207 * @tc.name: InputWindowsManagerTest_SelectWindowInfo_004
7208 * @tc.desc: Test SelectWindowInfo
7209 * @tc.type: FUNC
7210 * @tc.require:
7211 */
7212 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectWindowInfo_004, TestSize.Level1)
7213 {
7214 CALL_TEST_DEBUG;
7215 InputWindowsManager inputWindowsManager;
7216 int32_t windowId = 150;
7217 int32_t logicalX = 200;
7218 int32_t logicalY = 200;
7219 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
7220 EXPECT_NE(pointerEvent, nullptr);
7221 Rect rect {
7222 .x = 100,
7223 .y = 100,
7224 .width = 1000,
7225 .height = 1000,
7226 };
7227 WindowInfo windowInfo;
7228 WindowGroupInfo windowGroupInfo;
7229 pointerEvent->bitwise_ = 0x00000000;
7230 pointerEvent->SetZOrder(15.5f);
7231 pointerEvent->SetTargetDisplayId(-1);
7232 pointerEvent->SetTargetWindowId(100);
7233 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_UP);
7234 std::unique_ptr<Media::PixelMap> pixelMap = nullptr;
7235 windowInfo.id = 150;
7236 windowInfo.displayId = 300;
7237 windowInfo.flags = 0;
7238 windowInfo.pointerHotAreas.push_back(rect);
7239 windowInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
7240 inputWindowsManager.extraData_.appended = true;
7241 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
7242 windowInfo.uiExtentionWindowInfo.push_back(windowInfo);
7243 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
7244 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
7245 it->second.windowsInfo.push_back(windowInfo);
7246 }
7247 windowInfo.windowInputType = WindowInputType::NORMAL;
7248 it->second.windowsInfo.push_back(windowInfo);
7249 inputWindowsManager.firstBtnDownWindowInfo_.first = 150;
7250 inputWindowsManager.transparentWins_.insert_or_assign(windowId, std::move(pixelMap));
7251 EXPECT_NE(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent), std::nullopt);
7252 }
7253
7254 /**
7255 * @tc.name: InputWindowsManagerTest_SelectWindowInfo_005
7256 * @tc.desc: Test SelectWindowInfo
7257 * @tc.type: FUNC
7258 * @tc.require:
7259 */
7260 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectWindowInfo_005, TestSize.Level1)
7261 {
7262 CALL_TEST_DEBUG;
7263 InputWindowsManager inputWindowsManager;
7264 int32_t windowId = 50;
7265 int32_t logicalX = 200;
7266 int32_t logicalY = 200;
7267 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
7268 EXPECT_NE(pointerEvent, nullptr);
7269 Rect rect {
7270 .x = 100,
7271 .y = 100,
7272 .width = 1000,
7273 .height = 1000,
7274 };
7275 WindowInfo windowInfo;
7276 WindowGroupInfo windowGroupInfo;
7277 inputWindowsManager.firstBtnDownWindowInfo_.first = -1;
7278 pointerEvent->SetTargetDisplayId(-1);
7279 pointerEvent->SetTargetWindowId(-1);
7280 std::unique_ptr<Media::PixelMap> pixelMap = nullptr;
7281 windowInfo.id = 150;
7282 windowInfo.displayId = 300;
7283 windowInfo.flags = 0;
7284 windowInfo.pointerHotAreas.push_back(rect);
7285 windowInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
7286 inputWindowsManager.extraData_.appended = false;
7287 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_UNKNOWN;
7288 windowInfo.uiExtentionWindowInfo.push_back(windowInfo);
7289 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
7290 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
7291 it->second.windowsInfo.push_back(windowInfo);
7292 }
7293 inputWindowsManager.transparentWins_.insert_or_assign(windowId, std::move(pixelMap));
7294 EXPECT_EQ(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent), std::nullopt);
7295 pointerEvent->SetButtonPressed(2024);
7296 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_AXIS_BEGIN);
7297 EXPECT_EQ(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent), std::nullopt);
7298 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_AXIS_UPDATE);
7299 EXPECT_EQ(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent), std::nullopt);
7300 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_AXIS_END);
7301 EXPECT_EQ(inputWindowsManager.SelectWindowInfo(logicalX, logicalY, pointerEvent), std::nullopt);
7302 }
7303
7304 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
7305 /**
7306 * @tc.name: InputWindowsManagerTest_ReissueEvent_001
7307 * @tc.desc: Verify if (keyEvent->GetKeyAction() != KeyEvent::KEY_ACTION_CANCEL && focusWindowId_ != -1 &&
7308 * focusWindowId_ != focusWindowId && keyEvent->IsRepeatKey())
7309 * @tc.type: FUNC
7310 * @tc.require:
7311 */
7312 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ReissueEvent_001, TestSize.Level1)
7313 {
7314 CALL_TEST_DEBUG;
7315 auto keyEvent = KeyEvent::Create();
7316 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_CANCEL);
7317 InputWindowsManager inputWindowsManager;
7318 int32_t focusWindowId = 0;
7319 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.ReissueEvent(keyEvent, focusWindowId));
7320
7321 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
7322 focusWindowId = -1;
7323 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.ReissueEvent(keyEvent, focusWindowId));
7324
7325 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
7326 focusWindowId = 0;
7327 inputWindowsManager.focusWindowId_ = 0;
7328 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.ReissueEvent(keyEvent, focusWindowId));
7329
7330 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
7331 focusWindowId = 0;
7332 inputWindowsManager.focusWindowId_ = -1;
7333 keyEvent->SetRepeatKey(true);
7334 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.ReissueEvent(keyEvent, focusWindowId));
7335
7336 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_DOWN);
7337 focusWindowId = 0;
7338 inputWindowsManager.focusWindowId_ = -1;
7339 keyEvent->SetRepeatKey(false);
7340 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.ReissueEvent(keyEvent, focusWindowId));
7341 }
7342
7343 /**
7344 * @tc.name: InputWindowsManagerTest_ReissueEvent_002
7345 * @tc.desc: Verify ReissueEvent
7346 * @tc.type: FUNC
7347 * @tc.require:
7348 */
7349 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ReissueEvent_002, TestSize.Level1)
7350 {
7351 CALL_TEST_DEBUG;
7352 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
7353 ASSERT_NE(keyEvent, nullptr);
7354 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
7355 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_UNKNOWN);
7356 int32_t focusWindowId = -1;
7357 inputWindowsManager->focusWindowId_ = 0;
7358
7359 std::shared_ptr<EventDispatchHandler> handler = std::make_shared<EventDispatchHandler>();
7360 NiceMock<MockInputWindowsManager> mockInputWindowsManager;
7361 UDSServer udServer;
7362 EXPECT_CALL(mockInputWindowsManager, GetEventDispatchHandler).WillRepeatedly(Return(handler));
7363 EXPECT_CALL(mockInputWindowsManager, GetUDSServer).WillRepeatedly(Return(&udServer));
7364 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ReissueEvent(keyEvent, focusWindowId));
7365 }
7366
7367 /**
7368 * @tc.name: InputWindowsManagerTest_ReissueEvent_003
7369 * @tc.desc: Verify ReissueEvent
7370 * @tc.type: FUNC
7371 * @tc.require:
7372 */
7373 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ReissueEvent_003, TestSize.Level1)
7374 {
7375 CALL_TEST_DEBUG;
7376 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
7377 ASSERT_NE(keyEvent, nullptr);
7378 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
7379 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_UNKNOWN);
7380 int32_t focusWindowId = -1;
7381 inputWindowsManager->focusWindowId_ = 0;
7382
7383 NiceMock<MockInputWindowsManager> mockInputWindowsManager;
7384 UDSServer udServer;
7385 EXPECT_CALL(mockInputWindowsManager, GetEventDispatchHandler).WillRepeatedly(Return(nullptr));
7386 EXPECT_CALL(mockInputWindowsManager, GetUDSServer).WillRepeatedly(Return(&udServer));
7387 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ReissueEvent(keyEvent, focusWindowId));
7388 }
7389
7390 /**
7391 * @tc.name: InputWindowsManagerTest_ReissueEvent_004
7392 * @tc.desc: Verify ReissueEvent
7393 * @tc.type: FUNC
7394 * @tc.require:
7395 */
7396 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ReissueEvent_004, TestSize.Level1)
7397 {
7398 CALL_TEST_DEBUG;
7399 std::shared_ptr<KeyEvent> keyEvent = KeyEvent::Create();
7400 ASSERT_NE(keyEvent, nullptr);
7401 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
7402 keyEvent->SetKeyAction(KeyEvent::KEY_ACTION_UNKNOWN);
7403 int32_t focusWindowId = -1;
7404 inputWindowsManager->focusWindowId_ = 0;
7405
7406 NiceMock<MockInputWindowsManager> mockInputWindowsManager;
7407 EXPECT_CALL(mockInputWindowsManager, GetEventDispatchHandler).WillRepeatedly(Return(nullptr));
7408 EXPECT_CALL(mockInputWindowsManager, GetUDSServer).WillRepeatedly(Return(nullptr));
7409 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ReissueEvent(keyEvent, focusWindowId));
7410 }
7411 #endif // OHOS_BUILD_ENABLE_KEYBOARD
7412
7413 /**
7414 * @tc.name: InputWindowsManagerTest_JudgeCameraInFore_001
7415 * @tc.desc: Verify if (udsServer_ == nullptr)
7416 * @tc.type: FUNC
7417 * @tc.require:
7418 */
7419 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_JudgeCameraInFore_001, TestSize.Level1)
7420 {
7421 CALL_TEST_DEBUG;
7422 InputWindowsManager inputWindowsManager;
7423 EXPECT_EQ(inputWindowsManager.JudgeCameraInFore(), false);
7424
7425 UDSServer udsServer;
7426 inputWindowsManager.udsServer_ = &udsServer;
7427 EXPECT_NE(inputWindowsManager.udsServer_, nullptr);
7428 EXPECT_EQ(inputWindowsManager.JudgeCameraInFore(), false);
7429
7430 int32_t udsPid = 20;
7431 int32_t udsFd = 15;
7432 udsServer.idxPidMap_.insert(std::make_pair(udsPid, udsFd));
7433 SessionPtr session = CreateSessionPtr();
7434 udsServer.sessionsMap_.insert(std::make_pair(udsPid, session));
7435
7436 WindowInfo windowInfo;
7437 windowInfo.id = 20;
7438 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
7439 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
7440 it->second.windowsInfo.push_back(windowInfo);
7441 }
7442 it->second.focusWindowId = 20;
7443 EXPECT_EQ(inputWindowsManager.JudgeCameraInFore(), false);
7444 }
7445
7446 /**
7447 * @tc.name: InputWindowsManagerTest_SelectPointerChangeArea_003
7448 * @tc.desc: Test SelectPointerChangeArea
7449 * @tc.type: FUNC
7450 * @tc.require:
7451 */
7452 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectPointerChangeArea_003, TestSize.Level1)
7453 {
7454 CALL_TEST_DEBUG;
7455 InputWindowsManager inputWindowsMgr;
7456 std::vector<Rect> areas;
7457 Rect rect {
7458 .x = 100,
7459 .y = 100,
7460 .width = 1000,
7461 .height = 1000,
7462 };
7463 areas.push_back(rect);
7464 inputWindowsMgr.windowsHotAreas_.insert(std::make_pair(100, areas));
7465
7466 int32_t windowId = 100;
7467 int32_t logicalX = 300;
7468 int32_t logicalY = 300;
7469 EXPECT_NO_FATAL_FAILURE(inputWindowsMgr.SelectPointerChangeArea(windowId, logicalX, logicalY));
7470 }
7471
7472 /**
7473 * @tc.name: InputWindowsManagerTest_SelectPointerChangeArea_004
7474 * @tc.desc: Test SelectPointerChangeArea
7475 * @tc.type: FUNC
7476 * @tc.require:
7477 */
7478 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SelectPointerChangeArea_004, TestSize.Level1)
7479 {
7480 CALL_TEST_DEBUG;
7481 InputWindowsManager inputWindowsMgr;
7482 int32_t windowId = 100;
7483 int32_t logicalX = 300;
7484 int32_t logicalY = 300;
7485 EXPECT_FALSE(inputWindowsMgr.SelectPointerChangeArea(windowId, logicalX, logicalY));
7486 }
7487
7488 /**
7489 * @tc.name: InputWindowsManagerTest_InWhichHotArea_002
7490 * @tc.desc: Test InWhichHotArea
7491 * @tc.type: FUNC
7492 * @tc.require:
7493 */
7494 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_InWhichHotArea_002, TestSize.Level1)
7495 {
7496 CALL_TEST_DEBUG;
7497 InputWindowsManager inputWindowsManager;
7498 int32_t x = 500;
7499 int32_t y = 800;
7500 std::vector<Rect> rects;
7501 rects = {
7502 {100, 0, INT32_MAX, 0}
7503 };
7504 EXPECT_FALSE(inputWindowsManager.InWhichHotArea(x, y, rects));
7505 rects.clear();
7506 rects = {
7507 {150, 100, 300, INT32_MAX}
7508 };
7509 EXPECT_FALSE(inputWindowsManager.InWhichHotArea(x, y, rects));
7510 rects.clear();
7511 rects = {
7512 {150, 250, 300, 500}
7513 };
7514 EXPECT_FALSE(inputWindowsManager.InWhichHotArea(x, y, rects));
7515 x = 200;
7516 y = 300;
7517 EXPECT_TRUE(inputWindowsManager.InWhichHotArea(x, y, rects));
7518 int32_t cycleNum = 7;
7519 for (int32_t i = 0; i < cycleNum; ++i) {
7520 rects.insert(rects.begin(), {1000, 1000, 1500, 1500});
7521 EXPECT_TRUE(inputWindowsManager.InWhichHotArea(x, y, rects));
7522 }
7523 }
7524
7525 /**
7526 * @tc.name: InputWindowsManagerTest_HandleGestureInjection_001
7527 * @tc.desc: Verify if (!gestureInject)
7528 * @tc.type: FUNC
7529 * @tc.require:
7530 */
7531 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandleGestureInjection_001, TestSize.Level1)
7532 {
7533 CALL_TEST_DEBUG;
7534 InputWindowsManager inputWindowsManager;
7535 bool gestureInject = false;
7536 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.HandleGestureInjection(gestureInject));
7537
7538 gestureInject = true;
7539 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.HandleGestureInjection(gestureInject));
7540 }
7541
7542 /**
7543 * @tc.name: InputWindowsManagerTest_GetPhysicalDisplay_003
7544 * @tc.desc: Test GetPhysicalDisplay
7545 * @tc.type: FUNC
7546 * @tc.require:
7547 */
7548 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetPhysicalDisplay_003, TestSize.Level1)
7549 {
7550 CALL_TEST_DEBUG;
7551 InputWindowsManager inputWindowsManager;
7552 int32_t id = 1;
7553 OLD::DisplayInfo displayInfo;
7554 displayInfo.id = 0;
7555 OLD::DisplayGroupInfo displayGroupInfo;
7556 displayGroupInfo.displaysInfo.push_back(displayInfo);
7557 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetPhysicalDisplay(id, displayGroupInfo));
7558
7559 displayInfo.id = 1;
7560 displayGroupInfo.displaysInfo.push_back(displayInfo);
7561 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetPhysicalDisplay(id, displayGroupInfo));
7562 }
7563
7564 /**
7565 * @tc.name: InputWindowsManagerTest_AdjustFingerFlag_001
7566 * @tc.desc: Test if (pointerEvent->GetSourceType() != PointerEvent::SOURCE_TYPE_TOUCHSCREEN)
7567 * @tc.type: FUNC
7568 * @tc.require:
7569 */
7570 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_AdjustFingerFlag_001, TestSize.Level1)
7571 {
7572 CALL_TEST_DEBUG;
7573 auto pointerEvent = PointerEvent::Create();
7574 ASSERT_NE(pointerEvent, nullptr);
7575 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
7576 InputWindowsManager inputWindowsManager;
7577 EXPECT_FALSE(inputWindowsManager.AdjustFingerFlag(pointerEvent));
7578
7579 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
7580 EXPECT_FALSE(inputWindowsManager.AdjustFingerFlag(pointerEvent));
7581 }
7582
7583 /**
7584 * @tc.name: InputWindowsManagerTest_AdjustFingerFlag_002
7585 * @tc.desc: Test if (pointerEvent->HasFlag(InputEvent::EVENT_FLAG_SHELL))
7586 * @tc.type: FUNC
7587 * @tc.require:
7588 */
7589 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_AdjustFingerFlag_002, TestSize.Level1)
7590 {
7591 CALL_TEST_DEBUG;
7592 auto pointerEvent = PointerEvent::Create();
7593 ASSERT_NE(pointerEvent, nullptr);
7594 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
7595 uint32_t flag = 0x00000080;
7596 pointerEvent->bitwise_ |= flag;
7597 InputWindowsManager inputWindowsManager;
7598 EXPECT_FALSE(inputWindowsManager.AdjustFingerFlag(pointerEvent));
7599 }
7600
7601 /**
7602 * @tc.name: InputWindowsManagerTest_AdjustFingerFlag_003
7603 * @tc.desc: Test if (pointerEvent->HasFlag(InputEvent::EVENT_FLAG_SHELL))
7604 * @tc.type: FUNC
7605 * @tc.require:
7606 */
7607 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_AdjustFingerFlag_003, TestSize.Level1)
7608 {
7609 CALL_TEST_DEBUG;
7610 auto pointerEvent = PointerEvent::Create();
7611 ASSERT_NE(pointerEvent, nullptr);
7612 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
7613 uint32_t flag = 0x00000080;
7614 pointerEvent->bitwise_ |= flag;
7615 InputWindowsManager inputWindowsManager;
7616 EXPECT_FALSE(inputWindowsManager.AdjustFingerFlag(pointerEvent));
7617 }
7618
7619 /**
7620 * @tc.name: InputWindowsManagerTest_AdjustFingerFlag_004
7621 * @tc.desc: Test AdjustFingerFlag
7622 * @tc.type: FUNC
7623 * @tc.require:
7624 */
7625 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_AdjustFingerFlag_004, TestSize.Level1)
7626 {
7627 CALL_TEST_DEBUG;
7628 auto pointerEvent = PointerEvent::Create();
7629 ASSERT_NE(pointerEvent, nullptr);
7630 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
7631 uint32_t flag = 0x00000100;
7632 pointerEvent->bitwise_ |= flag;
7633 InputWindowsManager inputWindowsManager;
7634 EXPECT_FALSE(inputWindowsManager.AdjustFingerFlag(pointerEvent));
7635 }
7636
7637 /**
7638 * @tc.name: InputWindowsManagerTest_GetClientFd_007
7639 * @tc.desc: Test GetClientFd
7640 * @tc.type: FUNC
7641 * @tc.require:
7642 */
7643 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetClientFd_007, TestSize.Level1)
7644 {
7645 CALL_TEST_DEBUG;
7646 InputWindowsManager inputWindowsManager;
7647 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
7648 ASSERT_NE(pointerEvent, nullptr);
7649 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
7650 uint32_t flag = 0x00000100;
7651 pointerEvent->bitwise_ |= flag;
7652 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetClientFd(pointerEvent));
7653 }
7654
7655 /**
7656 * @tc.name: InputWindowsManagerTest_GetClientFd_008
7657 * @tc.desc: Test if (iter != touchItemDownInfos_.end() && !(iter->second.flag))
7658 * @tc.type: FUNC
7659 * @tc.require:
7660 */
7661 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetClientFd_008, TestSize.Level1)
7662 {
7663 CALL_TEST_DEBUG;
7664 InputWindowsManager inputWindowsManager;
7665 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
7666 ASSERT_NE(pointerEvent, nullptr);
7667
7668 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
7669 uint32_t flag = 0x00000100;
7670 pointerEvent->bitwise_ |= flag;
7671 WindowInfoEX winInfoEx;
7672 winInfoEx.flag = true;
7673 inputWindowsManager.touchItemDownInfos_.insert(std::make_pair(pointerEvent->GetPointerId(), winInfoEx));
7674
7675 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetClientFd(pointerEvent));
7676 }
7677
7678 /**
7679 * @tc.name: InputWindowsManagerTest_GetClientFd_009
7680 * @tc.desc: Test if (iter != touchItemDownInfos_.end() && !(iter->second.flag))
7681 * @tc.type: FUNC
7682 * @tc.require:
7683 */
7684 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetClientFd_009, TestSize.Level1)
7685 {
7686 CALL_TEST_DEBUG;
7687 InputWindowsManager inputWindowsManager;
7688 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
7689 ASSERT_NE(pointerEvent, nullptr);
7690
7691 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
7692 uint32_t flag = 0x00000100;
7693 pointerEvent->bitwise_ |= flag;
7694 WindowInfoEX winInfoEx;
7695 winInfoEx.flag = false;
7696 inputWindowsManager.touchItemDownInfos_.insert(std::make_pair(pointerEvent->GetPointerId(), winInfoEx));
7697
7698 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetClientFd(pointerEvent));
7699 }
7700
7701 /**
7702 * @tc.name: InputWindowsManagerTest_GetClientFd_010
7703 * @tc.desc: Test if (uiExtentionWindowInfo.id == pointerEvent->GetTargetWindowId())
7704 * @tc.type: FUNC
7705 * @tc.require:
7706 */
7707 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetClientFd_010, TestSize.Level1)
7708 {
7709 CALL_TEST_DEBUG;
7710 InputWindowsManager inputWindowsManager;
7711 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
7712 ASSERT_NE(pointerEvent, nullptr);
7713 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
7714 int32_t id = 1;
7715 pointerEvent->SetTargetWindowId(id);
7716
7717 WindowInfo windowInfo1;
7718 windowInfo1.id = 1;
7719 windowInfo1.uiExtentionWindowInfo.push_back(windowInfo1);
7720 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
7721 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
7722 it->second.windowsInfo.push_back(windowInfo1);
7723 }
7724 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetClientFd(pointerEvent));
7725 }
7726
7727 /**
7728 * @tc.name: InputWindowsManagerTest_GetClientFd_011
7729 * @tc.desc: Test if (uiExtentionWindowInfo.id == pointerEvent->GetTargetWindowId())
7730 * @tc.type: FUNC
7731 * @tc.require:
7732 */
7733 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetClientFd_011, TestSize.Level1)
7734 {
7735 CALL_TEST_DEBUG;
7736 InputWindowsManager inputWindowsManager;
7737 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
7738 ASSERT_NE(pointerEvent, nullptr);
7739 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
7740 int32_t id = 2;
7741 pointerEvent->SetTargetWindowId(id);
7742
7743 WindowInfo windowInfo1;
7744 windowInfo1.id = 1;
7745 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
7746 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
7747 it->second.windowsInfo.push_back(windowInfo1);
7748 }
7749 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetClientFd(pointerEvent));
7750 }
7751
7752 /**
7753 * @tc.name: InputWindowsManagerTest_FoldScreenRotation_001
7754 * @tc.desc: Test FoldScreenRotation
7755 * @tc.type: FUNC
7756 * @tc.require:
7757 */
7758 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_FoldScreenRotation_001, TestSize.Level1)
7759 {
7760 CALL_TEST_DEBUG;
7761 auto pointerEvent = PointerEvent::Create();
7762 ASSERT_NE(pointerEvent, nullptr);
7763 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
7764 uint32_t flag = 0x00000100;
7765 pointerEvent->bitwise_ |= flag;
7766 InputWindowsManager inputWindowsManager;
7767 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.FoldScreenRotation(pointerEvent));
7768 }
7769
7770 /**
7771 * @tc.name: InputWindowsManagerTest_FoldScreenRotation_002
7772 * @tc.desc: Test if (iter == touchItemDownInfos_.end())
7773 * @tc.type: FUNC
7774 * @tc.require:
7775 */
7776 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_FoldScreenRotation_002, TestSize.Level1)
7777 {
7778 CALL_TEST_DEBUG;
7779 auto pointerEvent = PointerEvent::Create();
7780 ASSERT_NE(pointerEvent, nullptr);
7781 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
7782 uint32_t flag = 0x00000100;
7783 pointerEvent->bitwise_ |= flag;
7784
7785 InputWindowsManager inputWindowsManager;
7786 WindowInfoEX winInfoEx;
7787 inputWindowsManager.touchItemDownInfos_.insert(std::make_pair(pointerEvent->GetPointerId(), winInfoEx));
7788
7789 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.FoldScreenRotation(pointerEvent));
7790 }
7791
7792 /**
7793 * @tc.name: InputWindowsManagerTest_GetWindowPid_003
7794 * @tc.desc: Test if (uiExtentionWindow.id == windowId)
7795 * @tc.type: FUNC
7796 * @tc.require:
7797 */
7798 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowPid_003, TestSize.Level1)
7799 {
7800 CALL_TEST_DEBUG;
7801 InputWindowsManager inputWindowsManager;
7802 int32_t windowId = 1;
7803 WindowInfo windowInfo1;
7804 windowInfo1.id = 2;
7805 WindowInfo windowInfo2;
7806 windowInfo2.id = 1;
7807 windowInfo1.uiExtentionWindowInfo.push_back(windowInfo2);
7808 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
7809 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
7810 it->second.windowsInfo.push_back(windowInfo1);
7811 }
7812
7813 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetWindowPid(windowId));
7814 }
7815
7816 /**
7817 * @tc.name: InputWindowsManagerTest_GetWindowPid_004
7818 * @tc.desc: Test if (uiExtentionWindow.id == windowId)
7819 * @tc.type: FUNC
7820 * @tc.require:
7821 */
7822 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowPid_004, TestSize.Level1)
7823 {
7824 CALL_TEST_DEBUG;
7825 InputWindowsManager inputWindowsManager;
7826 int32_t windowId = 1;
7827 WindowInfo windowInfo1;
7828 windowInfo1.id = 2;
7829 WindowInfo windowInfo2;
7830 windowInfo2.id = 3;
7831 windowInfo1.uiExtentionWindowInfo.push_back(windowInfo2);
7832 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
7833 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
7834 it->second.windowsInfo.push_back(windowInfo1);
7835 }
7836
7837 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.GetWindowPid(windowId));
7838 }
7839
7840 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)
7841 /**
7842 * @tc.name: InputWindowsManagerTest_ShiftAppPointerEvent_001
7843 * @tc.desc: Test ShiftAppPointerEvent failed for sourceWindowInfo not exist
7844 * @tc.type: FUNC
7845 * @tc.require:
7846 */
7847 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ShiftAppPointerEvent_001, TestSize.Level1)
7848 {
7849 CALL_TEST_DEBUG;
7850 InputWindowsManager inputWindowsManager;
7851 inputWindowsManager.lastPointerEvent_ = nullptr;
7852 int32_t sourceWindowId = 50;
7853 int32_t targetWindowId = 51;
7854 ShiftWindowParam param;
7855 param.sourceWindowId = sourceWindowId;
7856 param.targetWindowId = targetWindowId;
7857 bool autoGenDown = true;
7858 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
7859 EXPECT_NE(pointerEvent, nullptr);
7860 inputWindowsManager.lastPointerEvent_ = pointerEvent;
7861 PointerEvent::PointerItem item;
7862 item.SetPointerId(0);
7863 pointerEvent->SetPointerId(0);
7864 pointerEvent->AddPointerItem(item);
7865 int32_t ret = inputWindowsManager.ShiftAppPointerEvent(param, autoGenDown);
7866 EXPECT_NE(ret, RET_OK);
7867 }
7868
7869 /**
7870 * @tc.name: InputWindowsManagerTest_ShiftAppPointerEvent_002
7871 * @tc.desc: Test ShiftAppPointerEvent failed for targetWindowInfo not exist
7872 * @tc.type: FUNC
7873 * @tc.require:
7874 */
7875 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ShiftAppPointerEvent_002, TestSize.Level1)
7876 {
7877 CALL_TEST_DEBUG;
7878 InputWindowsManager inputWindowsManager;
7879 inputWindowsManager.lastPointerEvent_ = nullptr;
7880 int32_t sourceWindowId = 50;
7881 int32_t targetWindowId = 51;
7882 ShiftWindowParam param;
7883 param.sourceWindowId = sourceWindowId;
7884 param.targetWindowId = targetWindowId;
7885 bool autoGenDown = true;
7886 int32_t displayId = 0;
7887 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
7888 EXPECT_NE(pointerEvent, nullptr);
7889 inputWindowsManager.lastPointerEvent_ = pointerEvent;
7890 PointerEvent::PointerItem item;
7891 item.SetPointerId(0);
7892 pointerEvent->SetPointerId(0);
7893 pointerEvent->AddPointerItem(item);
7894 WindowGroupInfo windowGroupInfo;
7895 WindowInfo windowInfo;
7896 windowInfo.id = sourceWindowId;
7897 windowInfo.displayId = displayId;
7898 windowGroupInfo.windowsInfo.push_back(windowInfo);
7899 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(displayId, windowGroupInfo));
7900 int32_t ret = inputWindowsManager.ShiftAppPointerEvent(param, autoGenDown);
7901 EXPECT_NE(ret, RET_OK);
7902 }
7903
7904 /**
7905 * @tc.name: InputWindowsManagerTest_ShiftAppPointerEvent_003
7906 * @tc.desc: Test ShiftAppPointerEvent failed for displayId invalid
7907 * @tc.type: FUNC
7908 * @tc.require:
7909 */
7910 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ShiftAppPointerEvent_003, TestSize.Level1)
7911 {
7912 CALL_TEST_DEBUG;
7913 InputWindowsManager inputWindowsManager;
7914 inputWindowsManager.lastPointerEvent_ = nullptr;
7915 int32_t sourceWindowId = 50;
7916 int32_t targetWindowId = 51;
7917 ShiftWindowParam param;
7918 param.sourceWindowId = sourceWindowId;
7919 param.targetWindowId = targetWindowId;
7920 bool autoGenDown = true;
7921 int32_t displayId = -1;
7922 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
7923 EXPECT_NE(pointerEvent, nullptr);
7924 inputWindowsManager.lastPointerEvent_ = pointerEvent;
7925 PointerEvent::PointerItem item;
7926 item.SetPointerId(0);
7927 pointerEvent->SetPointerId(0);
7928 pointerEvent->AddPointerItem(item);
7929 WindowGroupInfo windowGroupInfo;
7930 WindowInfo windowInfo;
7931 windowInfo.id = sourceWindowId;
7932 windowInfo.displayId = displayId;
7933 windowGroupInfo.windowsInfo.push_back(windowInfo);
7934 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(displayId, windowGroupInfo));
7935 int32_t ret = inputWindowsManager.ShiftAppPointerEvent(param, autoGenDown);
7936 EXPECT_NE(ret, RET_OK);
7937 }
7938
7939 /**
7940 * @tc.name: InputWindowsManagerTest_ShiftAppPointerEvent_004
7941 * @tc.desc: Test ShiftAppPointerEvent failed for sourceWindowId untouchtable
7942 * @tc.type: FUNC
7943 * @tc.require:
7944 */
7945 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ShiftAppPointerEvent_004, TestSize.Level1)
7946 {
7947 CALL_TEST_DEBUG;
7948 InputWindowsManager inputWindowsManager;
7949 inputWindowsManager.lastPointerEvent_ = nullptr;
7950 int32_t sourceWindowId = 50;
7951 int32_t targetWindowId = 51;
7952 ShiftWindowParam param;
7953 param.sourceWindowId = sourceWindowId;
7954 param.targetWindowId = targetWindowId;
7955 bool autoGenDown = true;
7956 int32_t displayId = 0;
7957 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
7958 EXPECT_NE(pointerEvent, nullptr);
7959 inputWindowsManager.lastPointerEvent_ = pointerEvent;
7960 PointerEvent::PointerItem item;
7961 item.SetPointerId(0);
7962 pointerEvent->SetPointerId(0);
7963 pointerEvent->AddPointerItem(item);
7964 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_LEFT);
7965 WindowGroupInfo windowGroupInfo;
7966 WindowInfo windowInfo;
7967 windowInfo.id = sourceWindowId;
7968 windowInfo.displayId = displayId;
7969 windowGroupInfo.windowsInfo.push_back(windowInfo);
7970 windowInfo.flags &= WindowInfo::FLAG_BIT_UNTOUCHABLE;
7971 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(displayId, windowGroupInfo));
7972 int32_t ret = inputWindowsManager.ShiftAppPointerEvent(param, autoGenDown);
7973 EXPECT_NE(ret, RET_OK);
7974 }
7975
7976 /**
7977 * @tc.name: InputWindowsManagerTest_ShiftAppPointerEvent_005
7978 * @tc.desc: Test ShiftAppPointerEvent failed for sourceWindowId transparent
7979 * @tc.type: FUNC
7980 * @tc.require:
7981 */
7982 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ShiftAppPointerEvent_005, TestSize.Level1)
7983 {
7984 CALL_TEST_DEBUG;
7985 InputWindowsManager inputWindowsManager;
7986 inputWindowsManager.lastPointerEvent_ = nullptr;
7987 int32_t sourceWindowId = 50;
7988 int32_t targetWindowId = 51;
7989 ShiftWindowParam param;
7990 param.sourceWindowId = sourceWindowId;
7991 param.targetWindowId = targetWindowId;
7992 bool autoGenDown = true;
7993 int32_t displayId = 0;
7994 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
7995 EXPECT_NE(pointerEvent, nullptr);
7996 inputWindowsManager.lastPointerEvent_ = pointerEvent;
7997 PointerEvent::PointerItem item;
7998 item.SetPointerId(0);
7999 pointerEvent->SetPointerId(0);
8000 pointerEvent->AddPointerItem(item);
8001 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_LEFT);
8002 WindowGroupInfo windowGroupInfo;
8003 WindowInfo windowInfo;
8004 windowInfo.id = sourceWindowId;
8005 windowInfo.displayId = displayId;
8006 windowGroupInfo.windowsInfo.push_back(windowInfo);
8007 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(displayId, windowGroupInfo));
8008 inputWindowsManager.transparentWins_[sourceWindowId];
8009 int32_t ret = inputWindowsManager.ShiftAppPointerEvent(param, autoGenDown);
8010 EXPECT_NE(ret, RET_OK);
8011 }
8012
8013 /**
8014 * @tc.name: InputWindowsManagerTest_ShiftAppPointerEvent_006
8015 * @tc.desc: Test ShiftAppPointerEvent failed for null lastPointerEvent_
8016 * @tc.type: FUNC
8017 * @tc.require:
8018 */
8019 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ShiftAppPointerEvent_006, TestSize.Level1)
8020 {
8021 CALL_TEST_DEBUG;
8022 InputWindowsManager inputWindowsManager;
8023 inputWindowsManager.lastPointerEvent_ = nullptr;
8024 int32_t sourceWindowId = 50;
8025 int32_t targetWindowId = 51;
8026 ShiftWindowParam param;
8027 param.sourceWindowId = sourceWindowId;
8028 param.targetWindowId = targetWindowId;
8029 bool autoGenDown = true;
8030 int32_t displayId = 0;
8031 WindowGroupInfo windowGroupInfo;
8032 WindowInfo windowInfo;
8033 windowInfo.id = sourceWindowId;
8034 windowInfo.displayId = displayId;
8035 windowGroupInfo.windowsInfo.push_back(windowInfo);
8036 windowInfo.id = targetWindowId;
8037 windowGroupInfo.windowsInfo.push_back(windowInfo);
8038 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(displayId, windowGroupInfo));
8039 int32_t ret = inputWindowsManager.ShiftAppPointerEvent(param, autoGenDown);
8040 EXPECT_NE(ret, RET_OK);
8041 }
8042
8043 /**
8044 * @tc.name: InputWindowsManagerTest_ShiftAppPointerEvent_007
8045 * @tc.desc: Test ShiftAppPointerEvent failed for null lastPointerEvent_
8046 * @tc.type: FUNC
8047 * @tc.require:
8048 */
8049 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ShiftAppPointerEvent_007, TestSize.Level1)
8050 {
8051 CALL_TEST_DEBUG;
8052 InputWindowsManager inputWindowsManager;
8053 inputWindowsManager.lastTouchEvent_ = nullptr;
8054 int32_t sourceWindowId = 50;
8055 int32_t targetWindowId = 51;
8056 ShiftWindowParam param;
8057 param.sourceWindowId = sourceWindowId;
8058 param.targetWindowId = targetWindowId;
8059 param.sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
8060 bool autoGenDown = true;
8061 int32_t displayId = 0;
8062 WindowGroupInfo windowGroupInfo;
8063 WindowInfo windowInfo;
8064 windowInfo.id = sourceWindowId;
8065 windowInfo.displayId = displayId;
8066 windowGroupInfo.windowsInfo.push_back(windowInfo);
8067 windowInfo.id = targetWindowId;
8068 windowGroupInfo.windowsInfo.push_back(windowInfo);
8069 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(displayId, windowGroupInfo));
8070 int32_t ret = inputWindowsManager.ShiftAppPointerEvent(param, autoGenDown);
8071 EXPECT_NE(ret, RET_OK);
8072 }
8073
8074 /**
8075 * @tc.name: InputWindowsManagerTest_ShiftAppPointerEvent_008
8076 * @tc.desc: Test ShiftAppPointerEvent failed for null lastPointerEvent_
8077 * @tc.type: FUNC
8078 * @tc.require:
8079 */
8080 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ShiftAppPointerEvent_008, TestSize.Level1)
8081 {
8082 CALL_TEST_DEBUG;
8083 InputWindowsManager inputWindowsManager;
8084 inputWindowsManager.lastTouchEvent_ = nullptr;
8085 int32_t sourceWindowId = 50;
8086 int32_t targetWindowId = 51;
8087 int32_t fingerId = -1;
8088 ShiftWindowParam param;
8089 param.sourceWindowId = sourceWindowId;
8090 param.targetWindowId = targetWindowId;
8091 param.sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
8092 param.fingerId = fingerId;
8093 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
8094 EXPECT_NE(pointerEvent, nullptr);
8095 inputWindowsManager.lastTouchEvent_ = pointerEvent;
8096 bool autoGenDown = true;
8097 int32_t displayId = 0;
8098 WindowGroupInfo windowGroupInfo;
8099 WindowInfo windowInfo;
8100 windowInfo.id = sourceWindowId;
8101 windowInfo.displayId = displayId;
8102 windowGroupInfo.windowsInfo.push_back(windowInfo);
8103 windowInfo.id = targetWindowId;
8104 windowGroupInfo.windowsInfo.push_back(windowInfo);
8105 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(displayId, windowGroupInfo));
8106 int32_t ret = inputWindowsManager.ShiftAppPointerEvent(param, autoGenDown);
8107 EXPECT_NE(ret, RET_OK);
8108 }
8109
8110 /**
8111 * @tc.name: InputWindowsManagerTest_ShiftAppPointerEvent_009
8112 * @tc.desc: Test ShiftAppPointerEvent failed for null lastPointerEvent_
8113 * @tc.type: FUNC
8114 * @tc.require:
8115 */
8116 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ShiftAppPointerEvent_009, TestSize.Level1)
8117 {
8118 CALL_TEST_DEBUG;
8119 InputWindowsManager inputWindowsManager;
8120 inputWindowsManager.lastTouchEvent_ = nullptr;
8121 int32_t sourceWindowId = 50;
8122 int32_t targetWindowId = 51;
8123 int32_t fingerId = 1;
8124 ShiftWindowParam param;
8125 param.sourceWindowId = sourceWindowId;
8126 param.targetWindowId = targetWindowId;
8127 param.sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
8128 param.fingerId = fingerId;
8129 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
8130 EXPECT_NE(pointerEvent, nullptr);
8131 inputWindowsManager.lastTouchEvent_ = pointerEvent;
8132 bool autoGenDown = true;
8133 int32_t displayId = 0;
8134 WindowGroupInfo windowGroupInfo;
8135 WindowInfo windowInfo;
8136 windowInfo.id = sourceWindowId;
8137 windowInfo.displayId = displayId;
8138 windowGroupInfo.windowsInfo.push_back(windowInfo);
8139 windowInfo.id = targetWindowId;
8140 windowGroupInfo.windowsInfo.push_back(windowInfo);
8141 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(displayId, windowGroupInfo));
8142 int32_t ret = inputWindowsManager.ShiftAppPointerEvent(param, autoGenDown);
8143 EXPECT_NE(ret, RET_OK);
8144 }
8145
8146 /**
8147 * @tc.name: InputWindowsManagerTest_ShiftAppPointerEvent_010
8148 * @tc.desc: Test ShiftAppPointerEvent failed for null lastPointerEvent_
8149 * @tc.type: FUNC
8150 * @tc.require:
8151 */
8152 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ShiftAppPointerEvent_010, TestSize.Level1)
8153 {
8154 CALL_TEST_DEBUG;
8155 InputWindowsManager inputWindowsManager;
8156 inputWindowsManager.lastTouchEvent_ = nullptr;
8157 int32_t sourceWindowId = 50;
8158 int32_t targetWindowId = 51;
8159 int32_t fingerId = 0;
8160 ShiftWindowParam param;
8161 param.sourceWindowId = sourceWindowId;
8162 param.targetWindowId = targetWindowId;
8163 param.sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
8164 param.fingerId = fingerId;
8165 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
8166 EXPECT_NE(pointerEvent, nullptr);
8167 PointerEvent::PointerItem item;
8168 item.SetPointerId(0);
8169 pointerEvent->SetPointerId(0);
8170 pointerEvent->AddPointerItem(item);
8171 bool autoGenDown = true;
8172 int32_t displayId = 0;
8173 WindowGroupInfo windowGroupInfo;
8174 WindowInfo windowInfo;
8175 windowInfo.id = sourceWindowId;
8176 windowInfo.displayId = displayId;
8177 windowGroupInfo.windowsInfo.push_back(windowInfo);
8178 windowInfo.id = targetWindowId;
8179 windowGroupInfo.windowsInfo.push_back(windowInfo);
8180 inputWindowsManager.windowsPerDisplay_.insert(std::make_pair(displayId, windowGroupInfo));
8181 inputWindowsManager.lastTouchEvent_ = pointerEvent;
8182 int32_t ret = inputWindowsManager.ShiftAppPointerEvent(param, autoGenDown);
8183 EXPECT_NE(ret, RET_OK);
8184 }
8185
8186 /**
8187 * @tc.name: InputWindowsManagerTest_ResetPointerPositionIfOutValidDisplay_001
8188 * @tc.desc: Test if (isOut && isChange)
8189 * @tc.type: FUNC
8190 * @tc.require:
8191 */
8192 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ResetPointerPositionIfOutValidDisplay_001, TestSize.Level1)
8193 {
8194 CALL_TEST_DEBUG;
8195 OLD::DisplayGroupInfo displayGroupInfo;
8196 OLD::DisplayInfo displayInfo;
8197 displayInfo.id = 1;
8198 displayInfo.width = 1920;
8199 displayInfo.height = 1080;
8200 displayGroupInfo.displaysInfo.push_back(displayInfo);
8201
8202 InputWindowsManager inputWindowsManager;
8203 inputWindowsManager.cursorPos_.displayId = 1;
8204 inputWindowsManager.cursorPos_.cursorPos.x = -1;
8205 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
8206 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
8207 it->second.displaysInfo.push_back(displayInfo);
8208 }
8209
8210 // isOut = true, isChange = false
8211 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.ResetPointerPositionIfOutValidDisplay(displayGroupInfo));
8212
8213 displayGroupInfo.displaysInfo.clear();
8214 displayInfo.offsetX = 1;
8215 displayGroupInfo.displaysInfo.push_back(displayInfo);
8216 // isOut = true, isChange = true
8217 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.ResetPointerPositionIfOutValidDisplay(displayGroupInfo));
8218
8219 inputWindowsManager.cursorPos_.cursorPos.x = 10;
8220 inputWindowsManager.cursorPos_.cursorPos.y = 10;
8221 displayGroupInfo.displaysInfo.clear();
8222 displayInfo.validWidth = 11;
8223 displayInfo.validHeight = 11;
8224 displayGroupInfo.displaysInfo.push_back(displayInfo);
8225 // isOut = false, isChange = true
8226 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.ResetPointerPositionIfOutValidDisplay(displayGroupInfo));
8227
8228 displayGroupInfo.displaysInfo.clear();
8229 displayInfo.offsetX = 0;
8230 displayGroupInfo.displaysInfo.push_back(displayInfo);
8231 it->second.displaysInfo.clear();
8232 it->second.displaysInfo.push_back(displayInfo);
8233 // isOut = false, isChange = false
8234 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.ResetPointerPositionIfOutValidDisplay(displayGroupInfo));
8235 }
8236
8237 /**
8238 * @tc.name: InputWindowsManagerTest_IsPositionOutValidDisplay_001
8239 * @tc.desc: Test if (!isOut && isPhysicalPos)
8240 * @tc.type: FUNC
8241 * @tc.require:
8242 */
8243 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsPositionOutValidDisplay_001, TestSize.Level1)
8244 {
8245 CALL_TEST_DEBUG;
8246 OLD::DisplayInfo displayInfo;
8247 displayInfo.id = 1;
8248 displayInfo.width = 1;
8249 displayInfo.height = 1;
8250
8251 Coordinate2D position;
8252 position.x = -1;
8253
8254 // isOut = true, isChange = false
8255 bool isPhysicalPos = false;
8256 InputWindowsManager inputWindowsManager;
8257 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.IsPositionOutValidDisplay(position, displayInfo, isPhysicalPos));
8258
8259 position.x = 1;
8260 position.y = 1;
8261 displayInfo.validWidth = 1;
8262 displayInfo.validHeight = 1;
8263 // isOut = false, isChange = true, currentDisplay.fixedDirection = DIRECTION0
8264 isPhysicalPos = true;
8265 displayInfo.fixedDirection = DIRECTION0;
8266 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.IsPositionOutValidDisplay(position, displayInfo, isPhysicalPos));
8267
8268 displayInfo.fixedDirection = DIRECTION90;
8269 // isOut = false, isChange = true, currentDisplay.fixedDirection = DIRECTION90
8270 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.IsPositionOutValidDisplay(position, displayInfo, isPhysicalPos));
8271
8272 displayInfo.fixedDirection = DIRECTION180;
8273 // isOut = false, isChange = true, currentDisplay.fixedDirection = DIRECTION180
8274 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.IsPositionOutValidDisplay(position, displayInfo, isPhysicalPos));
8275
8276 displayInfo.fixedDirection = DIRECTION270;
8277 // isOut = false, isChange = true, currentDisplay.fixedDirection = DIRECTION270
8278 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.IsPositionOutValidDisplay(position, displayInfo, isPhysicalPos));
8279 }
8280
8281 /**
8282 * @tc.name: InputWindowsManagerTest_CancelTouchScreenEventIfValidDisplayChange_001
8283 * @tc.desc: Test if (lastPointerEventforGesture_->GetSourceType() != PointerEvent::SOURCE_TYPE_TOUCHSCREEN)
8284 * @tc.type: FUNC
8285 * @tc.require:
8286 */
8287 HWTEST_F(
8288 InputWindowsManagerTest, InputWindowsManagerTest_CancelTouchScreenEventIfValidDisplayChange_001, TestSize.Level1)
8289 {
8290 CALL_TEST_DEBUG;
8291 OLD::DisplayInfo displayInfo;
8292 displayInfo.id = 1;
8293 OLD::DisplayGroupInfo displayGroupInfo;
8294 displayGroupInfo.displaysInfo.push_back(displayInfo);
8295
8296 InputWindowsManager inputWindowsManager;
8297 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
8298 EXPECT_NE(pointerEvent, nullptr);
8299 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
8300 inputWindowsManager.lastPointerEventforGesture_ = pointerEvent;
8301 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelTouchScreenEventIfValidDisplayChange(displayGroupInfo));
8302
8303 inputWindowsManager.lastPointerEventforGesture_->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
8304 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelTouchScreenEventIfValidDisplayChange(displayGroupInfo));
8305 }
8306
8307 /**
8308 * @tc.name: InputWindowsManagerTest_CancelTouchScreenEventIfValidDisplayChange_002
8309 * @tc.desc: Test if (touchDisplayId == currentDisplay.id && IsValidDisplayChange(currentDisplay))
8310 * @tc.type: FUNC
8311 * @tc.require:
8312 */
8313 HWTEST_F(
8314 InputWindowsManagerTest, InputWindowsManagerTest_CancelTouchScreenEventIfValidDisplayChange_002, TestSize.Level1)
8315 {
8316 CALL_TEST_DEBUG;
8317 OLD::DisplayInfo displayInfo;
8318 displayInfo.id = 1;
8319 OLD::DisplayGroupInfo displayGroupInfo;
8320 displayGroupInfo.displaysInfo.push_back(displayInfo);
8321
8322 InputWindowsManager inputWindowsManager;
8323 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
8324 EXPECT_NE(pointerEvent, nullptr);
8325 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
8326 inputWindowsManager.lastPointerEventforGesture_ = pointerEvent;
8327 inputWindowsManager.lastPointerEventforGesture_->SetTargetDisplayId(displayInfo.id);
8328 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
8329 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
8330 it->second.displaysInfo.push_back(displayInfo);
8331 }
8332 // true false
8333 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelTouchScreenEventIfValidDisplayChange(displayGroupInfo));
8334
8335 // false false
8336 inputWindowsManager.lastPointerEventforGesture_->SetTargetDisplayId(0);
8337 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelTouchScreenEventIfValidDisplayChange(displayGroupInfo));
8338
8339 // false true
8340 displayGroupInfo.displaysInfo.clear();
8341 displayInfo.offsetX = 1;
8342 displayGroupInfo.displaysInfo.push_back(displayInfo);
8343 inputWindowsManager.lastPointerEventforGesture_->SetTargetDisplayId(0);
8344 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelTouchScreenEventIfValidDisplayChange(displayGroupInfo));
8345
8346 // true true
8347 inputWindowsManager.lastPointerEventforGesture_->SetTargetDisplayId(displayInfo.id);
8348 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelTouchScreenEventIfValidDisplayChange(displayGroupInfo));
8349 }
8350
8351 /**
8352 * @tc.name: InputWindowsManagerTest_CancelMouseEvent_001
8353 * @tc.desc: Test if (lastPointerEvent_ == nullptr)
8354 * @tc.type: FUNC
8355 * @tc.require:
8356 */
8357 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CancelMouseEvent_001, TestSize.Level1)
8358 {
8359 CALL_TEST_DEBUG;
8360 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
8361 EXPECT_NE(pointerEvent, nullptr);
8362
8363 InputWindowsManager inputWindowsManager;
8364 inputWindowsManager.lastPointerEvent_ = pointerEvent;
8365 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelMouseEvent());
8366
8367 inputWindowsManager.lastPointerEvent_ = nullptr;
8368 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelMouseEvent());
8369 }
8370
8371 /**
8372 * @tc.name: InputWindowsManagerTest_CancelMouseEvent_002
8373 * @tc.desc: Test if (lastPointerEvent_->GetSourceType() == PointerEvent::SOURCE_TYPE_MOUSE &&
8374 !lastPointerEvent_->GetPressedButtons().empty())
8375 * @tc.type: FUNC
8376 * @tc.require:
8377 */
8378 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CancelMouseEvent_002, TestSize.Level1)
8379 {
8380 CALL_TEST_DEBUG;
8381 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
8382 EXPECT_NE(pointerEvent, nullptr);
8383
8384 InputWindowsManager inputWindowsManager;
8385 inputWindowsManager.lastPointerEvent_ = pointerEvent;
8386 // true false
8387 inputWindowsManager.lastPointerEvent_->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
8388 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelMouseEvent());
8389
8390 // true true
8391 inputWindowsManager.lastPointerEvent_->pressedButtons_.insert(0);
8392 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelMouseEvent());
8393
8394 // false true
8395 inputWindowsManager.lastPointerEvent_->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
8396 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelMouseEvent());
8397
8398 // false false
8399 inputWindowsManager.lastPointerEvent_->pressedButtons_.clear();
8400 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelMouseEvent());
8401 }
8402
8403 /**
8404 * @tc.name: InputWindowsManagerTest_UpdatePointerDrawingManagerWindowInfo_001
8405 * @tc.desc: Test if (lastPointerEvent_->GetPointerAction() != PointerEvent::POINTER_ACTION_DOWN &&
8406 (lastPointerEvent_->GetPointerAction() == PointerEvent::POINTER_ACTION_BUTTON_UP ||
8407 lastPointerEvent_->GetPointerAction() == PointerEvent::POINTER_ACTION_PULL_UP ||
8408 lastPointerEvent_->GetPressedButtons().empty()))
8409 * @tc.type: FUNC
8410 * @tc.require:
8411 */
8412 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerDrawingManagerWindowInfo_001, TestSize.Level1)
8413 {
8414 CALL_TEST_DEBUG;
8415 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
8416 EXPECT_NE(pointerEvent, nullptr);
8417
8418 InputWindowsManager inputWindowsManager;
8419 inputWindowsManager.lastPointerEvent_ = pointerEvent;
8420 // true false
8421 inputWindowsManager.lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_UP);
8422 inputWindowsManager.lastPointerEvent_->pressedButtons_.insert(0);
8423 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePointerDrawingManagerWindowInfo());
8424
8425 // true true
8426 inputWindowsManager.lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_UP);
8427 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePointerDrawingManagerWindowInfo());
8428 inputWindowsManager.lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_UP);
8429 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePointerDrawingManagerWindowInfo());
8430 inputWindowsManager.lastPointerEvent_->pressedButtons_.clear();
8431 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePointerDrawingManagerWindowInfo());
8432
8433 // false true
8434 inputWindowsManager.lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
8435 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePointerDrawingManagerWindowInfo());
8436
8437 // false false
8438 inputWindowsManager.lastPointerEvent_->pressedButtons_.insert(0);
8439 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePointerDrawingManagerWindowInfo());
8440 }
8441
8442 /**
8443 * @tc.name: InputWindowsManagerTest_PrintHighZorder_001
8444 * @tc.desc: Test if (!info)
8445 * @tc.type: FUNC
8446 * @tc.require:
8447 */
8448 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintHighZorder_001, TestSize.Level1)
8449 {
8450 CALL_TEST_DEBUG;
8451 WindowInfo windowInfo;
8452 windowInfo.id = 0;
8453 windowInfo.flags = 2;
8454 ;
8455 WindowGroupInfo windowGroupInfo;
8456 windowGroupInfo.displayId = 0;
8457 windowGroupInfo.windowsInfo.push_back(windowInfo);
8458
8459 InputWindowsManager inputWindowsManager;
8460 inputWindowsManager.windowsPerDisplay_[0] = windowGroupInfo;
8461 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.PrintHighZorder(
8462 windowGroupInfo.windowsInfo, PointerEvent::POINTER_ACTION_AXIS_BEGIN, windowInfo.id, 0, 0));
8463
8464 inputWindowsManager.windowsPerDisplay_.clear();
8465 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.PrintHighZorder(
8466 windowGroupInfo.windowsInfo, PointerEvent::POINTER_ACTION_AXIS_BEGIN, windowInfo.id, 0, 0));
8467 }
8468
8469 /**
8470 * @tc.name: InputWindowsManagerTest_PrintHighZorder_002
8471 * @tc.desc: Test if (MMI_GNE(windowInfo.zOrder, targetWindow.zOrder) && !windowInfo.flags &&
8472 pointerAction == PointerEvent::POINTER_ACTION_AXIS_BEGIN &&
8473 windowInfo.windowInputType != WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE &&
8474 windowInfo.windowInputType != WindowInputType::MIX_BUTTOM_ANTI_AXIS_MOVE &&
8475 windowInfo.windowInputType != WindowInputType::TRANSMIT_ALL)
8476 * @tc.type: FUNC
8477 * @tc.require:
8478 */
8479 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintHighZorder_002, TestSize.Level1)
8480 {
8481 CALL_TEST_DEBUG;
8482 WindowInfo windowInfo;
8483 windowInfo.id = 0;
8484 windowInfo.flags = 2;
8485 windowInfo.zOrder = 1;
8486 WindowGroupInfo windowGroupInfo;
8487 windowGroupInfo.displayId = 0;
8488 windowGroupInfo.windowsInfo.push_back(windowInfo);
8489
8490 InputWindowsManager inputWindowsManager;
8491 inputWindowsManager.windowsPerDisplay_[0] = windowGroupInfo;
8492
8493 windowGroupInfo.windowsInfo.clear();
8494 windowInfo.flags = 0;
8495 windowInfo.zOrder = 10;
8496 windowInfo.windowInputType = WindowInputType::NORMAL;
8497 windowGroupInfo.windowsInfo.push_back(windowInfo);
8498 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.PrintHighZorder(
8499 windowGroupInfo.windowsInfo, PointerEvent::POINTER_ACTION_AXIS_BEGIN, windowInfo.id, 0, 0));
8500
8501 windowGroupInfo.windowsInfo.clear();
8502 windowInfo.windowInputType = WindowInputType::TRANSMIT_ALL;
8503 windowGroupInfo.windowsInfo.push_back(windowInfo);
8504 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.PrintHighZorder(
8505 windowGroupInfo.windowsInfo, PointerEvent::POINTER_ACTION_AXIS_BEGIN, windowInfo.id, 0, 0));
8506
8507 windowGroupInfo.windowsInfo.clear();
8508 windowInfo.windowInputType = WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE;
8509 windowGroupInfo.windowsInfo.push_back(windowInfo);
8510 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.PrintHighZorder(
8511 windowGroupInfo.windowsInfo, PointerEvent::POINTER_ACTION_AXIS_BEGIN, windowInfo.id, 0, 0));
8512
8513 windowGroupInfo.windowsInfo.clear();
8514 windowInfo.windowInputType = WindowInputType::MIX_BUTTOM_ANTI_AXIS_MOVE;
8515 windowGroupInfo.windowsInfo.push_back(windowInfo);
8516 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.PrintHighZorder(
8517 windowGroupInfo.windowsInfo, PointerEvent::POINTER_ACTION_AXIS_BEGIN, windowInfo.id, 0, 0));
8518
8519 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.PrintHighZorder(
8520 windowGroupInfo.windowsInfo, PointerEvent::POINTER_ACTION_AXIS_UPDATE, windowInfo.id, 0, 0));
8521
8522 windowGroupInfo.windowsInfo.clear();
8523 windowInfo.flags = 2;
8524 windowGroupInfo.windowsInfo.push_back(windowInfo);
8525 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.PrintHighZorder(
8526 windowGroupInfo.windowsInfo, PointerEvent::POINTER_ACTION_AXIS_UPDATE, windowInfo.id, 0, 0));
8527 }
8528
8529 /**
8530 * @tc.name: InputWindowsManagerTest_PrintHighZorder_003
8531 * @tc.desc: Test if (MMI_GNE(windowInfo.zOrder, targetWindow.zOrder) && !windowInfo.flags &&
8532 pointerAction == PointerEvent::POINTER_ACTION_AXIS_BEGIN &&
8533 windowInfo.windowInputType != WindowInputType::MIX_LEFT_RIGHT_ANTI_AXIS_MOVE &&
8534 windowInfo.windowInputType != WindowInputType::MIX_BUTTOM_ANTI_AXIS_MOVE &&
8535 windowInfo.windowInputType != WindowInputType::TRANSMIT_ALL)
8536 * @tc.type: FUNC
8537 * @tc.require:
8538 */
8539 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintHighZorder_003, TestSize.Level1)
8540 {
8541 CALL_TEST_DEBUG;
8542 WindowInfo windowInfo;
8543 windowInfo.id = 0;
8544 windowInfo.flags = 2;
8545 windowInfo.zOrder = 1;
8546 WindowGroupInfo windowGroupInfo;
8547 windowGroupInfo.displayId = 0;
8548 windowGroupInfo.windowsInfo.push_back(windowInfo);
8549
8550 InputWindowsManager inputWindowsManager;
8551 inputWindowsManager.windowsPerDisplay_[0] = windowGroupInfo;
8552
8553 windowGroupInfo.windowsInfo.clear();
8554 windowInfo.zOrder = 0;
8555 windowGroupInfo.windowsInfo.push_back(windowInfo);
8556 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.PrintHighZorder(
8557 windowGroupInfo.windowsInfo, PointerEvent::POINTER_ACTION_AXIS_UPDATE, windowInfo.id, 0, 0));
8558 }
8559
8560 /**
8561 * @tc.name: InputWindowsManagerTest_UpdateCustomStyle_001
8562 * @tc.desc: Test if (pointerStyle.id != MOUSE_ICON::DEVELOPER_DEFINED_ICON
8563 * @tc.type: FUNC
8564 * @tc.require:
8565 */
8566 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateCustomStyle_001, TestSize.Level1)
8567 {
8568 CALL_TEST_DEBUG;
8569 int32_t windowId = 0;
8570 PointerStyle pointerStyle;
8571 pointerStyle.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
8572 InputWindowsManager inputWindowsManager;
8573 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateCustomStyle(windowId, pointerStyle));
8574
8575 pointerStyle.id = MOUSE_ICON::TRANSPARENT_ICON;
8576 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateCustomStyle(windowId, pointerStyle));
8577 }
8578
8579 /**
8580 * @tc.name: InputWindowsManagerTest_UpdateCustomStyle_002
8581 * @tc.desc: Test if (innerIt.first != windowId && innerIt.second.id == MOUSE_ICON::DEVELOPER_DEFINED_ICON)
8582 * @tc.type: FUNC
8583 * @tc.require:
8584 */
8585 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateCustomStyle_002, TestSize.Level1)
8586 {
8587 CALL_TEST_DEBUG;
8588 int32_t windowId = 0;
8589 PointerStyle pointerStyle;
8590 pointerStyle.id = MOUSE_ICON::DEVELOPER_DEFINED_ICON;
8591
8592 std::map<int32_t, PointerStyle> pointerStyles;
8593 pointerStyles[1] = pointerStyle;
8594
8595 InputWindowsManager inputWindowsManager;
8596 inputWindowsManager.pointerStyle_[0] = pointerStyles;
8597 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateCustomStyle(windowId, pointerStyle));
8598
8599 windowId = 1;
8600 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateCustomStyle(windowId, pointerStyle));
8601
8602 windowId = 0;
8603 PointerStyle pointerStyle1;
8604 pointerStyle1.id = MOUSE_ICON::TRANSPARENT_ICON;
8605 pointerStyles[1] = pointerStyle1;
8606 inputWindowsManager.pointerStyle_[0] = pointerStyles;
8607 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateCustomStyle(windowId, pointerStyle));
8608 }
8609
8610 #ifdef OHOS_BUILD_ENABLE_ONE_HAND_MODE
8611 /**
8612 * @tc.name: InputWindowsManagerTest_UpdatePointerItemInOneHandMode_001
8613 * @tc.desc: Test if (pointerEvent->HasFlag(InputEvent::EVENT_FLAG_SIMULATE))
8614 * @tc.type: FUNC
8615 * @tc.require:
8616 */
8617 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerItemInOneHandMode_001, TestSize.Level1)
8618 {
8619 CALL_TEST_DEBUG;
8620 InputWindowsManager inputWindowsManager;
8621 DisplayInfo displayInfo;
8622 displayInfo.oneHandY = 10;
8623 displayInfo.height = 11;
8624
8625 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
8626 EXPECT_NE(pointerEvent, nullptr);
8627 PointerEvent::PointerItem pointerItem;
8628 pointerItem.SetPointerId(0);
8629 pointerEvent->AddPointerItem(pointerItem);
8630 pointerEvent->SetPointerId(0);
8631 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePointerItemInOneHandMode(displayInfo, pointerEvent));
8632
8633 pointerEvent->AddFlag(InputEvent::EVENT_FLAG_SIMULATE);
8634 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePointerItemInOneHandMode(displayInfo, pointerEvent));
8635 }
8636
8637 /**
8638 * @tc.name: InputWindowsManagerTest_UpdatePointerItemInOneHandMode_002
8639 * @tc.desc: Test if (autoToVirtualScreen)
8640 * @tc.type: FUNC
8641 * @tc.require:
8642 */
8643 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerItemInOneHandMode_002, TestSize.Level1)
8644 {
8645 CALL_TEST_DEBUG;
8646 InputWindowsManager inputWindowsManager;
8647 DisplayInfo displayInfo;
8648 displayInfo.oneHandY = 10;
8649 displayInfo.height = 11;
8650
8651 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
8652 EXPECT_NE(pointerEvent, nullptr);
8653 PointerEvent::PointerItem pointerItem;
8654 pointerItem.SetPointerId(0);
8655 pointerEvent->AddPointerItem(pointerItem);
8656 pointerEvent->SetPointerId(0);
8657 pointerEvent->AddFlag(InputEvent::EVENT_FLAG_SIMULATE);
8658 pointerEvent->SetAutoToVirtualScreen(true);
8659 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePointerItemInOneHandMode(displayInfo, pointerEvent));
8660
8661 pointerEvent->SetAutoToVirtualScreen(false);
8662 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePointerItemInOneHandMode(displayInfo, pointerEvent));
8663 }
8664 #endif // OHOS_BUILD_ENABLE_ONE_HAND_MODE
8665
8666 /**
8667 * @tc.name: InputWindowsManagerTest_ShiftAppMousePointerEvent_001
8668 * @tc.desc: Test if (!lastPointerEvent_ || !lastPointerEvent_->IsButtonPressed(PointerEvent::MOUSE_BUTTON_LEFT))
8669 * @tc.type: FUNC
8670 * @tc.require:
8671 */
8672 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ShiftAppMousePointerEvent_001, TestSize.Level1)
8673 {
8674 CALL_TEST_DEBUG;
8675 InputWindowsManager inputWindowsManager;
8676 inputWindowsManager.lastPointerEvent_ = nullptr;
8677 ShiftWindowInfo shiftWindowInfo;
8678 bool autoGenDown = false;
8679 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.ShiftAppMousePointerEvent(shiftWindowInfo, autoGenDown));
8680
8681 inputWindowsManager.lastPointerEvent_ = PointerEvent::Create();
8682 EXPECT_NE(inputWindowsManager.lastPointerEvent_, nullptr);
8683 inputWindowsManager.lastPointerEvent_->SetButtonPressed(PointerEvent::MOUSE_BUTTON_RIGHT);
8684 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.ShiftAppMousePointerEvent(shiftWindowInfo, autoGenDown));
8685 }
8686
8687 /**
8688 * @tc.name: InputWindowsManagerTest_CancelTouch_001
8689 * @tc.desc: Test if ((iter != touchItemDownInfos_.end()) && iter->second.flag)
8690 * @tc.type: FUNC
8691 * @tc.require:
8692 */
8693 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CancelTouch_001, TestSize.Level1)
8694 {
8695 CALL_TEST_DEBUG;
8696 InputWindowsManager inputWindowsManager;
8697 int32_t touch = 0;
8698 WindowInfoEX windowInfoEX;
8699 windowInfoEX.flag = true;
8700 inputWindowsManager.touchItemDownInfos_[0] = windowInfoEX;
8701 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelTouch(touch));
8702
8703 windowInfoEX.flag = false;
8704 inputWindowsManager.touchItemDownInfos_[0] = windowInfoEX;
8705 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelTouch(touch));
8706
8707 touch = 1;
8708 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelTouch(touch));
8709 }
8710
8711 /**
8712 * @tc.name: InputWindowsManagerTest_CancelAllTouches_001
8713 * @tc.desc: Test if (!item.IsPressed())
8714 * @tc.type: FUNC
8715 * @tc.require:
8716 */
8717 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CancelAllTouches_001, TestSize.Level1)
8718 {
8719 CALL_TEST_DEBUG;
8720 InputWindowsManager inputWindowsManager;
8721 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
8722 EXPECT_NE(pointerEvent, nullptr);
8723 PointerEvent::PointerItem pointerItem;
8724 pointerItem.SetPointerId(0);
8725 pointerItem.SetPressed(false);
8726 pointerEvent->AddPointerItem(pointerItem);
8727 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelAllTouches(pointerEvent));
8728 }
8729
8730 /**
8731 * @tc.name: InputWindowsManagerTest_CancelAllTouches_002
8732 * @tc.desc: Test if (AdjustFingerFlag(pointerEvent))
8733 * @tc.type: FUNC
8734 * @tc.require:
8735 */
8736 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CancelAllTouches_002, TestSize.Level1)
8737 {
8738 CALL_TEST_DEBUG;
8739 InputWindowsManager inputWindowsManager;
8740 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
8741 EXPECT_NE(pointerEvent, nullptr);
8742 PointerEvent::PointerItem pointerItem;
8743 pointerItem.SetPointerId(0);
8744 pointerItem.SetPressed(true);
8745 pointerEvent->AddPointerItem(pointerItem);
8746 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
8747
8748 WindowInfoEX windowInfoEX;
8749 windowInfoEX.flag = false;
8750 inputWindowsManager.touchItemDownInfos_[0] = windowInfoEX;
8751 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelAllTouches(pointerEvent));
8752
8753 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
8754 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelAllTouches(pointerEvent));
8755 }
8756
8757 /**
8758 * @tc.name: InputWindowsManagerTest_CancelAllTouches_003
8759 * @tc.desc: Test if (winOpt)
8760 * @tc.type: FUNC
8761 * @tc.require:
8762 */
8763 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CancelAllTouches_003, TestSize.Level1)
8764 {
8765 CALL_TEST_DEBUG;
8766 InputWindowsManager inputWindowsManager;
8767 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
8768 EXPECT_NE(pointerEvent, nullptr);
8769 PointerEvent::PointerItem pointerItem;
8770 pointerItem.SetPointerId(0);
8771 pointerItem.SetPressed(true);
8772 pointerItem.SetTargetWindowId(0);
8773 pointerEvent->AddPointerItem(pointerItem);
8774 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHPAD);
8775 pointerEvent->SetTargetDisplayId(-1);
8776
8777 WindowInfo windowInfo;
8778 windowInfo.id = 0;
8779 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
8780 if (it != inputWindowsManager.displayGroupInfoMap_.end()) {
8781 it->second.windowsInfo.push_back(windowInfo);
8782 }
8783 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelAllTouches(pointerEvent));
8784 }
8785 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH
8786
8787 #ifdef OHOS_BUILD_ENABLE_ONE_HAND_MODE
8788 /**
8789 * @tc.name: InputWindowsManagerTest_UpdateDisplayXYInOneHandMode_002
8790 * @tc.desc: Test UpdateDisplayXYInOneHandMode
8791 * @tc.type: FUNC
8792 * @tc.require:
8793 */
8794 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayXYInOneHandMode_002, TestSize.Level1)
8795 {
8796 CALL_TEST_DEBUG;
8797 InputWindowsManager inputWindowsManager;
8798 OLD::DisplayInfo disPlayInfo = {
8799 .id = 2,
8800 .oneHandX = 100,
8801 .oneHandY = 150,
8802 .width = 200,
8803 .name = "test",
8804 };
8805 float oneHandScale = 0.8;
8806 double physicalX = 200;
8807 double physicalY = 250;
8808 inputWindowsManager.UpdateDisplayXYInOneHandMode(physicalX, physicalY, disPlayInfo, oneHandScale);
8809 }
8810
8811 /**
8812 * @tc.name: InputWindowsManagerTest_UpdatePointerItemInOneHandMode_003
8813 * @tc.desc: Test UpdatePointerItemInOneHandMode
8814 * @tc.type: FUNC
8815 * @tc.require:
8816 */
8817 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerItemInOneHandMode_003, TestSize.Level1)
8818 {
8819 CALL_TEST_DEBUG;
8820 InputWindowsManager inputWindowsManager;
8821 OLD::DisplayInfo disPlayInfo = {
8822 .id = 2,
8823 .oneHandX = 100,
8824 .oneHandY = 150,
8825 .width = 200,
8826 .name = "test",
8827 .height = 250,
8828 .scalePercent = 150,
8829 };
8830 auto pointerEvent = PointerEvent::Create();
8831 int32_t pointerId = 3;
8832 pointerEvent->SetPointerId(pointerId);
8833 PointerEvent::PointerItem pointerItem;
8834 pointerItem.pointerId_ = pointerId;
8835 double physicalX = 20.3;
8836 double physicalY = 30.6;
8837 pointerItem.SetDisplayXPos(physicalX);
8838 pointerItem.SetDisplayYPos(physicalY);
8839 pointerEvent->AddPointerItem(pointerItem);
8840 ASSERT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePointerItemInOneHandMode(disPlayInfo, pointerEvent));
8841 }
8842
8843 /**
8844 * @tc.name: InputWindowsManagerTest_UpdatePointerItemInOneHandMode_004
8845 * @tc.desc: Test UpdatePointerItemInOneHandMode
8846 * @tc.type: FUNC
8847 * @tc.require:
8848 */
8849 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerItemInOneHandMode_004, TestSize.Level1)
8850 {
8851 CALL_TEST_DEBUG;
8852 InputWindowsManager inputWindowsManager;
8853 OLD::DisplayInfo disPlayInfo = {
8854 .id = 2,
8855 .oneHandX = 100,
8856 .oneHandY = 150,
8857 .width = 200,
8858 .name = "test",
8859 .height = 150,
8860 .scalePercent = 150,
8861 };
8862 auto pointerEvent = PointerEvent::Create();
8863 int32_t pointerId = 3;
8864 pointerEvent->SetPointerId(pointerId);
8865 PointerEvent::PointerItem pointerItem;
8866 pointerItem.pointerId_ = pointerId;
8867 double physicalX = 20.3;
8868 double physicalY = 30.6;
8869 pointerItem.SetDisplayXPos(physicalX);
8870 pointerItem.SetDisplayYPos(physicalY);
8871 pointerEvent->AddPointerItem(pointerItem);
8872 ASSERT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePointerItemInOneHandMode(disPlayInfo, pointerEvent));
8873 }
8874
8875 /**
8876 * @tc.name: InputWindowsManagerTest_UpdatePointerItemInOneHandMode_005
8877 * @tc.desc: Test UpdatePointerItemInOneHandMode
8878 * @tc.type: FUNC
8879 * @tc.require:
8880 */
8881 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerItemInOneHandMode_005, TestSize.Level1)
8882 {
8883 CALL_TEST_DEBUG;
8884 InputWindowsManager inputWindowsManager;
8885 OLD::DisplayInfo disPlayInfo = {
8886 .id = 2,
8887 .oneHandX = 100,
8888 .oneHandY = 150,
8889 .width = 200,
8890 .name = "test",
8891 .height = 250,
8892 .scalePercent = 50,
8893 };
8894 auto pointerEvent = PointerEvent::Create();
8895 int32_t pointerId = 3;
8896 pointerEvent->SetPointerId(pointerId);
8897 PointerEvent::PointerItem pointerItem;
8898 pointerItem.pointerId_ = pointerId;
8899 double physicalX = 20.3;
8900 double physicalY = 30.6;
8901 pointerItem.SetDisplayXPos(physicalX);
8902 pointerItem.SetDisplayYPos(physicalY);
8903 pointerEvent->bitwise_ = InputEvent::EVENT_FLAG_SIMULATE;
8904 pointerEvent->SetAutoToVirtualScreen(true);
8905 pointerEvent->AddPointerItem(pointerItem);
8906 ASSERT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePointerItemInOneHandMode(disPlayInfo, pointerEvent));
8907 }
8908
8909 /**
8910 * @tc.name: InputWindowsManagerTest_UpdatePointerItemInOneHandMode_006
8911 * @tc.desc: Test UpdatePointerItemInOneHandMode
8912 * @tc.type: FUNC
8913 * @tc.require:
8914 */
8915 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerItemInOneHandMode_006, TestSize.Level1)
8916 {
8917 CALL_TEST_DEBUG;
8918 InputWindowsManager inputWindowsManager;
8919 OLD::DisplayInfo disPlayInfo = {
8920 .id = 2,
8921 .oneHandX = 100,
8922 .oneHandY = 150,
8923 .width = 200,
8924 .name = "test",
8925 .height = 250,
8926 .scalePercent = 50,
8927 };
8928 auto pointerEvent = PointerEvent::Create();
8929 int32_t pointerId = 3;
8930 pointerEvent->SetPointerId(pointerId);
8931 PointerEvent::PointerItem pointerItem;
8932 pointerItem.pointerId_ = pointerId;
8933 double physicalX = 20.3;
8934 double physicalY = 30.6;
8935 pointerItem.SetDisplayXPos(physicalX);
8936 pointerItem.SetDisplayYPos(physicalY);
8937 pointerEvent->bitwise_ = InputEvent::EVENT_FLAG_NONE;
8938 pointerEvent->SetAutoToVirtualScreen(true);
8939 pointerEvent->AddPointerItem(pointerItem);
8940 ASSERT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePointerItemInOneHandMode(disPlayInfo, pointerEvent));
8941 }
8942
8943 /**
8944 * @tc.name: InputWindowsManagerTest_UpdatePointerItemInOneHandMode_007
8945 * @tc.desc: Test UpdatePointerItemInOneHandMode
8946 * @tc.type: FUNC
8947 * @tc.require:
8948 */
8949 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerItemInOneHandMode_007, TestSize.Level1)
8950 {
8951 CALL_TEST_DEBUG;
8952 InputWindowsManager inputWindowsManager;
8953 OLD::DisplayInfo disPlayInfo = {
8954 .id = 2,
8955 .oneHandX = 100,
8956 .oneHandY = 150,
8957 .width = 200,
8958 .name = "test",
8959 .height = 250,
8960 .scalePercent = 50,
8961 };
8962 auto pointerEvent = PointerEvent::Create();
8963 int32_t pointerId = 3;
8964 pointerEvent->SetPointerId(pointerId);
8965 PointerEvent::PointerItem pointerItem;
8966 pointerItem.pointerId_ = pointerId;
8967 double physicalX = 20.3;
8968 double physicalY = 30.6;
8969 pointerItem.SetDisplayXPos(physicalX);
8970 pointerItem.SetDisplayYPos(physicalY);
8971 pointerEvent->bitwise_ = InputEvent::EVENT_FLAG_SIMULATE;
8972 pointerEvent->SetAutoToVirtualScreen(false);
8973 pointerEvent->AddPointerItem(pointerItem);
8974 ASSERT_NO_FATAL_FAILURE(inputWindowsManager.UpdatePointerItemInOneHandMode(disPlayInfo, pointerEvent));
8975 }
8976 #endif // OHOS_BUILD_ENABLE_ONE_HAND_MODE
8977
8978 /**
8979 * @tc.name: InputWindowsManagerTest_CancelMouseEvent_003
8980 * @tc.desc: Test CancelMouseEvent
8981 * @tc.type: FUNC
8982 * @tc.require:
8983 */
8984 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CancelMouseEvent_003, TestSize.Level1)
8985 {
8986 CALL_TEST_DEBUG;
8987 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
8988 EXPECT_NE(pointerEvent, nullptr);
8989 InputWindowsManager inputWindowsManager;
8990 inputWindowsManager.lastPointerEvent_ = pointerEvent;
8991 inputWindowsManager.extraData_.appended = true;
8992 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
8993 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelMouseEvent());
8994 inputWindowsManager.extraData_.appended = true;
8995 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_UNKNOWN;
8996 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelMouseEvent());
8997 inputWindowsManager.extraData_.appended = false;
8998 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
8999 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelMouseEvent());
9000 inputWindowsManager.extraData_.appended = false;
9001 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_UNKNOWN;
9002 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.CancelMouseEvent());
9003 }
9004
9005 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_POINTER_DRAWING)
9006 /**
9007 * @tc.name: InputWindowsManagerTest_AdjustDragPosition_001
9008 * @tc.desc: Test AdjustDragPosition
9009 * @tc.type: FUNC
9010 * @tc.require:
9011 */
9012 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_AdjustDragPosition_001, TestSize.Level1)
9013 {
9014 CALL_TEST_DEBUG;
9015 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
9016 EXPECT_NE(pointerEvent, nullptr);
9017 InputWindowsManager inputWindowsManager;
9018 inputWindowsManager.lastPointerEvent_ = pointerEvent;
9019 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.AdjustDragPosition());
9020 }
9021 #endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_POINTER_DRAWING
9022
9023 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)
9024 /**
9025 * @tc.name: InputWindowsManagerTest_PrintEnterEventInfo_001
9026 * @tc.desc: Test PrintEnterEventInfo
9027 * @tc.type: FUNC
9028 * @tc.require:
9029 */
9030 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintEnterEventInfo_001, TestSize.Level1)
9031 {
9032 CALL_TEST_DEBUG;
9033 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
9034 EXPECT_NE(pointerEvent, nullptr);
9035 InputWindowsManager inputWindowsManager;
9036 pointerEvent->pointerAction_ = PointerEvent::POINTER_ACTION_LEAVE_WINDOW;
9037 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_UNKNOWN);
9038 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.PrintEnterEventInfo(pointerEvent));
9039 }
9040 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH
9041
9042 #ifdef OHOS_BUILD_ENABLE_TOUCH
9043 /**
9044 * @tc.name: InputWindowsManagerTest_TriggerTouchUpOnInvalidAreaEntry_001
9045 * @tc.desc: Test TriggerTouchUpOnInvalidAreaEntry
9046 * @tc.type: FUNC
9047 * @tc.require:
9048 */
9049 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_TriggerTouchUpOnInvalidAreaEntry_001, TestSize.Level1)
9050 {
9051 CALL_TEST_DEBUG;
9052 InputWindowsManager inputWindowsManager;
9053 inputWindowsManager.lastPointerEventforGesture_ = nullptr;
9054 int32_t pointerId = -5;
9055 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.TriggerTouchUpOnInvalidAreaEntry(pointerId));
9056 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
9057 EXPECT_NE(pointerEvent, nullptr);
9058 inputWindowsManager.lastPointerEventforGesture_ = pointerEvent;
9059 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.TriggerTouchUpOnInvalidAreaEntry(pointerId));
9060 PointerEvent::PointerItem pointerItem;
9061 pointerItem.pointerId_ = pointerId;
9062 pointerItem.canceled_ = true;
9063 pointerItem.pressed_ = true;
9064 pointerEvent->pointers_.push_back(pointerItem);
9065 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.TriggerTouchUpOnInvalidAreaEntry(pointerId));
9066 pointerItem.canceled_ = true;
9067 pointerItem.pressed_ = false;
9068 pointerEvent->pointers_.push_back(pointerItem);
9069 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.TriggerTouchUpOnInvalidAreaEntry(pointerId));
9070 pointerItem.canceled_ = false;
9071 pointerItem.pressed_ = true;
9072 pointerEvent->pointers_.push_back(pointerItem);
9073 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.TriggerTouchUpOnInvalidAreaEntry(pointerId));
9074 pointerItem.canceled_ = false;
9075 pointerItem.pressed_ = false;
9076 pointerEvent->pointers_.push_back(pointerItem);
9077 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.TriggerTouchUpOnInvalidAreaEntry(pointerId));
9078 }
9079 #endif // OHOS_BUILD_ENABLE_TOUCH
9080
9081 #ifdef OHOS_BUILD_ENABLE_ONE_HAND_MODE
9082 /**
9083 * @tc.name: InputWindowsManagerTest_UpdateDisplayXYInOneHandMode_001
9084 * @tc.desc: Test UpdateDisplayXYInOneHandMode
9085 * @tc.type: FUNC
9086 * @tc.require:
9087 */
9088 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayXYInOneHandMode_001, TestSize.Level1)
9089 {
9090 CALL_TEST_DEBUG;
9091 InputWindowsManager inputWindowsManager;
9092 double physicalX = 6;
9093 double physicalY = 6;
9094 float oneHandScale = 1.0;
9095 OLD::DisplayInfo displayInfo;
9096 displayInfo.oneHandY = 5;
9097 displayInfo.oneHandX = 5;
9098 displayInfo.width = 5;
9099 EXPECT_NO_FATAL_FAILURE(
9100 inputWindowsManager.UpdateDisplayXYInOneHandMode(physicalX, physicalY, displayInfo, oneHandScale));
9101 physicalX = 11;
9102 physicalY = 6;
9103 EXPECT_NO_FATAL_FAILURE(
9104 inputWindowsManager.UpdateDisplayXYInOneHandMode(physicalX, physicalY, displayInfo, oneHandScale));
9105 physicalX = 4;
9106 physicalY = 6;
9107 EXPECT_NO_FATAL_FAILURE(
9108 inputWindowsManager.UpdateDisplayXYInOneHandMode(physicalX, physicalY, displayInfo, oneHandScale));
9109 physicalX = 4;
9110 physicalY = 4;
9111 EXPECT_NO_FATAL_FAILURE(
9112 inputWindowsManager.UpdateDisplayXYInOneHandMode(physicalX, physicalY, displayInfo, oneHandScale));
9113 physicalX = 11;
9114 physicalY = 4;
9115 EXPECT_NO_FATAL_FAILURE(
9116 inputWindowsManager.UpdateDisplayXYInOneHandMode(physicalX, physicalY, displayInfo, oneHandScale));
9117 physicalX = 6;
9118 physicalY = 4;
9119 EXPECT_NO_FATAL_FAILURE(
9120 inputWindowsManager.UpdateDisplayXYInOneHandMode(physicalX, physicalY, displayInfo, oneHandScale));
9121 }
9122
9123 /**
9124 * @tc.name: InputWindowsManagerTest_HandleOneHandMode_001
9125 * @tc.desc: Test HandleOneHandMode
9126 * @tc.type: FUNC
9127 * @tc.require:
9128 */
9129 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandleOneHandMode_001, TestSize.Level1)
9130 {
9131 CALL_TEST_DEBUG;
9132 InputWindowsManager inputWindowsManager;
9133 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
9134 EXPECT_NE(pointerEvent, nullptr);
9135 PointerEvent::PointerItem pointerItem;
9136 pointerItem.pointerId_ = 2;
9137 pointerItem.canceled_ = true;
9138 pointerItem.pressed_ = true;
9139 OLD::DisplayInfo displayInfo;
9140 displayInfo.oneHandY = 5;
9141 displayInfo.oneHandX = 5;
9142 displayInfo.width = 5;
9143 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.HandleOneHandMode(displayInfo, pointerEvent, pointerItem));
9144 }
9145 #endif // OHOS_BUILD_ENABLE_ONE_HAND_MODE
9146
9147 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_POINTER_DRAWING)
9148 /**
9149 * @tc.name: InputWindowsManagerTest_DrawPointer_001
9150 * @tc.desc: Test DrawPointer
9151 * @tc.type: FUNC
9152 * @tc.require:
9153 */
9154 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DrawPointer_001, TestSize.Level1)
9155 {
9156 CALL_TEST_DEBUG;
9157 bool isDisplayRemoved = true;
9158 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9159 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->DrawPointer(isDisplayRemoved));
9160 }
9161 #endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_POINTER_DRAWING
9162
9163 /**
9164 * @tc.name: InputWindowsManagerTest_UpdateCaptureMode_003
9165 * @tc.desc: Test UpdateCaptureMode
9166 * @tc.type: FUNC
9167 * @tc.require:
9168 */
9169 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateCaptureMode_003, TestSize.Level1)
9170 {
9171 CALL_TEST_DEBUG;
9172 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9173 OLD::DisplayGroupInfo displayGroupInfo;
9174 WindowInfo windowInfo;
9175 inputWindowsManager->captureModeInfo_.isCaptureMode = true;
9176 auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
9177 if (it != inputWindowsManager->displayGroupInfoMap_.end()) {
9178 it->second.focusWindowId = 25;
9179 }
9180 displayGroupInfo.focusWindowId = 26;
9181 windowInfo.id = 10;
9182 it->second.windowsInfo.push_back(windowInfo);
9183 displayGroupInfo.windowsInfo.push_back(windowInfo);
9184 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->UpdateCaptureMode(displayGroupInfo));
9185
9186 inputWindowsManager->captureModeInfo_.isCaptureMode = false;
9187 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->UpdateCaptureMode(displayGroupInfo));
9188 }
9189
9190 #ifdef OHOS_BUILD_ENABLE_POINTER
9191 /**
9192 * @tc.name: InputWindowsManagerTest_NotifyPointerToWindow_002
9193 * @tc.desc: Test NotifyPointerToWindow
9194 * @tc.type: FUNC
9195 * @tc.require:
9196 */
9197 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_NotifyPointerToWindow_002, TestSize.Level1)
9198 {
9199 CALL_TEST_DEBUG;
9200 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9201 UDSServer udsServer;
9202 inputWindowsManager->lastPointerEvent_ = PointerEvent::Create();
9203 ASSERT_NE(inputWindowsManager->lastPointerEvent_, nullptr);
9204 inputWindowsManager->lastPointerEvent_->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
9205 inputWindowsManager->lastPointerEvent_->SetButtonPressed(PointerEvent::MOUSE_BUTTON_LEFT);
9206 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->NotifyPointerToWindow());
9207
9208 inputWindowsManager->lastPointerEvent_->pressedButtons_.clear();
9209 inputWindowsManager->lastPointerEvent_->bitwise_ = InputEvent::EVENT_FLAG_SIMULATE;
9210 PointerEvent::PointerItem pointerItem;
9211 pointerItem.pointerId_ = 100;
9212 pointerItem.canceled_ = true;
9213 pointerItem.pressed_ = true;
9214 inputWindowsManager->lastPointerEvent_->SetPointerId(pointerItem.pointerId_ + 1);
9215 inputWindowsManager->lastPointerEvent_->pointers_.push_back(pointerItem);
9216 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->NotifyPointerToWindow());
9217
9218 inputWindowsManager->lastPointerEvent_->SetPointerId(pointerItem.pointerId_);
9219 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->NotifyPointerToWindow());
9220 }
9221 #endif // OHOS_BUILD_ENABLE_POINTER
9222
9223 /**
9224 * @tc.name: InputWindowsManagerTest_PointerDrawingManagerOnDisplayInfo_002
9225 * @tc.desc: Test PointerDrawingManagerOnDisplayInfo
9226 * @tc.type: FUNC
9227 * @tc.require:
9228 */
9229 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PointerDrawingManagerOnDisplayInfo_002, TestSize.Level1)
9230 {
9231 CALL_TEST_DEBUG;
9232 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9233 OLD::DisplayGroupInfo displayGroupInfo;
9234 OLD::DisplayInfo displayInfo;
9235 displayInfo.id = 521;
9236 displayInfo.uniq = "uniq_test";
9237 displayInfo.dpi = 1000;
9238 displayGroupInfo.displaysInfo.push_back(displayInfo);
9239 displayInfo.dpi++;
9240 displayInfo.x = 300;
9241 displayInfo.y = 300;
9242 inputWindowsManager->lastDpi_ = displayInfo.dpi + 1;
9243 auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
9244 if (it != inputWindowsManager->displayGroupInfoMap_.end()) {
9245 it->second.displaysInfo.push_back(displayInfo);
9246 }
9247
9248 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->PointerDrawingManagerOnDisplayInfo(displayGroupInfo));
9249 }
9250
9251 /**
9252 * @tc.name: InputWindowsManagerTest_UpdatePointerDrawingManagerWindowInfo_002
9253 * @tc.desc: Test UpdatePointerDrawingManagerWindowInfo
9254 * @tc.type: FUNC
9255 * @tc.require:
9256 */
9257 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerDrawingManagerWindowInfo_002, TestSize.Level1)
9258 {
9259 CALL_TEST_DEBUG;
9260 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9261 inputWindowsManager->lastPointerEvent_ = PointerEvent::Create();
9262 EXPECT_NE(inputWindowsManager->lastPointerEvent_, nullptr);
9263 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->UpdatePointerDrawingManagerWindowInfo());
9264
9265 OLD::DisplayInfo displaysInfo;
9266 inputWindowsManager->lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
9267 inputWindowsManager->lastPointerEvent_->SetButtonPressed(1);
9268 auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
9269 if (it != inputWindowsManager->displayGroupInfoMap_.end()) {
9270 it->second.displaysInfo.push_back(displaysInfo);
9271 }
9272 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->UpdatePointerDrawingManagerWindowInfo());
9273 }
9274
9275 /**
9276 * @tc.name: InputWindowsManagerTest_UpdatePointerDrawingManagerWindowInfo_003
9277 * @tc.desc: Test UpdatePointerDrawingManagerWindowInfo
9278 * @tc.type: FUNC
9279 * @tc.require:
9280 */
9281 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerDrawingManagerWindowInfo_003, TestSize.Level1)
9282 {
9283 CALL_TEST_DEBUG;
9284 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9285 inputWindowsManager->lastPointerEvent_ = PointerEvent::Create();
9286 EXPECT_NE(inputWindowsManager->lastPointerEvent_, nullptr);
9287 OLD::DisplayInfo displaysInfo;
9288 inputWindowsManager->lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_UNKNOWN);
9289 auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
9290 if (it != inputWindowsManager->displayGroupInfoMap_.end()) {
9291 it->second.displaysInfo.push_back(displaysInfo);
9292 }
9293 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->UpdatePointerDrawingManagerWindowInfo());
9294 }
9295
9296 /**
9297 * @tc.name: InputWindowsManagerTest_UpdatePointerDrawingManagerWindowInfo_004
9298 * @tc.desc: Test UpdatePointerDrawingManagerWindowInfo
9299 * @tc.type: FUNC
9300 * @tc.require:
9301 */
9302 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerDrawingManagerWindowInfo_004, TestSize.Level1)
9303 {
9304 CALL_TEST_DEBUG;
9305 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9306 inputWindowsManager->lastPointerEvent_ = PointerEvent::Create();
9307 EXPECT_NE(inputWindowsManager->lastPointerEvent_, nullptr);
9308 OLD::DisplayInfo displaysInfo;
9309 inputWindowsManager->lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_UP);
9310 auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
9311 if (it != inputWindowsManager->displayGroupInfoMap_.end()) {
9312 it->second.displaysInfo.push_back(displaysInfo);
9313 }
9314 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->UpdatePointerDrawingManagerWindowInfo());
9315 }
9316
9317 /**
9318 * @tc.name: InputWindowsManagerTest_UpdatePointerDrawingManagerWindowInfo_005
9319 * @tc.desc: Test UpdatePointerDrawingManagerWindowInfo
9320 * @tc.type: FUNC
9321 * @tc.require:
9322 */
9323 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerDrawingManagerWindowInfo_005, TestSize.Level1)
9324 {
9325 CALL_TEST_DEBUG;
9326 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9327 inputWindowsManager->lastPointerEvent_ = PointerEvent::Create();
9328 EXPECT_NE(inputWindowsManager->lastPointerEvent_, nullptr);
9329 OLD::DisplayInfo displaysInfo;
9330 inputWindowsManager->lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_UP);
9331 auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
9332 if (it != inputWindowsManager->displayGroupInfoMap_.end()) {
9333 it->second.displaysInfo.push_back(displaysInfo);
9334 }
9335 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->UpdatePointerDrawingManagerWindowInfo());
9336 }
9337
9338 /**
9339 * @tc.name: InputWindowsManagerTest_UpdatePointerDrawingManagerWindowInfo_006
9340 * @tc.desc: Test UpdatePointerDrawingManagerWindowInfo
9341 * @tc.type: FUNC
9342 * @tc.require:
9343 */
9344 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdatePointerDrawingManagerWindowInfo_006, TestSize.Level1)
9345 {
9346 CALL_TEST_DEBUG;
9347 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9348 inputWindowsManager->lastPointerEvent_ = PointerEvent::Create();
9349 EXPECT_NE(inputWindowsManager->lastPointerEvent_, nullptr);
9350 OLD::DisplayInfo displaysInfo;
9351 inputWindowsManager->lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_DOWN);
9352 auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
9353 if (it != inputWindowsManager->displayGroupInfoMap_.end()) {
9354 it->second.displaysInfo.push_back(displaysInfo);
9355 }
9356 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->UpdatePointerDrawingManagerWindowInfo());
9357 }
9358
9359 /**
9360 * @tc.name: InputWindowsManagerTest_UpdateDisplayIdAndName_004
9361 * @tc.desc: Test updating display ID and name
9362 * @tc.type: FUNC
9363 * @tc.require:
9364 */
9365 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayIdAndName_004, TestSize.Level1)
9366 {
9367 CALL_TEST_DEBUG;
9368 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9369 OLD::DisplayInfo displaysInfo;
9370 displaysInfo.id = 1;
9371 displaysInfo.uniq = "abc";
9372 auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
9373 if (it != inputWindowsManager->displayGroupInfoMap_.end()) {
9374 it->second.displaysInfo.push_back(displaysInfo);
9375 }
9376 it->second.displaysInfo.push_back(displaysInfo);
9377
9378 inputWindowsManager->bindInfo_.AddDisplay(1, "abc");
9379 inputWindowsManager->bindInfo_.AddDisplay(1, "abc");
9380 inputWindowsManager->bindInfo_.AddDisplay(2, "abc");
9381 inputWindowsManager->bindInfo_.AddDisplay(1, "aaa");
9382 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->UpdateDisplayIdAndName());
9383 }
9384
9385 /* *
9386 * @tc.name: InputWindowsManagerTest_GetCursorPos_003
9387 * @tc.desc: Test the function GetCursorPos
9388 * @tc.type: FUNC
9389 * @tc.require:
9390 */
9391 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetCursorPos_003, TestSize.Level1)
9392 {
9393 CALL_TEST_DEBUG;
9394 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9395 CursorPosition cursorPosRef;
9396 auto it = inputWindowsManager->cursorPosMap_.find(DEFAULT_GROUP_ID);
9397 if (it != inputWindowsManager->cursorPosMap_.end()) {
9398 cursorPosRef = it->second;
9399 }
9400 cursorPosRef.displayId = -1;
9401 OLD::DisplayInfo displaysInfo;
9402 displaysInfo.id = 2;
9403 displaysInfo.width = 30;
9404 displaysInfo.height = 40;
9405 displaysInfo.validWidth = displaysInfo.width;
9406 displaysInfo.validHeight = displaysInfo.height;
9407 displaysInfo.name = "name2";
9408 displaysInfo.uniq = "uniq2";
9409 auto iter = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
9410 if (iter != inputWindowsManager->displayGroupInfoMap_.end()) {
9411 iter->second.displaysInfo.push_back(displaysInfo);
9412 }
9413 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->GetCursorPos());
9414 EXPECT_NE(cursorPosRef.displayId, displaysInfo.id);
9415 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->GetCursorPos());
9416 }
9417
9418 /* *
9419 * @tc.name: InputWindowsManagerTest_GetCursorPos_004
9420 * @tc.desc: Test the function GetCursorPos
9421 * @tc.type: FUNC
9422 * @tc.require:
9423 */
9424 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetCursorPos_004, TestSize.Level1)
9425 {
9426 CALL_TEST_DEBUG;
9427 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9428 CursorPosition cursorPosRef;
9429 auto it = inputWindowsManager->cursorPosMap_.find(DEFAULT_GROUP_ID);
9430 if (it != inputWindowsManager->cursorPosMap_.end()) {
9431 cursorPosRef = it->second;
9432 }
9433 cursorPosRef.displayId = -1;
9434 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->GetCursorPos());
9435 }
9436
9437 /* *
9438 * @tc.name: InputWindowsManagerTest_ResetPointerPositionIfOutValidDisplay_002
9439 * @tc.desc: Test the function ResetPointerPositionIfOutValidDisplay
9440 * @tc.type: FUNC
9441 * @tc.require:
9442 */
9443 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ResetPointerPositionIfOutValidDisplay_002, TestSize.Level1)
9444 {
9445 CALL_TEST_DEBUG;
9446 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9447 OLD::DisplayInfo displaysInfo;
9448 OLD::DisplayGroupInfo displayGroupInfo;
9449 displaysInfo.id = 2;
9450 displaysInfo.width = 30;
9451 displaysInfo.height = 40;
9452 displaysInfo.validWidth = displaysInfo.width;
9453 displaysInfo.validHeight = displaysInfo.height;
9454 displaysInfo.name = "name2";
9455 displaysInfo.uniq = "uniq2";
9456 displayGroupInfo.displaysInfo.push_back(displaysInfo);
9457 CursorPosition cursorPosRef;
9458 auto it = inputWindowsManager->cursorPosMap_.find(DEFAULT_GROUP_ID);
9459 if (it != inputWindowsManager->cursorPosMap_.end()) {
9460 cursorPosRef = it->second;
9461 }
9462 cursorPosRef.displayId = displaysInfo.id;
9463 cursorPosRef.cursorPos.x = 300;
9464 cursorPosRef.cursorPos.y = 300;
9465
9466 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ResetPointerPositionIfOutValidDisplay(displayGroupInfo));
9467 }
9468
9469 /* *
9470 * @tc.name: InputWindowsManagerTest_CancelTouchScreenEventIfValidDisplayChange_003
9471 * @tc.desc: Test the function CancelTouchScreenEventIfValidDisplayChange
9472 * @tc.type: FUNC
9473 * @tc.require:
9474 */
9475 HWTEST_F(
9476 InputWindowsManagerTest, InputWindowsManagerTest_CancelTouchScreenEventIfValidDisplayChange_003, TestSize.Level1)
9477 {
9478 CALL_TEST_DEBUG;
9479 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9480 OLD::DisplayGroupInfo displayGroupInfo;
9481 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
9482 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_UNKNOWN);
9483 EXPECT_NE(pointerEvent, nullptr);
9484 inputWindowsManager->lastPointerEventforGesture_ = pointerEvent;
9485 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->CancelTouchScreenEventIfValidDisplayChange(displayGroupInfo));
9486
9487 OLD::DisplayInfo displaysInfo;
9488 displaysInfo.id = 100;
9489 pointerEvent->SetTargetDisplayId(displaysInfo.id);
9490 auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
9491 if (it != inputWindowsManager->displayGroupInfoMap_.end()) {
9492 it->second.displaysInfo.push_back(displaysInfo);
9493 }
9494 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
9495 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->CancelTouchScreenEventIfValidDisplayChange(displayGroupInfo));
9496 }
9497
9498 /* *
9499 * @tc.name: InputWindowsManagerTest_CancelTouchScreenEventIfValidDisplayChange_004
9500 * @tc.desc: Test the function CancelTouchScreenEventIfValidDisplayChange
9501 * @tc.type: FUNC
9502 * @tc.require:
9503 */
9504 HWTEST_F(
9505 InputWindowsManagerTest, InputWindowsManagerTest_CancelTouchScreenEventIfValidDisplayChange_004, TestSize.Level1)
9506 {
9507 CALL_TEST_DEBUG;
9508 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9509 OLD::DisplayGroupInfo displayGroupInfo;
9510 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
9511 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_UNKNOWN);
9512 EXPECT_NE(pointerEvent, nullptr);
9513 OLD::DisplayInfo displaysInfo;
9514 displaysInfo.id = 100;
9515 pointerEvent->SetTargetDisplayId(displaysInfo.id + 1);
9516 displayGroupInfo.displaysInfo.push_back(displaysInfo);
9517 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
9518 inputWindowsManager->lastPointerEventforGesture_ = pointerEvent;
9519 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->CancelTouchScreenEventIfValidDisplayChange(displayGroupInfo));
9520 }
9521
9522 /* *
9523 * @tc.name: InputWindowsManagerTest_CancelTouchScreenEventIfValidDisplayChange_005
9524 * @tc.desc: Test the function CancelTouchScreenEventIfValidDisplayChange
9525 * @tc.type: FUNC
9526 * @tc.require:
9527 */
9528 HWTEST_F(
9529 InputWindowsManagerTest, InputWindowsManagerTest_CancelTouchScreenEventIfValidDisplayChange_005, TestSize.Level1)
9530 {
9531 CALL_TEST_DEBUG;
9532 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9533 OLD::DisplayInfo displaysInfo;
9534 OLD::DisplayGroupInfo displayGroupInfo;
9535 displaysInfo.id = 2;
9536 displaysInfo.width = 30;
9537 displaysInfo.height = 40;
9538 displaysInfo.validWidth = displaysInfo.width;
9539 displaysInfo.validHeight = displaysInfo.height;
9540 displaysInfo.name = "name2";
9541 displaysInfo.uniq = "uniq2";
9542 displayGroupInfo.displaysInfo.push_back(displaysInfo);
9543 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
9544 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_UNKNOWN);
9545 EXPECT_NE(pointerEvent, nullptr);
9546 inputWindowsManager->lastPointerEventforGesture_ = pointerEvent;
9547 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->CancelTouchScreenEventIfValidDisplayChange(displayGroupInfo));
9548 pointerEvent->SetTargetDisplayId(displaysInfo.id);
9549 auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
9550 if (it != inputWindowsManager->displayGroupInfoMap_.end()) {
9551 it->second.displaysInfo.push_back(displaysInfo);
9552 }
9553 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
9554 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->CancelTouchScreenEventIfValidDisplayChange(displayGroupInfo));
9555 }
9556
9557 /* *
9558 * @tc.name: InputWindowsManagerTest_CancelTouchScreenEventIfValidDisplayChange_006
9559 * @tc.desc: Test the function CancelTouchScreenEventIfValidDisplayChange
9560 * @tc.type: FUNC
9561 * @tc.require:
9562 */
9563 HWTEST_F(
9564 InputWindowsManagerTest, InputWindowsManagerTest_CancelTouchScreenEventIfValidDisplayChange_006, TestSize.Level1)
9565 {
9566 CALL_TEST_DEBUG;
9567 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9568 OLD::DisplayInfo displaysInfo;
9569 OLD::DisplayGroupInfo displayGroupInfo;
9570 displaysInfo.id = 2;
9571 displaysInfo.width = 30;
9572 displaysInfo.height = 40;
9573 displaysInfo.validWidth = displaysInfo.width;
9574 displaysInfo.validHeight = displaysInfo.height;
9575 displaysInfo.name = "name2";
9576 displaysInfo.uniq = "uniq2";
9577 displayGroupInfo.displaysInfo.push_back(displaysInfo);
9578 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
9579 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
9580 pointerEvent->SetTargetDisplayId(0);
9581 EXPECT_NE(pointerEvent, nullptr);
9582 inputWindowsManager->lastPointerEventforGesture_ = pointerEvent;
9583 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->CancelTouchScreenEventIfValidDisplayChange(displayGroupInfo));
9584 }
9585
9586 /**
9587 * @tc.name: InputWindowsManagerTest_UpdateDisplayInfo_006
9588 * @tc.desc: Test UpdateDisplayInfo
9589 * @tc.type: FUNC
9590 * @tc.require:
9591 */
9592 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayInfo_006, TestSize.Level1)
9593 {
9594 CALL_TEST_DEBUG;
9595 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9596 OLD::DisplayGroupInfo displayGroupInfo;
9597 OLD::DisplayInfo info;
9598 info.scalePercent = inputWindowsManager->scalePercent_ + 1;
9599 displayGroupInfo.displaysInfo.emplace_back(info);
9600 ASSERT_NO_FATAL_FAILURE(inputWindowsManager->UpdateDisplayInfo(displayGroupInfo));
9601 }
9602
9603 /**
9604 * @tc.name: InputWindowsManagerTest_UpdateWindowInfo_002
9605 * @tc.desc: Test the funcation UpdateWindowInfo
9606 * @tc.type: FUNC
9607 * @tc.require:
9608 */
9609 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateWindowInfo_002, TestSize.Level1)
9610 {
9611 CALL_TEST_DEBUG;
9612 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9613 OLD::DisplayGroupInfo displayGroupInfo;
9614 displayGroupInfo.focusWindowId = 1;
9615
9616 WindowInfo windowInfo;
9617 windowInfo.id = 1;
9618 windowInfo.pid = 1;
9619 windowInfo.uid = 1;
9620 windowInfo.area = {1, 1, 1, 1};
9621 windowInfo.defaultHotAreas = {windowInfo.area};
9622 windowInfo.pointerHotAreas = {windowInfo.area};
9623 windowInfo.agentWindowId = 1;
9624 windowInfo.flags = 1;
9625 windowInfo.transform = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};
9626 windowInfo.pointerChangeAreas = {1, 2, 1, 2, 1, 2, 1, 2, 1};
9627 windowInfo.action = WINDOW_UPDATE_ACTION::ADD;
9628 displayGroupInfo.windowsInfo.push_back(windowInfo);
9629
9630 #ifdef OHOS_BUILD_ENABLE_ANCO
9631 NiceMock<MockInputWindowsManager> mockInputWindowsManager;
9632 EXPECT_CALL(mockInputWindowsManager, IsAncoWindow).WillRepeatedly(Return(true));
9633 #endif // OHOS_BUILD_ENABLE_ANCO
9634 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->UpdateWindowInfo(displayGroupInfo));
9635
9636 displayGroupInfo.windowsInfo.clear();
9637 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->UpdateWindowInfo(displayGroupInfo));
9638 }
9639
9640 /**
9641 * @tc.name: InputWindowsManagerTest_PrintWindowNavbar_001
9642 * @tc.desc: Test the funcation PrintWindowNavbar
9643 * @tc.type: FUNC
9644 * @tc.require:
9645 */
9646 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintWindowNavbar_001, TestSize.Level1)
9647 {
9648 CALL_TEST_DEBUG;
9649 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9650 WindowInfo windowInfo;
9651 windowInfo.id = 20;
9652 windowInfo.windowInputType = WindowInputType::MIX_BUTTOM_ANTI_AXIS_MOVE;
9653 auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
9654 if (it != inputWindowsManager->displayGroupInfoMap_.end()) {
9655 it->second.windowsInfo.push_back(windowInfo);
9656 }
9657 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->PrintWindowNavbar());
9658 }
9659
9660 /**
9661 * @tc.name: InputWindowsManagerTest_PrintWindowNavbar_002
9662 * @tc.desc: Test the function PrintWindowNavbar
9663 * @tc.type: FUNC
9664 * @tc.require:
9665 */
9666 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintWindowNavbar_002, TestSize.Level1)
9667 {
9668 CALL_TEST_DEBUG;
9669 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9670 WindowInfo windowInfo;
9671 windowInfo.id = 21;
9672 windowInfo.windowInputType = WindowInputType::DUALTRIGGER_TOUCH;
9673 auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
9674 if (it != inputWindowsManager->displayGroupInfoMap_.end()) {
9675 it->second.windowsInfo.push_back(windowInfo);
9676 }
9677 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->PrintWindowNavbar());
9678 }
9679
9680 /**
9681 * @tc.name: InputWindowsManagerTest_CancelMouseEvent_004
9682 * @tc.desc: Test CancelMouseEvent
9683 * @tc.type: FUNC
9684 * @tc.require:
9685 */
9686 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CancelMouseEvent_004, TestSize.Level1)
9687 {
9688 CALL_TEST_DEBUG;
9689 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
9690 EXPECT_NE(pointerEvent, nullptr);
9691 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9692 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
9693 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_LEFT);
9694 pointerEvent->pointers_.clear();
9695 inputWindowsManager->lastPointerEvent_ = pointerEvent;
9696 inputWindowsManager->extraData_.appended = true;
9697 inputWindowsManager->extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
9698 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->CancelMouseEvent());
9699 }
9700
9701 /**
9702 * @tc.name: InputWindowsManagerTest_CancelMouseEvent_005
9703 * @tc.desc: Test CancelMouseEvent
9704 * @tc.type: FUNC
9705 * @tc.require:
9706 */
9707 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CancelMouseEvent_005, TestSize.Level1)
9708 {
9709 CALL_TEST_DEBUG;
9710 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
9711 EXPECT_NE(pointerEvent, nullptr);
9712 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9713 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
9714 pointerEvent->SetButtonPressed(PointerEvent::MOUSE_BUTTON_LEFT);
9715 PointerEvent::PointerItem pointerItem;
9716 pointerItem.pointerId_ = 0;
9717 pointerItem.canceled_ = true;
9718 pointerItem.pressed_ = true;
9719 pointerEvent->pointers_.push_back(pointerItem);
9720 inputWindowsManager->lastPointerEvent_ = pointerEvent;
9721 inputWindowsManager->extraData_.appended = true;
9722 inputWindowsManager->extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
9723 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->CancelMouseEvent());
9724 }
9725
9726 /**
9727 * @tc.name: InputWindowsManagerTest_CancelMouseEvent_006
9728 * @tc.desc: Test CancelMouseEvent
9729 * @tc.type: FUNC
9730 * @tc.require:
9731 */
9732 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CancelMouseEvent_006, TestSize.Level1)
9733 {
9734 CALL_TEST_DEBUG;
9735 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
9736 EXPECT_NE(pointerEvent, nullptr);
9737 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9738 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
9739 pointerEvent->pressedButtons_.clear();
9740 inputWindowsManager->lastPointerEvent_ = pointerEvent;
9741 inputWindowsManager->extraData_.appended = true;
9742 inputWindowsManager->extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
9743 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->CancelMouseEvent());
9744 }
9745
9746 /**
9747 * @tc.name: InputWindowsManagerTest_CancelMouseEvent_007
9748 * @tc.desc: Test CancelMouseEvent
9749 * @tc.type: FUNC
9750 * @tc.require:
9751 */
9752 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CancelMouseEvent_007, TestSize.Level1)
9753 {
9754 CALL_TEST_DEBUG;
9755 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
9756 EXPECT_NE(pointerEvent, nullptr);
9757 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9758 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_UNKNOWN);
9759 pointerEvent->pressedButtons_.clear();
9760 inputWindowsManager->lastPointerEvent_ = pointerEvent;
9761 inputWindowsManager->extraData_.appended = true;
9762 inputWindowsManager->extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
9763 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->CancelMouseEvent());
9764 }
9765
9766 /**
9767 * @tc.name: InputWindowsManagerTest_DeviceStatusChanged_001
9768 * @tc.desc: DeviceStatusChanged
9769 * @tc.type: FUNC
9770 * @tc.require:
9771 */
9772 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DeviceStatusChanged_001, TestSize.Level1)
9773 {
9774 CALL_TEST_DEBUG;
9775 int32_t deviceId = 0;
9776 std::string name = "mouse";
9777 std::string sysUid = "";
9778 std::string devStatus = "add";
9779 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9780 ASSERT_NO_FATAL_FAILURE(inputWindowsManager->DeviceStatusChanged(deviceId, name, sysUid, devStatus));
9781
9782 devStatus = "test";
9783 ASSERT_NO_FATAL_FAILURE(inputWindowsManager->DeviceStatusChanged(deviceId, name, sysUid, devStatus));
9784 }
9785
9786 #ifdef OHOS_BUILD_ENABLE_TOUCH
9787 /**
9788 * @tc.name: InputWindowsManagerTest_ReissueCancelTouchEvent_002
9789 * @tc.desc: Test the funcation ReissueCancelTouchEvent
9790 * @tc.type: FUNC
9791 * @tc.require:
9792 */
9793 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ReissueCancelTouchEvent_002, TestSize.Level1)
9794 {
9795 CALL_TEST_DEBUG;
9796 int32_t pointerId = 100;
9797 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9798 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
9799 ASSERT_NE(pointerEvent, nullptr);
9800 inputWindowsManager->extraData_.appended = true;
9801 inputWindowsManager->extraData_.sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
9802 inputWindowsManager->extraData_.pointerId = pointerId;
9803 PointerEvent::PointerItem item;
9804 item.SetPointerId(pointerId);
9805 item.SetToolType(PointerEvent::TOOL_TYPE_FINGER);
9806 item.SetPressed(true);
9807 WindowInfoEX windowInfoEX;
9808 windowInfoEX.flag = true;
9809 inputWindowsManager->touchItemDownInfos_.insert(std::make_pair(pointerId, windowInfoEX));
9810 pointerEvent->AddPointerItem(item);
9811 EXPECT_EQ(pointerEvent->pointers_.size(), 1);
9812
9813 std::shared_ptr<EventNormalizeHandler> handler = std::make_shared<EventNormalizeHandler>();
9814 NiceMock<MockInputWindowsManager> mockInputWindowsManager;
9815 EXPECT_CALL(mockInputWindowsManager, GetEventNormalizeHandler).WillRepeatedly(Return(handler));
9816
9817 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ReissueCancelTouchEvent(pointerEvent));
9818 }
9819
9820 /**
9821 * @tc.name: InputWindowsManagerTest_ReissueCancelTouchEvent_003
9822 * @tc.desc: Test the funcation ReissueCancelTouchEvent
9823 * @tc.type: FUNC
9824 * @tc.require:
9825 */
9826 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ReissueCancelTouchEvent_003, TestSize.Level1)
9827 {
9828 CALL_TEST_DEBUG;
9829 int32_t pointerId = 100;
9830 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9831 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
9832 ASSERT_NE(pointerEvent, nullptr);
9833 inputWindowsManager->extraData_.appended = true;
9834 inputWindowsManager->extraData_.sourceType = PointerEvent::SOURCE_TYPE_TOUCHSCREEN;
9835 inputWindowsManager->extraData_.pointerId = pointerId + 1;
9836 PointerEvent::PointerItem item;
9837 item.SetPointerId(pointerId);
9838 item.SetToolType(PointerEvent::TOOL_TYPE_FINGER);
9839 item.SetPressed(true);
9840 WindowInfoEX windowInfoEX;
9841 windowInfoEX.flag = true;
9842 inputWindowsManager->touchItemDownInfos_.insert(std::make_pair(pointerId, windowInfoEX));
9843 pointerEvent->AddPointerItem(item);
9844 EXPECT_EQ(pointerEvent->pointers_.size(), 1);
9845
9846 std::shared_ptr<EventNormalizeHandler> handler = std::make_shared<EventNormalizeHandler>();
9847 NiceMock<MockInputWindowsManager> mockInputWindowsManager;
9848 EXPECT_CALL(mockInputWindowsManager, GetEventNormalizeHandler).WillRepeatedly(Return(handler));
9849
9850 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->ReissueCancelTouchEvent(pointerEvent));
9851 }
9852 #endif // OHOS_BUILD_ENABLE_TOUCH
9853
9854 /**
9855 * @tc.name: InputWindowsManagerTest_CheckAppFocused_001
9856 * @tc.desc: Test the funcation CheckAppFocused
9857 * @tc.type: FUNC
9858 * @tc.require:
9859 */
9860 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CheckAppFocused_001, TestSize.Level1)
9861 {
9862 CALL_TEST_DEBUG;
9863 int32_t pid = 100;
9864 WindowInfo windowInfo;
9865 windowInfo.pid = pid;
9866 windowInfo.id = pid;
9867 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
9868 auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
9869 if (it != inputWindowsManager->displayGroupInfoMap_.end()) {
9870 it->second.windowsInfo.clear();
9871 it->second.windowsInfo.emplace_back(windowInfo);
9872 it->second.focusWindowId = pid;
9873 }
9874 EXPECT_TRUE(inputWindowsManager->CheckAppFocused(pid));
9875
9876 pid++;
9877 EXPECT_FALSE(inputWindowsManager->CheckAppFocused(pid));
9878
9879 it->second.focusWindowId = pid + 1;
9880 EXPECT_FALSE(inputWindowsManager->CheckAppFocused(pid));
9881 }
9882
9883 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)
9884 /**
9885 * @tc.name: InputWindowsManagerTest_CalculateAcrossDirection_001
9886 * @tc.desc: Test CalculateAcrossDirection
9887 * @tc.type: FUNC
9888 * @tc.require:
9889 */
9890 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_CalculateAcrossDirection_001, TestSize.Level1)
9891 {
9892 CALL_TEST_DEBUG;
9893 InputWindowsManager inputWindowsManager;
9894 Vector2D<double> layout;
9895 OLD::DisplayInfo displayInfo;
9896 displayInfo.x = 100;
9897 displayInfo.validWidth = 2147483600;
9898 auto ret = inputWindowsManager.CalculateAcrossDirection(displayInfo, layout);
9899 EXPECT_EQ(ret, AcrossDirection::ACROSS_ERROR);
9900 displayInfo.x = 100;
9901 displayInfo.validWidth = 100;
9902 displayInfo.y = 100;
9903 displayInfo.validHeight = 2147483600;
9904 ret = inputWindowsManager.CalculateAcrossDirection(displayInfo, layout);
9905 EXPECT_EQ(ret, AcrossDirection::ACROSS_ERROR);
9906 displayInfo.x = 100;
9907 displayInfo.validWidth = 100;
9908 displayInfo.y = 100;
9909 displayInfo.validHeight = 100;
9910 layout.x = 50;
9911 ret = inputWindowsManager.CalculateAcrossDirection(displayInfo, layout);
9912 EXPECT_EQ(ret, AcrossDirection::LEFTWARDS);
9913 displayInfo.x = -2147483648;
9914 layout.x = -2147483600;
9915 displayInfo.y = 100;
9916 layout.y = 50;
9917 ret = inputWindowsManager.CalculateAcrossDirection(displayInfo, layout);
9918 EXPECT_EQ(ret, AcrossDirection::UPWARDS);
9919 displayInfo.y = -2147483648;
9920 layout.y = -2147483600;
9921 ret = inputWindowsManager.CalculateAcrossDirection(displayInfo, layout);
9922 EXPECT_EQ(ret, AcrossDirection::ACROSS_ERROR);
9923 }
9924
9925 /**
9926 * @tc.name: InputWindowsManagerTest_HandlePullEvent_001
9927 * @tc.desc: Test HandlePullEvent
9928 * @tc.type: FUNC
9929 * @tc.require:
9930 */
9931 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandlePullEvent_001, TestSize.Level1)
9932 {
9933 CALL_TEST_DEBUG;
9934 InputWindowsManager inputWindowsManager;
9935 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
9936 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_CANCEL);
9937 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.HandlePullEvent(pointerEvent));
9938 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_MOVE);
9939 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.HandlePullEvent(pointerEvent));
9940 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
9941 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.HandlePullEvent(pointerEvent));
9942 }
9943 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH
9944
9945 #ifdef OHOS_BUILD_ENABLE_VKEYBOARD
9946 /**
9947 * @tc.name: InputWindowsManagerTest_IsPointInsideSpecialWindow_001
9948 * @tc.desc: Test that IsPointInsideSpecialWindow should return false when there is no window information
9949 * @tc.type: FUNC
9950 * @tc.require:
9951 */
9952 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsPointInsideSpecialWindow_001, TestSize.Level1)
9953 {
9954 CALL_TEST_DEBUG;
9955 InputWindowsManager inputWindowsManager;
9956 inputWindowsManager.displayGroupInfo_.windowsInfo.clear();
9957 EXPECT_FALSE(inputWindowsManager.IsPointInsideSpecialWindow(0, 0));
9958 }
9959
9960 /**
9961 * @tc.name: InputWindowsManagerTest_IsPointInsideSpecialWindow_002
9962 * @tc.desc: Test that IsPointInsideSpecialWindow should return false when the window type is not guide window
9963 * @tc.type: FUNC
9964 * @tc.require:
9965 */
9966 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsPointInsideSpecialWindow_002, TestSize.Level1)
9967 {
9968 CALL_TEST_DEBUG;
9969 InputWindowsManager inputWindowsManager;
9970 WindowInfo windowInfo;
9971 windowInfo.windowType = GUIDE_WINDOW_TYPE + 1;
9972 inputWindowsManager.displayGroupInfo_.windowsInfo.push_back(windowInfo);
9973 EXPECT_FALSE(inputWindowsManager.IsPointInsideSpecialWindow(0, 0));
9974 }
9975
9976 /**
9977 * @tc.name: InputWindowsManagerTest_IsPointInsideSpecialWindow_003
9978 * @tc.desc: Test that IsPointInsideSpecialWindow should return false
9979 when the window type is guide window, but the point is not within it
9980 * @tc.type: FUNC
9981 * @tc.require:
9982 */
9983 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsPointInsideSpecialWindow_003, TestSize.Level1)
9984 {
9985 CALL_TEST_DEBUG;
9986 WindowInfo testWindow;
9987 testWindow.windowType = GUIDE_WINDOW_TYPE;
9988 Rect rect = {TEST_WINDOW_START, TEST_WINDOW_START, TEST_WINDOW_END, TEST_WINDOW_END};
9989 testWindow.defaultHotAreas.push_back(rect);
9990
9991 InputWindowsManager manager;
9992 manager.displayGroupInfo_.windowsInfo.push_back(testWindow);
9993
9994 bool result = manager.IsPointInsideSpecialWindow(TEST_WINDOW_START - 1, TEST_WINDOW_START - 1);
9995 EXPECT_FALSE(result);
9996 }
9997
9998 /**
9999 * @tc.name: InputWindowsManagerTest_IsPointInsideSpecialWindow_004
10000 * @tc.desc: Test that IsPointInsideSpecialWindow should return true
10001 when the window type is guide window, abd the point is within it
10002 * @tc.type: FUNC
10003 * @tc.require:
10004 */
10005 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsPointInsideSpecialWindow_004, TestSize.Level1)
10006 {
10007 CALL_TEST_DEBUG;
10008 WindowInfo testWindow;
10009 testWindow.windowType = GUIDE_WINDOW_TYPE;
10010 Rect rect = {TEST_WINDOW_START, TEST_WINDOW_START, TEST_WINDOW_END, TEST_WINDOW_END};
10011 testWindow.defaultHotAreas.push_back(rect);
10012
10013 InputWindowsManager manager;
10014 manager.displayGroupInfo_.windowsInfo.push_back(testWindow);
10015
10016 bool result = manager.IsPointInsideSpecialWindow(0, 0);
10017 EXPECT_TRUE(result);
10018 }
10019
10020 /**
10021 * @tc.name: InputWindowsManagerTest_IsPointInsideSpecialWindow_005
10022 * @tc.desc: Test that IsPointInsideSpecialWindow should return false
10023 when the window zorder is xiaoyi voice input window, but the point is not within it
10024 * @tc.type: FUNC
10025 * @tc.require:
10026 */
10027 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsPointInsideSpecialWindow_005, TestSize.Level1)
10028 {
10029 CALL_TEST_DEBUG;
10030 WindowInfo testWindow;
10031 testWindow.zOrder = 4000;
10032 testWindow.area.x = TEST_WINDOW_START;
10033 testWindow.area.y = TEST_WINDOW_START;
10034 testWindow.area.width = TEST_WINDOW_END;
10035 testWindow.area.height = TEST_WINDOW_END;
10036
10037 InputWindowsManager manager;
10038 manager.displayGroupInfo_.windowsInfo.push_back(testWindow);
10039
10040 bool result = manager.IsPointInsideSpecialWindow(TEST_WINDOW_START - 1, TEST_WINDOW_START - 1);
10041 EXPECT_FALSE(result);
10042 }
10043
10044 /**
10045 * @tc.name: InputWindowsManagerTest_IsPointInsideSpecialWindow_006
10046 * @tc.desc: Test that IsPointInsideSpecialWindow should return true
10047 when the window zorder is xiaoyi voice input window, and the point is within it
10048 * @tc.type: FUNC
10049 * @tc.require:
10050 */
10051 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsPointInsideSpecialWindow_006, TestSize.Level1)
10052 {
10053 CALL_TEST_DEBUG;
10054 WindowInfo testWindow;
10055 testWindow.zOrder = 4000;
10056 testWindow.area.x = TEST_WINDOW_START;
10057 testWindow.area.y = TEST_WINDOW_START;
10058 testWindow.area.width = TEST_WINDOW_END;
10059 testWindow.area.height = TEST_WINDOW_END;
10060
10061 InputWindowsManager manager;
10062 manager.displayGroupInfo_.windowsInfo.push_back(testWindow);
10063
10064 bool result = manager.IsPointInsideSpecialWindow(0, 0);
10065 EXPECT_TRUE(result);
10066 }
10067
10068 /**
10069 * @tc.name: InputWindowsManagerTest_IsPointInsideWindowArea_001
10070 * @tc.desc: Test that IsPointInsideWindowArea should return false
10071 when the point is not within the window area
10072 * @tc.type: FUNC
10073 * @tc.require:
10074 */
10075 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsPointInsideWindowArea_001, TestSize.Level1)
10076 {
10077 CALL_TEST_DEBUG;
10078 WindowInfo testWindow;
10079 testWindow.area.x = TEST_WINDOW_START;
10080 testWindow.area.y = TEST_WINDOW_START;
10081 testWindow.area.width = TEST_WINDOW_END;
10082 testWindow.area.height = TEST_WINDOW_END;
10083
10084 InputWindowsManager manager;
10085 manager.displayGroupInfo_.windowsInfo.push_back(testWindow);
10086
10087 bool result = manager.IsPointInsideWindowArea(
10088 TEST_WINDOW_START - 1, TEST_WINDOW_START - 1, manager.displayGroupInfo_.windowsInfo[0]);
10089 EXPECT_FALSE(result);
10090 }
10091
10092 /**
10093 * @tc.name: InputWindowsManagerTest_IsPointInsideWindowArea_002
10094 * @tc.desc: Test that IsPointInsideWindowArea should return true
10095 when the point is within the window area
10096 * @tc.type: FUNC
10097 * @tc.require:
10098 */
10099 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsPointInsideWindowArea_002, TestSize.Level1)
10100 {
10101 CALL_TEST_DEBUG;
10102 WindowInfo testWindow;
10103 testWindow.area.x = TEST_WINDOW_START;
10104 testWindow.area.y = TEST_WINDOW_START;
10105 testWindow.area.width = TEST_WINDOW_END;
10106 testWindow.area.height = TEST_WINDOW_END;
10107
10108 InputWindowsManager manager;
10109 manager.displayGroupInfo_.windowsInfo.push_back(testWindow);
10110
10111 bool result = manager.IsPointInsideWindowArea(0, 0, manager.displayGroupInfo_.windowsInfo[0]);
10112 EXPECT_TRUE(result);
10113 }
10114 /**
10115 * @tc.name: InputWindowsManagerTest_IsMouseInCastWindow_001
10116 * @tc.desc: Test that IsMouseInCastWindow should return false when there is no window information
10117 * @tc.type: FUNC
10118 * @tc.require:
10119 */
10120 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsMouseInCastWindow_001, TestSize.Level1)
10121 {
10122 CALL_TEST_DEBUG;
10123 InputWindowsManager inputWindowsManager;
10124 inputWindowsManager.displayGroupInfo_.windowsInfo.clear();
10125 EXPECT_FALSE(inputWindowsManager.IsMouseInCastWindow());
10126 }
10127
10128 /**
10129 * @tc.name: InputWindowsManagerTest_IsMouseInCastWindow_002
10130 * @tc.desc: Test whether IsMouseInCastWindow returns false when there is window information
10131 * but no window of the CAST_WINDOW_TYPE type.
10132 * @tc.type: FUNC
10133 * @tc.require:
10134 */
10135 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsMouseInCastWindow_002, TestSize.Level1)
10136 {
10137 CALL_TEST_DEBUG;
10138 InputWindowsManager inputWindowsManager;
10139 WindowInfo windowInfo;
10140 windowInfo.windowType = CAST_WINDOW_TYPE + 1;
10141 inputWindowsManager.displayGroupInfo_.windowsInfo.push_back(windowInfo);
10142 EXPECT_FALSE(inputWindowsManager.IsMouseInCastWindow());
10143 }
10144
10145 /**
10146 * @tc.name: InputWindowsManagerTest_IsMouseInCastWindow_003
10147 * @tc.desc: Test whether IsMouseInCastWindow returns false when there is window information and
10148 * window of the CAST_WINDOW_TYPE type.
10149 * @tc.type: FUNC
10150 * @tc.require:
10151 */
10152 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsMouseInCastWindow_003, TestSize.Level1)
10153 {
10154 CALL_TEST_DEBUG;
10155 WindowInfo testWindow;
10156 testWindow.windowType = CAST_WINDOW_TYPE;
10157 testWindow.area.x = TEST_WINDOW_START;
10158 testWindow.area.y = TEST_WINDOW_START;
10159 testWindow.area.width = TEST_WINDOW_END;
10160 testWindow.area.height = TEST_WINDOW_END;
10161
10162 InputWindowsManager manager;
10163 manager.displayGroupInfo_.windowsInfo.push_back(testWindow);
10164
10165 bool result = manager.IsMouseInCastWindow();
10166 EXPECT_TRUE(result);
10167 }
10168
10169 /**
10170 * @tc.name: InputWindowsManagerTest_IsCaptureMode_001
10171 * @tc.desc: Test case for IsCaptureMode when screenshot window exists
10172 * @tc.require:
10173 */
10174 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsCaptureMode_001, TestSize.Level1)
10175 {
10176 CALL_TEST_DEBUG;
10177 InputWindowsManager manager;
10178 WindowInfo screenshotWindow;
10179 screenshotWindow.windowNameType = WINDOW_NAME_TYPE_SCREENSHOT;
10180 manager.displayGroupInfo_.windowsInfo.push_back(screenshotWindow);
10181
10182 EXPECT_FALSE(manager.IsCaptureMode());
10183 }
10184
10185 /**
10186 * @tc.name: InputWindowsManagerTest_IsCaptureMode_002
10187 * @tc.desc: Test case for IsCaptureMode when capture window exists and size exceeds threshold
10188 * @tc.require:
10189 */
10190 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsCaptureMode_002, TestSize.Level1)
10191 {
10192 CALL_TEST_DEBUG;
10193 InputWindowsManager manager;
10194 WindowInfo captureWindow;
10195 captureWindow.zOrder = SCREEN_CAPTURE_WINDOW_ZORDER;
10196 captureWindow.area.width = SCREEN_RECORD_WINDOW_WIDTH + 1;
10197 captureWindow.area.height = SCREEN_RECORD_WINDOW_HEIGHT + 1;
10198 manager.displayGroupInfo_.windowsInfo.push_back(captureWindow);
10199
10200 EXPECT_TRUE(manager.IsCaptureMode());
10201 }
10202
10203 /**
10204 * @tc.name: InputWindowsManagerTest_IsCaptureMode_003
10205 * @tc.desc: Test case for IsCaptureMode when capture window exists and size does not exceed threshold
10206 * @tc.require:
10207 */
10208 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsCaptureMode_003, TestSize.Level1)
10209 {
10210 CALL_TEST_DEBUG;
10211 InputWindowsManager manager;
10212 WindowInfo captureWindow;
10213 captureWindow.zOrder = SCREEN_CAPTURE_WINDOW_ZORDER;
10214 captureWindow.area.width = SCREEN_RECORD_WINDOW_WIDTH - 1;
10215 captureWindow.area.height = SCREEN_RECORD_WINDOW_HEIGHT - 1;
10216 manager.displayGroupInfo_.windowsInfo.push_back(captureWindow);
10217
10218 EXPECT_FALSE(manager.IsCaptureMode());
10219 }
10220
10221 /**
10222 * @tc.name: InputWindowsManagerTest_IsCaptureMode_004
10223 * @tc.desc: Test case for IsCaptureMode when no special windows exist
10224 * @tc.require:
10225 */
10226 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsCaptureMode_004, TestSize.Level1)
10227 {
10228 CALL_TEST_DEBUG;
10229 InputWindowsManager manager;
10230 WindowInfo normalWindow;
10231 normalWindow.windowNameType = WINDOW_NAME_TYPE_SCREENSHOT + 1;
10232 normalWindow.zOrder = SCREEN_CAPTURE_WINDOW_ZORDER - 1;
10233 manager.displayGroupInfo_.windowsInfo.push_back(normalWindow);
10234
10235 EXPECT_FALSE(manager.IsCaptureMode());
10236 }
10237
10238 /**
10239 * @tc.name: InputWindowsManagerTest_SetFoldState_001
10240 * @tc.desc: Test SetFoldState
10241 * @tc.type: FUNC
10242 * @tc.require:
10243 */
10244 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SetFoldState_001, TestSize.Level1)
10245 {
10246 CALL_TEST_DEBUG;
10247 InputWindowsManager manager;
10248 EXPECT_NO_FATAL_FAILURE(manager.SetFoldState());
10249 }
10250
10251 /**
10252 * @tc.name: InputWindowsManagerTest_DumpDisplayInfo_001
10253 * @tc.desc: Test DumpDisplayInfo
10254 * @tc.type: FUNC
10255 * @tc.require:
10256 */
10257 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DumpDisplayInfo_001, TestSize.Level1)
10258 {
10259 CALL_TEST_DEBUG;
10260 InputWindowsManager manager;
10261 int32_t fd = 1;
10262 OLD::DisplayInfo displaysInfo;
10263 displaysInfo.id = 2;
10264 displaysInfo.width = 30;
10265 displaysInfo.height = 40;
10266 displaysInfo.validWidth = displaysInfo.width;
10267 displaysInfo.validHeight = displaysInfo.height;
10268 displaysInfo.name = "name2";
10269 displaysInfo.uniq = "uniq2";
10270 std::vector<OLD::DisplayInfo> displaysInfos;
10271 displaysInfos.push_back(displaysInfo);
10272 EXPECT_NO_FATAL_FAILURE(manager.DumpDisplayInfo(fd, displaysInfos));
10273 }
10274
10275 /**
10276 * @tc.name: InputWindowsManagerTest_PrintZorderInfo_001
10277 * @tc.desc: Test PrintZorderInfo
10278 * @tc.type: FUNC
10279 * @tc.require:
10280 */
10281 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PrintZorderInfo_001, TestSize.Level1)
10282 {
10283 CALL_TEST_DEBUG;
10284 InputWindowsManager manager;
10285 WindowInfo testWindow;
10286 testWindow.id = 1;
10287 testWindow.pid = 100;
10288 testWindow.uid = 200;
10289 testWindow.area = {0, 0, 800, 600};
10290 testWindow.defaultHotAreas = {
10291 {10, 10, 100, 100},
10292 {200, 200, 50, 50 }
10293 };
10294 testWindow.pointerHotAreas = {
10295 {30, 30, 150, 150},
10296 {400, 400, 70, 70 }
10297 };
10298 testWindow.agentWindowId = 10;
10299 testWindow.flags = 1;
10300 testWindow.displayId = 3;
10301 testWindow.zOrder = 4.0f;
10302 testWindow.pointerChangeAreas = {10, 20, 30};
10303 testWindow.transform = {1.0f, 2.0f, 3.0f};
10304 std::string windowPrint;
10305 EXPECT_NO_FATAL_FAILURE(manager.PrintZorderInfo(testWindow, windowPrint));
10306 }
10307
10308 /**
10309 * @tc.name: InputWindowsManagerTest_ChangeWindowArea_001
10310 * @tc.desc: Test ChangeWindowArea
10311 * @tc.type: FUNC
10312 * @tc.require:
10313 */
10314 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ChangeWindowArea_001, TestSize.Level1)
10315 {
10316 CALL_TEST_DEBUG;
10317 InputWindowsManager manager;
10318 WindowInfo testWindow;
10319 testWindow.id = 1;
10320 testWindow.pid = 100;
10321 testWindow.uid = 200;
10322 testWindow.area = {0, 0, 800, 600};
10323 testWindow.defaultHotAreas = {
10324 {10, 10, 100, 100},
10325 {200, 200, 50, 50 }
10326 };
10327 testWindow.pointerHotAreas = {
10328 {30, 30, 150, 150},
10329 {400, 400, 70, 70 }
10330 };
10331 testWindow.agentWindowId = 10;
10332 testWindow.flags = 1;
10333 testWindow.displayId = 3;
10334 testWindow.zOrder = 4.0f;
10335 testWindow.pointerChangeAreas = {10, 20, 30};
10336 testWindow.transform = {1.0f, 2.0f, 3.0f};
10337 int32_t x = 20;
10338 int32_t y = 20;
10339 EXPECT_NO_FATAL_FAILURE(manager.ChangeWindowArea(x, y, testWindow));
10340 }
10341
10342 /**
10343 * @tc.name: InputWindowsManagerTest_GetWindowStateNotifyPid_001
10344 * @tc.desc: Test GetWindowStateNotifyPid
10345 * @tc.type: FUNC
10346 * @tc.require:
10347 */
10348 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowStateNotifyPid_001, TestSize.Level1)
10349 {
10350 CALL_TEST_DEBUG;
10351 InputWindowsManager manager;
10352 EXPECT_NO_FATAL_FAILURE(manager.GetWindowStateNotifyPid());
10353 }
10354
10355 /**
10356 * @tc.name: InputWindowsManagerTest_ProcessInjectEventGlobalXY_001
10357 * @tc.desc: Test ProcessInjectEventGlobalXY
10358 * @tc.type: FUNC
10359 * @tc.require:
10360 */
10361 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ProcessInjectEventGlobalXY_001, TestSize.Level1)
10362 {
10363 CALL_TEST_DEBUG;
10364 InputWindowsManager manager;
10365 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
10366 ;
10367 int32_t useCoordinate = 1;
10368 EXPECT_NO_FATAL_FAILURE(manager.ProcessInjectEventGlobalXY(pointerEvent, useCoordinate));
10369 }
10370
10371 /**
10372 * @tc.name: InputWindowsManagerTest_SendBackCenterPointerEevent_001
10373 * @tc.desc: Test SendBackCenterPointerEevent
10374 * @tc.type: FUNC
10375 * @tc.require:
10376 */
10377 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_SendBackCenterPointerEevent_001, TestSize.Level1)
10378 {
10379 CALL_TEST_DEBUG;
10380 InputWindowsManager manager;
10381 CursorPosition cursorPos = manager.GetCursorPos();
10382 EXPECT_NO_FATAL_FAILURE(manager.SendBackCenterPointerEevent(cursorPos));
10383 }
10384
10385 /**
10386 * @tc.name: InputWindowsManagerTest_DestroyInstance_001
10387 * @tc.desc: Test DestroyInstance
10388 * @tc.type: FUNC
10389 * @tc.require:
10390 */
10391 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DestroyInstance_001, TestSize.Level1)
10392 {
10393 CALL_TEST_DEBUG;
10394 WIN_MGR->DestroyInstance();
10395 EXPECT_EQ(WIN_MGR, nullptr);
10396 }
10397
10398 /**
10399 * @tc.name: InputWindowsManagerTest_GetDisplayMode_001
10400 * @tc.desc: Test GetDisplayMode
10401 * @tc.type: FUNC
10402 * @tc.require:
10403 */
10404 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetDisplayMode_001, TestSize.Level1)
10405 {
10406 CALL_TEST_DEBUG;
10407 InputWindowsManager manager;
10408 auto ret = manager.GetDisplayMode();
10409 EXPECT_EQ(static_cast<int32_t>(ret), 0);
10410 }
10411
10412 /**
10413 * @tc.name: InputWindowsManagerTest_GetLaunchDragPid_001
10414 * @tc.desc: Test GetLaunchDragPid
10415 * @tc.type: FUNC
10416 * @tc.require:
10417 */
10418 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetLaunchDragPid_001, TestSize.Level1)
10419 {
10420 CALL_TEST_DEBUG;
10421 InputWindowsManager manager;
10422 auto ret = manager.GetLaunchDragPid();
10423 EXPECT_EQ(static_cast<int32_t>(ret), 0);
10424 }
10425 #endif // OHOS_BUILD_ENABLE_VKEYBOARD
10426
10427 /**
10428 * @tc.name: InputWindowsManagerTest_GetWindowAndDisplayInfo_002
10429 * @tc.desc: Test GetWindowAndDisplayInfo
10430 * @tc.type: FUNC
10431 * @tc.require:
10432 */
10433 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowAndDisplayInfo_002, TestSize.Level1)
10434 {
10435 CALL_TEST_DEBUG;
10436 int32_t windowId = 0;
10437 int32_t displayId = 0;
10438 EXPECT_NO_FATAL_FAILURE(WIN_MGR->GetWindowAndDisplayInfo(windowId, displayId));
10439 auto result = WIN_MGR->GetWindowAndDisplayInfo(windowId, displayId);
10440 EXPECT_EQ(result->id, windowId);
10441 windowId = -1;
10442 displayId = 1;
10443 result = WIN_MGR->GetWindowAndDisplayInfo(windowId, displayId);
10444 EXPECT_FALSE(result.has_value());
10445 windowId = 1;
10446 displayId = 0;
10447 result = WIN_MGR->GetWindowAndDisplayInfo(windowId, displayId);
10448 EXPECT_TRUE(result.has_value());
10449 }
10450
10451 /**
10452 * @tc.name: InputWindowsManagerTest_GetMouseInfo_003
10453 * @tc.desc: Test the GetMouseInfo method
10454 * @tc.type: FUNC
10455 * @tc.require:
10456 */
10457 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetMouseInfo_003, TestSize.Level1)
10458 {
10459 CALL_TEST_DEBUG;
10460 OLD::DisplayGroupInfo displayGroupInfo;
10461 MouseLocation mouseLocation;
10462 displayGroupInfo.displaysInfo.clear();
10463 MouseLocation result = WIN_MGR->GetMouseInfo();
10464 OLD::DisplayInfo displayInfo;
10465 displayInfo.id = 10;
10466 displayInfo.width = 192;
10467 displayInfo.height = 108;
10468 displayGroupInfo.displaysInfo.push_back(displayInfo);
10469 mouseLocation.displayId = 0;
10470 result = WIN_MGR->GetMouseInfo();
10471 displayGroupInfo.displaysInfo.push_back(displayInfo);
10472 mouseLocation.displayId = -1;
10473 MouseLocation expectedResult;
10474 expectedResult.displayId = 10;
10475 expectedResult.physicalX = 60;
10476 expectedResult.physicalY = 40;
10477 ASSERT_NO_FATAL_FAILURE(WIN_MGR->GetMouseInfo());
10478 }
10479
10480 /**
10481 * @tc.name: InputWindowsManagerTest_GetCursorPos_005
10482 * @tc.desc: Test the functionality of getting the cursor position
10483 * @tc.type: FUNC
10484 * @tc.require:
10485 */
10486 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetCursorPos_005, TestSize.Level1)
10487 {
10488 InputWindowsManager manager;
10489 manager.cursorPosMap_[DEFAULT_GROUP_ID].displayId = -1;
10490 manager.displayGroupInfo_.displaysInfo.push_back({0, 800, 600});
10491 CursorPosition result = WIN_MGR->GetCursorPos();
10492 EXPECT_NE(result.displayId, RET_ERR);
10493 EXPECT_EQ(result.cursorPos.x, RET_OK);
10494 EXPECT_EQ(result.cursorPos.y, RET_OK);
10495 manager.cursorPosMap_[DEFAULT_GROUP_ID].displayId = 1;
10496 manager.displayGroupInfo_.displaysInfo.push_back({1, 800, 600});
10497 result = WIN_MGR->GetCursorPos();
10498 EXPECT_NE(result.displayId, RET_ERR);
10499 EXPECT_EQ(result.cursorPos.x, RET_OK);
10500 EXPECT_EQ(result.cursorPos.y, RET_OK);
10501 }
10502
10503 /**
10504 * @tc.name: InputWindowsManagerTest_ResetCursorPos_003
10505 * @tc.desc: Test the functionality of resetting cursor position
10506 * @tc.type: FUNC
10507 * @tc.require:
10508 */
10509 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ResetCursorPos_003, TestSize.Level1)
10510 {
10511 InputWindowsManager manager;
10512 manager.displayGroupInfo_.displaysInfo.push_back({1, 800, 600});
10513 CursorPosition result = WIN_MGR->ResetCursorPos();
10514 EXPECT_NE(result.displayId, RET_ERR);
10515 EXPECT_EQ(result.cursorPos.x, 0);
10516 EXPECT_EQ(result.cursorPos.y, 0);
10517 manager.displayGroupInfo_.displaysInfo.clear();
10518 result = WIN_MGR->ResetCursorPos();
10519 EXPECT_NE(result.displayId, RET_ERR);
10520 EXPECT_EQ(result.cursorPos.x, 0);
10521 EXPECT_EQ(result.cursorPos.y, 0);
10522 }
10523
10524 /**
10525 * @tc.name: InputWindowsManagerTest_PointerDrawingManagerOnDisplayInfo004
10526 * @tc.desc: Test PointerDrawingManagerOnDisplayInfo
10527 * @tc.type: FUNC
10528 * @tc.require:
10529 */
10530 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PointerDrawingManagerOnDisplayInfo004, TestSize.Level1)
10531 {
10532 CALL_TEST_DEBUG;
10533 auto *pointerDrawingMgr = static_cast<PointerDrawingManager *>(IPointerDrawingManager::GetInstance());
10534 pointerDrawingMgr->displayInfo_.id = 521;
10535 OLD::DisplayGroupInfo displayGroupInfo;
10536 OLD::DisplayInfo displayInfo;
10537 displayInfo.id = 521;
10538 displayInfo.uniq = "uniq_test";
10539 displayInfo.dpi = 1000;
10540 displayGroupInfo.displaysInfo.push_back(displayInfo);
10541 int32_t deviceId = 1;
10542 InputDeviceManager::InputDeviceInfo inputDeviceInfo;
10543 inputDeviceInfo.isPointerDevice = true;
10544 INPUT_DEV_MGR->inputDevice_.insert(std::make_pair(deviceId, inputDeviceInfo));
10545 WIN_MGR->mouseLocation_.displayId = 10;
10546 WIN_MGR->mouseLocation_.physicalX = 500;
10547 WIN_MGR->mouseLocation_.physicalY = 500;
10548 WIN_MGR->cursorPosMap_[DEFAULT_GROUP_ID].displayId = 10;
10549 WIN_MGR->cursorPosMap_[DEFAULT_GROUP_ID].cursorPos.x = 300;
10550 WIN_MGR->cursorPosMap_[DEFAULT_GROUP_ID].cursorPos.y = 300;
10551 displayInfo.id = 10;
10552 displayInfo.x = 300;
10553 displayInfo.y = 300;
10554 WIN_MGR->displayGroupInfo_.displaysInfo.push_back(displayInfo);
10555 WIN_MGR->lastPointerEvent_ = nullptr;
10556 EXPECT_NO_FATAL_FAILURE(WIN_MGR->PointerDrawingManagerOnDisplayInfo(displayGroupInfo));
10557 WIN_MGR->lastPointerEvent_ = PointerEvent::Create();
10558 EXPECT_NE(WIN_MGR->lastPointerEvent_, nullptr);
10559 WIN_MGR->lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE);
10560 EXPECT_NO_FATAL_FAILURE(WIN_MGR->PointerDrawingManagerOnDisplayInfo(displayGroupInfo));
10561 WIN_MGR->lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_UP);
10562 EXPECT_NO_FATAL_FAILURE(WIN_MGR->PointerDrawingManagerOnDisplayInfo(displayGroupInfo));
10563 }
10564
10565 /**
10566 * @tc.name: InputWindowsManagerTest_PointerDrawingManagerOnDisplayInfo_001
10567 * @tc.desc: Test PointerDrawingManagerOnDisplayInfo
10568 * @tc.type: FUNC
10569 * @tc.require:
10570 */
10571 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_PointerDrawingManagerOnDisplayInfo_001, TestSize.Level1)
10572 {
10573 CALL_TEST_DEBUG;
10574 auto *pointerDrawingMgr = static_cast<PointerDrawingManager *>(IPointerDrawingManager::GetInstance());
10575 pointerDrawingMgr->displayInfo_.id = 521;
10576 OLD::DisplayGroupInfo displayGroupInfo;
10577 OLD::DisplayInfo displayInfo;
10578 displayInfo.id = 521;
10579 displayInfo.uniq = "uniq_test";
10580 displayInfo.dpi = 1000;
10581 displayGroupInfo.displaysInfo.push_back(displayInfo);
10582 int32_t deviceId = 1;
10583 InputDeviceManager::InputDeviceInfo inputDeviceInfo;
10584 inputDeviceInfo.isPointerDevice = true;
10585 INPUT_DEV_MGR->inputDevice_.insert(std::make_pair(deviceId, inputDeviceInfo));
10586 WIN_MGR->mouseLocation_.displayId = 10;
10587 WIN_MGR->mouseLocation_.physicalX = 500;
10588 WIN_MGR->mouseLocation_.physicalY = 500;
10589 WIN_MGR->cursorPosMap_[DEFAULT_GROUP_ID].displayId = 10;
10590 WIN_MGR->cursorPosMap_[DEFAULT_GROUP_ID].cursorPos.x = 300;
10591 WIN_MGR->cursorPosMap_[DEFAULT_GROUP_ID].cursorPos.y = 300;
10592 displayInfo.id = 10;
10593 displayInfo.x = 300;
10594 displayInfo.y = 300;
10595 WIN_MGR->displayGroupInfo_.displaysInfo.push_back(displayInfo);
10596 WIN_MGR->lastPointerEvent_ = PointerEvent::Create();
10597 EXPECT_NE(WIN_MGR->lastPointerEvent_, nullptr);
10598 WIN_MGR->lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_ENTER_WINDOW);
10599 WIN_MGR->lastPointerEvent_->SetTargetDisplayId(-1);
10600 WIN_MGR->firstBtnDownWindowInfo_.first = -1;
10601 WIN_MGR->extraData_.appended = false;
10602 WIN_MGR->extraData_.sourceType = PointerEvent::SOURCE_TYPE_JOYSTICK;
10603 WindowInfo windowInfo;
10604 windowInfo.id = -1;
10605 windowInfo.pid = 1;
10606 WIN_MGR->displayGroupInfo_.windowsInfo.push_back(windowInfo);
10607 WIN_MGR->isDragBorder_ = true;
10608 WIN_MGR->dragFlag_ = true;
10609 EXPECT_NO_FATAL_FAILURE(WIN_MGR->PointerDrawingManagerOnDisplayInfo(displayGroupInfo));
10610 WIN_MGR->isDragBorder_ = false;
10611 WIN_MGR->dragFlag_ = false;
10612 WIN_MGR->lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_DOWN);
10613 EXPECT_NO_FATAL_FAILURE(WIN_MGR->PointerDrawingManagerOnDisplayInfo(displayGroupInfo));
10614 WIN_MGR->lastPointerEvent_->SetButtonPressed(1);
10615 WIN_MGR->lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_BUTTON_UP);
10616 EXPECT_NO_FATAL_FAILURE(WIN_MGR->PointerDrawingManagerOnDisplayInfo(displayGroupInfo));
10617 }
10618
10619 /**
10620 * @tc.name: InputWindowsManagerTest_UpdateDisplayIdAndName_005
10621 * @tc.desc: Test updating display ID and name
10622 * @tc.type: FUNC
10623 * @tc.require:
10624 */
10625 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayIdAndName_005, TestSize.Level1)
10626 {
10627 CALL_TEST_DEBUG;
10628 InputWindowsManager inputWindowsManager;
10629 OLD::DisplayInfo displaysInfo;
10630 displaysInfo.id = 1;
10631 displaysInfo.uniq = "abc";
10632 inputWindowsManager.displayGroupInfo_.displaysInfo.push_back(displaysInfo);
10633 inputWindowsManager.bindInfo_.AddDisplay(2, "cde");
10634 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.UpdateDisplayIdAndName());
10635 }
10636
10637 /**
10638 * @tc.name: InputWindowsManagerTest_HandleWindowPositionChange
10639 * @tc.desc: Test the funcation HandleWindowPositionChange
10640 * @tc.type: FUNC
10641 * @tc.require:
10642 */
10643 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_HandleWindowPositionChange, TestSize.Level1)
10644 {
10645 CALL_TEST_DEBUG;
10646 InputWindowsManager inputWindowsManager;
10647 WindowInfoEX winInfoEx;
10648 int32_t pointerId = 10;
10649 WindowInfo winInfo;
10650 inputWindowsManager.lastPointerEventforWindowChange_ = PointerEvent::Create();
10651 ASSERT_NE(inputWindowsManager.lastPointerEventforWindowChange_, nullptr);
10652 winInfo.id = 100;
10653 winInfoEx.window.id = 50;
10654 winInfo.rectChangeBySystem = true;
10655 inputWindowsManager.lastPointerEventforWindowChange_->bitwise_ = 0x00000080;
10656 inputWindowsManager.displayGroupInfo_.windowsInfo.clear();
10657 inputWindowsManager.displayGroupInfo_.windowsInfo.push_back(winInfo);
10658 inputWindowsManager.touchItemDownInfos_.insert(std::make_pair(pointerId, winInfoEx));
10659 pointerId = 50;
10660 winInfoEx.window.id = 100;
10661 winInfo.rectChangeBySystem = false;
10662 inputWindowsManager.touchItemDownInfos_.insert(std::make_pair(pointerId, winInfoEx));
10663 inputWindowsManager.displayGroupInfo_.windowsInfo.clear();
10664 inputWindowsManager.displayGroupInfo_.windowsInfo.push_back(winInfo);
10665 pointerId = 80;
10666 winInfo.rectChangeBySystem = true;
10667 inputWindowsManager.displayGroupInfo_.windowsInfo.clear();
10668 inputWindowsManager.displayGroupInfo_.windowsInfo.push_back(winInfo);
10669 inputWindowsManager.touchItemDownInfos_.insert(std::make_pair(pointerId, winInfoEx));
10670 OLD::DisplayGroupInfo displayGroupInfoRef;
10671 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
10672 if (it != inputWindowsManager.displayGroupInfoMap_.end())
10673 {
10674 displayGroupInfoRef = it->second;
10675 }
10676 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.HandleWindowPositionChange(displayGroupInfoRef));
10677 }
10678
10679 /**
10680 * @tc.name: CancelMouseEvent_CancelAction_008
10681 * @tc.desc: Test CancelMouseEvent
10682 * @tc.type: FUNC
10683 * @tc.require:
10684 */
10685 HWTEST_F(InputWindowsManagerTest, CancelMouseEvent_CancelAction_008, TestSize.Level1)
10686 {
10687 CALL_TEST_DEBUG;
10688 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
10689 EXPECT_NE(pointerEvent, nullptr);
10690 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
10691 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
10692 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL);
10693 inputWindowsManager->lastPointerEvent_ = pointerEvent;
10694 inputWindowsManager->extraData_.appended = true;
10695 inputWindowsManager->extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
10696 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->CancelMouseEvent());
10697 EXPECT_EQ(inputWindowsManager->lastPointerEvent_->GetPointerAction(), PointerEvent::POINTER_ACTION_CANCEL);
10698 }
10699
10700 /**
10701 * @tc.name: CancelMouseEvent_PullCancelAction_009
10702 * @tc.desc: Test CancelMouseEvent
10703 * @tc.type: FUNC
10704 * @tc.require:
10705 */
10706 HWTEST_F(InputWindowsManagerTest, CancelMouseEvent_PullCancelAction_009, TestSize.Level1)
10707 {
10708 CALL_TEST_DEBUG;
10709 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
10710 EXPECT_NE(pointerEvent, nullptr);
10711 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
10712 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
10713 pointerEvent->SetPointerAction(PointerEvent::POINTER_ACTION_PULL_CANCEL);
10714 inputWindowsManager->lastPointerEvent_ = pointerEvent;
10715 inputWindowsManager->extraData_.appended = true;
10716 inputWindowsManager->extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
10717 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->CancelMouseEvent());
10718 EXPECT_EQ(inputWindowsManager->lastPointerEvent_->GetPointerAction(), PointerEvent::POINTER_ACTION_PULL_CANCEL);
10719 }
10720
10721 /**
10722 * @tc.name: InputWindowsManagerTest_GetMouseInfo_004
10723 * @tc.desc: Test the function GetMouseInfo
10724 * @tc.type: FUNC
10725 * @tc.require:
10726 */
10727 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetMouseInfo_004, TestSize.Level1)
10728 {
10729 CALL_TEST_DEBUG;
10730 InputWindowsManager inputWindowsManager;
10731 inputWindowsManager.mouseLocation_.displayId = -1;
10732 OLD::DisplayInfo displaysInfo;
10733 displaysInfo.id = 2;
10734 displaysInfo.width = 20;
10735 displaysInfo.height = 30;
10736 displaysInfo.validWidth = displaysInfo.width;
10737 displaysInfo.validHeight = displaysInfo.height;
10738 displaysInfo.name = "name1";
10739 displaysInfo.uniq = "uniq1";
10740 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
10741 if (it != inputWindowsManager.displayGroupInfoMap_.end())
10742 {
10743 it->second.displaysInfo.push_back(displaysInfo);
10744 }
10745
10746 inputWindowsManager.mouseLocationMap_.clear();
10747 EXPECT_EQ(inputWindowsManager.mouseLocationMap_.size(), 0);
10748
10749 MouseLocation result = inputWindowsManager.GetMouseInfo();
10750 EXPECT_EQ(result.displayId, -1);
10751 EXPECT_EQ(result.physicalX, 0);
10752 EXPECT_EQ(result.physicalY, 0);
10753 }
10754
10755 #ifdef OHOS_BUILD_ENABLE_POINTER_DRAWING
10756 /**
10757 * @tc.name: InputWindowsManagerTest_AdjustDragPosition_002
10758 * @tc.desc: Test AdjustDragPosition
10759 * @tc.type: FUNC
10760 * @tc.require:
10761 */
10762 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_AdjustDragPosition_002, TestSize.Level1)
10763 {
10764 CALL_TEST_DEBUG;
10765 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
10766 EXPECT_NE(pointerEvent, nullptr);
10767 InputWindowsManager inputWindowsManager;
10768 inputWindowsManager.lastPointerEvent_ = pointerEvent;
10769 inputWindowsManager.lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_AXIS_UPDATE);
10770 WindowInfo windowInfo;
10771 windowInfo.id = 1;
10772 windowInfo.pid = 1;
10773 windowInfo.uid = 1;
10774 windowInfo.area = {1, 1, 1, 1};
10775 windowInfo.defaultHotAreas = {windowInfo.area};
10776 windowInfo.pointerHotAreas = {windowInfo.area};
10777 windowInfo.agentWindowId = 1;
10778 windowInfo.flags = 1;
10779 windowInfo.transform = {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f};
10780 windowInfo.pointerChangeAreas = {1, 2, 1, 2, 1, 2, 1, 2, 1};
10781 windowInfo.action = WINDOW_UPDATE_ACTION::ADD;
10782 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
10783 if (it != inputWindowsManager.displayGroupInfoMap_.end())
10784 {
10785 it->second.windowsInfo.push_back(windowInfo);
10786 }
10787 inputWindowsManager.axisBeginWindowInfo_ = std::make_optional(windowInfo);
10788 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.AdjustDragPosition());
10789 }
10790 #endif // OHOS_BUILD_ENABLE_POINTER_DRAWING
10791
10792 #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)
10793 /**
10794 * @tc.name: InputWindowsManagerTest_ResetCursorPos_004
10795 * @tc.desc: Test ResetCursorPos
10796 * @tc.type: FUNC
10797 * @tc.require:
10798 */
10799 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ResetCursorPos_004, TestSize.Level1)
10800 {
10801 CALL_TEST_DEBUG;
10802 InputWindowsManager inputWindowsManager;
10803 OLD::DisplayInfo displaysInfo;
10804 OLD::DisplayGroupInfo displayGroupInfo;
10805 displaysInfo.id = 2;
10806 displaysInfo.width = 30;
10807 displaysInfo.height = 40;
10808 displaysInfo.validWidth = displaysInfo.width;
10809 displaysInfo.validHeight = displaysInfo.height;
10810 displaysInfo.name = "name2";
10811 displaysInfo.uniq = "uniq2";
10812 displayGroupInfo.displaysInfo.push_back(displaysInfo);
10813 EXPECT_EQ(inputWindowsManager.ResetCursorPos(displayGroupInfo).displayId, displaysInfo.id);
10814 }
10815 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH
10816
10817 /**
10818 * @tc.name: InputWindowsManagerTest_IsPointerOnCenter_001
10819 * @tc.desc: Test is pointer on center
10820 * @tc.type: FUNC
10821 * @tc.require:
10822 */
10823 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_IsPointerOnCenter_001, TestSize.Level1)
10824 {
10825 CALL_TEST_DEBUG;
10826 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
10827 OLD::DisplayInfo displayInfo;
10828 displayInfo.id = 1;
10829 displayInfo.validWidth = 1;
10830 displayInfo.validHeight = 1;
10831 CursorPosition currentPos;
10832 currentPos.cursorPos.x = 0.5;
10833 currentPos.cursorPos.y = 0.5;
10834 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->IsPointerOnCenter(currentPos, displayInfo));
10835 currentPos.cursorPos.x = 1;
10836 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->IsPointerOnCenter(currentPos, displayInfo));
10837 currentPos.cursorPos.x = 0.5;
10838 currentPos.cursorPos.y = 1;
10839 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->IsPointerOnCenter(currentPos, displayInfo));
10840 }
10841
10842 /**
10843 * @tc.name: InputWindowsManagerTest_DispatchPointer_003
10844 * @tc.desc: Test DispatchPointer
10845 * @tc.type: FUNC
10846 * @tc.require:
10847 */
10848 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_DispatchPointer_003, TestSize.Level1)
10849 {
10850 CALL_TEST_DEBUG;
10851 InputWindowsManager inputWindowsManager;
10852 int32_t pointerAction = PointerEvent::POINTER_ACTION_ENTER_WINDOW;
10853 UDSServer udsServer;
10854 inputWindowsManager.udsServer_ = &udsServer;
10855 inputWindowsManager.lastPointerEvent_ = PointerEvent::Create();
10856 EXPECT_NE(inputWindowsManager.lastPointerEvent_, nullptr);
10857 PointerEvent::PointerItem item;
10858 item.SetPointerId(0);
10859 item.SetDisplayX(100);
10860 item.SetDisplayY(100);
10861 inputWindowsManager.lastPointerEvent_->AddPointerItem(item);
10862 inputWindowsManager.lastPointerEvent_->SetPointerId(0);
10863 inputWindowsManager.firstBtnDownWindowInfo_.first = 1;
10864 inputWindowsManager.lastPointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_UP);
10865 inputWindowsManager.lastPointerEvent_->SetTargetDisplayId(-1);
10866 inputWindowsManager.lastPointerEvent_->AddFlag(InputEvent::EVENT_FLAG_SIMULATE);
10867 inputWindowsManager.lastPointerEvent_->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
10868 inputWindowsManager.lastPointerEvent_->HasFlag(InputEvent::EVENT_FLAG_SIMULATE);
10869 EXPECT_EQ(inputWindowsManager.lastPointerEvent_->GetSourceType(), 1);
10870 EXPECT_EQ(inputWindowsManager.IsMouseSimulate(), true);
10871 GlobalCoords globalCoords = inputWindowsManager.DisplayCoords2GlobalCoords({item.GetDisplayX(),
10872 item.GetDisplayY()},
10873 inputWindowsManager.lastPointerEvent_->GetTargetDisplayId());
10874 item.SetGlobalX(globalCoords.x);
10875 item.SetGlobalY(globalCoords.y);
10876 WindowInfo windowInfo;
10877 windowInfo.id = 1;
10878 auto it = inputWindowsManager.displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
10879 if (it != inputWindowsManager.displayGroupInfoMap_.end())
10880 {
10881 it->second.windowsInfo.push_back(windowInfo);
10882 }
10883 inputWindowsManager.lastWindowInfo_.id = 2;
10884 inputWindowsManager.lastWindowInfo_.agentWindowId = 2;
10885 inputWindowsManager.lastWindowInfo_.area.x = 100;
10886 inputWindowsManager.lastWindowInfo_.area.y = 100;
10887 inputWindowsManager.lastPointerEvent_->SetSourceType(PointerEvent::SOURCE_TYPE_MOUSE);
10888 inputWindowsManager.lastPointerEvent_->SetDeviceId(5);
10889 inputWindowsManager.extraData_.appended = true;
10890 inputWindowsManager.extraData_.sourceType = PointerEvent::SOURCE_TYPE_MOUSE;
10891 InputHandler->eventFilterHandler_ = std::make_shared<EventFilterHandler>();
10892 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointer(pointerAction));
10893 inputWindowsManager.lastWindowInfo_.id = 1;
10894 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointer(pointerAction));
10895 inputWindowsManager.extraData_.appended = false;
10896 pointerAction = PointerEvent::POINTER_ACTION_LEAVE_WINDOW;
10897 EXPECT_NO_FATAL_FAILURE(inputWindowsManager.DispatchPointer(pointerAction));
10898 }
10899
10900 /**
10901 * @tc.name: InputWindowsManagerTest_GetDefaultDisplayGroupInfo_001
10902 * @tc.desc: Test GetDefaultDisplayGroupInfo
10903 * @tc.type: FUNC
10904 * @tc.require:
10905 */
10906 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetDefaultDisplayGroupInfo_001, TestSize.Level1)
10907 {
10908 CALL_TEST_DEBUG;
10909
10910 OLD::DisplayGroupInfo defaultGroup;
10911 defaultGroup.type = GroupType::GROUP_DEFAULT;
10912 InputWindowsManager manager;
10913 manager.displayGroupInfoMap_[0] = defaultGroup;
10914 OLD::DisplayGroupInfo result = manager.GetDefaultDisplayGroupInfo();
10915 EXPECT_EQ(result.type, GroupType::GROUP_DEFAULT);
10916 }
10917
10918 /**
10919 * @tc.name: InputWindowsManagerTest_GetDefaultDisplayGroupInfo
10920 * @tc.desc: Test GetDefaultDisplayGroupInfo
10921 * @tc.type: FUNC
10922 * @tc.require:
10923 */
10924 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetDefaultDisplayGroupInfo, TestSize.Level1)
10925 {
10926 CALL_TEST_DEBUG;
10927 InputWindowsManager manager;
10928 OLD::DisplayGroupInfo displayGroupInfo;
10929 displayGroupInfo.groupId = 0;
10930 displayGroupInfo.type = GroupType::GROUP_SPECIAL;
10931 displayGroupInfo.focusWindowId = -1;
10932 manager.displayGroupInfoMap_[0] = displayGroupInfo;
10933 auto info = manager.GetDefaultDisplayGroupInfo();
10934 ASSERT_EQ(info.groupId, 0);
10935 }
10936
10937 /**
10938 * @tc.name: InputWindowsManagerTest_InitDisplayGroupInfo
10939 * @tc.desc: Test InitDisplayGroupInfo
10940 * @tc.type: FUNC
10941 * @tc.require:
10942 */
10943 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_InitDisplayGroupInfo, TestSize.Level1)
10944 {
10945 CALL_TEST_DEBUG;
10946 InputWindowsManager manager;
10947 OLD::DisplayGroupInfo displayGroupInfo;
10948 displayGroupInfo.groupId = 0;
10949 displayGroupInfo.type = GroupType::GROUP_DEFAULT;
10950 displayGroupInfo.focusWindowId = -1;
10951 EXPECT_NO_FATAL_FAILURE(manager.InitDisplayGroupInfo(displayGroupInfo));
10952 displayGroupInfo.groupId = 1;
10953 displayGroupInfo.type = GroupType::GROUP_DEFAULT;
10954 displayGroupInfo.focusWindowId = -1;
10955 EXPECT_NO_FATAL_FAILURE(manager.InitDisplayGroupInfo(displayGroupInfo));
10956 }
10957
10958 /**
10959 * @tc.name: InputWindowsManagerTest_ResetPointerPosition_001
10960 * @tc.desc: Test ResetPointerPosition
10961 * @tc.type: FUNC
10962 * @tc.require:
10963 */
10964 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ResetPointerPosition_001, TestSize.Level1)
10965 {
10966 CALL_TEST_DEBUG;
10967 InputWindowsManager inputManager;
10968 OLD::DisplayGroupInfo displayGroupInfo;
10969 std::map<int32_t, CursorPosition> cursorPosMap_;
10970 std::map<int32_t, OLD::DisplayGroupInfo> displayGroupInfoMap_;
10971 OLD::DisplayInfo displaysInfo;
10972 displaysInfo.id = 1;
10973 displaysInfo.x = 0;
10974 displaysInfo.y = 0;
10975 displaysInfo.width = 1024;
10976 displaysInfo.height = 768;
10977 displaysInfo.dpi = 160;
10978 displaysInfo.name = "Display1";
10979 displaysInfo.uniq = "default0";
10980 displaysInfo.direction = Direction::DIRECTION0;
10981 displaysInfo.displayDirection = Direction::DIRECTION0;
10982 displayGroupInfo.displaysInfo.push_back(displaysInfo);
10983 OLD::DisplayInfo displaysInfo2;
10984 displaysInfo2.id = 2;
10985 displaysInfo2.x = 0;
10986 displaysInfo2.y = 0;
10987 displaysInfo2.width = 1024;
10988 displaysInfo2.height = 768;
10989 displaysInfo2.dpi = 160;
10990 displaysInfo2.name = "Display2";
10991 displaysInfo2.uniq = "default1";
10992 displaysInfo2.direction = Direction::DIRECTION0;
10993 displaysInfo2.displayDirection = Direction::DIRECTION0;
10994 displayGroupInfo.displaysInfo.push_back(displaysInfo2);
10995 displayGroupInfo.displaysInfo[0].displaySourceMode = DisplaySourceMode::SCREEN_MAIN;
10996 displayGroupInfo.displaysInfo[1].displaySourceMode = DisplaySourceMode::SCREEN_MAIN;
10997 cursorPosMap_[1] = {1, Direction::DIRECTION0, Direction::DIRECTION0, {512, 384}};
10998 cursorPosMap_[2] = {2, Direction::DIRECTION0, Direction::DIRECTION0, {512, 384}};
10999 displayGroupInfoMap_[1] = displayGroupInfo;
11000 displayGroupInfoMap_[2] = displayGroupInfo;
11001 displayGroupInfo.displaysInfo[0].rsId = 10;
11002 displayGroupInfo.displaysInfo[0].validWidth = 1024;
11003 displayGroupInfo.displaysInfo[0].validHeight = 768;
11004 cursorPosMap_[1].cursorPos.x = 512;
11005 cursorPosMap_[1].cursorPos.y = 384;
11006 inputManager.cursorPosMap_ = cursorPosMap_;
11007 inputManager.displayGroupInfoMap_ = displayGroupInfoMap_;
11008 EXPECT_NO_FATAL_FAILURE(inputManager.ResetPointerPosition(displayGroupInfo));
11009 }
11010
11011 /**
11012 * @tc.name: InputWindowsManagerTest_GetWindowGroupInfoByDisplayIdCopy_001
11013 * @tc.desc: Test GetWindowGroupInfoByDisplayIdCopy
11014 * @tc.type: FUNC
11015 * @tc.require:
11016 */
11017 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowGroupInfoByDisplayIdCopy_001, TestSize.Level1)
11018 {
11019 CALL_TEST_DEBUG;
11020 InputWindowsManager manager;
11021 int32_t displayId = 1;
11022 WindowGroupInfo windowGroupInfo;
11023 WindowInfo windowInfo;
11024 windowInfo.id = 1;
11025 windowInfo.displayId = displayId;
11026 windowGroupInfo.windowsInfo.push_back(windowInfo);
11027 manager.windowsPerDisplay_.insert(std::make_pair(displayId, windowGroupInfo));
11028 auto ret = manager.GetWindowGroupInfoByDisplayIdCopy(displayId);
11029 EXPECT_FALSE(!ret.empty());
11030 }
11031
11032 /**
11033 * @tc.name: InputWindowsManagerTest_GetWindowGroupInfoByDisplayIdCopy_002
11034 * @tc.desc: Test GetWindowGroupInfoByDisplayIdCopy
11035 * @tc.type: FUNC
11036 * @tc.require:
11037 */
11038 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetWindowGroupInfoByDisplayIdCopy_002, TestSize.Level1)
11039 {
11040 CALL_TEST_DEBUG;
11041 InputWindowsManager manager;
11042 int32_t displayId = 1;
11043 WindowGroupInfo windowGroupInfo;
11044 manager.windowsPerDisplay_.insert(std::make_pair(displayId, windowGroupInfo));
11045 WindowInfo windowInfo;
11046 windowInfo.id = 1;
11047 windowInfo.displayId = displayId;
11048 manager.displayGroupInfo_.windowsInfo.push_back(windowInfo);
11049 auto ret = manager.GetWindowGroupInfoByDisplayIdCopy(displayId);
11050 EXPECT_FALSE(!ret.empty());
11051 }
11052
11053 /**
11054 * @tc.name: InputWindowsManagerTest_GetCancelEventFlag_002
11055 * @tc.desc: Test the funcation GetCancelEventFlag
11056 * @tc.type: FUNC
11057 * @tc.require:
11058 */
11059 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetCancelEventFlag_002, TestSize.Level1)
11060 {
11061 CALL_TEST_DEBUG;
11062 InputWindowsManager inputWindowsManager;
11063 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
11064 ASSERT_NE(pointerEvent, nullptr);
11065 WindowInfoEX winInfoEx;
11066 winInfoEx.flag = true;
11067 int32_t pointerId = 100;
11068 pointerEvent->SetPointerId(100);
11069 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
11070 pointerEvent->AddFlag(InputEvent::EVENT_TYPE_AXIS);
11071 inputWindowsManager.touchItemDownInfos_.insert(std::make_pair(pointerId, winInfoEx));
11072 EXPECT_TRUE(inputWindowsManager.GetCancelEventFlag(pointerEvent));
11073 }
11074
11075 /**
11076 * @tc.name: InputWindowsManagerTest_GetCancelEventFlag_003
11077 * @tc.desc: Test the funcation GetCancelEventFlag
11078 * @tc.type: FUNC
11079 * @tc.require:
11080 */
11081 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_GetCancelEventFlag_003, TestSize.Level1)
11082 {
11083 CALL_TEST_DEBUG;
11084 InputWindowsManager inputWindowsManager;
11085 std::shared_ptr<PointerEvent> pointerEvent = PointerEvent::Create();
11086 ASSERT_NE(pointerEvent, nullptr);
11087 WindowInfoEX winInfoEx;
11088 winInfoEx.flag = true;
11089 int32_t pointerId = 100;
11090 pointerEvent->SetPointerId(100);
11091 pointerEvent->SetSourceType(PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
11092 pointerEvent->AddFlag(InputEvent::EVENT_FLAG_ACCESSIBILITY);
11093 inputWindowsManager.touchItemDownInfos_.insert(std::make_pair(pointerId, winInfoEx));
11094 EXPECT_TRUE(inputWindowsManager.GetCancelEventFlag(pointerEvent));
11095 }
11096
11097 /**
11098 * @tc.name: InputWindowsManagerTest_UpdateDisplayIdAndName_006
11099 * @tc.desc: Test updating display ID and name
11100 * @tc.type: FUNC
11101 * @tc.require:
11102 */
11103 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayIdAndName_006, TestSize.Level1)
11104 {
11105 CALL_TEST_DEBUG;
11106 std::shared_ptr<InputWindowsManager> inputWindowsManager = std::make_shared<InputWindowsManager>();
11107 OLD::DisplayInfo displaysInfo;
11108 displaysInfo.id = 1;
11109 displaysInfo.rsId = 1010;
11110 displaysInfo.uniq = "abc";
11111 auto it = inputWindowsManager->displayGroupInfoMap_.find(DEFAULT_GROUP_ID);
11112 if (it != inputWindowsManager->displayGroupInfoMap_.end())
11113 {
11114 it->second.displaysInfo.push_back(displaysInfo);
11115 }
11116 it->second.displaysInfo.push_back(displaysInfo);
11117
11118 inputWindowsManager->bindInfo_.AddDisplay(1, "abc");
11119 inputWindowsManager->bindInfo_.AddDisplay(1, "abc");
11120 inputWindowsManager->bindInfo_.AddDisplay(2, "abc");
11121 inputWindowsManager->bindInfo_.AddDisplay(1, "aaa");
11122 EXPECT_NO_FATAL_FAILURE(inputWindowsManager->UpdateDisplayIdAndName());
11123 }
11124
11125 /**
11126 * @tc.name: InputWindowsManagerTest_ResetPointerPosition_003
11127 * @tc.desc: Test ResetPointerPosition
11128 * @tc.type: FUNC
11129 * @tc.require:
11130 */
11131 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ResetPointerPosition_003, TestSize.Level1)
11132 {
11133 CALL_TEST_DEBUG;
11134 InputWindowsManager inputManager;
11135 OLD::DisplayGroupInfo displayGroupInfo;
11136 std::map<int32_t, CursorPosition> cursorPosMap_;
11137 std::map<int32_t, OLD::DisplayGroupInfo> displayGroupInfoMap_;
11138 OLD::DisplayInfo displaysInfo;
11139 displaysInfo.id = 1;
11140 displaysInfo.x = 0;
11141 displaysInfo.y = 0;
11142 displaysInfo.width = 1024;
11143 displaysInfo.height = 768;
11144 displaysInfo.dpi = 160;
11145 displaysInfo.name = "Display1";
11146 displaysInfo.uniq = "default0";
11147 displaysInfo.direction = Direction::DIRECTION0;
11148 displaysInfo.displayDirection = Direction::DIRECTION0;
11149 displaysInfo.ppi = 160;
11150 displaysInfo.screenRealWidth = 1024;
11151 displaysInfo.screenRealHeight = 768;
11152 displaysInfo.screenRealDPI = 160;
11153 displaysInfo.validWidth = 1024;
11154 displaysInfo.validHeight = 768;
11155 displaysInfo.fixedDirection = Direction::DIRECTION0;
11156 displaysInfo.physicalWidth = 0;
11157 displaysInfo.physicalHeight = 0;
11158 displaysInfo.pointerActiveWidth = 1;
11159 displaysInfo.pointerActiveHeight = 1;
11160 displaysInfo.rsId = 1;
11161 displayGroupInfo.displaysInfo.push_back(displaysInfo);
11162 OLD::DisplayInfo displaysInfo2;
11163 displaysInfo2.id = 2;
11164 displaysInfo2.x = 0;
11165 displaysInfo2.y = 0;
11166 displaysInfo2.width = 1024;
11167 displaysInfo2.height = 768;
11168 displaysInfo2.dpi = 160;
11169 displaysInfo2.name = "Display2";
11170 displaysInfo2.uniq = "default1";
11171 displaysInfo2.direction = Direction::DIRECTION0;
11172 displaysInfo2.displayDirection = Direction::DIRECTION0;
11173 displaysInfo2.ppi = 160;
11174 displaysInfo2.screenRealWidth = 1024;
11175 displaysInfo2.screenRealHeight = 768;
11176 displaysInfo2.screenRealDPI = 160;
11177 displaysInfo2.validWidth = 1024;
11178 displaysInfo2.validHeight = 768;
11179 displaysInfo2.fixedDirection = Direction::DIRECTION0;
11180 displaysInfo2.physicalWidth = 0;
11181 displaysInfo2.physicalHeight = 0;
11182 displaysInfo2.pointerActiveWidth = 2;
11183 displaysInfo2.pointerActiveHeight = 2;
11184 displaysInfo2.rsId = 2;
11185 displayGroupInfo.displaysInfo.push_back(displaysInfo2);
11186 displayGroupInfo.displaysInfo[0].displaySourceMode = DisplaySourceMode::SCREEN_MAIN;
11187 displayGroupInfo.displaysInfo[1].displaySourceMode = DisplaySourceMode::SCREEN_MAIN;
11188 cursorPosMap_[1] = {1, Direction::DIRECTION0, Direction::DIRECTION0, {512, 384}};
11189 cursorPosMap_[2] = {2, Direction::DIRECTION0, Direction::DIRECTION0, {512, 384}};
11190 displayGroupInfoMap_[1] = displayGroupInfo;
11191 displayGroupInfoMap_[2] = displayGroupInfo;
11192 displayGroupInfo.displaysInfo[0].rsId = 1;
11193 displayGroupInfo.displaysInfo[0].validWidth = 1024;
11194 displayGroupInfo.displaysInfo[0].validHeight = 768;
11195 cursorPosMap_[1].cursorPos.x = 513;
11196 cursorPosMap_[1].cursorPos.y = 384;
11197 inputManager.cursorPosMap_ = cursorPosMap_;
11198 inputManager.displayGroupInfoMap_ = displayGroupInfoMap_;
11199 EXPECT_NO_FATAL_FAILURE(inputManager.ResetPointerPosition(displayGroupInfo));
11200 }
11201
11202 /**
11203 * @tc.name: InputWindowsManagerTest_ResetPointerPosition_004
11204 * @tc.desc: Test ResetPointerPosition
11205 * @tc.type: FUNC
11206 * @tc.require:
11207 */
11208 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ResetPointerPosition_004, TestSize.Level1)
11209 {
11210 CALL_TEST_DEBUG;
11211 InputWindowsManager inputManager;
11212 OLD::DisplayGroupInfo displayGroupInfo;
11213 std::map<int32_t, CursorPosition> cursorPosMap_;
11214 std::map<int32_t, OLD::DisplayGroupInfo> displayGroupInfoMap_;
11215 OLD::DisplayInfo displaysInfo;
11216 displaysInfo.id = 1;
11217 displaysInfo.x = 0;
11218 displaysInfo.y = 0;
11219 displaysInfo.width = 1024;
11220 displaysInfo.height = 768;
11221 displaysInfo.dpi = 160;
11222 displaysInfo.name = "Display1";
11223 displaysInfo.uniq = "default0";
11224 displaysInfo.direction = Direction::DIRECTION0;
11225 displaysInfo.displayDirection = Direction::DIRECTION0;
11226 displaysInfo.ppi = 160;
11227 displaysInfo.screenRealWidth = 1024;
11228 displaysInfo.screenRealHeight = 768;
11229 displaysInfo.screenRealDPI = 160;
11230 displaysInfo.validWidth = 1024;
11231 displaysInfo.validHeight = 768;
11232 displaysInfo.fixedDirection = Direction::DIRECTION0;
11233 displaysInfo.physicalWidth = 0;
11234 displaysInfo.physicalHeight = 0;
11235 displaysInfo.pointerActiveWidth = 1;
11236 displaysInfo.pointerActiveHeight = 1;
11237 displaysInfo.rsId = 1;
11238 displayGroupInfo.displaysInfo.push_back(displaysInfo);
11239 OLD::DisplayInfo displaysInfo2;
11240 displaysInfo2.id = 2;
11241 displaysInfo2.x = 0;
11242 displaysInfo2.y = 0;
11243 displaysInfo2.width = 1024;
11244 displaysInfo2.height = 768;
11245 displaysInfo2.dpi = 160;
11246 displaysInfo2.name = "Display2";
11247 displaysInfo2.uniq = "default1";
11248 displaysInfo2.direction = Direction::DIRECTION0;
11249 displaysInfo2.displayDirection = Direction::DIRECTION0;
11250 displaysInfo2.ppi = 160;
11251 displaysInfo2.screenRealWidth = 1024;
11252 displaysInfo2.screenRealHeight = 768;
11253 displaysInfo2.screenRealDPI = 160;
11254 displaysInfo2.validWidth = 1024;
11255 displaysInfo2.validHeight = 768;
11256 displaysInfo2.fixedDirection = Direction::DIRECTION0;
11257 displaysInfo2.physicalWidth = 0;
11258 displaysInfo2.physicalHeight = 0;
11259 displaysInfo2.pointerActiveWidth = 2;
11260 displaysInfo2.pointerActiveHeight = 2;
11261 displaysInfo2.rsId = 2;
11262 displayGroupInfo.displaysInfo.push_back(displaysInfo2);
11263 displayGroupInfo.displaysInfo[0].displaySourceMode = DisplaySourceMode::SCREEN_MAIN;
11264 displayGroupInfo.displaysInfo[1].displaySourceMode = DisplaySourceMode::SCREEN_MAIN;
11265 cursorPosMap_[1] = {1, Direction::DIRECTION0, Direction::DIRECTION0, {512, 384}};
11266 cursorPosMap_[2] = {2, Direction::DIRECTION0, Direction::DIRECTION0, {512, 384}};
11267 displayGroupInfoMap_[1] = displayGroupInfo;
11268 displayGroupInfoMap_[2] = displayGroupInfo;
11269 displayGroupInfo.displaysInfo[0].rsId = 1;
11270 displayGroupInfo.displaysInfo[0].validWidth = 1024;
11271 displayGroupInfo.displaysInfo[0].validHeight = 768;
11272 cursorPosMap_[1].cursorPos.x = 512;
11273 cursorPosMap_[1].cursorPos.y = 384;
11274 inputManager.cursorPosMap_ = cursorPosMap_;
11275 inputManager.displayGroupInfoMap_ = displayGroupInfoMap_;
11276 EXPECT_NO_FATAL_FAILURE(inputManager.ResetPointerPosition(displayGroupInfo));
11277 }
11278
11279 class MockPointerEvent : public PointerEvent
11280 {
11281 public:
MockPointerEvent()11282 MockPointerEvent() : PointerEvent(PointerEvent::GLOBAL_COORDINATE) {}
11283 MOCK_METHOD(bool, HasFlag, (uint32_t));
11284 MOCK_METHOD(bool, GetPointerItem, (int32_t, PointerItem &), (const));
11285 MOCK_METHOD(void, SetTargetDisplayId, (int32_t));
11286 MOCK_METHOD(void, UpdatePointerItem, (int32_t, PointerItem &));
11287
11288 class MockPointerItem : public PointerEvent::PointerItem
11289 {
11290 public:
11291 MOCK_METHOD(int32_t, GetPointerId, (), (const));
11292 MOCK_METHOD(double, GetGlobalX, (), (const));
11293 MOCK_METHOD(double, GetGlobalY, (), (const));
11294 MOCK_METHOD(void, SetDisplayX, (int32_t));
11295 MOCK_METHOD(void, SetDisplayY, (int32_t));
11296 };
11297 };
11298
11299 /**
11300 * @tc.name: InputWindowsManagerTest_ProcessInjectEventGlobalXY_009
11301 * @tc.desc: Test ProcessInjectEventGlobalXY
11302 * @tc.type: FUNC
11303 * @tc.require:
11304 */
11305 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ProcessInjectEventGlobalXY_009, TestSize.Level1)
11306 {
11307 CALL_TEST_DEBUG;
11308 InputWindowsManager manager;
11309 OLD::DisplayGroupInfo defaultGroup;
11310 defaultGroup.type = GroupType::GROUP_DEFAULT;
11311 defaultGroup.displaysInfo = {{1, 0, 0, 100, 100}, {2, 150, 150, 100, 100}};
11312 manager.displayGroupInfoMap_[0] = defaultGroup;
11313
11314 auto mockPointerEvent = std::make_shared<MockPointerEvent>();
11315 EXPECT_CALL(*mockPointerEvent, HasFlag(InputEvent::EVENT_FLAG_SIMULATE)).WillRepeatedly(Return(false));
11316 EXPECT_NO_FATAL_FAILURE(manager.ProcessInjectEventGlobalXY(mockPointerEvent, PointerEvent::GLOBAL_COORDINATE));
11317 }
11318
11319 /**
11320 * @tc.name: InputWindowsManagerTest_ProcessInjectEventGlobalXY_010
11321 * @tc.desc: Test ProcessInjectEventGlobalXY
11322 * @tc.type: FUNC
11323 * @tc.require:
11324 */
11325 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ProcessInjectEventGlobalXY_010, TestSize.Level1)
11326 {
11327 CALL_TEST_DEBUG;
11328
11329 InputWindowsManager manager;
11330 OLD::DisplayGroupInfo defaultGroup;
11331 defaultGroup.type = GroupType::GROUP_DEFAULT;
11332 defaultGroup.displaysInfo = {{1, 0, 0, 100, 100}, {2, 150, 150, 100, 100}};
11333 manager.displayGroupInfoMap_[0] = defaultGroup;
11334
11335 auto mockPointerEvent = std::make_shared<MockPointerEvent>();
11336 EXPECT_CALL(*mockPointerEvent, HasFlag(InputEvent::EVENT_FLAG_SIMULATE)).WillRepeatedly(Return(true));
11337 EXPECT_NO_FATAL_FAILURE(manager.ProcessInjectEventGlobalXY(mockPointerEvent, 0));
11338 }
11339
11340 /**
11341 * @tc.name: InputWindowsManagerTest_ProcessInjectEventGlobalXY_011
11342 * @tc.desc: Test ProcessInjectEventGlobalXY
11343 * @tc.type: FUNC
11344 * @tc.require:
11345 */
11346 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ProcessInjectEventGlobalXY_011, TestSize.Level1)
11347 {
11348 CALL_TEST_DEBUG;
11349
11350 InputWindowsManager manager;
11351 OLD::DisplayGroupInfo defaultGroup;
11352 defaultGroup.type = GroupType::GROUP_DEFAULT;
11353 defaultGroup.displaysInfo = {{1, 0, 0, 100, 100}, {2, 150, 150, 100, 100}};
11354 manager.displayGroupInfoMap_[0] = defaultGroup;
11355
11356 auto mockPointerEvent = std::make_shared<MockPointerEvent>();
11357 EXPECT_CALL(*mockPointerEvent, HasFlag(InputEvent::EVENT_FLAG_SIMULATE)).WillRepeatedly(Return(true));
11358 EXPECT_CALL(*mockPointerEvent, GetPointerItem(::testing::_, ::testing::_)).WillRepeatedly(Return(false));
11359 EXPECT_NO_FATAL_FAILURE(manager.ProcessInjectEventGlobalXY(mockPointerEvent, PointerEvent::GLOBAL_COORDINATE));
11360 }
11361
11362 /**
11363 * @tc.name: InputWindowsManagerTest_ProcessInjectEventGlobalXY_012
11364 * @tc.desc: Test ProcessInjectEventGlobalXY
11365 * @tc.type: FUNC
11366 * @tc.require:
11367 */
11368 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ProcessInjectEventGlobalXY_012, TestSize.Level1)
11369 {
11370 CALL_TEST_DEBUG;
11371
11372 InputWindowsManager manager;
11373 OLD::DisplayGroupInfo defaultGroup;
11374 defaultGroup.type = GroupType::GROUP_DEFAULT;
11375 defaultGroup.displaysInfo = {{1, 0, 0, 100, 100}, {2, 150, 150, 100, 100}};
11376 manager.displayGroupInfoMap_[0] = defaultGroup;
11377
11378 auto mockPointerEvent = std::make_shared<MockPointerEvent>();
11379 MockPointerEvent::MockPointerItem mockPointerItem;
11380 EXPECT_CALL(*mockPointerEvent, HasFlag(InputEvent::EVENT_FLAG_SIMULATE)).WillRepeatedly(Return(true));
11381 EXPECT_CALL(*mockPointerEvent, GetPointerItem(::testing::_, ::testing::_))
11382 .WillRepeatedly(DoAll(SetArgReferee<1>(::testing::ByRef(mockPointerItem)), Return(true)));
11383 EXPECT_CALL(mockPointerItem, GetGlobalX()).WillRepeatedly(Return(DBL_MAX));
11384 EXPECT_CALL(mockPointerItem, GetGlobalY()).WillRepeatedly(Return(50.0));
11385 EXPECT_EQ(mockPointerItem.GetGlobalY(), 50.0);
11386 EXPECT_EQ(mockPointerItem.GetGlobalX(), DBL_MAX);
11387 EXPECT_NO_FATAL_FAILURE(manager.ProcessInjectEventGlobalXY(mockPointerEvent, PointerEvent::GLOBAL_COORDINATE));
11388 }
11389
11390 /**
11391 * @tc.name: InputWindowsManagerTest_ProcessInjectEventGlobalXY_013
11392 * @tc.desc: Test ProcessInjectEventGlobalXY
11393 * @tc.type: FUNC
11394 * @tc.require:
11395 */
11396 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ProcessInjectEventGlobalXY_013, TestSize.Level1)
11397 {
11398 CALL_TEST_DEBUG;
11399
11400 InputWindowsManager manager;
11401 OLD::DisplayGroupInfo defaultGroup;
11402 defaultGroup.type = GroupType::GROUP_DEFAULT;
11403 defaultGroup.displaysInfo = {{1, 0, 0, 100, 100}, {2, 150, 150, 100, 100}};
11404 manager.displayGroupInfoMap_[0] = defaultGroup;
11405
11406 auto mockPointerEvent = std::make_shared<MockPointerEvent>();
11407 MockPointerEvent::MockPointerItem mockPointerItem;
11408 EXPECT_CALL(*mockPointerEvent, HasFlag(InputEvent::EVENT_FLAG_SIMULATE)).WillRepeatedly(Return(true));
11409 EXPECT_CALL(*mockPointerEvent, GetPointerItem(::testing::_, ::testing::_))
11410 .WillRepeatedly(DoAll(SetArgReferee<1>(::testing::ByRef(mockPointerItem)), Return(true)));
11411 EXPECT_CALL(mockPointerItem, GetGlobalX()).WillRepeatedly(Return(50.0));
11412 EXPECT_CALL(mockPointerItem, GetGlobalY()).WillRepeatedly(Return(50.0));
11413 EXPECT_EQ(mockPointerItem.GetGlobalY(), 50.0);
11414 EXPECT_EQ(mockPointerItem.GetGlobalX(), 50.0);
11415 EXPECT_NO_FATAL_FAILURE(manager.ProcessInjectEventGlobalXY(mockPointerEvent, PointerEvent::GLOBAL_COORDINATE));
11416 }
11417
11418 /**
11419 * @tc.name: InputWindowsManagerTest_ProcessInjectEventGlobalXY_014
11420 * @tc.desc: Test ProcessInjectEventGlobalXY
11421 * @tc.type: FUNC
11422 * @tc.require:
11423 */
11424 HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_ProcessInjectEventGlobalXY_014, TestSize.Level1)
11425 {
11426 CALL_TEST_DEBUG;
11427
11428 InputWindowsManager manager;
11429 OLD::DisplayGroupInfo defaultGroup;
11430 defaultGroup.type = GroupType::GROUP_DEFAULT;
11431 defaultGroup.displaysInfo = {{1, 0, 0, 100, 100}, {2, 150, 150, 100, 100}};
11432 manager.displayGroupInfoMap_[0] = defaultGroup;
11433
11434 auto mockPointerEvent = std::make_shared<MockPointerEvent>();
11435 MockPointerEvent::MockPointerItem mockPointerItem;
11436 EXPECT_CALL(*mockPointerEvent, HasFlag(InputEvent::EVENT_FLAG_SIMULATE)).WillRepeatedly(Return(true));
11437 EXPECT_CALL(*mockPointerEvent, GetPointerItem(::testing::_, ::testing::_))
11438 .WillRepeatedly(DoAll(SetArgReferee<1>(::testing::ByRef(mockPointerItem)), Return(true)));
11439 EXPECT_CALL(mockPointerItem, GetGlobalX()).WillRepeatedly(Return(200.0));
11440 EXPECT_CALL(mockPointerItem, GetGlobalY()).WillRepeatedly(Return(200.0));
11441 EXPECT_EQ(mockPointerItem.GetGlobalY(), 200.0);
11442 EXPECT_EQ(mockPointerItem.GetGlobalX(), 200.0);
11443 EXPECT_NO_FATAL_FAILURE(manager.ProcessInjectEventGlobalXY(mockPointerEvent, PointerEvent::GLOBAL_COORDINATE));
11444 }
11445 } // namespace MMI
11446 } // namespace OHOS