• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-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 #include <sys/stat.h>
18 #include <sys/types.h>
19 #include <string>
20 #include <vector>
21 #include <iostream>
22 
23 #include "profile_utils.h"
24 #include "permission_manager.h"
25 #include "distributed_device_profile_constants.h"
26 #include "distributed_device_profile_log.h"
27 #include "distributed_device_profile_errors.h"
28 
29 namespace OHOS {
30 namespace DistributedDeviceProfile {
31 using namespace testing::ext;
32 using namespace std;
33 namespace {
34     const std::string TAG = "PermissionManagerTest";
35 }
36 class PermissionManagerTest : public testing::Test {
37 public:
38     static void SetUpTestCase();
39     static void TearDownTestCase();
40     void SetUp();
41     void TearDown();
42 };
43 
SetUpTestCase()44 void PermissionManagerTest::SetUpTestCase()
45 {
46     int32_t ret = PermissionManager::GetInstance().Init();
47     EXPECT_EQ(ret, DP_SUCCESS);
48 }
49 
TearDownTestCase()50 void PermissionManagerTest::TearDownTestCase()
51 {
52     int32_t ret = PermissionManager::GetInstance().UnInit();
53     EXPECT_EQ(ret, DP_SUCCESS);
54 }
55 
SetUp()56 void PermissionManagerTest::SetUp()
57 {
58 }
59 
TearDown()60 void PermissionManagerTest::TearDown()
61 {
62 }
63 
64 /*
65  * @tc.name: IsCallerTrust_001
66  * @tc.desc: Normal testCase of PermissionManagerTest for CRUD
67  * @tc.type: FUNC
68  */
69 HWTEST_F(PermissionManagerTest, IsCallerTrust_001, TestSize.Level1)
70 {
71     PermissionManager::GetInstance().GetCallerProcName();
72 
73     bool ret = PermissionManager::GetInstance().IsCallerTrust(PUT_ACCESS_CONTROL_PROFILE);
74     EXPECT_EQ(ret, false);
75 }
76 
77 /*
78  * @tc.name: CheckCallerPermission_001
79  * @tc.desc: Normal testCase of PermissionManagerTest for CRUD
80  * @tc.type: FUNC
81  */
82 HWTEST_F(PermissionManagerTest, CheckCallerPermission_001, TestSize.Level1)
83 {
84     bool ret = PermissionManager::GetInstance().CheckCallerPermission();
85     EXPECT_EQ(ret, false);
86 }
87 
88 /*
89  * @tc.name: CheckCallerSyncPermission_001
90  * @tc.desc: Normal testCase of PermissionManagerTest for CRUD
91  * @tc.type: FUNC
92  */
93 HWTEST_F(PermissionManagerTest, CheckCallerSyncPermission_001, TestSize.Level1)
94 {
95     bool ret = PermissionManager::GetInstance().CheckCallerSyncPermission();
96     EXPECT_EQ(ret, false);
97 }
98 } // namespace DistributedDeviceProfile
99 } // namespace OHOS