1 /*
2  * Copyright (c) 2023 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 #define private public
19 #define protected public
20 #include "auto_startup_info.h"
21 #undef private
22 #undef protected
23 
24 #include "string_ex.h"
25 #include "types.h"
26 
27 using namespace testing;
28 using namespace testing::ext;
29 using namespace OHOS::AbilityRuntime;
30 
31 namespace OHOS {
32 namespace AbilityRuntime {
33 class AutoStartupInfoTest : public testing::Test {
34 public:
35     static void SetUpTestCase();
36     static void TearDownTestCase();
37     void SetUp() override;
38     void TearDown() override;
39 };
40 
SetUpTestCase()41 void AutoStartupInfoTest::SetUpTestCase() {}
42 
TearDownTestCase()43 void AutoStartupInfoTest::TearDownTestCase() {}
44 
SetUp()45 void AutoStartupInfoTest::SetUp() {}
46 
TearDown()47 void AutoStartupInfoTest::TearDown() {}
48 
49 /**
50  * Feature: AutoStartupInfo
51  * Function: ReadFromParcel
52  * SubFunction: NA
53  * FunctionPoints: AutoStartupInfo ReadFromParcel
54  */
55 HWTEST_F(AutoStartupInfoTest, ReadFromParcel_100, TestSize.Level1)
56 {
57     GTEST_LOG_(INFO) << "ReadFromParcel_100 start";
58     Parcel parcel;
59     auto autoStartupInfo = new (std::nothrow) AutoStartupInfo();
60     auto result = autoStartupInfo->ReadFromParcel(parcel);
61     EXPECT_TRUE(result);
62     GTEST_LOG_(INFO) << "ReadFromParcel_100 end";
63 }
64 
65 /**
66  * Feature: AutoStartupInfo
67  * Function: Unmarshalling
68  * SubFunction: NA
69  * FunctionPoints: AutoStartupInfo Unmarshalling
70  */
71 HWTEST_F(AutoStartupInfoTest, Unmarshalling_100, TestSize.Level1)
72 {
73     GTEST_LOG_(INFO) << "Unmarshalling_100 start";
74     Parcel parcel;
75     auto autoStartupInfo = new (std::nothrow) AutoStartupInfo();
76     auto result = autoStartupInfo->Unmarshalling(parcel);
77     EXPECT_NE(result, nullptr);
78     GTEST_LOG_(INFO) << "Unmarshalling_100 end";
79 }
80 
81 /**
82  * Feature: AutoStartupInfo
83  * Function: Marshalling
84  * SubFunction: NA
85  * FunctionPoints: AutoStartupInfo Marshalling
86  */
87 HWTEST_F(AutoStartupInfoTest, Marshalling_100, TestSize.Level1)
88 {
89     GTEST_LOG_(INFO) << "Marshalling_100 start";
90     auto autoStartupInfo = new (std::nothrow) AutoStartupInfo();
91     autoStartupInfo->bundleName = "com.example.testbundle";
92     autoStartupInfo->abilityName = "test.app.Ability";
93     autoStartupInfo->moduleName = "test.app.Moudle";
94     autoStartupInfo->abilityTypeName = "test.app.mainAbility";
95     autoStartupInfo->appCloneIndex = 0;
96     Parcel parcel;
97     bool result = autoStartupInfo->Marshalling(parcel);
98     EXPECT_TRUE(result);
99     GTEST_LOG_(INFO) << "Marshalling_100 end";
100 }
101 } // namespace AbilityRuntime
102 } // namespace OHOS
103