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 #define private public
16 #define protected public
17 #include "screenlock_manager.h"
18 #undef private
19 #undef protected
20
21 #include <cstdint>
22 #include <list>
23 #include <string>
24 #include <sys/time.h>
25
26 #include "sclock_log.h"
27 #include "screenlock_callback_test.h"
28 #include "screenlock_client_test.h"
29 #include "screenlock_common.h"
30 #include "screenlock_event_list_test.h"
31 #include "screenlock_notify_test_instance.h"
32 #include "screenlock_system_ability.h"
33 #include "securec.h"
34 #include "dump_helper.h"
35 #include "screenlock_get_info_callback.h"
36 #include "screenlock_inner_listener.h"
37 #include "inner_listener_test.h"
38
39 namespace OHOS {
40 namespace ScreenLock {
41 using namespace testing::ext;
42
43 static EventListenerTest g_unlockTestListener;
44
SetUpTestCase()45 void ScreenLockClientTest::SetUpTestCase()
46 {
47 }
48
TearDownTestCase()49 void ScreenLockClientTest::TearDownTestCase()
50 {
51 }
52
SetUp()53 void ScreenLockClientTest::SetUp()
54 {
55 }
56
TearDown()57 void ScreenLockClientTest::TearDown()
58 {
59 }
60
61 /**
62 * @tc.name: SetScreenLockTest001
63 * @tc.desc: set screen state and get state of the screen.
64 * @tc.type: FUNC
65 * @tc.require:
66 * @tc.author:
67 */
68 HWTEST_F(ScreenLockClientTest, SetScreenLockTest001, TestSize.Level0)
69 {
70 SCLOCK_HILOGD("Test IsScreenLocked state");
71 int32_t userId = ScreenLockSystemAbility::GetInstance()->GetState().GetCurrentUser();
72 ScreenLockSystemAbility::GetInstance()->SetScreenlocked(true, userId);
73 bool isLocked = ScreenLockSystemAbility::GetInstance()->IsScreenLocked();
74 EXPECT_EQ(isLocked, true);
75 }
76
77 /**
78 * @tc.name: GetSecureTest002
79 * @tc.desc: get secure.
80 * @tc.type: FUNC
81 * @tc.require:
82 * @tc.author:
83 */
84 HWTEST_F(ScreenLockClientTest, GetSecureTest002, TestSize.Level0)
85 {
86 SCLOCK_HILOGD("Test secure");
87 bool isLocked = false;
88 ScreenLockManager::GetInstance()->IsLocked(isLocked);
89 bool result = ScreenLockManager::GetInstance()->GetSecure();
90 SCLOCK_HILOGD(" result is-------->%{public}d", result);
91 EXPECT_EQ(result, false);
92 }
93
94 /**
95 * @tc.name: LockTest003
96 * @tc.desc: Test Lock and Unlock
97 * @tc.type: FUNC
98 * @tc.require:
99 * @tc.author:
100 */
101 HWTEST_F(ScreenLockClientTest, LockTest003, TestSize.Level0)
102 {
103 SCLOCK_HILOGD("Test RequestLock and RequestUnlock");
104 sptr<ScreenLockCallbackInterface> listener = nullptr;
105 int32_t result = ScreenLockManager::GetInstance()->Lock(listener);
106 EXPECT_EQ(result, E_SCREENLOCK_NULLPTR);
107 result = ScreenLockManager::GetInstance()->Unlock(Action::UNLOCK, listener);
108 EXPECT_EQ(result, E_SCREENLOCK_NULLPTR);
109 result = ScreenLockManager::GetInstance()->Unlock(Action::UNLOCKSCREEN, listener);
110 EXPECT_EQ(result, E_SCREENLOCK_NULLPTR);
111 listener = new (std::nothrow) ScreenlockCallbackTest(g_unlockTestListener);
112 ASSERT_NE(listener, nullptr);
113 result = ScreenLockManager::GetInstance()->Lock(listener);
114 EXPECT_EQ(result, E_SCREENLOCK_NOT_SYSTEM_APP);
115 result = ScreenLockManager::GetInstance()->Unlock(Action::UNLOCK, listener);
116 EXPECT_EQ(result, E_SCREENLOCK_NOT_SYSTEM_APP);
117 result = ScreenLockManager::GetInstance()->Unlock(Action::UNLOCKSCREEN, listener);
118 EXPECT_EQ(result, E_SCREENLOCK_NOT_FOCUS_APP);
119 }
120
121 /**
122 * @tc.name: OnSystemEventTest004
123 * @tc.desc: Test OnSystemEvent.
124 * @tc.type: FUNC
125 * @tc.require:
126 * @tc.author:
127 */
128 HWTEST_F(ScreenLockClientTest, OnSystemEventTest004, TestSize.Level0)
129 {
130 SCLOCK_HILOGD("Test OnSystemEvent");
131 sptr<ScreenLockSystemAbilityInterface> listener = new (std::nothrow)
132 ScreenLockSystemAbilityTest(g_unlockTestListener);
133 ASSERT_NE(listener, nullptr);
134 int32_t result = ScreenLockManager::GetInstance()->OnSystemEvent(listener);
135 EXPECT_EQ(result, E_SCREENLOCK_NOT_SYSTEM_APP);
136 }
137
138 /**
139 * @tc.name: SendScreenLockEventTest005
140 * @tc.desc: Test SendScreenLockEvent.
141 * @tc.type: FUNC
142 * @tc.require:
143 * @tc.author:
144 */
145 HWTEST_F(ScreenLockClientTest, SendScreenLockEventTest005, TestSize.Level0)
146 {
147 SCLOCK_HILOGD("Test SendScreenLockEvent");
148 int testNum = 0;
149 int32_t result = ScreenLockManager::GetInstance()->SendScreenLockEvent("test", testNum);
150 EXPECT_EQ(result, E_SCREENLOCK_NOT_SYSTEM_APP);
151 }
152
153 /**
154 * @tc.name: OnSystemEventTest006
155 * @tc.desc: Test OnSystemEvent.
156 * @tc.type: FUNC
157 * @tc.require:
158 * @tc.author:
159 */
160 HWTEST_F(ScreenLockClientTest, OnSystemEventTest006, TestSize.Level0)
161 {
162 SCLOCK_HILOGD("Test OnSystemEvent");
163 sptr<ScreenLockSystemAbilityInterface> listener = nullptr;
164 int32_t result = ScreenLockManager::GetInstance()->OnSystemEvent(listener);
165 EXPECT_EQ(result, E_SCREENLOCK_NULLPTR);
166 }
167
168 /**
169 * @tc.name: GetProxyTest007
170 * @tc.desc: Test GetProxy.
171 * @tc.type: FUNC
172 * @tc.require:
173 * @tc.author:
174 */
175 HWTEST_F(ScreenLockClientTest, GetProxyTest007, TestSize.Level0)
176 {
177 SCLOCK_HILOGD("Test GetProxy");
178 ScreenLockManager::GetInstance()->screenlockManagerProxy_ = nullptr;
179 sptr<ScreenLockManagerInterface> proxy = ScreenLockManager::GetInstance()->GetProxy();
180 EXPECT_NE(proxy, nullptr);
181 ScreenLockManager::GetInstance()->screenlockManagerProxy_ = nullptr;
182 proxy = nullptr;
183 proxy = ScreenLockManager::GetInstance()->GetProxy();
184 EXPECT_NE(proxy, nullptr);
185 }
186
187 /**
188 * @tc.name: ProxyTest008
189 * @tc.desc: Test Lock, UnLock and OnSystemEvent.
190 * @tc.type: FUNC
191 * @tc.require:
192 * @tc.author:
193 */
194 HWTEST_F(ScreenLockClientTest, ProxyTest008, TestSize.Level0)
195 {
196 SCLOCK_HILOGD("Test RequestLock, RequestUnLock and OnSystemEvent.");
197 auto proxy = ScreenLockManager::GetInstance()->GetProxy();
198 sptr<ScreenLockSystemAbilityInterface> listener = nullptr;
199 int32_t result = proxy->OnSystemEvent(listener);
200 EXPECT_EQ(result, E_SCREENLOCK_NULLPTR);
201 sptr<ScreenLockCallbackInterface> callback = nullptr;
202 result = proxy->Lock(callback);
203 EXPECT_EQ(result, E_SCREENLOCK_NULLPTR);
204 result = proxy->Unlock(callback);
205 EXPECT_EQ(result, E_SCREENLOCK_NULLPTR);
206 result = proxy->Unlock(callback);
207 EXPECT_EQ(result, E_SCREENLOCK_NULLPTR);
208 }
209
210 /**
211 * @tc.name: LockTest009
212 * @tc.desc: Test Lock Screen.
213 * @tc.type: FUNC
214 * @tc.require:
215 * @tc.author:
216 */
217 HWTEST_F(ScreenLockClientTest, LockTest009, TestSize.Level0)
218 {
219 SCLOCK_HILOGD("Test RequestLock.");
220 auto proxy = ScreenLockManager::GetInstance()->GetProxy();
221 int32_t userId = 0;
222 int32_t result = proxy->Lock(userId);
223 EXPECT_EQ(result, E_SCREENLOCK_NO_PERMISSION);
224 }
225
226 /**
227 * @tc.name: LockTest010
228 * @tc.desc: Test SetScreenLockDisabled.
229 * @tc.type: FUNC
230 * @tc.require:
231 * @tc.author:
232 */
233 HWTEST_F(ScreenLockClientTest, LockTest0010, TestSize.Level0)
234 {
235 SCLOCK_HILOGD("Test SetScreenLockDisabled.");
236 auto proxy = ScreenLockManager::GetInstance()->GetProxy();
237 int32_t userId = 0;
238 int32_t result = proxy->SetScreenLockDisabled(false, userId);
239 SCLOCK_HILOGD("SetScreenLockDisabled.[result]:%{public}d", result);
240 bool isDisabled = true;
241 result = proxy->IsScreenLockDisabled(userId, isDisabled);
242 SCLOCK_HILOGD("SetScreenLockDisabled.[result]:%{public}d", result);
243 EXPECT_EQ(result, E_SCREENLOCK_NO_PERMISSION);
244 }
245
246
247 /**
248 * @tc.name: LockTest0011
249 * @tc.desc: Test SetScreenLockAuthState.
250 * @tc.type: FUNC
251 * @tc.require:
252 * @tc.author:
253 */
254 HWTEST_F(ScreenLockClientTest, LockTest0011, TestSize.Level0)
255 {
256 SCLOCK_HILOGD("Test SetScreenLockAuthState.");
257 auto proxy = ScreenLockManager::GetInstance()->GetProxy();
258 int32_t userId = 0;
259 std::string authtoken = "test";
260 int32_t result = proxy->SetScreenLockAuthState(1, userId, authtoken);
261 SCLOCK_HILOGD("SetScreenLockAuthState.[result]:%{public}d", result);
262 int32_t authState = 0;
263 result = proxy->GetScreenLockAuthState(userId, authState);
264 SCLOCK_HILOGD("SetScreenLockAuthState.[result]:%{public}d", result);
265 EXPECT_EQ(result, E_SCREENLOCK_NOT_SYSTEM_APP);
266 }
267
268 /**
269 * @tc.name: LockTest0012
270 * @tc.desc: Test SetScreenLockAuthState.
271 * @tc.type: FUNC
272 * @tc.require:
273 * @tc.author:
274 */
275 HWTEST_F(ScreenLockClientTest, LockTest0012, TestSize.Level0)
276 {
277 SCLOCK_HILOGD("Test RequestStrongAuth.");
278 int32_t userId = 0;
279 std::string authtoken = "test";
280 int32_t result = ScreenLockManager::GetInstance()->RequestStrongAuth(1, userId);
281 SCLOCK_HILOGD("RequestStrongAuth.[result]:%{public}d", result);
282 int32_t reasonFlag = 0;
283 result = ScreenLockManager::GetInstance()->GetStrongAuth(userId, reasonFlag);
284 SCLOCK_HILOGD("GetStrongAuth.[result]:%{public}d", result);
285 EXPECT_EQ(result, E_SCREENLOCK_NOT_SYSTEM_APP);
286 }
287
288 /**
289 * @tc.name: LockTest013
290 * @tc.desc: Test SetScreenLockDisabled.
291 * @tc.type: FUNC
292 * @tc.require:
293 * @tc.author:
294 */
295 HWTEST_F(ScreenLockClientTest, LockTest0013, TestSize.Level0)
296 {
297 SCLOCK_HILOGD("Test SetScreenLockDisabled.");
298 int32_t userId = 0;
299 int32_t result = ScreenLockManager::GetInstance()->SetScreenLockDisabled(false, userId);
300 SCLOCK_HILOGD("SetScreenLockDisabled.[result]:%{public}d", result);
301 bool isDisabled = true;
302 result = ScreenLockManager::GetInstance()->IsScreenLockDisabled(userId, isDisabled);
303 SCLOCK_HILOGD("SetScreenLockDisabled.[result]:%{public}d", result);
304 EXPECT_EQ(result, E_SCREENLOCK_NO_PERMISSION);
305 }
306
307
308 /**
309 * @tc.name: LockTest0014
310 * @tc.desc: Test SetScreenLockAuthState.
311 * @tc.type: FUNC
312 * @tc.require:
313 * @tc.author:
314 */
315 HWTEST_F(ScreenLockClientTest, LockTest0014, TestSize.Level0)
316 {
317 SCLOCK_HILOGD("Test SetScreenLockAuthState.");
318 int32_t userId = 0;
319 std::string authtoken = "test";
320 int32_t result = ScreenLockManager::GetInstance()->SetScreenLockAuthState(1, userId, authtoken);
321 SCLOCK_HILOGD("SetScreenLockAuthState.[result]:%{public}d", result);
322 int32_t authState = 0;
323 result = ScreenLockManager::GetInstance()->GetScreenLockAuthState(userId, authState);
324 SCLOCK_HILOGD("SetScreenLockAuthState.[result]:%{public}d", result);
325 EXPECT_EQ(result, E_SCREENLOCK_NOT_SYSTEM_APP);
326 }
327
328 /**
329 * @tc.name: LockTest0015
330 * @tc.desc: Test RequestStrongAuth.
331 * @tc.type: FUNC
332 * @tc.require:
333 * @tc.author:
334 */
335 HWTEST_F(ScreenLockClientTest, LockTest0015, TestSize.Level0)
336 {
337 SCLOCK_HILOGD("Test SetScreenLockAuthState.");
338 auto proxy = ScreenLockManager::GetInstance()->GetProxy();
339 int32_t userId = 0;
340 int32_t result = proxy->RequestStrongAuth(1, userId);
341 SCLOCK_HILOGD("RequestStrongAuth.[result]:%{public}d", result);
342 int32_t reasonFlag = 0;
343 result = proxy->GetStrongAuth(userId, reasonFlag);
344 SCLOCK_HILOGD("GetStrongAuth.[result]:%{public}d", result);
345 EXPECT_EQ(result, E_SCREENLOCK_NOT_SYSTEM_APP);
346 }
347
348
349 /**
350 * @tc.name: LockTest0016
351 * @tc.desc: Test IsDeviceLocked.
352 * @tc.type: FUNC
353 * @tc.require:
354 * @tc.author:
355 */
356 HWTEST_F(ScreenLockClientTest, LockTest0016, TestSize.Level0)
357 {
358 SCLOCK_HILOGD("Test IsDeviceLocked.");
359 int userId = 100;
360 bool isDeviceLocked = false;
361 int32_t retCode = 0;
362 retCode = ScreenLockManager::GetInstance()->IsDeviceLocked(userId, isDeviceLocked);
363 SCLOCK_HILOGI("LockTest0016.[retCode]:%{public}d", retCode);
364 EXPECT_EQ(retCode, E_SCREENLOCK_NOT_SYSTEM_APP);
365 }
366
367 /**
368 * @tc.name: LockTest0017
369 * @tc.desc: Test StrongAuthListener.
370 * @tc.type: FUNC
371 * @tc.require:
372 * @tc.author:
373 */
374 HWTEST_F(ScreenLockClientTest, LockTest0017, TestSize.Level0)
375 {
376 SCLOCK_HILOGD("Test StrongAuthListener.");
377 int userId = 100;
378 int32_t retCode = 0;
379 sptr<StrongAuthListener> StrongAuthListenerTest1 = nullptr;
380 retCode = ScreenLockManager::GetInstance()->RegisterStrongAuthListener(StrongAuthListenerTest1);
381 SCLOCK_HILOGI("LockTest0017.[retCode]:%{public}d", retCode);
382 EXPECT_EQ(retCode, E_SCREENLOCK_NULLPTR);
383
384 retCode = ScreenLockManager::GetInstance()->UnRegisterStrongAuthListener(StrongAuthListenerTest1);
385 EXPECT_EQ(retCode, E_SCREENLOCK_NULLPTR);
386
387 StrongAuthListenerTest1 = new (std::nothrow) StrongAuthListenerTest(userId);
388 retCode = ScreenLockManager::GetInstance()->RegisterStrongAuthListener(StrongAuthListenerTest1);
389 EXPECT_EQ(retCode, E_SCREENLOCK_NOT_SYSTEM_APP);
390
391 retCode = ScreenLockManager::GetInstance()->UnRegisterStrongAuthListener(StrongAuthListenerTest1);
392 EXPECT_EQ(retCode, E_SCREENLOCK_NOT_SYSTEM_APP);
393 }
394
395 /**
396 * @tc.name: LockTest0018
397 * @tc.desc: Test StrongAuthListener.
398 * @tc.type: FUNC
399 * @tc.require:
400 * @tc.author:
401 */
402 HWTEST_F(ScreenLockClientTest, LockTest0018, TestSize.Level0)
403 {
404 SCLOCK_HILOGD("Test DeviceLockedListener");
405 int userId = 100;
406 int32_t retCode = 0;
407 sptr<DeviceLockedListener> DeviceLockedListenerTest1 = nullptr;
408 retCode = ScreenLockManager::GetInstance()->RegisterDeviceLockedListener(DeviceLockedListenerTest1);
409 SCLOCK_HILOGI("LockTest0018.[retCode]:%{public}d", retCode);
410 EXPECT_EQ(retCode, E_SCREENLOCK_NULLPTR);
411
412 retCode = ScreenLockManager::GetInstance()->UnRegisterDeviceLockedListener(DeviceLockedListenerTest1);
413 EXPECT_EQ(retCode, E_SCREENLOCK_NULLPTR);
414
415 DeviceLockedListenerTest1 = new (std::nothrow) DeviceLockedListenerTest(userId);
416 retCode = ScreenLockManager::GetInstance()->RegisterDeviceLockedListener(DeviceLockedListenerTest1);
417 EXPECT_EQ(retCode, E_SCREENLOCK_NOT_SYSTEM_APP);
418
419 retCode = ScreenLockManager::GetInstance()->UnRegisterDeviceLockedListener(DeviceLockedListenerTest1);
420 EXPECT_EQ(retCode, E_SCREENLOCK_NOT_SYSTEM_APP);
421 }
422
423 /**
424 * @tc.name: LockTest0019
425 * @tc.desc: Test IsLockedWithUserId.
426 * @tc.type: FUNC
427 * @tc.require:
428 * @tc.author:
429 */
430 HWTEST_F(ScreenLockClientTest, LockTest0019, TestSize.Level0)
431 {
432 SCLOCK_HILOGD("Test IsDeviceLocked.");
433 int userId = 100;
434 bool isLocked = false;
435 int32_t retCode = 0;
436 bool isDeviceLocked = false;
437 retCode = ScreenLockManager::GetInstance()->IsLockedWithUserId(userId, isDeviceLocked);
438 SCLOCK_HILOGI("LockTest0019.[retCode]:%{public}d", retCode);
439 EXPECT_EQ(retCode, E_SCREENLOCK_NOT_SYSTEM_APP);
440 }
441
442 /**
443 * @tc.name: LockTest0020
444 * @tc.desc: Test SetScreenLockAuthState.
445 * @tc.type: FUNC
446 * @tc.require:
447 * @tc.author:
448 */
449 HWTEST_F(ScreenLockClientTest, LockTest0020, TestSize.Level0)
450 {
451 SCLOCK_HILOGD("Test SetScreenLockAuthState.");
452 int userId = 0;
453 int state = 0;
454 sptr<StrongAuthListener> listener = nullptr;
455 sptr<InnerListenerWrapper> wrapper = new (std::nothrow) InnerListenerWrapper(listener);
456 wrapper->OnStateChanged(userId, state);
457 listener = new (std::nothrow) StrongAuthListenerTest(userId);
458 wrapper->OnStateChanged(userId, state);
459 }
460
461 HWTEST_F(ScreenLockClientTest, SetScreenLockTest021, TestSize.Level0)
462 {
463 SCLOCK_HILOGD("Test OnRemoveUser state");
464 AccountSA::OsAccountSubscribeInfo info;
465 sptr<ScreenLockCallbackInterface> listener = nullptr;
466 int32_t result = ScreenLockManager::GetInstance()->Lock(listener);
467 EXPECT_EQ(result, E_SCREENLOCK_NULLPTR);
468 }
469
470 HWTEST_F(ScreenLockClientTest, SetScreenLockTest022, TestSize.Level0)
471 {
472 SCLOCK_HILOGD("Test OnRemoveUser state");
473 AccountSA::OsAccountSubscribeInfo info;
__anona65522090102(const int lastUser, const int targetUser) 474 ScreenLockSystemAbility::AccountSubscriber acount(info, [](const int lastUser, const int targetUser) { return; });
475 acount.OnAccountsChanged(0);
476 sptr<ScreenLockCallbackInterface> listener = nullptr;
477 int32_t result = ScreenLockManager::GetInstance()->Lock(listener);
478 EXPECT_EQ(result, E_SCREENLOCK_NULLPTR);
479 }
480
481 HWTEST_F(ScreenLockClientTest, SetScreenLockTest023, TestSize.Level0)
482 {
483 SCLOCK_HILOGD("Test OnRemoveUser state");
484 AccountSA::OsAccountSubscribeInfo info;
__anona65522090202(const int lastUser, const int targetUser) 485 ScreenLockSystemAbility::AccountSubscriber acount(info, [](const int lastUser, const int targetUser) { return; });
486 acount.OnAccountsChanged(0);
487 sptr<ScreenLockCallbackInterface> listener = nullptr;
488 int32_t result = ScreenLockManager::GetInstance()->Lock(listener);
489 EXPECT_EQ(result, E_SCREENLOCK_NULLPTR);
490 }
491
492 HWTEST_F(ScreenLockClientTest, SetScreenLockTest024, TestSize.Level0)
493 {
494 SCLOCK_HILOGD("Test OnRemoveUser state");
495 sptr<ScreenLockSystemAbility> instance = ScreenLockSystemAbility::GetInstance();
496 instance->SetScreenLockDisabled(true, 0);
497 sptr<ScreenLockCallbackInterface> listener = nullptr;
498 int32_t result = ScreenLockManager::GetInstance()->Lock(listener);
499 EXPECT_EQ(result, E_SCREENLOCK_NULLPTR);
500 }
501
502 HWTEST_F(ScreenLockClientTest, SetScreenLockTest025, TestSize.Level0)
503 {
504 SCLOCK_HILOGD("Test dumpHelper.Dispatch");
505 std::vector<std::string> args;
506 DumpHelper dumpHelper = DumpHelper::GetInstance();
507 bool result = dumpHelper.Dispatch(0, args);
508 EXPECT_EQ(result, false);
509 }
510
511 HWTEST_F(ScreenLockClientTest, SetScreenLockTest026, TestSize.Level0)
512 {
513 SCLOCK_HILOGD("Test dumpHelper.Dispatch");
514 std::vector<std::string> args;
515 std::string param("-h");
516 args.emplace_back(param);
517 DumpHelper dumpHelper = DumpHelper::GetInstance();
518 bool result = dumpHelper.Dispatch(0, args);
519 EXPECT_EQ(result, false);
520 }
521
522 HWTEST_F(ScreenLockClientTest, SetScreenLockTest027, TestSize.Level0)
523 {
524 SCLOCK_HILOGD("Test duScreenLockGetInfoCallbackpHelper.OnCredentialInfo");
525 ScreenLockGetInfoCallback callback;
526 std::vector<OHOS::UserIam::UserAuth::CredentialInfo> infoList;
527 callback.OnCredentialInfo(0, infoList);
528 sptr<ScreenLockCallbackInterface> listener = nullptr;
529 int32_t result = ScreenLockManager::GetInstance()->Lock(listener);
530 EXPECT_EQ(result, E_SCREENLOCK_NULLPTR);
531 }
532
533 HWTEST_F(ScreenLockClientTest, SetScreenLockTest028, TestSize.Level0)
534 {
535 SCLOCK_HILOGD("Test duScreenLockGetInfoCallbackpHelper.OnCredentialInfo");
536 ScreenLockGetInfoCallback callback;
537 OHOS::UserIam::UserAuth::CredentialInfo createntialInfo;
538 std::vector<OHOS::UserIam::UserAuth::CredentialInfo> infoList;
539 infoList.emplace_back(createntialInfo);
540 callback.OnCredentialInfo(0, infoList);
541 sptr<ScreenLockCallbackInterface> listener = nullptr;
542 int32_t result = ScreenLockManager::GetInstance()->Lock(listener);
543 EXPECT_EQ(result, E_SCREENLOCK_NULLPTR);
544 }
545
546 HWTEST_F(ScreenLockClientTest, SetScreenLockTest029, TestSize.Level0)
547 {
548 SCLOCK_HILOGD("Test duScreenLockGetInfoCallbackpHelper.OnCredentialInfo");
549 ScreenLockGetInfoCallback callback;
550 OHOS::UserIam::UserAuth::CredentialInfo createntialInfo;
551 std::vector<OHOS::UserIam::UserAuth::CredentialInfo> infoList;
552 infoList.emplace_back(createntialInfo);
553 callback.OnCredentialInfo(UserIam::UserAuth::SUCCESS + 10001, infoList);
554 sptr<ScreenLockCallbackInterface> listener = nullptr;
555 int32_t result = ScreenLockManager::GetInstance()->Lock(listener);
556 EXPECT_EQ(result, E_SCREENLOCK_NULLPTR);
557 }
558
559 } // namespace ScreenLock
560 } // namespace OHOS