• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
18 #include "ability_util.h"
19 
20 using namespace testing;
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace AAFwk {
25 class AbilityUtilTest : public testing::Test {
26 public:
27     static void SetUpTestCase();
28     static void TearDownTestCase();
29     void SetUp() override;
30     void TearDown() override;
31 };
32 
SetUpTestCase()33 void AbilityUtilTest::SetUpTestCase()
34 {}
35 
TearDownTestCase()36 void AbilityUtilTest::TearDownTestCase()
37 {}
38 
SetUp()39 void AbilityUtilTest::SetUp()
40 {}
41 
TearDown()42 void AbilityUtilTest::TearDown()
43 {}
44 
45 /**
46  * @tc.name: HandleDlpApp_0100
47  * @tc.desc: HandleDlpApp Test
48  * @tc.type: FUNC
49  * @tc.require: issueI581T3
50  */
51 HWTEST_F(AbilityUtilTest, HandleDlpApp_0100, TestSize.Level0)
52 {
53     Want want;
54     bool result = AbilityUtil::HandleDlpApp(want);
55     EXPECT_FALSE(result);
56 }
57 
58 /**
59  * @tc.name: HandleDlpApp_0200
60  * @tc.desc: HandleDlpApp Test
61  * @tc.type: FUNC
62  * @tc.require: issueI581T3
63  */
64 HWTEST_F(AbilityUtilTest, HandleDlpApp_0200, TestSize.Level0)
65 {
66     Want want;
67     want.SetParam(AbilityUtil::DLP_PARAMS_SANDBOX, true);
68     bool result = AbilityUtil::HandleDlpApp(want);
69     EXPECT_FALSE(result);
70 }
71 
72 /**
73  * @tc.name: HandleDlpApp_0300
74  * @tc.desc: HandleDlpApp Test
75  * @tc.type: FUNC
76  * @tc.require: issueI581T3
77  */
78 HWTEST_F(AbilityUtilTest, HandleDlpApp_0300, TestSize.Level0)
79 {
80     Want want;
81     want.SetParam(AbilityUtil::DLP_PARAMS_SANDBOX, true);
82     want.SetElementName("com.ohos.test", "MainAbility");
83     bool result = AbilityUtil::HandleDlpApp(want);
84     EXPECT_TRUE(result);
85 }
86 
87 /**
88  * @tc.name: HandleDlpApp_0400
89  * @tc.desc: HandleDlpApp Test
90  * @tc.type: FUNC
91  * @tc.require: issueI5825N
92  */
93 HWTEST_F(AbilityUtilTest, HandleDlpApp_0400, TestSize.Level0)
94 {
95     Want want;
96     want.SetParam(AbilityUtil::DLP_PARAMS_SANDBOX, true);
97     want.SetElementName("", "");
98     bool result = AbilityUtil::HandleDlpApp(want);
99     EXPECT_FALSE(result);
100 }
101 
102 /**
103  * @tc.name: HandleDlpApp_0500
104  * @tc.desc: HandleDlpApp Test
105  * @tc.type: FUNC
106  * @tc.require: issueI5826I
107  */
108 HWTEST_F(AbilityUtilTest, HandleDlpApp_0500, TestSize.Level0)
109 {
110     Want want;
111     want.SetParam(AbilityUtil::DLP_PARAMS_SANDBOX, true);
112     want.SetElementName("", "MainAbility");
113     bool result = AbilityUtil::HandleDlpApp(want);
114     EXPECT_FALSE(result);
115 }
116 
117 /**
118  * @tc.name: HandleDlpApp_0600
119  * @tc.desc: HandleDlpApp Test
120  * @tc.type: FUNC
121  * @tc.require: issueI583ZA
122  */
123 HWTEST_F(AbilityUtilTest, HandleDlpApp_0600, TestSize.Level0)
124 {
125     Want want;
126     want.SetParam(AbilityUtil::DLP_PARAMS_SANDBOX, true);
127     want.SetElementName("com.ohos.test", "");
128     bool result = AbilityUtil::HandleDlpApp(want);
129     EXPECT_FALSE(result);
130 }
131 }  // namespace AAFwk
132 }  // namespace OHOS
133