• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 #include "accessibility_element_info_parcel.h"
18 
19 using namespace testing;
20 using namespace testing::ext;
21 
22 namespace OHOS {
23 namespace Accessibility {
24 class AccessibilityElementInfoParcelTest : public ::testing::Test {
25 public:
AccessibilityElementInfoParcelTest()26     AccessibilityElementInfoParcelTest()
27     {}
~AccessibilityElementInfoParcelTest()28     ~AccessibilityElementInfoParcelTest()
29     {}
SetUpTestCase()30     static void SetUpTestCase()
31     {
32         GTEST_LOG_(INFO) << "AccessibilityElementInfoParcelTest Start";
33     }
TearDownTestCase()34     static void TearDownTestCase()
35     {
36         GTEST_LOG_(INFO) << "AccessibilityElementInfoParcelTest End";
37     }
SetUp()38     void SetUp()
39     {
40         GTEST_LOG_(INFO) << "AccessibilityElementInfoParcelTest SetUp() Start";
41         elementInfo_ = std::make_shared<AccessibilityElementInfo>();
42         elementInfoParcel_ = std::make_shared<AccessibilityElementInfoParcel>(*elementInfo_);
43         spanInfo_ = std::make_shared<SpanInfo>();
44         spanInfoParcel_ = std::make_shared<SpanInfoParcel>(*spanInfo_);
45         action_ = std::make_shared<AccessibleAction>();
46         actionParcel_ = std::make_shared<AccessibleActionParcel>(*action_);
47         rangeInfo_ = std::make_shared<RangeInfo>();
48         rangeInfoParcel_ = std::make_shared<RangeInfoParcel>(*rangeInfo_);
49         gridInfo_ = std::make_shared<GridInfo>();
50         gridInfoParcel_ = std::make_shared<GridInfoParcel>(*gridInfo_);
51         gridItemInfo_ = std::make_shared<GridItemInfo>();
52         gridItemInfoParcel_ = std::make_shared<GridItemInfoParcel>(*gridItemInfo_);
53         rect_ = std::make_shared<Rect>();
54         rectParcel_ = std::make_shared<RectParcel>(*rect_);
55         extraElementInfo_ = std::make_shared<ExtraElementInfo>();
56         extraElementInfoParcel_ = std::make_shared<ExtraElementInfoParcel>(*extraElementInfo_);
57         GTEST_LOG_(INFO) << "AccessibilityElementInfoParcelTest SetUp() End";
58     };
TearDown()59     void TearDown()
60     {
61         GTEST_LOG_(INFO) << "AccessibilityElementInfoParcelTest TearDown()";
62         elementInfo_ = nullptr;
63         elementInfoParcel_ = nullptr;
64         spanInfo_ = nullptr;
65         spanInfoParcel_ = nullptr;
66         action_ = nullptr;
67         actionParcel_ = nullptr;
68         rangeInfo_ = nullptr;
69         rangeInfoParcel_ = nullptr;
70         gridInfo_ = nullptr;
71         gridInfoParcel_ = nullptr;
72         gridItemInfo_ = nullptr;
73         gridItemInfoParcel_ = nullptr;
74         rect_ = nullptr;
75         rectParcel_ = nullptr;
76         extraElementInfo_ = nullptr;
77         extraElementInfoParcel_ = nullptr;
78     }
79 
80     std::shared_ptr<AccessibleAction> action_ = nullptr;
81     std::shared_ptr<AccessibleActionParcel> actionParcel_ = nullptr;
82     std::shared_ptr<RangeInfo> rangeInfo_ = nullptr;
83     std::shared_ptr<RangeInfoParcel> rangeInfoParcel_ = nullptr;
84     std::shared_ptr<GridInfo> gridInfo_ = nullptr;
85     std::shared_ptr<GridInfoParcel> gridInfoParcel_ = nullptr;
86     std::shared_ptr<GridItemInfo> gridItemInfo_ = nullptr;
87     std::shared_ptr<GridItemInfoParcel> gridItemInfoParcel_ = nullptr;
88     std::shared_ptr<Rect> rect_ = nullptr;
89     std::shared_ptr<RectParcel> rectParcel_ = nullptr;
90     std::shared_ptr<AccessibilityElementInfo> elementInfo_ = nullptr;
91     std::shared_ptr<AccessibilityElementInfoParcel> elementInfoParcel_ = nullptr;
92     std::shared_ptr<SpanInfo> spanInfo_ = nullptr;
93     std::shared_ptr<SpanInfoParcel> spanInfoParcel_ = nullptr;
94     std::shared_ptr<ExtraElementInfo> extraElementInfo_ = nullptr;
95     std::shared_ptr<ExtraElementInfoParcel> extraElementInfoParcel_ = nullptr;
96 };
97 
98 /**
99  * @tc.number: Element_Info__Marshalling_001
100  * @tc.name: Element_Info_Marshalling
101  * @tc.desc: Test function Marshalling
102  */
103 HWTEST_F(AccessibilityElementInfoParcelTest, Element_Info_Marshalling_001, TestSize.Level1)
104 {
105     GTEST_LOG_(INFO) << "Element_Info_Marshalling_001 start";
106     if (!elementInfoParcel_) {
107         GTEST_LOG_(INFO) << "elementInfoParcel_ is null";
108     } else {
109         Parcel parcel;
110         bool ret = elementInfoParcel_->Marshalling(parcel);
111         EXPECT_EQ(ret, true);
112     }
113     GTEST_LOG_(INFO) << "Element_Info_Marshalling_001 end";
114 }
115 
116 /**
117  * @tc.number: Element_Info_Unmarshalling_001
118  * @tc.name: Element_Info_Unmarshalling
119  * @tc.desc: Test function Unmarshalling
120  */
121 HWTEST_F(AccessibilityElementInfoParcelTest, Element_Info_Unmarshalling_001, TestSize.Level1)
122 {
123     GTEST_LOG_(INFO) << "Element_Info_Unmarshalling_001 start";
124     if (!elementInfoParcel_) {
125         GTEST_LOG_(INFO) << "elementInfoParcel_ is null";
126     } else {
127         Parcel parcel;
128         sptr<AccessibilityElementInfoParcel> elementInfoParcel = elementInfoParcel_->Unmarshalling(parcel);
129         EXPECT_EQ(true, elementInfoParcel == nullptr);
130     }
131     GTEST_LOG_(INFO) << "Element_Info_Unmarshalling_001 end";
132 }
133 
134 /**
135  * @tc.number: Rect_Marshalling_001
136  * @tc.name: Rect_Marshalling
137  * @tc.desc: Test function Marshalling
138  */
139 HWTEST_F(AccessibilityElementInfoParcelTest, Rect_Marshalling_001, TestSize.Level1)
140 {
141     GTEST_LOG_(INFO) << "Rect_Marshalling_001 start";
142     if (!rectParcel_) {
143         GTEST_LOG_(INFO) << "rectParcel_ is null";
144     } else {
145         Parcel parcel;
146         bool ret = rectParcel_->Marshalling(parcel);
147         EXPECT_EQ(ret, true);
148     }
149     GTEST_LOG_(INFO) << "Rect_Marshalling_001 end";
150 }
151 
152 /**
153  * @tc.number: Rect_Unmarshalling_001
154  * @tc.name: Rect__Unmarshalling
155  * @tc.desc: Test function Unmarshalling
156  */
157 HWTEST_F(AccessibilityElementInfoParcelTest, Rect_Unmarshalling_001, TestSize.Level1)
158 {
159     GTEST_LOG_(INFO) << "Rect_Unmarshalling_001 start";
160     if (!rectParcel_) {
161         GTEST_LOG_(INFO) << "rectParcel_ is null";
162     } else {
163         Parcel parcel;
164         sptr<RectParcel> rectParcel = rectParcel_->Unmarshalling(parcel);
165         EXPECT_EQ(true, rectParcel == nullptr);
166     }
167     GTEST_LOG_(INFO) << "Rect_Unmarshalling_001 end";
168 }
169 
170 /**
171  * @tc.number: Grid_Item_Info_Marshalling_001
172  * @tc.name: Grid_Item_Info_Marshalling
173  * @tc.desc: Test function Marshalling
174  */
175 HWTEST_F(AccessibilityElementInfoParcelTest, Grid_Item_Info_Marshalling_001, TestSize.Level1)
176 {
177     GTEST_LOG_(INFO) << "Grid_Item_Info_Marshalling_001 start";
178     if (!gridItemInfoParcel_) {
179         GTEST_LOG_(INFO) << "gridItemInfoParcel_ is null";
180     } else {
181         Parcel parcel;
182         bool ret = gridItemInfoParcel_->Marshalling(parcel);
183         EXPECT_EQ(ret, true);
184     }
185     GTEST_LOG_(INFO) << "Grid_Item_Info_Marshalling_001 end";
186 }
187 
188 /**
189  * @tc.number: Grid_Item_Info_Unmarshalling_001
190  * @tc.name: Grid_Item_Info_Unmarshalling
191  * @tc.desc: Test function Unmarshalling
192  */
193 HWTEST_F(AccessibilityElementInfoParcelTest, Grid_Item_Info_Unmarshalling_001, TestSize.Level1)
194 {
195     GTEST_LOG_(INFO) << "Grid_Item_Info_Unmarshalling_001 start";
196     if (!gridItemInfoParcel_) {
197         GTEST_LOG_(INFO) << "gridItemInfoParcel_ is null";
198     } else {
199         Parcel parcel;
200         sptr<GridItemInfoParcel> gridItemInfoParcel = gridItemInfoParcel_->Unmarshalling(parcel);
201         EXPECT_EQ(true, gridItemInfoParcel == nullptr);
202     }
203     GTEST_LOG_(INFO) << "Grid_Item_Info_Unmarshalling_001 end";
204 }
205 
206 /**
207  * @tc.number: Action_Marshalling_001
208  * @tc.name: Action_Marshalling
209  * @tc.desc: Test function Marshalling
210  */
211 HWTEST_F(AccessibilityElementInfoParcelTest, Action_Marshalling_001, TestSize.Level1)
212 {
213     GTEST_LOG_(INFO) << "Action_Marshalling_001 start";
214     if (!actionParcel_) {
215         GTEST_LOG_(INFO) << "actionParcel_ is null";
216     } else {
217         Parcel parcel;
218         bool ret = actionParcel_->Marshalling(parcel);
219         EXPECT_EQ(ret, true);
220     }
221     GTEST_LOG_(INFO) << "Action_Marshalling_001 end";
222 }
223 
224 /**
225  * @tc.number: Action_Unmarshalling_001
226  * @tc.name: Action_Unmarshalling
227  * @tc.desc: Test function Unmarshalling
228  */
229 HWTEST_F(AccessibilityElementInfoParcelTest, Action_Unmarshalling_001, TestSize.Level1)
230 {
231     GTEST_LOG_(INFO) << "Action_Unmarshalling_001 start";
232     if (!actionParcel_) {
233         GTEST_LOG_(INFO) << "actionParcel_ is null";
234     } else {
235         Parcel parcel;
236         sptr<AccessibleActionParcel> actionParcel = actionParcel_->Unmarshalling(parcel);
237         EXPECT_EQ(true, actionParcel == nullptr);
238     }
239     GTEST_LOG_(INFO) << "Action_Unmarshalling_001 end";
240 }
241 
242 /**
243  * @tc.number: Range_Info_Marshalling_001
244  * @tc.name: Range_Info_Marshalling
245  * @tc.desc: Test function Marshalling
246  */
247 HWTEST_F(AccessibilityElementInfoParcelTest, Range_Info_Marshalling_001, TestSize.Level1)
248 {
249     GTEST_LOG_(INFO) << "Range_Info_Marshalling_001 start";
250     if (!rangeInfoParcel_) {
251         GTEST_LOG_(INFO) << "rangeInfoParcel_ is null";
252     } else {
253         Parcel parcel;
254         bool ret = rangeInfoParcel_->Marshalling(parcel);
255         EXPECT_EQ(ret, true);
256     }
257     GTEST_LOG_(INFO) << "Range_Info_Marshalling_001 end";
258 }
259 
260 /**
261  * @tc.number: Range_Info_Unmarshalling_001
262  * @tc.name: Range_Info_Unmarshalling
263  * @tc.desc: Test function Unmarshalling
264  */
265 HWTEST_F(AccessibilityElementInfoParcelTest, Range_Info_Unmarshalling_001, TestSize.Level1)
266 {
267     GTEST_LOG_(INFO) << "Range_Info_Unmarshalling_001 start";
268     if (!rangeInfoParcel_) {
269         GTEST_LOG_(INFO) << "rangeInfoParcel_ is null";
270     } else {
271         Parcel parcel;
272         sptr<RangeInfoParcel> rangeInfoParcel = rangeInfoParcel_->Unmarshalling(parcel);
273         EXPECT_EQ(true, rangeInfoParcel == nullptr);
274     }
275     GTEST_LOG_(INFO) << "Range_Info_Unmarshalling_001 end";
276 }
277 
278 /**
279  * @tc.number: Grid_Info_Marshalling_001
280  * @tc.name: Grid_Info_Marshalling
281  * @tc.desc: Test function Marshalling
282  */
283 HWTEST_F(AccessibilityElementInfoParcelTest, Grid_Info_Marshalling_001, TestSize.Level1)
284 {
285     GTEST_LOG_(INFO) << "Grid_Info_Marshalling_001 start";
286     if (!gridInfoParcel_) {
287         GTEST_LOG_(INFO) << "gridInfoParcel_ is null";
288     } else {
289         Parcel parcel;
290         bool ret = gridInfoParcel_->Marshalling(parcel);
291         EXPECT_EQ(ret, true);
292     }
293     GTEST_LOG_(INFO) << "Grid_Info_Marshalling_001 end";
294 }
295 
296 /**
297  * @tc.number: Grid_Info_Unmarshalling_001
298  * @tc.name: Grid_Info_Unmarshalling
299  * @tc.desc: Test function Unmarshalling
300  */
301 HWTEST_F(AccessibilityElementInfoParcelTest, Grid_Info_Unmarshalling_001, TestSize.Level1)
302 {
303     GTEST_LOG_(INFO) << "Grid_Info_Unmarshalling_001 start";
304     if (!gridInfoParcel_) {
305         GTEST_LOG_(INFO) << "gridInfoParcel_ is null";
306     } else {
307         Parcel parcel;
308         sptr<GridInfoParcel> gridInfoParcel = gridInfoParcel_->Unmarshalling(parcel);
309         EXPECT_EQ(true, gridInfoParcel == nullptr);
310     }
311     GTEST_LOG_(INFO) << "Grid_Info_Unmarshalling_001 end";
312 }
313 
314 /**
315  * @tc.number: Extra_Element_Info_Parcel__001
316  * @tc.name: Extra_Element_Info_Parcel
317  * @tc.desc: Test function ReadFromParcel
318  */
319 HWTEST_F(AccessibilityElementInfoParcelTest, Extra_Element_Info_Parcel__001, TestSize.Level1)
320 {
321     GTEST_LOG_(INFO) << "Extra_Element_Info_Parcel__001 start";
322     if (!extraElementInfoParcel_) {
323         GTEST_LOG_(INFO) << "extraElementInfoParcel_ is null";
324     } else {
325         Parcel parcel;
326         EXPECT_EQ(false, extraElementInfoParcel_->ReadFromParcel(parcel));
327     }
328     GTEST_LOG_(INFO) << "Extra_Element_Info_Parcel__001 end";
329 }
330 
331 /**
332  * @tc.number: Extra_Element_Info_Parcel__002
333  * @tc.name: Extra_Element_Info_Parcel
334  * @tc.desc: Test function Unmarshalling
335  */
336 HWTEST_F(AccessibilityElementInfoParcelTest, Extra_Element_Info_Parcel__002, TestSize.Level1)
337 {
338     GTEST_LOG_(INFO) << "Extra_Element_Info_Parcel__002 start";
339     if (!extraElementInfoParcel_) {
340         GTEST_LOG_(INFO) << "extraElementInfoParcel_ is null";
341     } else {
342         Parcel parcel;
343         sptr<ExtraElementInfoParcel> extraElementInfoParcel = extraElementInfoParcel_->Unmarshalling(parcel);
344         EXPECT_EQ(true, extraElementInfoParcel == nullptr);
345     }
346     GTEST_LOG_(INFO) << "Extra_Element_Info_Parcel__002 end";
347 }
348 
349 /**
350  * @tc.number: Span_Info_Parcel__001
351  * @tc.name: Span_Info_Parcel
352  * @tc.desc: Test function ReadFromParcel
353  */
354 HWTEST_F(AccessibilityElementInfoParcelTest, Span_Info_Parcel__001, TestSize.Level1)
355 {
356     GTEST_LOG_(INFO) << "Span_Info_Parcel__001 start";
357     if (!spanInfoParcel_) {
358         GTEST_LOG_(INFO) << "spanInfoParcel_ is null";
359     } else {
360         Parcel parcel;
361         EXPECT_EQ(false, spanInfoParcel_->ReadFromParcel(parcel));
362     }
363     GTEST_LOG_(INFO) << "Span_Info_Parcel__001 end";
364 }
365 
366 /**
367  * @tc.number: Span_Info_Marshalling_001
368  * @tc.name: Span_Info_Marshalling
369  * @tc.desc: Test function Marshalling
370  */
371 HWTEST_F(AccessibilityElementInfoParcelTest, Span_Info_Marshalling_001, TestSize.Level1)
372 {
373     GTEST_LOG_(INFO) << "Span_Info_Marshalling_001 start";
374     if (!spanInfoParcel_) {
375         GTEST_LOG_(INFO) << "spanInfoParcel_ is null";
376     } else {
377         Parcel parcel;
378         bool ret = spanInfoParcel_->Marshalling(parcel);
379         EXPECT_EQ(ret, true);
380     }
381     GTEST_LOG_(INFO) << "Span_Info_Marshalling_001 end";
382 }
383 
384 /**
385  * @tc.number: Span_Info_Unmarshalling__001
386  * @tc.name: Span_Info_Unmarshalling
387  * @tc.desc: Test function Unmarshalling
388  */
389 HWTEST_F(AccessibilityElementInfoParcelTest, Span_Info_Unmarshalling__001, TestSize.Level1)
390 {
391     GTEST_LOG_(INFO) << "Span_Info_Unmarshalling__001 start";
392     if (!spanInfoParcel_) {
393         GTEST_LOG_(INFO) << "spanInfoParcel_ is null";
394     } else {
395         Parcel parcel;
396         sptr<SpanInfoParcel> spanInfoParcel = spanInfoParcel_->Unmarshalling(parcel);
397         EXPECT_EQ(true, spanInfoParcel == nullptr);
398     }
399     GTEST_LOG_(INFO) << "Span_Info_Unmarshalling__001 end";
400 }
401 } // namespace Accessibility
402 } // namespace OHOS