diff --git a/dm/test/systemtest/display_power_test.cpp b/dm/test/systemtest/display_power_test.cpp index 5308157d07..d03be7623e 100644 --- a/dm/test/systemtest/display_power_test.cpp +++ b/dm/test/systemtest/display_power_test.cpp @@ -130,6 +130,7 @@ HWTEST_F(DisplayPowerTest, register_display_power_event_listener_001, Function | sptr listener = new DisplayPowerEventListener(); bool ret = DisplayManager::GetInstance().RegisterDisplayPowerEventListener(listener); ASSERT_EQ(true, ret); + DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(listener); } /** @@ -143,6 +144,42 @@ HWTEST_F(DisplayPowerTest, register_display_power_event_listener_002, Function | ASSERT_EQ(false, ret); } +/** + * @tc.name: unregister_display_power_event_listener_001 + * @tc.desc: call UnregisterDisplayPowerEventListener with a valid listener and check return value + * @tc.type: FUNC + */ +HWTEST_F(DisplayPowerTest, unregister_display_power_event_listener_001, Function | SmallTest | Level2) +{ + sptr listener = new DisplayPowerEventListener(); + DisplayManager::GetInstance().RegisterDisplayPowerEventListener(listener); + bool ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(listener); + ASSERT_EQ(true, ret); +} + +/** +* @tc.name: unregister_display_power_event_listener_002 +* @tc.desc: call UnregisterDisplayPowerEventListener with nullptr and check return value +* @tc.type: FUNC +*/ +HWTEST_F(DisplayPowerTest, unregister_display_power_event_listener_002, Function | SmallTest | Level2) +{ + bool ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(nullptr); + ASSERT_EQ(false, ret); +} + +/** +* @tc.name: unregister_display_power_event_listener_003 +* @tc.desc: call UnregisterDisplayPowerEventListener with an invalid listener and check return value +* @tc.type: FUNC +*/ +HWTEST_F(DisplayPowerTest, unregister_display_power_event_listener_003, Function | SmallTest | Level2) +{ + sptr listener = new DisplayPowerEventListener(); + bool ret = DisplayManager::GetInstance().UnregisterDisplayPowerEventListener(listener); + ASSERT_EQ(false, ret); +} + /** * @tc.name: set_display_state_001 * @tc.desc: Call SetDisplayState and check if it the state set is the same as calling GetDisplayState