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 action_ = std::make_shared<AccessibleAction>(); 44 actionParcel_ = std::make_shared<AccessibleActionParcel>(*action_); 45 rangeInfo_ = std::make_shared<RangeInfo>(); 46 rangeInfoParcel_ = std::make_shared<RangeInfoParcel>(*rangeInfo_); 47 gridInfo_ = std::make_shared<GridInfo>(); 48 gridInfoParcel_ = std::make_shared<GridInfoParcel>(*gridInfo_); 49 gridItemInfo_ = std::make_shared<GridItemInfo>(); 50 gridItemInfoParcel_ = std::make_shared<GridItemInfoParcel>(*gridItemInfo_); 51 rect_ = std::make_shared<Rect>(); 52 rectParcel_ = std::make_shared<RectParcel>(*rect_); 53 GTEST_LOG_(INFO) << "AccessibilityElementInfoParcelTest SetUp() End"; 54 }; TearDown()55 void TearDown() 56 { 57 GTEST_LOG_(INFO) << "AccessibilityElementInfoParcelTest TearDown()"; 58 elementInfo_ = nullptr; 59 elementInfoParcel_ = nullptr; 60 action_ = nullptr; 61 actionParcel_ = nullptr; 62 rangeInfo_ = nullptr; 63 rangeInfoParcel_ = nullptr; 64 gridInfo_ = nullptr; 65 gridInfoParcel_ = nullptr; 66 gridItemInfo_ = nullptr; 67 gridItemInfoParcel_ = nullptr; 68 rect_ = nullptr; 69 rectParcel_ = nullptr; 70 } 71 72 std::shared_ptr<AccessibleAction> action_ = nullptr; 73 std::shared_ptr<AccessibleActionParcel> actionParcel_ = nullptr; 74 std::shared_ptr<RangeInfo> rangeInfo_ = nullptr; 75 std::shared_ptr<RangeInfoParcel> rangeInfoParcel_ = nullptr; 76 std::shared_ptr<GridInfo> gridInfo_ = nullptr; 77 std::shared_ptr<GridInfoParcel> gridInfoParcel_ = nullptr; 78 std::shared_ptr<GridItemInfo> gridItemInfo_ = nullptr; 79 std::shared_ptr<GridItemInfoParcel> gridItemInfoParcel_ = nullptr; 80 std::shared_ptr<Rect> rect_ = nullptr; 81 std::shared_ptr<RectParcel> rectParcel_ = nullptr; 82 std::shared_ptr<AccessibilityElementInfo> elementInfo_ = nullptr; 83 std::shared_ptr<AccessibilityElementInfoParcel> elementInfoParcel_ = nullptr; 84 }; 85 86 /** 87 * @tc.number: Element_Info__Marshalling_001 88 * @tc.name: Element_Info_Marshalling 89 * @tc.desc: Test function Marshalling 90 */ 91 HWTEST_F(AccessibilityElementInfoParcelTest, Element_Info_Marshalling_001, TestSize.Level1) 92 { 93 GTEST_LOG_(INFO) << "Element_Info_Marshalling_001 start"; 94 if (!elementInfoParcel_) { 95 GTEST_LOG_(INFO) << "elementInfoParcel_ is null"; 96 return; 97 } 98 99 Parcel parcel; 100 bool ret = elementInfoParcel_->Marshalling(parcel); 101 EXPECT_EQ(ret, true); 102 GTEST_LOG_(INFO) << "Element_Info_Marshalling_001 end"; 103 } 104 105 /** 106 * @tc.number: Element_Info_Unmarshalling_001 107 * @tc.name: Element_Info_Unmarshalling 108 * @tc.desc: Test function Unmarshalling 109 */ 110 HWTEST_F(AccessibilityElementInfoParcelTest, Element_Info_Unmarshalling_001, TestSize.Level1) 111 { 112 GTEST_LOG_(INFO) << "Element_Info_Unmarshalling_001 start"; 113 if (!elementInfoParcel_) { 114 GTEST_LOG_(INFO) << "elementInfoParcel_ is null"; 115 return; 116 } 117 118 Parcel parcel; 119 sptr<AccessibilityElementInfoParcel> elementInfoParcel = elementInfoParcel_->Unmarshalling(parcel); 120 EXPECT_EQ(true, elementInfoParcel == nullptr); 121 GTEST_LOG_(INFO) << "Element_Info_Unmarshalling_001 end"; 122 } 123 124 /** 125 * @tc.number: Rect_Marshalling_001 126 * @tc.name: Rect_Marshalling 127 * @tc.desc: Test function Marshalling 128 */ 129 HWTEST_F(AccessibilityElementInfoParcelTest, Rect_Marshalling_001, TestSize.Level1) 130 { 131 GTEST_LOG_(INFO) << "Rect_Marshalling_001 start"; 132 if (!rectParcel_) { 133 GTEST_LOG_(INFO) << "rectParcel_ is null"; 134 return; 135 } 136 137 Parcel parcel; 138 bool ret = rectParcel_->Marshalling(parcel); 139 EXPECT_EQ(ret, true); 140 GTEST_LOG_(INFO) << "Rect_Marshalling_001 end"; 141 } 142 143 /** 144 * @tc.number: Rect_Unmarshalling_001 145 * @tc.name: Rect__Unmarshalling 146 * @tc.desc: Test function Unmarshalling 147 */ 148 HWTEST_F(AccessibilityElementInfoParcelTest, Rect_Unmarshalling_001, TestSize.Level1) 149 { 150 GTEST_LOG_(INFO) << "Rect_Unmarshalling_001 start"; 151 if (!rectParcel_) { 152 GTEST_LOG_(INFO) << "rectParcel_ is null"; 153 return; 154 } 155 156 Parcel parcel; 157 sptr<RectParcel> rectParcel = rectParcel_->Unmarshalling(parcel); 158 EXPECT_EQ(true, rectParcel == nullptr); 159 GTEST_LOG_(INFO) << "Rect_Unmarshalling_001 end"; 160 } 161 162 /** 163 * @tc.number: Grid_Item_Info_Marshalling_001 164 * @tc.name: Grid_Item_Info_Marshalling 165 * @tc.desc: Test function Marshalling 166 */ 167 HWTEST_F(AccessibilityElementInfoParcelTest, Grid_Item_Info_Marshalling_001, TestSize.Level1) 168 { 169 GTEST_LOG_(INFO) << "Grid_Item_Info_Marshalling_001 start"; 170 if (!gridItemInfoParcel_) { 171 GTEST_LOG_(INFO) << "gridItemInfoParcel_ is null"; 172 return; 173 } 174 175 Parcel parcel; 176 bool ret = gridItemInfoParcel_->Marshalling(parcel); 177 EXPECT_EQ(ret, true); 178 GTEST_LOG_(INFO) << "Grid_Item_Info_Marshalling_001 end"; 179 } 180 181 /** 182 * @tc.number: Grid_Item_Info_Unmarshalling_001 183 * @tc.name: Grid_Item_Info_Unmarshalling 184 * @tc.desc: Test function Unmarshalling 185 */ 186 HWTEST_F(AccessibilityElementInfoParcelTest, Grid_Item_Info_Unmarshalling_001, TestSize.Level1) 187 { 188 GTEST_LOG_(INFO) << "Grid_Item_Info_Unmarshalling_001 start"; 189 if (!gridItemInfoParcel_) { 190 GTEST_LOG_(INFO) << "gridItemInfoParcel_ is null"; 191 return; 192 } 193 194 Parcel parcel; 195 sptr<GridItemInfoParcel> gridItemInfoParcel = gridItemInfoParcel_->Unmarshalling(parcel); 196 EXPECT_EQ(true, gridItemInfoParcel == nullptr); 197 GTEST_LOG_(INFO) << "Grid_Item_Info_Unmarshalling_001 end"; 198 } 199 200 /** 201 * @tc.number: Action_Marshalling_001 202 * @tc.name: Action_Marshalling 203 * @tc.desc: Test function Marshalling 204 */ 205 HWTEST_F(AccessibilityElementInfoParcelTest, Action_Marshalling_001, TestSize.Level1) 206 { 207 GTEST_LOG_(INFO) << "Action_Marshalling_001 start"; 208 if (!actionParcel_) { 209 GTEST_LOG_(INFO) << "actionParcel_ is null"; 210 return; 211 } 212 213 Parcel parcel; 214 bool ret = actionParcel_->Marshalling(parcel); 215 EXPECT_EQ(ret, true); 216 GTEST_LOG_(INFO) << "Action_Marshalling_001 end"; 217 } 218 219 /** 220 * @tc.number: Action_Unmarshalling_001 221 * @tc.name: Action_Unmarshalling 222 * @tc.desc: Test function Unmarshalling 223 */ 224 HWTEST_F(AccessibilityElementInfoParcelTest, Action_Unmarshalling_001, TestSize.Level1) 225 { 226 GTEST_LOG_(INFO) << "Action_Unmarshalling_001 start"; 227 if (!actionParcel_) { 228 GTEST_LOG_(INFO) << "actionParcel_ is null"; 229 return; 230 } 231 232 Parcel parcel; 233 sptr<AccessibleActionParcel> actionParcel = actionParcel_->Unmarshalling(parcel); 234 EXPECT_EQ(true, actionParcel == nullptr); 235 GTEST_LOG_(INFO) << "Action_Unmarshalling_001 end"; 236 } 237 238 /** 239 * @tc.number: Range_Info_Marshalling_001 240 * @tc.name: Range_Info_Marshalling 241 * @tc.desc: Test function Marshalling 242 */ 243 HWTEST_F(AccessibilityElementInfoParcelTest, Range_Info_Marshalling_001, TestSize.Level1) 244 { 245 GTEST_LOG_(INFO) << "Range_Info_Marshalling_001 start"; 246 if (!rangeInfoParcel_) { 247 GTEST_LOG_(INFO) << "rangeInfoParcel_ is null"; 248 return; 249 } 250 251 Parcel parcel; 252 bool ret = rangeInfoParcel_->Marshalling(parcel); 253 EXPECT_EQ(ret, true); 254 GTEST_LOG_(INFO) << "Range_Info_Marshalling_001 end"; 255 } 256 257 /** 258 * @tc.number: Range_Info_Unmarshalling_001 259 * @tc.name: Range_Info_Unmarshalling 260 * @tc.desc: Test function Unmarshalling 261 */ 262 HWTEST_F(AccessibilityElementInfoParcelTest, Range_Info_Unmarshalling_001, TestSize.Level1) 263 { 264 GTEST_LOG_(INFO) << "Range_Info_Unmarshalling_001 start"; 265 if (!rangeInfoParcel_) { 266 GTEST_LOG_(INFO) << "rangeInfoParcel_ is null"; 267 return; 268 } 269 270 Parcel parcel; 271 sptr<RangeInfoParcel> rangeInfoParcel = rangeInfoParcel_->Unmarshalling(parcel); 272 EXPECT_EQ(true, rangeInfoParcel == nullptr); 273 GTEST_LOG_(INFO) << "Range_Info_Unmarshalling_001 end"; 274 } 275 276 /** 277 * @tc.number: Grid_Info_Marshalling_001 278 * @tc.name: Grid_Info_Marshalling 279 * @tc.desc: Test function Marshalling 280 */ 281 HWTEST_F(AccessibilityElementInfoParcelTest, Grid_Info_Marshalling_001, TestSize.Level1) 282 { 283 GTEST_LOG_(INFO) << "Grid_Info_Marshalling_001 start"; 284 if (!gridInfoParcel_) { 285 GTEST_LOG_(INFO) << "gridInfoParcel_ is null"; 286 return; 287 } 288 289 Parcel parcel; 290 bool ret = gridInfoParcel_->Marshalling(parcel); 291 EXPECT_EQ(ret, true); 292 GTEST_LOG_(INFO) << "Grid_Info_Marshalling_001 end"; 293 } 294 295 /** 296 * @tc.number: Grid_Info_Unmarshalling_001 297 * @tc.name: Grid_Info_Unmarshalling 298 * @tc.desc: Test function Unmarshalling 299 */ 300 HWTEST_F(AccessibilityElementInfoParcelTest, Grid_Info_Unmarshalling_001, TestSize.Level1) 301 { 302 GTEST_LOG_(INFO) << "Grid_Info_Unmarshalling_001 start"; 303 if (!gridInfoParcel_) { 304 GTEST_LOG_(INFO) << "gridInfoParcel_ is null"; 305 return; 306 } 307 308 Parcel parcel; 309 sptr<GridInfoParcel> gridInfoParcel = gridInfoParcel_->Unmarshalling(parcel); 310 EXPECT_EQ(true, gridInfoParcel == nullptr); 311 GTEST_LOG_(INFO) << "Grid_Info_Unmarshalling_001 end"; 312 } 313 } // namespace Accessibility 314 } // namespace OHOS