• 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 <gtest/gtest.h>
17 
18 #include "pointer_style.h"
19 #include "mmi_log.h"
20 
21 #undef MMI_LOG_TAG
22 #define MMI_LOG_TAG "PointerStyleTest"
23 
24 namespace OHOS {
25 namespace MMI {
26 namespace {
27 using namespace testing::ext;
28 } // namespace
29 
30 class PointerStyleTest : public testing::Test {
31 public:
SetUpTestCase(void)32     static void SetUpTestCase(void) {}
TearDownTestCase(void)33     static void TearDownTestCase(void) {}
34 };
35 
36 /**
37  * @tc.name: PointerStyleTest_CursorPixelMap_Marshalling_001
38  * @tc.desc: Test Marshalling
39  * @tc.type: FUNC
40  * @tc.require:
41  */
42 HWTEST_F(PointerStyleTest, PointerStyleTest_CursorPixelMap_Marshalling_001, TestSize.Level1)
43 {
44     CALL_TEST_DEBUG;
45     CursorPixelMap cMap;
46     Parcel out;
47     cMap.pixelMap = nullptr;
48     bool ret = cMap.Marshalling(out);
49     ASSERT_FALSE(ret);
50 }
51 
52 /**
53  * @tc.name: PointerStyleTest_CursorPixelMap_ReadFromParcel_001
54  * @tc.desc: Test ReadFromParcel
55  * @tc.type: FUNC
56  * @tc.require:
57  */
58 HWTEST_F(PointerStyleTest, PointerStyleTest_CursorPixelMap_ReadFromParcel_001, TestSize.Level1)
59 {
60     CALL_TEST_DEBUG;
61     CursorPixelMap cMap;
62     Parcel out;
63     cMap.pixelMap = nullptr;
64     bool ret = cMap.ReadFromParcel(out);
65     ASSERT_FALSE(ret);
66 }
67 
68 /**
69  * @tc.name: PointerStyleTest_CursorPixelMap_Unmarshalling_001
70  * @tc.desc: Test Unmarshalling
71  * @tc.type: FUNC
72  * @tc.require:
73  */
74 HWTEST_F(PointerStyleTest, PointerStyleTest_CursorPixelMap_Unmarshalling_001, TestSize.Level1)
75 {
76     CALL_TEST_DEBUG;
77     CursorPixelMap cMap;
78     Parcel out;
79     cMap.pixelMap = nullptr;
80     auto ret = cMap.Unmarshalling(out);
81     ASSERT_EQ(ret, nullptr);
82 }
83 
84 /**
85  * @tc.name: PointerStyleTest_CursorOptionsParcel_ReadFromParcel_001
86  * @tc.desc: Test ReadFromParcel
87  * @tc.type: FUNC
88  * @tc.require:
89  */
90 HWTEST_F(PointerStyleTest, PointerStyleTest_CursorOptionsParcel_ReadFromParcel_001, TestSize.Level1)
91 {
92     CALL_TEST_DEBUG;
93     CursorOptionsParcel cOpt;
94     Parcel out;
95     cOpt.followSystem = true;
96     bool ret = cOpt.ReadFromParcel(out);
97     ASSERT_FALSE(ret);
98 }
99 
100 /**
101  * @tc.name: PointerStyleTest_CursorOptionsParcel_Unmarshalling_001
102  * @tc.desc: Test Unmarshalling
103  * @tc.type: FUNC
104  * @tc.require:
105  */
106 HWTEST_F(PointerStyleTest, PointerStyleTest_CursorOptionsParcel_Unmarshalling_001, TestSize.Level1)
107 {
108     CALL_TEST_DEBUG;
109     CursorOptionsParcel cOpt;
110     Parcel out;
111     cOpt.followSystem = true;
112     auto ret = cOpt.Unmarshalling(out);
113     ASSERT_EQ(ret, nullptr);
114 }
115 
116 /**
117  * @tc.name: PointerStyleTest_CustomCursorParcel_ReadFromParcel_001
118  * @tc.desc: Test ReadFromParcel
119  * @tc.type: FUNC
120  * @tc.require:
121  */
122 HWTEST_F(PointerStyleTest, PointerStyleTest_CustomCursorParcel_ReadFromParcel_001, TestSize.Level1)
123 {
124     CALL_TEST_DEBUG;
125     CustomCursorParcel cusCor;
126     cusCor.pixelMap = nullptr;
127     cusCor.focusX = 1;
128     cusCor.focusY = 1;
129     Parcel in;
130     bool ret = cusCor.ReadFromParcel(in);
131     ASSERT_FALSE(ret);
132 }
133 
134 /**
135  * @tc.name: PointerStyleTest_CustomCursorParcel_Unmarshalling_001
136  * @tc.desc: Test Unmarshalling
137  * @tc.type: FUNC
138  * @tc.require:
139  */
140 HWTEST_F(PointerStyleTest, PointerStyleTest_CustomCursorParcel_Unmarshalling_001, TestSize.Level1)
141 {
142     CALL_TEST_DEBUG;
143     CustomCursorParcel cusCor;
144     cusCor.pixelMap = nullptr;
145     cusCor.focusX = 1;
146     cusCor.focusY = 1;
147     Parcel out;
148     auto ret = cusCor.Unmarshalling(out);
149     ASSERT_EQ(ret, nullptr);
150 }
151 
152 /**
153  * @tc.name: PointerStyleTest_PointerStyle_ReadFromParcel_001
154  * @tc.desc: Test ReadFromParcel
155  * @tc.type: FUNC
156  * @tc.require:
157  */
158 HWTEST_F(PointerStyleTest, PointerStyleTest_PointerStyle_ReadFromParcel_001, TestSize.Level1)
159 {
160     CALL_TEST_DEBUG;
161     PointerStyle pointerStyle;
162     Parcel parcel;
163     ASSERT_NO_FATAL_FAILURE(pointerStyle.ReadFromParcel(parcel));
164 }
165 
166 /**
167  * @tc.name: PointerStyleTest_PointerStyle_Unmarshalling_001
168  * @tc.desc: Test Unmarshalling
169  * @tc.type: FUNC
170  * @tc.require:
171  */
172 HWTEST_F(PointerStyleTest, PointerStyleTest_PointerStyle_Unmarshalling_001, TestSize.Level1)
173 {
174     CALL_TEST_DEBUG;
175     PointerStyle pointerStyle;
176     Parcel parcel;
177     ASSERT_NO_FATAL_FAILURE(pointerStyle.Unmarshalling(parcel));
178 }
179 } // namespace MMI
180 } // namespace OHOS