1365d9939Sopenharmony_ci/*
2365d9939Sopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd.
3365d9939Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4365d9939Sopenharmony_ci * you may not use this file except in compliance with the License.
5365d9939Sopenharmony_ci * You may obtain a copy of the License at
6365d9939Sopenharmony_ci *
7365d9939Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8365d9939Sopenharmony_ci *
9365d9939Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10365d9939Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11365d9939Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12365d9939Sopenharmony_ci * See the License for the specific language governing permissions and
13365d9939Sopenharmony_ci * limitations under the License.
14365d9939Sopenharmony_ci */
15365d9939Sopenharmony_ci
16365d9939Sopenharmony_ci#include <cstdint>
17365d9939Sopenharmony_ci#include <list>
18365d9939Sopenharmony_ci#include <string>
19365d9939Sopenharmony_ci#include <sys/time.h>
20365d9939Sopenharmony_ci
21365d9939Sopenharmony_ci#include "sclock_log.h"
22365d9939Sopenharmony_ci#include "screenlock_common.h"
23365d9939Sopenharmony_ci#include "securec.h"
24365d9939Sopenharmony_ci#include "strongauthmanager.h"
25365d9939Sopenharmony_ci#include "commeventsubscriber.h"
26365d9939Sopenharmony_ci#include "screenlock_strongauth_test.h"
27365d9939Sopenharmony_ci
28365d9939Sopenharmony_ci
29365d9939Sopenharmony_cinamespace OHOS {
30365d9939Sopenharmony_cinamespace ScreenLock {
31365d9939Sopenharmony_ciusing namespace testing::ext;
32365d9939Sopenharmony_ci
33365d9939Sopenharmony_civoid ScreenLockStrongAuthTest::SetUpTestCase()
34365d9939Sopenharmony_ci{
35365d9939Sopenharmony_ci}
36365d9939Sopenharmony_ci
37365d9939Sopenharmony_civoid ScreenLockStrongAuthTest::TearDownTestCase()
38365d9939Sopenharmony_ci{
39365d9939Sopenharmony_ci}
40365d9939Sopenharmony_ci
41365d9939Sopenharmony_civoid ScreenLockStrongAuthTest::SetUp()
42365d9939Sopenharmony_ci{
43365d9939Sopenharmony_ci}
44365d9939Sopenharmony_ci
45365d9939Sopenharmony_civoid ScreenLockStrongAuthTest::TearDown()
46365d9939Sopenharmony_ci{
47365d9939Sopenharmony_ci}
48365d9939Sopenharmony_ci
49365d9939Sopenharmony_ci/**
50365d9939Sopenharmony_ci* @tc.name: ScreenLockStrongAuthTest001
51365d9939Sopenharmony_ci* @tc.desc: ScreenLockStrongAuthTest RmvAll.
52365d9939Sopenharmony_ci* @tc.type: FUNC
53365d9939Sopenharmony_ci* @tc.require:
54365d9939Sopenharmony_ci* @tc.author:
55365d9939Sopenharmony_ci*/
56365d9939Sopenharmony_ciHWTEST_F(ScreenLockStrongAuthTest, ScreenLockStrongAuthTest001, TestSize.Level0)
57365d9939Sopenharmony_ci{
58365d9939Sopenharmony_ci    SCLOCK_HILOGD("ScreenLockStrongAuthTest");
59365d9939Sopenharmony_ci    auto authmanager = DelayedSingleton<StrongAuthManger>::GetInstance();
60365d9939Sopenharmony_ci    if (authmanager == nullptr) {
61365d9939Sopenharmony_ci        SCLOCK_HILOGE("authmanager is nullptr!");
62365d9939Sopenharmony_ci        return;
63365d9939Sopenharmony_ci    }
64365d9939Sopenharmony_ci
65365d9939Sopenharmony_ci    int32_t userId = 100;
66365d9939Sopenharmony_ci    int32_t defaulVal = 1;
67365d9939Sopenharmony_ci    authmanager->RegistUserAuthSuccessEventListener();
68365d9939Sopenharmony_ci    authmanager->StartStrongAuthTimer(userId);
69365d9939Sopenharmony_ci    authmanager->GetTimerId(userId);
70365d9939Sopenharmony_ci    authmanager->ResetStrongAuthTimer(userId);
71365d9939Sopenharmony_ci    authmanager->DestroyStrongAuthTimer(userId);
72365d9939Sopenharmony_ci    authmanager->DestroyAllStrongAuthTimer();
73365d9939Sopenharmony_ci    authmanager->UnRegistUserAuthSuccessEventListener();
74365d9939Sopenharmony_ci    authmanager->SetStrongAuthStat(userId, defaulVal);
75365d9939Sopenharmony_ci    int32_t val = authmanager->GetStrongAuthStat(userId);
76365d9939Sopenharmony_ci
77365d9939Sopenharmony_ci    Singleton<CommeventMgr>::GetInstance().SubscribeEvent();
78365d9939Sopenharmony_ci    Singleton<CommeventMgr>::GetInstance().UnSubscribeEvent();
79365d9939Sopenharmony_ci    EXPECT_EQ(defaulVal, val);
80365d9939Sopenharmony_ci}
81365d9939Sopenharmony_ci
82365d9939Sopenharmony_ciHWTEST_F(ScreenLockStrongAuthTest, ScreenLockStrongAuthTest002, TestSize.Level0)
83365d9939Sopenharmony_ci{
84365d9939Sopenharmony_ci    StrongAuthManger::authTimer timer(true, 1000, true, true);
85365d9939Sopenharmony_ci    EXPECT_EQ(timer.repeat, true);
86365d9939Sopenharmony_ci    EXPECT_EQ(timer.interval, 1000);
87365d9939Sopenharmony_ci}
88365d9939Sopenharmony_ci
89365d9939Sopenharmony_ci} // namespace ScreenLock
90365d9939Sopenharmony_ci} // namespace OHOS
91