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 
18 #include "extension_ability_info.h"
19 #include "startup_util.h"
20 #include "want.h"
21 
22 using namespace testing::ext;
23 namespace OHOS {
24 namespace AbilityRuntime {
25 
26 class StartupUtilTest : public testing::Test {
27 public:
28     static void SetUpTestCase();
29     static void TearDownTestCase();
30     void SetUp();
31     void TearDown();
32 };
33 
SetUpTestCase()34 void StartupUtilTest::SetUpTestCase()
35 {}
36 
TearDownTestCase()37 void StartupUtilTest::TearDownTestCase()
38 {}
39 
SetUp()40 void StartupUtilTest::SetUp()
41 {}
42 
TearDown()43 void StartupUtilTest::TearDown()
44 {}
45 
46 /**
47  * @tc.name: GetAppIndex_001
48  * @tc.desc: test class StartupUtil number function
49  * @tc.type: FUNC
50  */
51 HWTEST_F(StartupUtilTest, GetAppIndex_001, TestSize.Level1)
52 {
53     AAFwk::Want want;
54     int32_t appIndex = 0;
55     auto queryRet = StartupUtil::GetAppIndex(want, appIndex);
56     EXPECT_TRUE(queryRet);
57 }
58 
59 /**
60  * @tc.name: GetAppIndex_002
61  * @tc.desc: test class StartupUtil number function
62  * @tc.type: FUNC
63  */
64 HWTEST_F(StartupUtilTest, GetAppIndex_002, TestSize.Level1)
65 {
66     AAFwk::Want want;
67     want.SetParam(AAFwk::Want::PARAM_APP_CLONE_INDEX_KEY, -1);
68     int32_t appIndex = 0;
69     auto queryRet = StartupUtil::GetAppIndex(want, appIndex);
70     EXPECT_FALSE(queryRet);
71 }
72 
73 /**
74  * @tc.name: GetAppIndex_003
75  * @tc.desc: test class StartupUtil number function
76  * @tc.type: FUNC
77  */
78 HWTEST_F(StartupUtilTest, GetAppIndex_003, TestSize.Level1)
79 {
80     AAFwk::Want want;
81     int32_t appIndex = 1001;
82     want.SetParam(AAFwk::Want::PARAM_APP_CLONE_INDEX_KEY, appIndex);
83     auto queryRet = StartupUtil::GetAppIndex(want, appIndex);
84     EXPECT_FALSE(queryRet);
85 }
86 
87 /**
88  * @tc.name: IsSupportAppClone_001
89  * @tc.desc: test class StartupUtil number function
90  * @tc.type: FUNC
91  */
92 HWTEST_F(StartupUtilTest, IsSupportAppClone_001, TestSize.Level1)
93 {
94     AppExecFwk::ExtensionAbilityType type = AppExecFwk::ExtensionAbilityType::WORK_SCHEDULER;
95     auto queryRet = StartupUtil::IsSupportAppClone(type);
96     EXPECT_TRUE(queryRet);
97 }
98 
99 /**
100  * @tc.name: IsSupportAppClone_002
101  * @tc.desc: test class StartupUtil number function
102  * @tc.type: FUNC
103  */
104 HWTEST_F(StartupUtilTest, IsSupportAppClone_002, TestSize.Level1)
105 {
106     AppExecFwk::ExtensionAbilityType type = AppExecFwk::ExtensionAbilityType::FORM;
107     auto queryRet = StartupUtil::IsSupportAppClone(type);
108     EXPECT_FALSE(queryRet);
109 }
110 }  // namespace AbilityRuntime
111 }  // namespace OHOS
112