mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-12-21 14:20:46 +00:00
add ut for screen rotation
Signed-off-by: wangxinpeng <wangxinpeng4@huawei.com> Change-Id: Idcb59d5ce63499c038a0e883f520e4ed46b4d3d1
This commit is contained in:
parent
3e8630dfc4
commit
e1fc27b446
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user