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 "permission_manager_mock_test.h"
17
18 #include "access_token.h"
19 #include "access_token_error.h"
20
21 using namespace testing::ext;
22 using namespace OHOS;
23
24 namespace OHOS {
25 namespace Security {
26 namespace AccessToken {
27
SetUpTestCase()28 void PermissionManagerMockTest::SetUpTestCase()
29 {}
30
TearDownTestCase()31 void PermissionManagerMockTest::TearDownTestCase()
32 {}
33
SetUp()34 void PermissionManagerMockTest::SetUp()
35 {}
36
TearDown()37 void PermissionManagerMockTest::TearDown()
38 {}
39
40 /**
41 * @tc.name: RequestAppPermOnSettingTest001
42 * @tc.desc: Test RequestAppPermOnSetting.
43 * @tc.type: FUNC
44 * @tc.require: Issue
45 */
46 HWTEST_F(PermissionManagerMockTest, RequestAppPermOnSettingTest001, TestSize.Level4)
47 {
48 HapTokenInfo hapInfo;
49 hapInfo.bundleName = "aaa";
50 hapInfo.instIndex = 0;
51 hapInfo.tokenID = 123;
52 hapInfo.userID = 100;
53 std::string bundleName = "bundleName";
54 std::string abilityName = "abilityName";
55
56 EXPECT_EQ(ERR_SERVICE_ABNORMAL,
57 PermissionManager::GetInstance().RequestAppPermOnSetting(hapInfo, bundleName, abilityName));
58
59 hapInfo.instIndex = 1;
60 EXPECT_EQ(ERR_OK,
61 PermissionManager::GetInstance().RequestAppPermOnSetting(hapInfo, bundleName, abilityName));
62 }
63 } // namespace AccessToken
64 } // namespace Security
65 } // namespace OHOS
66