mirror of
https://gitee.com/openharmony/useriam_user_auth_framework
synced 2024-11-23 07:39:51 +00:00
fix: ut coverage
Signed-off-by: 居凯 <shun0304@126.com> Change-Id: Ie40a6b769c3c94a53ef28275cff992697ad558d8
This commit is contained in:
parent
0a15c280f1
commit
f7699533fa
@ -137,6 +137,7 @@ ohos_unittest("iam_services_test") {
|
|||||||
"src/identification_impl_test.cpp",
|
"src/identification_impl_test.cpp",
|
||||||
"src/identify_context_test.cpp",
|
"src/identify_context_test.cpp",
|
||||||
"src/ipc_common_test.cpp",
|
"src/ipc_common_test.cpp",
|
||||||
|
"src/keygurad_status_listener_test.cpp",
|
||||||
"src/relative_timer_test.cpp",
|
"src/relative_timer_test.cpp",
|
||||||
"src/resource_node_pool_test.cpp",
|
"src/resource_node_pool_test.cpp",
|
||||||
"src/resource_node_test.cpp",
|
"src/resource_node_test.cpp",
|
||||||
|
37
test/unittest/services/inc/keyguard_status_listener_test.h
Normal file
37
test/unittest/services/inc/keyguard_status_listener_test.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef KEYGUARD_STATUS_LISTENER_TEST
|
||||||
|
#define KEYGUARD_STATUS_LISTENER_TEST
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace UserIam {
|
||||||
|
namespace UserAuth {
|
||||||
|
class KeyguardStatusListenerTest : public testing::Test {
|
||||||
|
public:
|
||||||
|
static void SetUpTestCase();
|
||||||
|
|
||||||
|
static void TearDownTestCase();
|
||||||
|
|
||||||
|
void SetUp() override;
|
||||||
|
|
||||||
|
void TearDown() override;
|
||||||
|
};
|
||||||
|
} // namespace UserAuth
|
||||||
|
} // namespace UserIam
|
||||||
|
} // namespace OHOS
|
||||||
|
|
||||||
|
#endif // KEYGUARD_STATUS_LISTENER_TEST
|
54
test/unittest/services/src/keygurad_status_listener_test.cpp
Normal file
54
test/unittest/services/src/keygurad_status_listener_test.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "keyguard_status_listener_test.h"
|
||||||
|
#include "keyguard_status_listener.h"
|
||||||
|
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace UserIam {
|
||||||
|
namespace UserAuth {
|
||||||
|
using namespace testing;
|
||||||
|
using namespace testing::ext;
|
||||||
|
|
||||||
|
void KeyguardStatusListenerTest::SetUpTestCase()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeyguardStatusListenerTest::TearDownTestCase()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeyguardStatusListenerTest::SetUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeyguardStatusListenerTest::TearDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
HWTEST_F(KeyguardStatusListenerTest, KeyguardStatusListenerTestRegisterListener, TestSize.Level0)
|
||||||
|
{
|
||||||
|
ResultCode result = KeyguardStatusListenerManager::GetInstance().RegisterCommonEventListener();
|
||||||
|
EXPECT_EQ(result, GENERAL_ERROR);
|
||||||
|
EXPECT_NO_THROW(KeyguardStatusListenerManager::GetInstance().RegisterKeyguardStatusSwitchCallback());
|
||||||
|
EXPECT_NO_THROW(KeyguardStatusListenerManager::GetInstance().UnRegisterKeyguardStatusSwitchCallback());
|
||||||
|
ResultCode result = KeyguardStatusListenerManager::GetInstance().UnRegisterCommonEventListener();
|
||||||
|
EXPECT_EQ(result, GENERAL_ERROR);
|
||||||
|
}
|
||||||
|
} // namespace UserAuth
|
||||||
|
} // namespace UserIam
|
||||||
|
} // namespace OHOS
|
@ -199,8 +199,13 @@ HWTEST_F(SoftBusManagerTest, SoftBusManagerTestOnShutdown_001, TestSize.Level0)
|
|||||||
{
|
{
|
||||||
ShutdownReason reason = SHUTDOWN_REASON_UNKNOWN;
|
ShutdownReason reason = SHUTDOWN_REASON_UNKNOWN;
|
||||||
EXPECT_NO_THROW(SoftBusManager::GetInstance().OnShutdown(-2, reason));
|
EXPECT_NO_THROW(SoftBusManager::GetInstance().OnShutdown(-2, reason));
|
||||||
SoftBusManager::GetInstance().ClearServerSocket();
|
int32_t socketId = 100;
|
||||||
|
std::shared_ptr<BaseSocket> serverSocket = SocketFactory::CreateServerSocket(socketId);
|
||||||
|
SoftBusManager::GetInstance().AddSocket(socketId, serverSocket);
|
||||||
|
SoftBusManager::GetInstance().SetServerSocket(serverSocket);
|
||||||
EXPECT_NO_THROW(SoftBusManager::GetInstance().OnShutdown(600, reason));
|
EXPECT_NO_THROW(SoftBusManager::GetInstance().OnShutdown(600, reason));
|
||||||
|
SoftBusManager::GetInstance().ServiceSocketUnInit();
|
||||||
|
SoftBusManager::GetInstance().DeleteSocket(socketId);
|
||||||
}
|
}
|
||||||
|
|
||||||
HWTEST_F(SoftBusManagerTest, SoftBusManagerTestOnServerBytes_002, TestSize.Level0)
|
HWTEST_F(SoftBusManagerTest, SoftBusManagerTestOnServerBytes_002, TestSize.Level0)
|
||||||
|
Loading…
Reference in New Issue
Block a user