From 21f4e72112b030791b1caf48a119ec3ed5a7000e Mon Sep 17 00:00:00 2001 From: suozhipeng Date: Mon, 22 Apr 2024 16:42:26 +0800 Subject: [PATCH] fix: display_UT_bug Signed-off-by: suozhipeng --- .../src/display_power_mgr_service_test.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/state_manager/test/unittest/src/display_power_mgr_service_test.cpp b/state_manager/test/unittest/src/display_power_mgr_service_test.cpp index b462244..45ab45d 100644 --- a/state_manager/test/unittest/src/display_power_mgr_service_test.cpp +++ b/state_manager/test/unittest/src/display_power_mgr_service_test.cpp @@ -311,7 +311,8 @@ HWTEST_F(DisplayPowerMgrServiceTest, DisplayPowerMgrService019, TestSize.Level0) DisplayPowerMgrClient::GetInstance().SetDisplayState(DisplayState::DISPLAY_OFF); DisplayState delayState = DisplayPowerMgrClient::GetInstance().GetDisplayState(); EXPECT_TRUE(delayState == DisplayState::DISPLAY_DELAY_OFF); - int sleepTime = 1; // sleep time is 1s + //Callback for waiting window + int sleepTime = 2; // sleep time is 2s sleep(sleepTime); DisplayState offState = DisplayPowerMgrClient::GetInstance().GetDisplayState(); EXPECT_TRUE(offState == DisplayState::DISPLAY_OFF); @@ -348,6 +349,9 @@ HWTEST_F(DisplayPowerMgrServiceTest, DisplayPowerMgrService021, TestSize.Level0) { DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrService021 is start"); DisplayPowerMgrClient::GetInstance().SetDisplayState(DisplayState::DISPLAY_OFF); + int sleepTime = 2; + //Callback for waiting window 2s + sleep(sleepTime); bool coordinated = true; auto ret = DisplayPowerMgrClient::GetInstance().SetCoordinated(coordinated); EXPECT_TRUE(ret); @@ -355,7 +359,7 @@ HWTEST_F(DisplayPowerMgrServiceTest, DisplayPowerMgrService021, TestSize.Level0) // If the state of display is DISPLAY_ON, change it to DISPLAY_OFF. DisplayPowerMgrClient::GetInstance().SetDisplayState( DisplayState::DISPLAY_OFF, PowerMgr::StateChangeReason::STATE_CHANGE_REASON_APPLICATION); - + sleep(sleepTime); ret = DisplayPowerMgrClient::GetInstance().SetDisplayState( DisplayState::DISPLAY_ON, PowerMgr::StateChangeReason::STATE_CHANGE_REASON_TIMEOUT); EXPECT_TRUE(ret); @@ -375,6 +379,9 @@ HWTEST_F(DisplayPowerMgrServiceTest, DisplayPowerMgrService022, TestSize.Level0) DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrService022 is start"); DisplayPowerMgrClient::GetInstance().SetDisplayState(DisplayState::DISPLAY_ON); DisplayPowerMgrClient::GetInstance().SetDisplayState(DisplayState::DISPLAY_OFF); + int sleepTime = 2; + //Callback for waiting window 2s + sleep(sleepTime); DisplayState currentState = DisplayPowerMgrClient::GetInstance().GetDisplayState(); EXPECT_TRUE(currentState == DisplayState::DISPLAY_OFF); @@ -395,6 +402,9 @@ HWTEST_F(DisplayPowerMgrServiceTest, DisplayPowerMgrService023, TestSize.Level0) { DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrService023 is start"); bool ret = DisplayPowerMgrClient::GetInstance().SetDisplayState(DisplayState::DISPLAY_OFF); + int sleepTime = 2; + //Callback for waiting window 2s + sleep(sleepTime); DisplayState currentState = DisplayPowerMgrClient::GetInstance().GetDisplayState(); EXPECT_TRUE(currentState == DisplayState::DISPLAY_OFF); @@ -415,6 +425,9 @@ HWTEST_F(DisplayPowerMgrServiceTest, DisplayPowerMgrService024, TestSize.Level0) { DISPLAY_HILOGI(LABEL_TEST, "DisplayPowerMgrService024 is start"); bool ret = DisplayPowerMgrClient::GetInstance().SetDisplayState(DisplayState::DISPLAY_OFF); + int sleepTime = 2; + //Callback for waiting window 2s + sleep(sleepTime); DisplayState currentState = DisplayPowerMgrClient::GetInstance().GetDisplayState(); EXPECT_TRUE(currentState == DisplayState::DISPLAY_OFF); -- Gitee