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_window_info_parcel.h" 18 19 using namespace testing; 20 using namespace testing::ext; 21 22 namespace OHOS { 23 namespace Accessibility { 24 class AccessibilityWindowInfoParcelTest : public ::testing::Test { 25 public: AccessibilityWindowInfoParcelTest()26 AccessibilityWindowInfoParcelTest() 27 {} ~AccessibilityWindowInfoParcelTest()28 ~AccessibilityWindowInfoParcelTest() 29 {} SetUpTestCase()30 static void SetUpTestCase() 31 { 32 GTEST_LOG_(INFO) << "AccessibilityWindowInfoParcelTest Start"; 33 } TearDownTestCase()34 static void TearDownTestCase() 35 { 36 GTEST_LOG_(INFO) << "AccessibilityWindowInfoParcelTest End"; 37 } SetUp()38 void SetUp() 39 { 40 GTEST_LOG_(INFO) << "AccessibilityWindowInfoParcelTest SetUp() Start"; 41 AccessibilityWindowInfo windowInfo; 42 windowInfoParcel_ = std::make_shared<AccessibilityWindowInfoParcel>(windowInfo); 43 GTEST_LOG_(INFO) << "AccessibilityWindowInfoParcelTest SetUp() End"; 44 }; TearDown()45 void TearDown() 46 { 47 GTEST_LOG_(INFO) << "AccessibilityWindowInfoParcelTest TearDown()"; 48 windowInfoParcel_ = nullptr; 49 } 50 51 std::shared_ptr<AccessibilityWindowInfoParcel> windowInfoParcel_ = nullptr; 52 }; 53 54 /** 55 * @tc.number: Window_Info_Marshalling_001 56 * @tc.name: Window_Info_Marshalling 57 * @tc.desc: Test function Marshalling 58 */ 59 HWTEST_F(AccessibilityWindowInfoParcelTest, Window_Info_Marshalling_001, TestSize.Level1) 60 { 61 GTEST_LOG_(INFO) << "Window_Info_Marshalling_001 start"; 62 if (!windowInfoParcel_) { 63 GTEST_LOG_(INFO) << "captionPropertyParcel_ is null"; 64 return; 65 } 66 67 Parcel parcel; 68 bool ret = windowInfoParcel_->Marshalling(parcel); 69 EXPECT_EQ(ret, true); 70 GTEST_LOG_(INFO) << "Window_Info_Marshalling_001 end"; 71 } 72 73 /** 74 * @tc.number: Window_Info_Unmarshalling_001 75 * @tc.name: Window_Info_Unmarshalling 76 * @tc.desc: Test function Unmarshalling 77 */ 78 HWTEST_F(AccessibilityWindowInfoParcelTest, Window_Info_Unmarshalling_001, TestSize.Level1) 79 { 80 GTEST_LOG_(INFO) << "Window_Info_Unmarshalling_001 start"; 81 if (!windowInfoParcel_) { 82 GTEST_LOG_(INFO) << "windowInfoParcel_ is null"; 83 return; 84 } 85 86 Parcel parcel; 87 sptr<AccessibilityWindowInfoParcel> windowInfoParcel = windowInfoParcel_->Unmarshalling(parcel); 88 EXPECT_EQ(true, windowInfoParcel == nullptr); 89 GTEST_LOG_(INFO) << "Window_Info_Unmarshalling_001 end"; 90 } 91 } // namespace Accessibility 92 } // namespace OHOS