• 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_PostClonedEvent001
25  * @tc.desc: Test with null event pointer
26  * @tc.type: FUNC
27  */
28 HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_PostClonedEvent001, TestSize.Level0)
29 {
30     auto result = OH_ArkUI_PointerEvent_PostClonedEvent(nullptr, nullptr);
31     EXPECT_EQ(result, ARKUI_ERROR_CODE_PARAM_INVALID);
32 }
33 
34 /**
35  * @tc.name: OH_ArkUI_PointerEvent_PostClonedEvent002
36  * @tc.desc: Test with null node handle
37  * @tc.type: FUNC
38  */
39 HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_PostClonedEvent002, TestSize.Level0)
40 {
41     ArkUITouchEvent touchEvent = {};
42     ArkUI_UIInputEvent event = { ARKUI_UIINPUTEVENT_TYPE_TOUCH, C_TOUCH_EVENT_ID, &touchEvent, true };
43 
44     auto result = OH_ArkUI_PointerEvent_PostClonedEvent(nullptr, &event);
45     EXPECT_EQ(result, ARKUI_ERROR_CODE_POST_CLONED_COMPONENT_STATUS_ABNORMAL);
46 }
47 
48 /**
49  * @tc.name: OH_ArkUI_PointerEvent_PostClonedEvent003
50  * @tc.desc: Test with non-cloned event
51  * @tc.type: FUNC
52  */
53 HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_PostClonedEvent003, TestSize.Level0)
54 {
55     ArkUITouchEvent touchEvent = {};
56     ArkUI_UIInputEvent event = { ARKUI_UIINPUTEVENT_TYPE_TOUCH, C_TOUCH_EVENT_ID, &touchEvent, false };
57     ArkUI_NodeHandle node = reinterpret_cast<ArkUI_NodeHandle>(0x1234);
58 
59     auto result = OH_ArkUI_PointerEvent_PostClonedEvent(node, &event);
60     EXPECT_EQ(result, ARKUI_ERROR_CODE_NOT_CLONED_POINTER_EVENT);
61 }
62 
63 /**`
64  * @tc.name: OH_ArkUI_PointerEvent_PostClonedEvent004
65  * @tc.desc: Test with null inputEvent in event
66  * @tc.type: FUNC
67  */
68 HWTEST_F(UIInputEventTest, OH_ArkUI_PointerEvent_PostClonedEvent004, TestSize.Level0)
69 {
70     ArkUI_UIInputEvent event = { ARKUI_UIINPUTEVENT_TYPE_TOUCH, C_TOUCH_EVENT_ID, nullptr, true };
71     ArkUI_NodeHandle node = reinterpret_cast<ArkUI_NodeHandle>(0x1234);
72 
73     auto result = OH_ArkUI_PointerEvent_PostClonedEvent(node, &event);
74     EXPECT_EQ(result, ARKUI_ERROR_CODE_PARAM_INVALID);
75 }
76 
77 } // namespace OHOS::Ace
78