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 <cstdint>
17 #include <list>
18 #include <string>
19 #include <sys/time.h>
20
21 #include "sclock_log.h"
22 #include "screenlock_common.h"
23 #include "securec.h"
24 #ifndef IS_SO_CROP_H
25 #include "strongauthmanager.h"
26 #endif // IS_SO_CROP_H
27 #include "commeventsubscriber.h"
28 #include "screenlock_strongauth_test.h"
29
30
31 namespace OHOS {
32 namespace ScreenLock {
33 using namespace testing::ext;
34
SetUpTestCase()35 void ScreenLockStrongAuthTest::SetUpTestCase()
36 {
37 }
38
TearDownTestCase()39 void ScreenLockStrongAuthTest::TearDownTestCase()
40 {
41 }
42
SetUp()43 void ScreenLockStrongAuthTest::SetUp()
44 {
45 }
46
TearDown()47 void ScreenLockStrongAuthTest::TearDown()
48 {
49 }
50
51 /**
52 * @tc.name: ScreenLockStrongAuthTest001
53 * @tc.desc: ScreenLockStrongAuthTest RmvAll.
54 * @tc.type: FUNC
55 * @tc.require:
56 * @tc.author:
57 */
58 HWTEST_F(ScreenLockStrongAuthTest, ScreenLockStrongAuthTest001, TestSize.Level0)
59 {
60 SCLOCK_HILOGD("ScreenLockStrongAuthTest");
61 #ifndef IS_SO_CROP_H
62 auto authmanager = DelayedSingleton<StrongAuthManger>::GetInstance();
63 if (authmanager == nullptr) {
64 SCLOCK_HILOGE("authmanager is nullptr!");
65 return;
66 }
67
68 int32_t userId = 100;
69 int32_t defaulVal = 1;
70 authmanager->RegistUserAuthSuccessEventListener();
71 authmanager->StartStrongAuthTimer(userId);
72 authmanager->GetTimerId(userId);
73 authmanager->ResetStrongAuthTimer(userId);
74 authmanager->DestroyStrongAuthTimer(userId);
75 authmanager->DestroyAllStrongAuthTimer();
76 authmanager->UnRegistUserAuthSuccessEventListener();
77 authmanager->SetStrongAuthStat(userId, defaulVal);
78 int32_t val = authmanager->GetStrongAuthStat(userId);
79
80 Singleton<CommeventMgr>::GetInstance().SubscribeEvent();
81 Singleton<CommeventMgr>::GetInstance().UnSubscribeEvent();
82 EXPECT_EQ(defaulVal, val);
83 #endif // IS_SO_CROP_H
84 return;
85 }
86
87 HWTEST_F(ScreenLockStrongAuthTest, ScreenLockStrongAuthTest002, TestSize.Level0)
88 {
89 #ifndef IS_SO_CROP_H
90 StrongAuthManger::authTimer timer(true, 1000, true, true);
91 EXPECT_EQ(timer.repeat, true);
92 EXPECT_EQ(timer.interval, 1000);
93 #endif // IS_SO_CROP_H
94 }
95
96 } // namespace ScreenLock
97 } // namespace OHOS
98