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 } else { 69 Parcel parcel; 70 bool ret = eventInfoParcel_->Marshalling(parcel); 71 EXPECT_EQ(ret, true); 72 } 73 GTEST_LOG_(INFO) << "Event_Info_Marshalling_001 end"; 74 } 75 76 /** 77 * @tc.number: Event_Info_Unmarshalling_001 78 * @tc.name: Event_Info_Unmarshalling 79 * @tc.desc: Test function Unmarshalling 80 */ 81 HWTEST_F(AccessibilityEventInfoParcelTest, Event_Info_Unmarshalling_001, TestSize.Level1) 82 { 83 GTEST_LOG_(INFO) << "Event_Info_Unmarshalling_001 start"; 84 if (!eventInfoParcel_) { 85 GTEST_LOG_(INFO) << "eventInfoParcel_ is null"; 86 } else { 87 Parcel parcel; 88 sptr<AccessibilityEventInfoParcel> eventInfoParcel = eventInfoParcel_->Unmarshalling(parcel); 89 EXPECT_EQ(true, eventInfoParcel == nullptr); 90 } 91 GTEST_LOG_(INFO) << "Event_Info_Unmarshalling_001 end"; 92 } 93 94 /** 95 * @tc.number: Element_Info_Unmarshalling_001 96 * @tc.name: Element_Info_Unmarshalling 97 * @tc.desc: Test function Unmarshalling 98 */ 99 HWTEST_F(AccessibilityEventInfoParcelTest, Element_Info_Unmarshalling_001, TestSize.Level1) 100 { 101 GTEST_LOG_(INFO) << "Element_Info_Unmarshalling_001 start"; 102 if (!elementInfoParcel_) { 103 GTEST_LOG_(INFO) << "elementInfoParcel_ is null"; 104 } else { 105 Parcel parcel; 106 sptr<AccessibilityElementInfoParcel> elementInfoParcel = elementInfoParcel_->Unmarshalling(parcel); 107 EXPECT_EQ(true, elementInfoParcel == nullptr); 108 } 109 GTEST_LOG_(INFO) << "Element_Info_Unmarshalling_001 end"; 110 } 111 } // namespace Accessibility 112 } // namespace OHOS 113