From 1f7001dcfb36d4f6352194db3f46b82ba7a9625c Mon Sep 17 00:00:00 2001 From: yangziyong Date: Thu, 21 Oct 2021 18:37:42 +0800 Subject: [PATCH] Add test cases to check abnormal senarios Change-Id: I9bd5c141fd3cf694faccf7ee13fdd74183d451f1 Signed-off-by: Du Jiang --- .../src/display_power_mgr_service_test.cpp | 57 ++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/test/native/unittest/src/display_power_mgr_service_test.cpp b/test/native/unittest/src/display_power_mgr_service_test.cpp index fc0e17c..5da1fc4 100644 --- a/test/native/unittest/src/display_power_mgr_service_test.cpp +++ b/test/native/unittest/src/display_power_mgr_service_test.cpp @@ -136,4 +136,59 @@ HWTEST_F(DisplayPowerMgrServiceTest, DisplayPowerMgrService008, TestSize.Level0) EXPECT_TRUE(state == DisplayState::DISPLAY_SUSPEND); } #endif // IPC_AVAILABLE -} \ No newline at end of file +/** + * @tc.name: DisplayPowerMgrService009 + * @tc.desc: Test set screen state off + * @tc.type: FUNC + */ +HWTEST_F(DisplayPowerMgrServiceTest, DisplayPowerMgrService009, TestSize.Level0) +{ + DISPLAY_HILOGE(MODULE_SERVICE, "DisplayPowerMgrServiceTest::DisplayPowerMgrService009: fun is start"); + auto ret = DisplayPowerMgrClient::GetInstance().SetDisplayState(DisplayState::DISPLAY_UNKNOWN); + sleep(5); + EXPECT_TRUE(ret); + DISPLAY_HILOGE(MODULE_SERVICE, "DisplayPowerMgrServiceTest::DisplayPowerMgrService009: fun is end"); +} + +/** + * @tc.name: DisplayPowerMgrService010 + * @tc.desc: Test set brightness + * @tc.type: FUNC + */ +HWTEST_F(DisplayPowerMgrServiceTest, DisplayPowerMgrService010, TestSize.Level0) +{ + DISPLAY_HILOGE(MODULE_SERVICE, "DisplayPowerMgrServiceTest::DisplayPowerMgrService010: fun is start"); + auto ret = DisplayPowerMgrClient::GetInstance().SetBrightness(9999); + sleep(5); + EXPECT_FALSE(ret); + DISPLAY_HILOGE(MODULE_SERVICE, "DisplayPowerMgrServiceTest::DisplayPowerMgrService010: fun is end"); +} + +/** + * @tc.name: DisplayPowerMgrService011 + * @tc.desc: Test set screen state off + * @tc.type: FUNC + */ +HWTEST_F(DisplayPowerMgrServiceTest, DisplayPowerMgrService011, TestSize.Level0) +{ + DISPLAY_HILOGE(MODULE_SERVICE, "DisplayPowerMgrServiceTest::DisplayPowerMgrService011: fun is start"); + DisplayState state = DisplayPowerMgrClient::GetInstance().GetDisplayState(); + EXPECT_TRUE(state == DisplayState::DISPLAY_UNKNOWN); + DISPLAY_HILOGE(MODULE_SERVICE, "DisplayPowerMgrServiceTest::DisplayPowerMgrService011: fun is end"); +} + +/** + * @tc.name: DisplayPowerMgrService012 + * @tc.desc: Test DisplayPowerMgrService service ready. + * @tc.type: FUNC + */ +HWTEST_F(DisplayPowerMgrServiceTest, DisplayPowerMgrService012, TestSize.Level0) +{ + DISPLAY_HILOGE(MODULE_SERVICE, "DisplayPowerMgrServiceTest::DisplayPowerMgrService012: fun is start"); + sptr sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + EXPECT_TRUE(sam != nullptr) << "DisplayPowerMgrService01 fail to get GetSystemAbilityManager"; + sptr remoteObject_ = sam->CheckSystemAbility(DISPLAY_MANAGER_SERVICE_ID); + EXPECT_TRUE(remoteObject_ != nullptr) << "GetSystemAbility failed."; + DISPLAY_HILOGE(MODULE_SERVICE, "DisplayPowerMgrServiceTest::DisplayPowerMgrService012: fun is end"); +} +} -- Gitee