1 /*
2 * Copyright (c) 2025 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
18 #include "parcel.h"
19 #define private public
20 #include "rule.h"
21 #undef private
22
23 using namespace testing;
24 using namespace testing::ext;
25
26 namespace OHOS {
27 namespace AbilityRuntime {
28 const RuleType type = RuleType::ALLOW;
29 class RuleTest : public testing::Test {
30 public:
31 static void SetUpTestCase();
32 static void TearDownTestCase();
33 void SetUp() override;
34 void TearDown() override;
35 };
36
SetUpTestCase(void)37 void RuleTest::SetUpTestCase(void)
38 {}
39
TearDownTestCase(void)40 void RuleTest::TearDownTestCase(void)
41 {}
42
SetUp()43 void RuleTest::SetUp()
44 {}
45
TearDown()46 void RuleTest::TearDown()
47 {}
48
49 /*
50 * @tc.number: ReadFromParcel_0100
51 * @tc.name: ReadFromParcel
52 * @tc.desc: Verify ReadFromParcel functionality
53 */
54 HWTEST_F(RuleTest, ReadFromParcel_0100, TestSize.Level1)
55 {
56 GTEST_LOG_(INFO)
57 << "RuleTest, Rule_0100, TestSize.Level1";
58 Rule rule;
59 Parcel parcel;
60
61 parcel.WriteInt32(static_cast<int32_t>(type));
62 EXPECT_TRUE(rule.ReadFromParcel(parcel));
63 }
64
65 /*
66 * @tc.number: Marshalling_0100
67 * @tc.name: Marshalling
68 * @tc.desc: Verify Marshalling functionality
69 */
70 HWTEST_F(RuleTest, Marshalling_0100, TestSize.Level1)
71 {
72 GTEST_LOG_(INFO)
73 << "RuleTest, Marshalling_0100, TestSize.Level1";
74 Rule rule;
75 Parcel parcel;
76 EXPECT_TRUE(rule.Marshalling(parcel));
77 }
78
79 /*
80 * @tc.number: Unmarshalling_0100
81 * @tc.name: Unmarshalling
82 * @tc.desc: Verify Unmarshalling functionality
83 */
84 HWTEST_F(RuleTest, Unmarshalling_0100, TestSize.Level1)
85 {
86 GTEST_LOG_(INFO)
87 << "RuleTest, Unmarshalling_0100, TestSize.Level1";
88 Rule rule;
89 Parcel parcel;
90
91 parcel.WriteInt32(static_cast<int32_t>(type));
92 EXPECT_NE(rule.Unmarshalling(parcel), nullptr);
93 }
94 } // namespace AbilityRuntime
95 } // namespace OHOS