• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {
38 }
39 
TearDownTestCase()40 void SessionPermissionTest::TearDownTestCase()
41 {
42 }
43 
SetUp()44 void SessionPermissionTest::SetUp()
45 {
46 }
47 
TearDown()48 void SessionPermissionTest::TearDown()
49 {
50 }
51 namespace {
52 
53 /**
54  * @tc.name: IsSystemServiceCalling
55  * @tc.desc: test function : IsSystemServiceCalling
56  * @tc.type: FUNC
57  */
58 HWTEST_F(SessionPermissionTest, IsSystemServiceCalling, Function | SmallTest | Level1)
59 {
60     bool needPrintLog = true;
61     bool result = SessionPermission::IsSystemServiceCalling(needPrintLog);
62     ASSERT_EQ(true, result);
63 }
64 
65 /**
66  * @tc.name: IsSACalling
67  * @tc.desc: test function : IsSACalling
68  * @tc.type: FUNC
69  */
70 HWTEST_F(SessionPermissionTest, IsSACalling, Function | SmallTest | Level1)
71 {
72     bool result = SessionPermission::IsSACalling();
73     ASSERT_EQ(false, result);
74 }
75 
76 /**
77  * @tc.name: VerifyCallingPermission
78  * @tc.desc: test function : VerifyCallingPermission1
79  * @tc.type: FUNC
80 */
81 HWTEST_F(SessionPermissionTest, VerifyCallingPermission, Function | SmallTest | Level1)
82 {
83     const std::string *permissionNode = new string;
84     bool result = SessionPermission::VerifyCallingPermission(*permissionNode);
85     ASSERT_EQ(false, result);
86 }
87 
88 /**
89  * @tc.name: IsSameBundleNameAsCalling
90  * @tc.desc: test function : IsSameBundleNameAsCalling1
91  * @tc.type: FUNC
92 */
93 HWTEST_F(SessionPermissionTest, IsSameBundleNameAsCalling, Function | SmallTest | Level1)
94 {
95     const std::string *bundleName = new string;
96     bool result = SessionPermission::IsSameBundleNameAsCalling(*bundleName);
97     ASSERT_EQ(false, result);
98 }
99 
100 /**
101  * @tc.name: VerifySessionPermission
102  * @tc.desc: test function : VerifySessionPermission
103  * @tc.type: FUNC
104 */
105 HWTEST_F(SessionPermissionTest, VerifySessionPermission, Function | SmallTest | Level1)
106 {
107     bool result = SessionPermission::VerifySessionPermission();
108     ASSERT_EQ(false, result);
109 }
110 
111 /**
112  * @tc.name: JudgeCallerIsAllowedToUseSystemAPI
113  * @tc.desc: test function : JudgeCallerIsAllowedToUseSystemAPI
114  * @tc.type: FUNC
115 */
116 HWTEST_F(SessionPermissionTest, JudgeCallerIsAllowedToUseSystemAPI, Function | SmallTest | Level1)
117 {
118     bool result = SessionPermission::JudgeCallerIsAllowedToUseSystemAPI();
119     ASSERT_EQ(true, result);
120 }
121 
122 /**
123  * @tc.name: IsShellCall
124  * @tc.desc: test function : IsShellCall
125  * @tc.type: FUNC
126 */
127 HWTEST_F(SessionPermissionTest, IsShellCall, Function | SmallTest | Level1)
128 {
129     bool result = SessionPermission::IsShellCall();
130     ASSERT_EQ(true, result);
131 }
132 
133 /**
134  * @tc.name: IsStartByHdcd
135  * @tc.desc: test function : IsStartByHdcd
136  * @tc.type: FUNC
137 */
138 HWTEST_F(SessionPermissionTest, IsStartByHdcd, Function | SmallTest | Level1)
139 {
140     bool result = SessionPermission::IsStartByHdcd();
141     ASSERT_EQ(true, result);
142 }
143 
144 /**
145  * @tc.name: IsStartedByInputMethod
146  * @tc.desc: test function : IsStartedByInputMethod
147  * @tc.type: FUNC
148 */
149 HWTEST_F(SessionPermissionTest, IsStartedByInputMethod, Function | SmallTest | Level1)
150 {
151     bool result = SessionPermission::IsStartedByInputMethod();
152     ASSERT_EQ(false, result);
153 }
154 
155 /**
156  * @tc.name: session_permission_test001
157  * @tc.desc: test function : session_permission_test001
158  * @tc.type: FUNC
159 */
160 HWTEST_F(SessionPermissionTest, session_permission_test001, Function | SmallTest | Level1)
161 {
162     GTEST_LOG_(INFO) << "SessionPermissionTest: session_permission_test001 start";
163     bool result = SessionPermission::IsStartByHdcd();
164     ASSERT_EQ(result, true);
165     GTEST_LOG_(INFO) << "SessionPermissionTest: session_permission_test001 end";
166 }
167 
168 /**
169  * @tc.name: session_permission_test002
170  * @tc.desc: test function : session_permission_test002
171  * @tc.type: FUNC
172 */
173 HWTEST_F(SessionPermissionTest, session_permission_test002, Function | SmallTest | Level1)
174 {
175     GTEST_LOG_(INFO) << "SessionPermissionTest: session_permission_test002 start";
176     bool result = SessionPermission::IsStartedByInputMethod();
177     ASSERT_EQ(result, false);
178     GTEST_LOG_(INFO) << "SessionPermissionTest: session_permission_test002 end";
179 }
180 } // namespacecd
181 } // namespace Rosen
182 } // namespace OHOS