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_event_info_parcel.h" 18 #include "accessibility_element_info_parcel.h" 19 20 using namespace testing; 21 using namespace testing::ext; 22 23 namespace OHOS { 24 namespace Accessibility { 25 class AccessibilityEventInfoParcelTest : public ::testing::Test { 26 public: AccessibilityEventInfoParcelTest()27 AccessibilityEventInfoParcelTest() 28 {} ~AccessibilityEventInfoParcelTest()29 ~AccessibilityEventInfoParcelTest() 30 {} SetUpTestCase()31 static void SetUpTestCase() 32 { 33 GTEST_LOG_(INFO) << "AccessibilityEventInfoParcelTest Start"; 34 } TearDownTestCase()35 static void TearDownTestCase() 36 { 37 GTEST_LOG_(INFO) << "AccessibilityEventInfoParcelTest End"; 38 } SetUp()39 void SetUp() 40 { 41 GTEST_LOG_(INFO) << "AccessibilityEventInfoParcelTest SetUp() Start"; 42 AccessibilityEventInfo eventInfo; 43 eventInfoParcel_ = std::make_shared<AccessibilityEventInfoParcel>(eventInfo); 44 AccessibilityElementInfo elementInfo; 45 elementInfoParcel_ = std::make_shared<AccessibilityElementInfoParcel>(elementInfo); 46 GTEST_LOG_(INFO) << "AccessibilityEventInfoParcelTest SetUp() End"; 47 }; TearDown()48 void TearDown() 49 { 50 GTEST_LOG_(INFO) << "AccessibilityEventInfoParcelTest TearDown()"; 51 eventInfoParcel_ = nullptr; 52 } 53 54 std::shared_ptr<AccessibilityEventInfoParcel> eventInfoParcel_ = nullptr; 55 std::shared_ptr<AccessibilityElementInfoParcel> elementInfoParcel_ = nullptr; 56 }; 57 58 /** 59 * @tc.number: Event_Info_Marshalling_001 60 * @tc.name: Event_Info_Marshalling 61 * @tc.desc: Test function Marshalling 62 */ 63 HWTEST_F(AccessibilityEventInfoParcelTest, Event_Info_Marshalling_001, TestSize.Level1) 64 { 65 GTEST_LOG_(INFO) << "Event_Info_Marshalling_001 start"; 66 if (!eventInfoParcel_) { 67 GTEST_LOG_(INFO) << "eventInfoParcel_ is null"; 68 return; 69 } 70 71 Parcel parcel; 72 bool ret = eventInfoParcel_->Marshalling(parcel); 73 EXPECT_EQ(ret, true); 74 GTEST_LOG_(INFO) << "Event_Info_Marshalling_001 end"; 75 } 76 77 /** 78 * @tc.number: Event_Info_Unmarshalling_001 79 * @tc.name: Event_Info_Unmarshalling 80 * @tc.desc: Test function Unmarshalling 81 */ 82 HWTEST_F(AccessibilityEventInfoParcelTest, Event_Info_Unmarshalling_001, TestSize.Level1) 83 { 84 GTEST_LOG_(INFO) << "Event_Info_Unmarshalling_001 start"; 85 if (!eventInfoParcel_) { 86 GTEST_LOG_(INFO) << "eventInfoParcel_ is null"; 87 return; 88 } 89 90 Parcel parcel; 91 sptr<AccessibilityEventInfoParcel> eventInfoParcel = eventInfoParcel_->Unmarshalling(parcel); 92 EXPECT_EQ(true, eventInfoParcel == nullptr); 93 GTEST_LOG_(INFO) << "Event_Info_Unmarshalling_001 end"; 94 } 95 96 /** 97 * @tc.number: Element_Info_Unmarshalling_001 98 * @tc.name: Element_Info_Unmarshalling 99 * @tc.desc: Test function Unmarshalling 100 */ 101 HWTEST_F(AccessibilityEventInfoParcelTest, Element_Info_Unmarshalling_001, TestSize.Level1) 102 { 103 GTEST_LOG_(INFO) << "Element_Info_Unmarshalling_001 start"; 104 if (!elementInfoParcel_) { 105 GTEST_LOG_(INFO) << "elementInfoParcel_ is null"; 106 return; 107 } 108 109 Parcel parcel; 110 sptr<AccessibilityElementInfoParcel> elementInfoParcel = elementInfoParcel_->Unmarshalling(parcel); 111 EXPECT_EQ(true, elementInfoParcel == nullptr); 112 GTEST_LOG_(INFO) << "Element_Info_Unmarshalling_001 end"; 113 } 114 } // namespace Accessibility 115 } // namespace OHOS 116