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 #ifdef WITH_DLP
19 #include "dlp_utils.h"
20 #endif // WITH_DLP
21
22 using namespace testing;
23 using namespace testing::ext;
24
25 namespace OHOS {
26 namespace AAFwk {
27 class DlpUtilsTest : public testing::Test {
28 public:
29 static void SetUpTestCase();
30 static void TearDownTestCase();
31 void SetUp() override;
32 void TearDown() override;
33 };
34
SetUpTestCase()35 void DlpUtilsTest::SetUpTestCase()
36 {}
37
TearDownTestCase()38 void DlpUtilsTest::TearDownTestCase()
39 {}
40
SetUp()41 void DlpUtilsTest::SetUp()
42 {}
43
TearDown()44 void DlpUtilsTest::TearDown()
45 {}
46
47 #ifdef WITH_DLP
48 /**
49 * @tc.name: OtherAppsAccessDlpCheck_0100
50 * @tc.desc: OtherAppsAccessDlpCheck Test
51 * @tc.type: FUNC
52 * @tc.require: issueI581SE
53 */
54 HWTEST_F(DlpUtilsTest, OtherAppsAccessDlpCheck_0100, TestSize.Level0)
55 {
56 AbilityRequest abilityRequest;
57 std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
58 EXPECT_NE(abilityRecord, nullptr);
59 abilityRecord->SetAppIndex(1);
60 Want want;
61 bool result = DlpUtils::OtherAppsAccessDlpCheck(abilityRecord->GetToken(), want);
62 EXPECT_TRUE(result);
63 }
64
65 /**
66 * @tc.name: OtherAppsAccessDlpCheck_0200
67 * @tc.desc: OtherAppsAccessDlpCheck Test
68 * @tc.type: FUNC
69 * @tc.require: issueI581RO
70 */
71 HWTEST_F(DlpUtilsTest, OtherAppsAccessDlpCheck_0200, TestSize.Level0)
72 {
73 AbilityRequest abilityRequest;
74 std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
75 EXPECT_NE(abilityRecord, nullptr);
76 Want want;
77 bool result = DlpUtils::OtherAppsAccessDlpCheck(abilityRecord->GetToken(), want);
78 EXPECT_TRUE(result);
79 }
80
81 /**
82 * @tc.name: DlpAccessOtherAppsCheck_0100
83 * @tc.desc: DlpAccessOtherAppsCheck test
84 * @tc.type: FUNC
85 * @tc.require: issueI581RO
86 */
87 HWTEST_F(DlpUtilsTest, DlpAccessOtherAppsCheck_0100, TestSize.Level0)
88 {
89 AbilityRequest abilityRequest;
90 std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
91 EXPECT_NE(abilityRecord, nullptr);
92 Want want;
93 bool result = DlpUtils::DlpAccessOtherAppsCheck(abilityRecord->GetToken(), want);
94 EXPECT_TRUE(result);
95 }
96 #endif // WITH_DLP
97 } // namespace AAFwk
98 } // namespace OHOS
99