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