1 /*
2 * Copyright (c) 2022 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 "parcel.h"
18
19 #define private public
20 #include "ability_running_info.h"
21 #undef private
22
23 using namespace testing;
24 using namespace testing::ext;
25
26 namespace OHOS {
27 namespace AAFwk {
28 const int32_t USER_ID_U100 = 100;
29 class AbilityRunningInfoTest : 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 AbilityRunningInfoTest::SetUpTestCase(void)
38 {}
39
TearDownTestCase(void)40 void AbilityRunningInfoTest::TearDownTestCase(void)
41 {}
42
SetUp()43 void AbilityRunningInfoTest::SetUp()
44 {}
45
TearDown()46 void AbilityRunningInfoTest::TearDown()
47 {}
48
49 /*
50 * Feature: AbilityRunningInfo
51 * Function: ReadFromParcel
52 * SubFunction: NA
53 * FunctionPoints: AbilityRunningInfo ReadFromParcel
54 */
55 HWTEST_F(AbilityRunningInfoTest, ReadFromParcel_0100, TestSize.Level1)
56 {
57 GTEST_LOG_(INFO)
58 << "AbilityRunningInfoTest, AbilityRunningInfo_0100, TestSize.Level1";
59 AbilityRunningInfo info;
60 MessageParcel parcel;
61 EXPECT_FALSE(info.ReadFromParcel(parcel));
62 }
63
64 /*
65 * Feature: AbilityRunningInfo
66 * Function: ReadFromParcel
67 * SubFunction: NA
68 * FunctionPoints: AbilityRunningInfo ReadFromParcel
69 */
70 HWTEST_F(AbilityRunningInfoTest, ReadFromParcel_0200, TestSize.Level1)
71 {
72 GTEST_LOG_(INFO)
73 << "AbilityRunningInfoTest, AbilityRunningInfo_0200, TestSize.Level1";
74 AbilityRunningInfo info;
75 MessageParcel parcel;
76
77 auto uid = USER_ID_U100;
78 parcel.WriteInt32(uid);
79 EXPECT_TRUE(info.ReadFromParcel(parcel));
80 }
81
82 /*
83 * Feature: AbilityRunningInfo
84 * Function: Marshalling
85 * SubFunction: NA
86 * FunctionPoints: AbilityRunningInfo Marshalling
87 */
88 HWTEST_F(AbilityRunningInfoTest, Marshalling_0100, TestSize.Level1)
89 {
90 GTEST_LOG_(INFO)
91 << "AbilityRunningInfoTest, Marshalling_0100, TestSize.Level1";
92 AbilityRunningInfo info;
93 MessageParcel parcel;
94 EXPECT_TRUE(info.Marshalling(parcel));
95 }
96
97 /*
98 * Feature: AbilityRunningInfo
99 * Function: Unmarshalling
100 * SubFunction: NA
101 * FunctionPoints: AbilityRunningInfo Unmarshalling
102 */
103 HWTEST_F(AbilityRunningInfoTest, Unmarshalling_0100, TestSize.Level1)
104 {
105 GTEST_LOG_(INFO)
106 << "AbilityRunningInfoTest, Unmarshalling_0100, TestSize.Level1";
107 AbilityRunningInfo info;
108 MessageParcel parcel;
109 EXPECT_EQ(info.Unmarshalling(parcel), nullptr);
110 }
111
112 /*
113 * Feature: AbilityRunningInfo
114 * Function: Unmarshalling
115 * SubFunction: NA
116 * FunctionPoints: AbilityRunningInfo Unmarshalling
117 */
118 HWTEST_F(AbilityRunningInfoTest, Unmarshalling_0200, TestSize.Level1)
119 {
120 GTEST_LOG_(INFO)
121 << "AbilityRunningInfoTest, Unmarshalling_0200, TestSize.Level1";
122 AbilityRunningInfo info;
123 MessageParcel parcel;
124
125 auto uid = USER_ID_U100;
126 parcel.WriteInt32(uid);
127 EXPECT_NE(info.Unmarshalling(parcel), nullptr);
128 }
129 } // namespace AppExecFwk
130 } // namespace OHOS