• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     } else {
65         Parcel parcel;
66         bool ret = windowInfoParcel_->Marshalling(parcel);
67         EXPECT_EQ(ret, true);
68     }
69     GTEST_LOG_(INFO) << "Window_Info_Marshalling_001 end";
70 }
71 
72 /**
73  * @tc.number: Window_Info_Unmarshalling_001
74  * @tc.name: Window_Info_Unmarshalling
75  * @tc.desc: Test function Unmarshalling
76  */
77 HWTEST_F(AccessibilityWindowInfoParcelTest, Window_Info_Unmarshalling_001, TestSize.Level1)
78 {
79     GTEST_LOG_(INFO) << "Window_Info_Unmarshalling_001 start";
80     if (!windowInfoParcel_) {
81         GTEST_LOG_(INFO) << "windowInfoParcel_ is null";
82     } else {
83         Parcel parcel;
84         sptr<AccessibilityWindowInfoParcel> windowInfoParcel = windowInfoParcel_->Unmarshalling(parcel);
85         EXPECT_EQ(true, windowInfoParcel == nullptr);
86     }
87     GTEST_LOG_(INFO) << "Window_Info_Unmarshalling_001 end";
88 }
89 
90 /**
91  * @tc.number: Window_Info_Parcel__001
92  * @tc.name: Window_Info_Parcel
93  * @tc.desc: Test function ReadFromParcel
94  */
95 HWTEST_F(AccessibilityWindowInfoParcelTest, Window_Info_Parcel__001, TestSize.Level1)
96 {
97     GTEST_LOG_(INFO) << "Window_Info_Parcel__001 start";
98     if (!windowInfoParcel_) {
99         GTEST_LOG_(INFO) << "windowInfoParcel_ is null";
100     } else {
101         Parcel parcel;
102         EXPECT_EQ(false, windowInfoParcel_->ReadFromParcel(parcel));
103     }
104     GTEST_LOG_(INFO) << "Window_Info_Parcel__001 end";
105 }
106 } // namespace Accessibility
107 } // namespace OHOS