• 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_ability_info_parcel.h"
18 
19 using namespace testing;
20 using namespace testing::ext;
21 
22 namespace OHOS {
23 namespace Accessibility {
24 class AccessibilityAbilityInfoParcelTest : public ::testing::Test {
25 public:
AccessibilityAbilityInfoParcelTest()26     AccessibilityAbilityInfoParcelTest()
27     {}
~AccessibilityAbilityInfoParcelTest()28     ~AccessibilityAbilityInfoParcelTest()
29     {}
SetUpTestCase()30     static void SetUpTestCase()
31     {
32         GTEST_LOG_(INFO) << "AccessibilityAbilityInfoParcelTest Start";
33     }
TearDownTestCase()34     static void TearDownTestCase()
35     {
36         GTEST_LOG_(INFO) << "AccessibilityAbilityInfoParcelTest End";
37     }
38 
SetUp()39     void SetUp()
40     {
41         GTEST_LOG_(INFO) << "AccessibilityAbilityInfoParcelTest SetUp() Start";
42         AccessibilityAbilityInitParams params;
43         params.bundleName = "bundleName";
44         params.moduleName = "moduleName";
45         params.name = "name";
46         params.description = "description";
47         params.rationale = "rationale";
48         params.settingsAbility = "settingsAbility";
49         params.staticCapabilities = 1;
50         params.abilityTypes = ACCESSIBILITY_ABILITY_TYPE_SPOKEN;
51         params.isImportant = true;
52         params.needHide = false;
53         abilityInfo_ = std::make_shared<AccessibilityAbilityInfo>(params);
54         abilityInfoParcel_ = std::make_shared<AccessibilityAbilityInfoParcel>(*abilityInfo_);
55         GTEST_LOG_(INFO) << "AccessibilityAbilityInfoParcelTest SetUp() End";
56     };
57 
TearDown()58     void TearDown()
59     {
60         GTEST_LOG_(INFO) << "AccessibilityAbilityInfoParcelTest TearDown()";
61         abilityInfo_ = nullptr;
62         abilityInfoParcel_ = nullptr;
63     }
64 
65     std::shared_ptr<AccessibilityAbilityInfo> abilityInfo_ = nullptr;
66     std::shared_ptr<AccessibilityAbilityInfoParcel> abilityInfoParcel_ = nullptr;
67 };
68 
69 /**
70  * @tc.number: Marshalling_001
71  * @tc.name: Marshalling
72  * @tc.desc: Test function Marshalling
73  */
74 HWTEST_F(AccessibilityAbilityInfoParcelTest, Marshalling_001, TestSize.Level1)
75 {
76     GTEST_LOG_(INFO) << "Marshalling_001 start";
77     if (!abilityInfoParcel_) {
78         GTEST_LOG_(INFO) << "abilityInfoParcel_ is null";
79     } else {
80         Parcel parcel;
81         bool ret = abilityInfoParcel_->Marshalling(parcel);
82         EXPECT_EQ(ret, true);
83     }
84     GTEST_LOG_(INFO) << "Marshalling_001 end";
85 }
86 
87 /**
88  * @tc.number: Unmarshalling_001
89  * @tc.name: Unmarshalling
90  * @tc.desc: Test function Unmarshalling
91  */
92 HWTEST_F(AccessibilityAbilityInfoParcelTest, Unmarshalling_001, TestSize.Level1)
93 {
94     GTEST_LOG_(INFO) << "Unmarshalling_001 start";
95     if (!abilityInfoParcel_) {
96         GTEST_LOG_(INFO) << "abilityInfoParcel_ is null";
97     } else {
98         Parcel parcel;
99         sptr<AccessibilityAbilityInfoParcel> infoParcel = abilityInfoParcel_->Unmarshalling(parcel);
100         EXPECT_EQ(true, infoParcel == nullptr);
101     }
102     GTEST_LOG_(INFO) << "Unmarshalling_001 end";
103 }
104 } // namespace Accessibility
105 } // namespace OHOS