add ut for screen rotation

Signed-off-by: wangxinpeng <wangxinpeng4@huawei.com>
Change-Id: Idcb59d5ce63499c038a0e883f520e4ed46b4d3d1
This commit is contained in:
wangxinpeng 2022-02-14 18:52:26 +08:00
parent 3e8630dfc4
commit e1fc27b446
2 changed files with 98 additions and 3 deletions

View File

@ -222,19 +222,19 @@ void RSHardwareProcessor::OnRotate()
switch (rotation_) {
case ScreenRotation::ROTATION_90: {
ROSEN_LOGI("RsDebug RSHardwareProcessor::OnRotate 90.");
layer->SetLayerSize({width - rect.y - rect.h, rect.x, rect.h, rect.w});
layer->SetLayerSize({ width - rect.y - rect.h, rect.x, rect.h, rect.w });
layer->SetTransform(TransformType::ROTATE_90);
break;
}
case ScreenRotation::ROTATION_180: {
ROSEN_LOGI("RsDebug RSHardwareProcessor::OnRotate 180.");
layer->SetLayerSize({width - rect.x - rect.w, height - rect.y - rect.h, rect.w, rect.h});
layer->SetLayerSize({ width - rect.x - rect.w, height - rect.y - rect.h, rect.w, rect.h });
layer->SetTransform(TransformType::ROTATE_180);
break;
}
case ScreenRotation::ROTATION_270: {
ROSEN_LOGI("RsDebug RSHardwareProcessor::OnRotate 270.");
layer->SetLayerSize({rect.y, height - rect.x - rect.w, rect.h, rect.w});
layer->SetLayerSize({ rect.y, height - rect.x - rect.w, rect.h, rect.w });
layer->SetTransform(TransformType::ROTATE_270);
break;
}

View File

@ -627,5 +627,100 @@ HWTEST_F(RSInterfacesTest, SetScreenChangeCallback, Function | SmallTest | Level
EXPECT_EQ(screenEvent, ScreenEvent::UNKNOWN);
}
}
/*
* Function: RequestRotation
* Type: Function
* Rank: Important(2)
* EnvConditions: N/A
* CaseDescription: 1. call RequestRotation with default screenId
* 2. check ret
*/
HWTEST_F(RSInterfacesTest, RequestRotation001, Function | SmallTest | Level2)
{
auto screenId = rsInterfaces->GetDefaultScreenId();
EXPECT_NE(screenId, INVALID_SCREEN_ID);
bool res = rsInterfaces->RequestRotation(screenId, ScreenRotation::ROTATION_90);
ASSERT_EQ(res, true);
res = rsInterfaces->RequestRotation(screenId, ScreenRotation::ROTATION_180);
ASSERT_EQ(res, true);
res = rsInterfaces->RequestRotation(screenId, ScreenRotation::ROTATION_270);
ASSERT_EQ(res, true);
res = rsInterfaces->RequestRotation(screenId, ScreenRotation::ROTATION_0);
ASSERT_EQ(res, true);
}
/*
* Function: RequestRotation
* Type: Function
* Rank: Important(2)
* EnvConditions: N/A
* CaseDescription: 1. call RequestRotation with invalid screenId
* 2. check ret
*/
HWTEST_F(RSInterfacesTest, RequestRotation002, Function | SmallTest | Level2)
{
ScreenId screenId = INVALID_SCREEN_ID;
bool res = rsInterfaces->RequestRotation(screenId, ScreenRotation::ROTATION_90);
ASSERT_EQ(res, false);
}
/*
* Function: GetRotation
* Type: Function
* Rank: Important(2)
* EnvConditions: N/A
* CaseDescription: 1. call GetRotation with default screenId
* 2. check ret
*/
HWTEST_F(RSInterfacesTest, GetRotation001, Function | SmallTest | Level2)
{
auto screenId = rsInterfaces->GetDefaultScreenId();
EXPECT_NE(screenId, INVALID_SCREEN_ID);
ScreenRotation rotation = rsInterfaces->GetRotation(screenId);
ASSERT_EQ(rotation, ScreenRotation::ROTATION_0);
}
/*
* Function: GetRotation
* Type: Function
* Rank: Important(2)
* EnvConditions: N/A
* CaseDescription: 1. call GetRotation with default screenId
* 2. check ret
*/
HWTEST_F(RSInterfacesTest, GetRotation002, Function | SmallTest | Level2)
{
auto screenId = rsInterfaces->GetDefaultScreenId();
EXPECT_NE(screenId, INVALID_SCREEN_ID);
bool res = rsInterfaces->RequestRotation(screenId, ScreenRotation::ROTATION_90);
ASSERT_EQ(res, true);
ScreenRotation rotation = rsInterfaces->GetRotation(screenId);
ASSERT_EQ(rotation, ScreenRotation::ROTATION_90);
}
/*
* Function: GetRotation
* Type: Function
* Rank: Important(2)
* EnvConditions: N/A
* CaseDescription: 1. call GetRotation with invalid screenId
* 2. check ret
*/
HWTEST_F(RSInterfacesTest, GetRotation003, Function | SmallTest | Level2)
{
ScreenId screenId = INVALID_SCREEN_ID;
ScreenRotation rotation = rsInterfaces->GetRotation(screenId);
ASSERT_EQ(rotation, ScreenRotation::INVALID_SCREEN_ROTATION);
}
} // namespace Rosen
} // namespace OHOS