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