• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 "../ui_input_event_test.h"
17 
18 using namespace testing;
19 using namespace testing::ext;
20 
21 namespace OHOS::Ace {
22 
23 /**
24  * @tc.name: OH_ArkUI_PointerEvent_SetClonedEventLocalPosition001
25  * @tc.desc: Test with null event pointer
26  * @tc.type: FUNC
27  */
28 HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_SetClonedEventLocalPosition001, TestSize.Level0)
29 {
30     auto result = OH_ArkUI_PointerEvent_SetClonedEventLocalPosition(nullptr, 10.0f, 20.0f);
31     EXPECT_EQ(result, ARKUI_ERROR_CODE_PARAM_INVALID);
32 }
33 
34 /**
35  * @tc.name: OH_ArkUI_PointerEvent_SetClonedEventLocalPosition002
36  * @tc.desc: Test with non-cloned event
37  * @tc.type: FUNC
38  */
39 HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_SetClonedEventLocalPosition002, TestSize.Level0)
40 {
41     ArkUITouchEvent touchEvent = {};
42     ArkUI_UIInputEvent event = { ARKUI_UIINPUTEVENT_TYPE_UNKNOWN, C_TOUCH_EVENT_ID, &touchEvent, false };
43 
44     auto result = OH_ArkUI_PointerEvent_SetClonedEventLocalPosition(&event, 10.0f, 20.0f);
45     EXPECT_EQ(result, ARKUI_ERROR_CODE_NOT_CLONED_POINTER_EVENT);
46 }
47 
48 /**
49  * @tc.name: OH_ArkUI_PointerEvent_SetClonedEventLocalPosition003
50  * @tc.desc: Test with null inputEvent in cloned event
51  * @tc.type: FUNC
52  */
53 HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_SetClonedEventLocalPosition003, TestSize.Level0)
54 {
55     ArkUI_UIInputEvent event = { ARKUI_UIINPUTEVENT_TYPE_UNKNOWN, C_TOUCH_EVENT_ID, nullptr, true };
56 
57     auto result = OH_ArkUI_PointerEvent_SetClonedEventLocalPosition(&event, 10.0f, 20.0f);
58     EXPECT_EQ(result, ARKUI_ERROR_CODE_PARAM_INVALID);
59 }
60 
61 /**
62  * @tc.name: OH_ArkUI_PointerEvent_SetClonedEventLocalPosition101
63  * @tc.desc: Test successful position setting with valid parameters
64  * @tc.type: FUNC
65  */
66 HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_SetClonedEventLocalPosition101, TestSize.Level0)
67 {
68     ArkUITouchEvent touchEvent = {};
69     ArkUI_UIInputEvent event = { ARKUI_UIINPUTEVENT_TYPE_UNKNOWN, C_TOUCH_EVENT_ID, &touchEvent, true };
70 
71     const float testX = 15.5f;
72     const float testY = 25.5f;
73     auto result = OH_ArkUI_PointerEvent_SetClonedEventLocalPosition(&event, testX, testY);
74 
75     EXPECT_EQ(result, ARKUI_ERROR_CODE_NO_ERROR);
76     EXPECT_FLOAT_EQ(touchEvent.actionTouchPoint.nodeX, testX);
77     EXPECT_FLOAT_EQ(touchEvent.actionTouchPoint.nodeY, testY);
78 }
79 
80 /**
81  * @tc.name: OH_ArkUI_PointerEvent_SetClonedEventLocalPosition102
82  * @tc.desc: Test with unsupported event type (mouse event)
83  * @tc.type: FUNC
84  */
85 HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_SetClonedEventLocalPosition102, TestSize.Level0)
86 {
87     ArkUITouchEvent touchEvent = {};
88     ArkUI_UIInputEvent event = { ARKUI_UIINPUTEVENT_TYPE_UNKNOWN, C_MOUSE_EVENT_ID, &touchEvent, true };
89 
90     auto result = OH_ArkUI_PointerEvent_SetClonedEventLocalPosition(&event, 10.0f, 20.0f);
91     EXPECT_EQ(result, ARKUI_ERROR_CODE_NO_ERROR);
92 }
93 
94 } // namespace OHOS::Ace