提高分支覆盖率

Signed-off-by: cxy20001123 <chenxingyu34@h-partners.com>
This commit is contained in:
cxy20001123 2024-07-04 09:53:50 +00:00
parent 361c688879
commit 0bc3169108
4 changed files with 57 additions and 3 deletions

View File

@ -39,6 +39,7 @@ public:
sptr<AbstractDisplay> absDisplay;
sptr<AbstractDisplay> absDisplay2;
sptr<AbstractDisplay> absDisplay3;
sptr<AbstractDisplay> absDisplay4;
};
void AbstractDisplayTest::SetUpTestCase()
@ -64,6 +65,9 @@ void AbstractDisplayTest::SetUp()
modesInfo.width_ = 2560;
modesInfo.height_ = 2560;
absDisplay3 = new AbstractDisplay(id, info, absScreen);
modesInfo.width_ = 2560;
modesInfo.height_ = 1600;
absDisplay4 = new AbstractDisplay(id, info, absScreen);
}
void AbstractDisplayTest::TearDown()

View File

@ -537,6 +537,43 @@ HWTEST_F(ScreenSceneConfigTest, GetExternalScreenDefaultMode02, Function | Small
ASSERT_EQ("", res);
}
/**
* @tc.name: GetCurvedCompressionAreaInLandscape01
* @tc.desc: GetCurvedCompressionAreaInLandscape
* @tc.type: FUNC
*/
HWTEST_F(ScreenSceneConfigTest, GetCurvedCompressionAreaInLandscape01, Function | SmallTest | Level3)
{
ScreenSceneConfig::isWaterfallDisplay_ = false;
ScreenSceneConfig::isScreenCompressionEnableInLandscape_ = false;
auto result = ScreenSceneConfig:GetCurvedCompressionAreaInLandscape();
ASSERT_FALSE(result == 0);
}
/**
* @tc.name: GetCurvedCompressionAreaInLandscape02
* @tc.desc: GetCurvedCompressionAreaInLandscape
* @tc.type: FUNC
*/
HWTEST_F(ScreenSceneConfigTest, GetCurvedCompressionAreaInLandscape02, Function | SmallTest | Level3)
{
ScreenSceneConfig::isWaterfallDisplay_ = true;
ScreenSceneConfig::isScreenCompressionEnableInLandscape_ = false;
auto result = ScreenSceneConfig:GetCurvedCompressionAreaInLandscape();
ASSERT_FALSE(result == 0);
}
/**
* @tc.name: ReadStringListConfigInfo
* @tc.desc: ReadStringListConfigInfo
* @tc.type: FUNC
*/
HWTEST_F(ScreenSceneConfigTest, ReadStringListConfigInfo, Function | SmallTest | Level3)
{
xmlNodePtr rootNode = nullptr;
ScreenSceneConfig::ReadStringListConfigInfo(nullptr, "");
EXPECT_EQ(rootNode, nullptr);
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -152,8 +152,7 @@ HWTEST_F(ScreenSnapshotPickerConnectionTest, GetScreenSnapshotInfo01, Function |
Media::Rect rect{};
ScreenId screenId = SCREEN_ID_INVALID;
ScreenSnapshotPickerConnection::GetInstance().GetScreenSnapshotInfo(rect, screenId);
EXPECT_NE(rect.width, 0);
EXPECT_NE(rect.height, 0);
EXPECT_EQ(rect.height, 0);
}
/**
@ -167,7 +166,6 @@ HWTEST_F(ScreenSnapshotPickerConnectionTest, GetScreenSnapshotInfo02, Function |
Media::Rect rect{};
ScreenId screenId;
ScreenSnapshotPickerConnection::GetInstance().GetScreenSnapshotInfo(rect, screenId);
EXPECT_EQ(rect.width, 0);
EXPECT_EQ(rect.height, 0);
}

View File

@ -125,6 +125,21 @@ HWTEST_F(SessionDisplayPowerControllerTest, SuspendBegin, Function | SmallTest |
EXPECT_TRUE(controller.SuspendBegin(reason));
}
/**
* @tc.name: WaitScreenOffNotify
* @tc.desc: WaitScreenOffNotify func
* @tc.type: FUNC
*/
HWTEST_F(SessionDisplayPowerControllerTest, WaitScreenOffNotify, Function | SmallTest | Level1)
{
DisplayState state = DisplayState::ON_SUSPEND;
SessionDisplayPowerController controller(mutex_, [](DisplayId id, sptr<DisplayInfo> info, const std::map<DisplayId,
sptr<DisplayInfo>>& infos, DisplayStateChangeType type) {
EXPECT_TRUE(true);
});
EXPECT_EQ(state, DisplayState::ON_SUSPEND);
}
}
} // namespace Rosen
} // namespace OHOS