• 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 "permission.h"
19 
20 #include <accesstoken_kit.h>
21 #include <bundle_constants.h>
22 #include <ipc_skeleton.h>
23 #include <bundle_mgr_proxy.h>
24 #include <bundle_mgr_interface.h>
25 #include <system_ability_definition.h>
26 #include <iservice_registry.h>
27 #include <tokenid_kit.h>
28 
29 #include "window_manager_hilog.h"
30 
31 using namespace testing;
32 using namespace testing::ext;
33 
34 namespace OHOS {
35 namespace Rosen {
36 class PermissionTest : public testing::Test {
37 public:
38     static void SetUpTestCase();
39     static void TearDownTestCase();
40     void SetUp() override;
41     void TearDown() override;
42 };
43 
SetUpTestCase()44 void PermissionTest::SetUpTestCase()
45 {
46 }
47 
TearDownTestCase()48 void PermissionTest::TearDownTestCase()
49 {
50 }
51 
SetUp()52 void PermissionTest::SetUp()
53 {
54 }
55 
TearDown()56 void PermissionTest::TearDown()
57 {
58 }
59 
60 namespace {
61 /**
62  * @tc.name: IsSystemServiceCalling
63  * @tc.desc: test fuction : IsSystemServiceCalling
64  * @tc.type: FUNC
65  */
66 HWTEST_F(PermissionTest, IsSystemServiceCalling, Function | SmallTest | Level2)
67 {
68     bool result = Permission::IsSystemServiceCalling(true, true);
69     ASSERT_EQ(true, result);
70 }
71 
72 /**
73  * @tc.name: IsSystemCallingOrStartByHdcd
74  * @tc.desc: test fuction : IsSystemCallingOrStartByHdcd
75  * @tc.type: FUNC
76  */
77 HWTEST_F(PermissionTest, IsSystemCallingOrStartByHdcd, Function | SmallTest | Level2)
78 {
79     bool result1 = Permission::IsSystemCallingOrStartByHdcd(false);
80     ASSERT_EQ(true, result1);
81     bool result2 = Permission::IsSystemCallingOrStartByHdcd(true);
82     ASSERT_EQ(true, result2);
83 }
84 
85 /**
86  * @tc.name: IsStartByInputMethod
87  * @tc.desc: test fuction : IsStartByInputMethod
88  * @tc.type: FUNC
89  */
90 HWTEST_F(PermissionTest, IsStartByInputMethod, Function | SmallTest | Level2)
91 {
92     bool result = Permission::IsStartByInputMethod();
93     ASSERT_EQ(false, result);
94 }
95 
96 /**
97  * @tc.name: CheckIsCallingBundleName
98  * @tc.desc: test fuction : CheckIsCallingBundleName
99  * @tc.type: FUNC
100  */
101 HWTEST_F(PermissionTest, CheckIsCallingBundleName, Function | SmallTest | Level2)
102 {
103     bool result = Permission::CheckIsCallingBundleName("err");
104     ASSERT_EQ(false, result);
105 }
106 }
107 }
108 }