1 /*
2 * Copyright (c) 2023 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 <libxml/globals.h>
18 #include <libxml/xmlstring.h>
19 #include "window_scene_config.h"
20 #include "window_manager_hilog.h"
21 #include "common/include/session_permission.h"
22
23 using namespace testing;
24 using namespace testing::ext;
25
26 namespace OHOS {
27 namespace Rosen {
28 class SessionPermissionTest : public testing::Test {
29 public:
30 static void SetUpTestCase();
31 static void TearDownTestCase();
32 void SetUp() override;
33 void TearDown() override;
34 };
35
SetUpTestCase()36 void SessionPermissionTest::SetUpTestCase() {}
37
TearDownTestCase()38 void SessionPermissionTest::TearDownTestCase() {}
39
SetUp()40 void SessionPermissionTest::SetUp() {}
41
TearDown()42 void SessionPermissionTest::TearDown() {}
43 namespace {
44
45 /**
46 * @tc.name: IsSystemServiceCalling
47 * @tc.desc: test function : IsSystemServiceCalling
48 * @tc.type: FUNC
49 */
50 HWTEST_F(SessionPermissionTest, IsSystemServiceCalling, TestSize.Level1)
51 {
52 bool needPrintLog = true;
53 bool result = SessionPermission::IsSystemServiceCalling(needPrintLog);
54 ASSERT_EQ(true, result);
55 }
56
57 /**
58 * @tc.name: IsSACalling
59 * @tc.desc: test function : IsSACalling
60 * @tc.type: FUNC
61 */
62 HWTEST_F(SessionPermissionTest, IsSACalling, TestSize.Level1)
63 {
64 bool result = SessionPermission::IsSACalling();
65 ASSERT_EQ(false, result);
66 }
67
68 /**
69 * @tc.name: VerifyCallingPermission
70 * @tc.desc: test function : VerifyCallingPermission1
71 * @tc.type: FUNC
72 */
73 HWTEST_F(SessionPermissionTest, VerifyCallingPermission, TestSize.Level1)
74 {
75 const std::string* permissionNode = new string;
76 bool result = SessionPermission::VerifyCallingPermission(*permissionNode);
77 ASSERT_EQ(false, result);
78 }
79
80 /**
81 * @tc.name: VerifyPermissionByCallerToken
82 * @tc.desc: test function : VerifyPermissionByCallerToken
83 * @tc.type: FUNC
84 */
85 HWTEST_F(SessionPermissionTest, VerifyPermissionByCallerToken, TestSize.Level1)
86 {
87 const uint32_t callerToken = 1000;
88 const std::string* permissionNode = new string;
89 bool result = SessionPermission::VerifyPermissionByCallerToken(callerToken, *permissionNode);
90 ASSERT_EQ(false, result);
91 }
92
93 /**
94 * @tc.name: IsSameBundleNameAsCalling
95 * @tc.desc: test function : IsSameBundleNameAsCalling1
96 * @tc.type: FUNC
97 */
98 HWTEST_F(SessionPermissionTest, IsSameBundleNameAsCalling, TestSize.Level1)
99 {
100 const std::string* bundleName = new string;
101 bool result = SessionPermission::IsSameBundleNameAsCalling(*bundleName);
102 ASSERT_EQ(false, result);
103
104 const std::string* bundleName2 = new string("test");
105 bool result2 = SessionPermission::IsSameBundleNameAsCalling(*bundleName2);
106 ASSERT_EQ(false, result2);
107 }
108
109 /**
110 * @tc.name: IsSameAppAsCalling
111 * @tc.desc: test function : IsSameAppAsCalling
112 * @tc.type: FUNC
113 */
114 HWTEST_F(SessionPermissionTest, IsSameAppAsCalling, TestSize.Level1)
115 {
116 const std::string appIdentifier = "123";
117 const std::string bundleName = "";
118 bool result = SessionPermission::IsSameAppAsCalling(bundleName, appIdentifier);
119 ASSERT_EQ(false, result);
120
121 const std::string bundleName2 = "test";
122 bool result2 = SessionPermission::IsSameAppAsCalling(bundleName2, appIdentifier);
123 ASSERT_EQ(false, result2);
124 }
125
126 /**
127 * @tc.name: VerifySessionPermission
128 * @tc.desc: test function : VerifySessionPermission
129 * @tc.type: FUNC
130 */
131 HWTEST_F(SessionPermissionTest, VerifySessionPermission, TestSize.Level1)
132 {
133 bool result = SessionPermission::VerifySessionPermission();
134 ASSERT_EQ(false, result);
135 }
136
137 /**
138 * @tc.name: JudgeCallerIsAllowedToUseSystemAPI
139 * @tc.desc: test function : JudgeCallerIsAllowedToUseSystemAPI
140 * @tc.type: FUNC
141 */
142 HWTEST_F(SessionPermissionTest, JudgeCallerIsAllowedToUseSystemAPI, TestSize.Level1)
143 {
144 bool result = SessionPermission::JudgeCallerIsAllowedToUseSystemAPI();
145 ASSERT_EQ(true, result);
146 }
147
148 /**
149 * @tc.name: IsShellCall
150 * @tc.desc: test function : IsShellCall
151 * @tc.type: FUNC
152 */
153 HWTEST_F(SessionPermissionTest, IsShellCall, TestSize.Level1)
154 {
155 bool result = SessionPermission::IsShellCall();
156 ASSERT_EQ(true, result);
157 }
158
159 /**
160 * @tc.name: IsStartByHdcd
161 * @tc.desc: test function : IsStartByHdcd
162 * @tc.type: FUNC
163 */
164 HWTEST_F(SessionPermissionTest, IsStartByHdcd, TestSize.Level1)
165 {
166 bool result = SessionPermission::IsStartByHdcd();
167 ASSERT_EQ(true, result);
168 }
169
170 /**
171 * @tc.name: IsStartedByInputMethod
172 * @tc.desc: test function : IsStartedByInputMethod
173 * @tc.type: FUNC
174 */
175 HWTEST_F(SessionPermissionTest, IsStartedByInputMethod, TestSize.Level1)
176 {
177 bool result = SessionPermission::IsStartedByInputMethod();
178 ASSERT_EQ(false, result);
179 }
180
181 /**
182 * @tc.name: IsStartedByUIExtension
183 * @tc.desc: test function : IsStartedByUIExtension
184 * @tc.type: FUNC
185 */
186 HWTEST_F(SessionPermissionTest, IsStartedByUIExtension, TestSize.Level1)
187 {
188 bool result = SessionPermission::IsStartedByUIExtension();
189 ASSERT_EQ(result, false);
190 }
191
192 /**
193 * @tc.name: IsFoundationCall
194 * @tc.desc: test function : IsFoundationCall
195 * @tc.type: FUNC
196 */
197 HWTEST_F(SessionPermissionTest, IsFoundationCall, TestSize.Level1)
198 {
199 bool result = SessionPermission::IsFoundationCall();
200 ASSERT_EQ(false, result);
201 }
202
203 } // namespace
204 } // namespace Rosen
205 } // namespace OHOS