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 <bundle_mgr_interface.h>
23 #include <bundle_mgr_proxy.h>
24 #include <ipc_skeleton.h>
25 #include <iservice_registry.h>
26 #include <system_ability_definition.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
TearDownTestCase()46 void PermissionTest::TearDownTestCase() {}
47
SetUp()48 void PermissionTest::SetUp() {}
49
TearDown()50 void PermissionTest::TearDown() {}
51
52 namespace {
53 /**
54 * @tc.name: IsSystemServiceCalling
55 * @tc.desc: test fuction : IsSystemServiceCalling
56 * @tc.type: FUNC
57 */
58 HWTEST_F(PermissionTest, IsSystemServiceCalling, TestSize.Level1)
59 {
60 bool result = Permission::IsSystemServiceCalling(true, true);
61 ASSERT_EQ(true, result);
62 }
63
64 /**
65 * @tc.name: IsSystemCallingOrStartByHdcd
66 * @tc.desc: test fuction : IsSystemCallingOrStartByHdcd
67 * @tc.type: FUNC
68 */
69 HWTEST_F(PermissionTest, IsSystemCallingOrStartByHdcd, TestSize.Level1)
70 {
71 bool result1 = Permission::IsSystemCallingOrStartByHdcd(false);
72 ASSERT_EQ(true, result1);
73 bool result2 = Permission::IsSystemCallingOrStartByHdcd(true);
74 ASSERT_EQ(true, result2);
75 }
76
77 /**
78 * @tc.name: IsStartByInputMethod
79 * @tc.desc: test fuction : IsStartByInputMethod
80 * @tc.type: FUNC
81 */
82 HWTEST_F(PermissionTest, IsStartByInputMethod, TestSize.Level1)
83 {
84 bool result = Permission::IsStartByInputMethod();
85 ASSERT_EQ(false, result);
86 }
87
88 /**
89 * @tc.name: CheckIsCallingBundleName
90 * @tc.desc: test fuction : CheckIsCallingBundleName
91 * @tc.type: FUNC
92 */
93 HWTEST_F(PermissionTest, CheckIsCallingBundleName, TestSize.Level1)
94 {
95 bool result = Permission::CheckIsCallingBundleName("err");
96 ASSERT_EQ(false, result);
97 }
98 } // namespace
99 } // namespace Rosen
100 } // namespace OHOS