From 9de33fc51a4f05514c5cc6875a9cafca6544438a Mon Sep 17 00:00:00 2001 From: wuliangdong Date: Mon, 14 Jul 2025 15:09:20 +0800 Subject: [PATCH 1/2] Add Tdd for OnConnected Signed-off-by: wuliangdong Change-Id: Ie0241af8478463dfee033534b2f6c5cf7f6bf414 --- .../proxy/event_handler/test/input_manager_impl_test.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frameworks/proxy/event_handler/test/input_manager_impl_test.cpp b/frameworks/proxy/event_handler/test/input_manager_impl_test.cpp index 90d5fa76d7..c95d1fbf06 100644 --- a/frameworks/proxy/event_handler/test/input_manager_impl_test.cpp +++ b/frameworks/proxy/event_handler/test/input_manager_impl_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 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 @@ -489,6 +489,8 @@ HWTEST_F(InputManagerImplTest, InputManagerImplTest_OnConnected_04, TestSize.Lev ASSERT_NO_FATAL_FAILURE(InputMgrImpl.OnConnected()); } + + /** * @tc.name: InputManagerImplTest_SetPixelMapData_01 * @tc.desc: Test SetPixelMapData -- Gitee From 607e90ff4cff58af91b818f14f17c36e660f02ee Mon Sep 17 00:00:00 2001 From: wuliangdong Date: Mon, 14 Jul 2025 07:12:00 +0000 Subject: [PATCH 2/2] update frameworks/proxy/event_handler/test/input_manager_impl_test.cpp. Signed-off-by: wuliangdong --- .../test/input_manager_impl_test.cpp | 67 ++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/frameworks/proxy/event_handler/test/input_manager_impl_test.cpp b/frameworks/proxy/event_handler/test/input_manager_impl_test.cpp index c95d1fbf06..1b3f5db6d3 100644 --- a/frameworks/proxy/event_handler/test/input_manager_impl_test.cpp +++ b/frameworks/proxy/event_handler/test/input_manager_impl_test.cpp @@ -489,7 +489,72 @@ HWTEST_F(InputManagerImplTest, InputManagerImplTest_OnConnected_04, TestSize.Lev ASSERT_NO_FATAL_FAILURE(InputMgrImpl.OnConnected()); } - +/** + * @tc.name: InputManagerImplTest_OnConnected_05 + * @tc.desc: Test OnConnected + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputManagerImplTest, InputManagerImplTest_OnConnected_05, TestSize.Level1) +{ + CALL_TEST_DEBUG; + InputMgrImpl.anrObservers_.push_back(nullptr); + EXPECT_FALSE(InputMgrImpl.anrObservers_.empty()); + ASSERT_NO_FATAL_FAILURE(InputMgrImpl.OnConnected()); +} + +/** + * @tc.name: InputManagerImplTest_OnConnected_06 + * @tc.desc: Test OnConnected + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputManagerImplTest, InputManagerImplTest_OnConnected_06, TestSize.Level1) +{ + CALL_TEST_DEBUG; + class IAnrObserverTest : public IAnrObserver { + public: + IAnrObserverTest() : IAnrObserver() + {} + virtual ~IAnrObserverTest() + {} + void OnAnr(int32_t pid, int32_t eventId) const override + { + MMI_HILOGD("Set anr success"); + }; + }; + std::shared_ptr observer = std::make_shared(); + InputMgrImpl.anrObservers_.push_back(observer); + ASSERT_NO_FATAL_FAILURE(InputMgrImpl.OnConnected()); +} + +/** + * @tc.name: InputManagerImplTest_OnConnected_07 + * @tc.desc: Test OnConnected + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputManagerImplTest, InputManagerImplTest_OnConnected_07, TestSize.Level1) +{ + CALL_TEST_DEBUG; + InputMgrImpl.currentUserId_.store(42); + EXPECT_TRUE(InputMgrImpl.currentUserId_ != -1); + ASSERT_NO_FATAL_FAILURE(InputMgrImpl.OnConnected()); +} + +/** + * @tc.name: InputManagerImplTest_OnConnected_08 + * @tc.desc: Test OnConnected + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(InputManagerImplTest, InputManagerImplTest_OnConnected_08, TestSize.Level1) +{ + CALL_TEST_DEBUG; + InputMgrImpl.currentUserId_.store(-1); + EXPECT_TRUE(InputMgrImpl.currentUserId_ == -1); + ASSERT_NO_FATAL_FAILURE(InputMgrImpl.OnConnected()); +} /** * @tc.name: InputManagerImplTest_SetPixelMapData_01 -- Gitee