1 /*
2 * Copyright (C) 2025 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 "strong_auth_status_manager_test.h"
17
18 #include "strong_auth_status_manager.h"
19
20 #include "iam_logger.h"
21 #include "securec.h"
22
23 #define LOG_TAG "USER_AUTH_SA"
24
25 namespace OHOS {
26 namespace UserIam {
27 namespace UserAuth {
28 using namespace testing;
29 using namespace testing::ext;
30
SetUpTestCase()31 void StrongAuthStatusManagerTest::SetUpTestCase()
32 {
33 }
34
TearDownTestCase()35 void StrongAuthStatusManagerTest::TearDownTestCase()
36 {
37 }
38
SetUp()39 void StrongAuthStatusManagerTest::SetUp()
40 {
41 }
42
TearDown()43 void StrongAuthStatusManagerTest::TearDown()
44 {
45 }
46
47 HWTEST_F(StrongAuthStatusManagerTest, RegisterStrongAuthListenerTest, TestSize.Level0)
48 {
49 EXPECT_NO_THROW(StrongAuthStatusManager::Instance().RegisterStrongAuthListener());
50 EXPECT_NO_THROW(StrongAuthStatusManager::Instance().RegisterStrongAuthListener());
51 EXPECT_NO_THROW(StrongAuthStatusManager::Instance().SyncStrongAuthStatusForAllAccounts());
52 EXPECT_NO_THROW(StrongAuthStatusManager::Instance().UnRegisterStrongAuthListener());
53 EXPECT_NO_THROW(StrongAuthStatusManager::Instance().UnRegisterStrongAuthListener());
54 }
55
56 HWTEST_F(StrongAuthStatusManagerTest, StartSubscribeTest, TestSize.Level0)
57 {
58 EXPECT_NO_THROW(StrongAuthStatusManager::Instance().StartSubscribe());
59 EXPECT_NO_THROW(StrongAuthStatusManager::Instance().StartSubscribe());
60 }
61
62 HWTEST_F(StrongAuthStatusManagerTest, IsScreenLockStrongAuthTest, TestSize.Level0)
63 {
64 int32_t mainUserId = 100;
65 int32_t inValidUserId = -1;
66 EXPECT_NO_THROW(StrongAuthStatusManager::Instance().IsScreenLockStrongAuth(mainUserId));
67 EXPECT_NO_THROW(StrongAuthStatusManager::Instance().IsScreenLockStrongAuth(inValidUserId));
68 }
69 } // namespace UserAuth
70 } // namespace UserIam
71 } // namespace OHOS