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 return; 109 } 110 111 Parcel parcel; 112 bool ret = elementInfoParcel_->Marshalling(parcel); 113 EXPECT_EQ(ret, true); 114 GTEST_LOG_(INFO) << "Element_Info_Marshalling_001 end"; 115 } 116 117 /** 118 * @tc.number: Element_Info_Unmarshalling_001 119 * @tc.name: Element_Info_Unmarshalling 120 * @tc.desc: Test function Unmarshalling 121 */ 122 HWTEST_F(AccessibilityElementInfoParcelTest, Element_Info_Unmarshalling_001, TestSize.Level1) 123 { 124 GTEST_LOG_(INFO) << "Element_Info_Unmarshalling_001 start"; 125 if (!elementInfoParcel_) { 126 GTEST_LOG_(INFO) << "elementInfoParcel_ is null"; 127 return; 128 } 129 130 Parcel parcel; 131 sptr<AccessibilityElementInfoParcel> elementInfoParcel = elementInfoParcel_->Unmarshalling(parcel); 132 EXPECT_EQ(true, elementInfoParcel == nullptr); 133 GTEST_LOG_(INFO) << "Element_Info_Unmarshalling_001 end"; 134 } 135 136 /** 137 * @tc.number: Rect_Marshalling_001 138 * @tc.name: Rect_Marshalling 139 * @tc.desc: Test function Marshalling 140 */ 141 HWTEST_F(AccessibilityElementInfoParcelTest, Rect_Marshalling_001, TestSize.Level1) 142 { 143 GTEST_LOG_(INFO) << "Rect_Marshalling_001 start"; 144 if (!rectParcel_) { 145 GTEST_LOG_(INFO) << "rectParcel_ is null"; 146 return; 147 } 148 149 Parcel parcel; 150 bool ret = rectParcel_->Marshalling(parcel); 151 EXPECT_EQ(ret, true); 152 GTEST_LOG_(INFO) << "Rect_Marshalling_001 end"; 153 } 154 155 /** 156 * @tc.number: Rect_Unmarshalling_001 157 * @tc.name: Rect__Unmarshalling 158 * @tc.desc: Test function Unmarshalling 159 */ 160 HWTEST_F(AccessibilityElementInfoParcelTest, Rect_Unmarshalling_001, TestSize.Level1) 161 { 162 GTEST_LOG_(INFO) << "Rect_Unmarshalling_001 start"; 163 if (!rectParcel_) { 164 GTEST_LOG_(INFO) << "rectParcel_ is null"; 165 return; 166 } 167 168 Parcel parcel; 169 sptr<RectParcel> rectParcel = rectParcel_->Unmarshalling(parcel); 170 EXPECT_EQ(true, rectParcel == nullptr); 171 GTEST_LOG_(INFO) << "Rect_Unmarshalling_001 end"; 172 } 173 174 /** 175 * @tc.number: Grid_Item_Info_Marshalling_001 176 * @tc.name: Grid_Item_Info_Marshalling 177 * @tc.desc: Test function Marshalling 178 */ 179 HWTEST_F(AccessibilityElementInfoParcelTest, Grid_Item_Info_Marshalling_001, TestSize.Level1) 180 { 181 GTEST_LOG_(INFO) << "Grid_Item_Info_Marshalling_001 start"; 182 if (!gridItemInfoParcel_) { 183 GTEST_LOG_(INFO) << "gridItemInfoParcel_ is null"; 184 return; 185 } 186 187 Parcel parcel; 188 bool ret = gridItemInfoParcel_->Marshalling(parcel); 189 EXPECT_EQ(ret, true); 190 GTEST_LOG_(INFO) << "Grid_Item_Info_Marshalling_001 end"; 191 } 192 193 /** 194 * @tc.number: Grid_Item_Info_Unmarshalling_001 195 * @tc.name: Grid_Item_Info_Unmarshalling 196 * @tc.desc: Test function Unmarshalling 197 */ 198 HWTEST_F(AccessibilityElementInfoParcelTest, Grid_Item_Info_Unmarshalling_001, TestSize.Level1) 199 { 200 GTEST_LOG_(INFO) << "Grid_Item_Info_Unmarshalling_001 start"; 201 if (!gridItemInfoParcel_) { 202 GTEST_LOG_(INFO) << "gridItemInfoParcel_ is null"; 203 return; 204 } 205 206 Parcel parcel; 207 sptr<GridItemInfoParcel> gridItemInfoParcel = gridItemInfoParcel_->Unmarshalling(parcel); 208 EXPECT_EQ(true, gridItemInfoParcel == nullptr); 209 GTEST_LOG_(INFO) << "Grid_Item_Info_Unmarshalling_001 end"; 210 } 211 212 /** 213 * @tc.number: Action_Marshalling_001 214 * @tc.name: Action_Marshalling 215 * @tc.desc: Test function Marshalling 216 */ 217 HWTEST_F(AccessibilityElementInfoParcelTest, Action_Marshalling_001, TestSize.Level1) 218 { 219 GTEST_LOG_(INFO) << "Action_Marshalling_001 start"; 220 if (!actionParcel_) { 221 GTEST_LOG_(INFO) << "actionParcel_ is null"; 222 return; 223 } 224 225 Parcel parcel; 226 bool ret = actionParcel_->Marshalling(parcel); 227 EXPECT_EQ(ret, true); 228 GTEST_LOG_(INFO) << "Action_Marshalling_001 end"; 229 } 230 231 /** 232 * @tc.number: Action_Unmarshalling_001 233 * @tc.name: Action_Unmarshalling 234 * @tc.desc: Test function Unmarshalling 235 */ 236 HWTEST_F(AccessibilityElementInfoParcelTest, Action_Unmarshalling_001, TestSize.Level1) 237 { 238 GTEST_LOG_(INFO) << "Action_Unmarshalling_001 start"; 239 if (!actionParcel_) { 240 GTEST_LOG_(INFO) << "actionParcel_ is null"; 241 return; 242 } 243 244 Parcel parcel; 245 sptr<AccessibleActionParcel> actionParcel = actionParcel_->Unmarshalling(parcel); 246 EXPECT_EQ(true, actionParcel == nullptr); 247 GTEST_LOG_(INFO) << "Action_Unmarshalling_001 end"; 248 } 249 250 /** 251 * @tc.number: Range_Info_Marshalling_001 252 * @tc.name: Range_Info_Marshalling 253 * @tc.desc: Test function Marshalling 254 */ 255 HWTEST_F(AccessibilityElementInfoParcelTest, Range_Info_Marshalling_001, TestSize.Level1) 256 { 257 GTEST_LOG_(INFO) << "Range_Info_Marshalling_001 start"; 258 if (!rangeInfoParcel_) { 259 GTEST_LOG_(INFO) << "rangeInfoParcel_ is null"; 260 return; 261 } 262 263 Parcel parcel; 264 bool ret = rangeInfoParcel_->Marshalling(parcel); 265 EXPECT_EQ(ret, true); 266 GTEST_LOG_(INFO) << "Range_Info_Marshalling_001 end"; 267 } 268 269 /** 270 * @tc.number: Range_Info_Unmarshalling_001 271 * @tc.name: Range_Info_Unmarshalling 272 * @tc.desc: Test function Unmarshalling 273 */ 274 HWTEST_F(AccessibilityElementInfoParcelTest, Range_Info_Unmarshalling_001, TestSize.Level1) 275 { 276 GTEST_LOG_(INFO) << "Range_Info_Unmarshalling_001 start"; 277 if (!rangeInfoParcel_) { 278 GTEST_LOG_(INFO) << "rangeInfoParcel_ is null"; 279 return; 280 } 281 282 Parcel parcel; 283 sptr<RangeInfoParcel> rangeInfoParcel = rangeInfoParcel_->Unmarshalling(parcel); 284 EXPECT_EQ(true, rangeInfoParcel == nullptr); 285 GTEST_LOG_(INFO) << "Range_Info_Unmarshalling_001 end"; 286 } 287 288 /** 289 * @tc.number: Grid_Info_Marshalling_001 290 * @tc.name: Grid_Info_Marshalling 291 * @tc.desc: Test function Marshalling 292 */ 293 HWTEST_F(AccessibilityElementInfoParcelTest, Grid_Info_Marshalling_001, TestSize.Level1) 294 { 295 GTEST_LOG_(INFO) << "Grid_Info_Marshalling_001 start"; 296 if (!gridInfoParcel_) { 297 GTEST_LOG_(INFO) << "gridInfoParcel_ is null"; 298 return; 299 } 300 301 Parcel parcel; 302 bool ret = gridInfoParcel_->Marshalling(parcel); 303 EXPECT_EQ(ret, true); 304 GTEST_LOG_(INFO) << "Grid_Info_Marshalling_001 end"; 305 } 306 307 /** 308 * @tc.number: Grid_Info_Unmarshalling_001 309 * @tc.name: Grid_Info_Unmarshalling 310 * @tc.desc: Test function Unmarshalling 311 */ 312 HWTEST_F(AccessibilityElementInfoParcelTest, Grid_Info_Unmarshalling_001, TestSize.Level1) 313 { 314 GTEST_LOG_(INFO) << "Grid_Info_Unmarshalling_001 start"; 315 if (!gridInfoParcel_) { 316 GTEST_LOG_(INFO) << "gridInfoParcel_ is null"; 317 return; 318 } 319 320 Parcel parcel; 321 sptr<GridInfoParcel> gridInfoParcel = gridInfoParcel_->Unmarshalling(parcel); 322 EXPECT_EQ(true, gridInfoParcel == nullptr); 323 GTEST_LOG_(INFO) << "Grid_Info_Unmarshalling_001 end"; 324 } 325 326 /** 327 * @tc.number: Extra_Element_Info_Parcel__001 328 * @tc.name: Extra_Element_Info_Parcel 329 * @tc.desc: Test function ReadFromParcel 330 */ 331 HWTEST_F(AccessibilityElementInfoParcelTest, Extra_Element_Info_Parcel__001, TestSize.Level1) 332 { 333 GTEST_LOG_(INFO) << "Extra_Element_Info_Parcel__001 start"; 334 if (!extraElementInfoParcel_) { 335 GTEST_LOG_(INFO) << "extraElementInfoParcel_ is null"; 336 return; 337 } 338 339 Parcel parcel; 340 EXPECT_EQ(false, extraElementInfoParcel_->ReadFromParcel(parcel)); 341 GTEST_LOG_(INFO) << "Extra_Element_Info_Parcel__001 end"; 342 } 343 344 /** 345 * @tc.number: Extra_Element_Info_Parcel__002 346 * @tc.name: Extra_Element_Info_Parcel 347 * @tc.desc: Test function Unmarshalling 348 */ 349 HWTEST_F(AccessibilityElementInfoParcelTest, Extra_Element_Info_Parcel__002, TestSize.Level1) 350 { 351 GTEST_LOG_(INFO) << "Extra_Element_Info_Parcel__002 start"; 352 if (!extraElementInfoParcel_) { 353 GTEST_LOG_(INFO) << "extraElementInfoParcel_ is null"; 354 return; 355 } 356 357 Parcel parcel; 358 sptr<ExtraElementInfoParcel> extraElementInfoParcel = extraElementInfoParcel_->Unmarshalling(parcel); 359 EXPECT_EQ(true, extraElementInfoParcel == nullptr); 360 GTEST_LOG_(INFO) << "Extra_Element_Info_Parcel__002 end"; 361 } 362 363 /** 364 * @tc.number: Span_Info_Parcel__001 365 * @tc.name: Span_Info_Parcel 366 * @tc.desc: Test function ReadFromParcel 367 */ 368 HWTEST_F(AccessibilityElementInfoParcelTest, Span_Info_Parcel__001, TestSize.Level1) 369 { 370 GTEST_LOG_(INFO) << "Span_Info_Parcel__001 start"; 371 if (!spanInfoParcel_) { 372 GTEST_LOG_(INFO) << "spanInfoParcel_ is null"; 373 return; 374 } 375 376 Parcel parcel; 377 EXPECT_EQ(false, spanInfoParcel_->ReadFromParcel(parcel)); 378 GTEST_LOG_(INFO) << "Span_Info_Parcel__001 end"; 379 } 380 381 /** 382 * @tc.number: Span_Info_Marshalling_001 383 * @tc.name: Span_Info_Marshalling 384 * @tc.desc: Test function Marshalling 385 */ 386 HWTEST_F(AccessibilityElementInfoParcelTest, Span_Info_Marshalling_001, TestSize.Level1) 387 { 388 GTEST_LOG_(INFO) << "Span_Info_Marshalling_001 start"; 389 if (!spanInfoParcel_) { 390 GTEST_LOG_(INFO) << "spanInfoParcel_ is null"; 391 return; 392 } 393 394 Parcel parcel; 395 bool ret = spanInfoParcel_->Marshalling(parcel); 396 EXPECT_EQ(ret, true); 397 GTEST_LOG_(INFO) << "Span_Info_Marshalling_001 end"; 398 } 399 400 /** 401 * @tc.number: Span_Info_Unmarshalling__001 402 * @tc.name: Span_Info_Unmarshalling 403 * @tc.desc: Test function Unmarshalling 404 */ 405 HWTEST_F(AccessibilityElementInfoParcelTest, Span_Info_Unmarshalling__001, TestSize.Level1) 406 { 407 GTEST_LOG_(INFO) << "Span_Info_Unmarshalling__001 start"; 408 if (!spanInfoParcel_) { 409 GTEST_LOG_(INFO) << "spanInfoParcel_ is null"; 410 return; 411 } 412 413 Parcel parcel; 414 sptr<SpanInfoParcel> spanInfoParcel = spanInfoParcel_->Unmarshalling(parcel); 415 EXPECT_EQ(true, spanInfoParcel == nullptr); 416 GTEST_LOG_(INFO) << "Span_Info_Unmarshalling__001 end"; 417 } 418 } // namespace Accessibility 419 } // namespace OHOS