Signed-off-by: 王德海 <wangdehai2@huawei.com>
Change-Id: Ie562dfb5cc294d856a253a2b532bbca1385dc84f
This commit is contained in:
王德海 2024-09-26 14:47:25 +08:00
parent 71f8844804
commit 9e49b67d5c
7 changed files with 35 additions and 2 deletions

View File

@ -68,6 +68,12 @@ group("test") {
## Build RSGraphicTest
ohos_unittest("RSGraphicTest") {
sanitize = {
cfi = true
cfi_cross_dso = true
debug = false
}
module_out_path = module_output_path
sources = []
sources += drawing_engine_sources

View File

@ -178,6 +178,7 @@ HWTEST_F(RSPaintFilterCanvasTest, SetHighContrastTest001, TestSize.Level1)
HWTEST_F(RSPaintFilterCanvasTest, RestoreAlphaTest001, TestSize.Level1)
{
paintFilterCanvas_->RestoreAlpha();
ASSERT_EQ(paintFilterCanvas_->GetAlphaSaveCount(), 1);
}
/**
@ -202,6 +203,7 @@ HWTEST_F(RSPaintFilterCanvasTest, RestoreAlphaToCountTest, TestSize.Level1)
HWTEST_F(RSPaintFilterCanvasTest, RestoreEnvTest, TestSize.Level1)
{
paintFilterCanvas_->RestoreEnv();
ASSERT_EQ(paintFilterCanvas_->GetAlphaSaveCount(), 1);
}
/**
@ -227,6 +229,7 @@ HWTEST_F(RSPaintFilterCanvasTest, SetEnvForegroundColorTest, TestSize.Level1)
{
Color color;
paintFilterCanvas_->SetEnvForegroundColor(color);
ASSERT_EQ(paintFilterCanvas_->GetEnvForegroundColor(), 0);
}
/**
@ -240,6 +243,7 @@ HWTEST_F(RSPaintFilterCanvasTest, GetEnvForegroundColorTest, TestSize.Level1)
Color color { SET_COLOR };
Color setColor {};
paintFilterCanvas_->SetEnvForegroundColor(setColor);
ASSERT_EQ(paintFilterCanvas_->GetEnvForegroundColor(), 0);
}
/**

View File

@ -173,6 +173,7 @@ HWTEST_F(RSPointLightManagerTest, PrepareLight001, TestSize.Level1)
instance->AddDirtyLightSource(node.weak_from_this());
instance->PrepareLight();
EXPECT_TRUE(!instance->illuminatedNodeMap_.empty());
}
/**
@ -389,18 +390,28 @@ HWTEST_F(RSPointLightManagerTest, CalculateLightPosForIlluminated001, TestSize.L
instance->SetScreenRotation(ScreenRotation::ROTATION_0);
auto pos = instance->CalculateLightPosForIlluminated(*lightSourcePtr, illuminatedGeoPtr->GetAbsRect());
EXPECT_EQ(pos.x_, 20);
EXPECT_EQ(pos.y_, 20);
instance->SetScreenRotation(ScreenRotation::ROTATION_90);
pos = instance->CalculateLightPosForIlluminated(*lightSourcePtr, illuminatedGeoPtr->GetAbsRect());
EXPECT_EQ(pos.x_, -20);
EXPECT_EQ(pos.y_, 20);
instance->SetScreenRotation(ScreenRotation::ROTATION_180);
pos = instance->CalculateLightPosForIlluminated(*lightSourcePtr, illuminatedGeoPtr->GetAbsRect());
EXPECT_EQ(pos.x_, -20);
EXPECT_EQ(pos.y_, -20);
instance->SetScreenRotation(ScreenRotation::ROTATION_270);
pos = instance->CalculateLightPosForIlluminated(*lightSourcePtr, illuminatedGeoPtr->GetAbsRect());
EXPECT_EQ(pos.x_, 20);
EXPECT_EQ(pos.y_, -20);
instance->SetScreenRotation(ScreenRotation::INVALID_SCREEN_ROTATION);
pos = instance->CalculateLightPosForIlluminated(*lightSourcePtr, illuminatedGeoPtr->GetAbsRect());
EXPECT_EQ(pos.x_, 0);
EXPECT_EQ(pos.y_, 0);
}
} // namespace Rosen
} // namespace OHOS

View File

@ -47,6 +47,7 @@ HWTEST_F(RSPropertyTraceTest, PropertiesDisplayByTrace001, TestSize.Level1)
auto boundsGeometry = std::make_shared<RSObjAbsGeometry>();
const NodeId id = 1;
RSPropertyTrace::GetInstance().PropertiesDisplayByTrace(id, boundsGeometry);
EXPECT_NE(RSPropertyTrace::GetInstance().IsNeedRefreshConfig(), true);
}
/**
@ -58,6 +59,7 @@ HWTEST_F(RSPropertyTraceTest, PropertiesDisplayByTrace001, TestSize.Level1)
HWTEST_F(RSPropertyTraceTest, RefreshNodeTraceInfo001, TestSize.Level1)
{
RSPropertyTrace::GetInstance().RefreshNodeTraceInfo();
EXPECT_NE(RSPropertyTrace::GetInstance().IsNeedRefreshConfig(), true);
}
/**
@ -191,7 +193,12 @@ HWTEST_F(RSPropertyTraceTest, IsNeedPropertyTrace002, TestSize.Level1)
HWTEST_F(RSPropertyTraceTest, AddTraceFlag001, TestSize.Level1)
{
std::string flag = "flag";
std::string nodeName = "node";
std::string info = "NODE_NAME:";
RSPropertyTrace::GetInstance().AddTraceFlag(flag);
RSPropertyTrace::GetInstance().DealNodeNameConfig(info);
bool res = RSPropertyTrace::GetInstance().IsNeedPropertyTrace(nodeName);
EXPECT_EQ(res, true);
}
/**
@ -203,6 +210,7 @@ HWTEST_F(RSPropertyTraceTest, AddTraceFlag001, TestSize.Level1)
HWTEST_F(RSPropertyTraceTest, ClearNodeAndPropertyInfo001, TestSize.Level1)
{
RSPropertyTrace::GetInstance().ClearNodeAndPropertyInfo();
EXPECT_TRUE(RSPropertyTrace::GetInstance().nodeIdSet_.empty());
}
} // namespace Rosen
} // namespace OHOS

View File

@ -36,6 +36,7 @@ HWTEST_F(RSExtNodeOperationTest, GetInstance001, TestSize.Level1)
{
auto& rs = RSExtNodeOperation::GetInstance();
(void)(rs);
ASSERT_FALSE(RSExtNodeOperation::GetInstance().CheckNeedToProcess("test"));
}
/**
@ -57,5 +58,6 @@ HWTEST_F(RSExtNodeOperationTest, CheckNeedToProcess001, TestSize.Level1)
HWTEST_F(RSExtNodeOperationTest, ProcessRSSurfaceNode001, TestSize.Level1)
{
RSExtNodeOperation::GetInstance().ProcessRSExtNode("test_id", 0x5555, 1.0f, 1.0f, nullptr);
ASSERT_FALSE(RSExtNodeOperation::GetInstance().CheckNeedToProcess("test_id"));
}
} // namespace OHOS::Rosen

View File

@ -51,7 +51,7 @@ HWTEST_F(RSFrameRatePolicyTest, interface, TestSize.Level1)
std::string scene = "0";
float speed = 1.0;
instance->GetPreferredFps(scene, speed);
EXPECT_EQ(instance->GetPreferredFps(scene, speed), 0);
}
/**
@ -65,7 +65,7 @@ HWTEST_F(RSFrameRatePolicyTest, GetRefreshRateMode_Test, TestSize.Level1)
instance->RegisterHgmConfigChangeCallback();
instance->GetRefreshRateModeName();
EXPECT_EQ(instance->GetRefreshRateModeName(), -1);
}
/**

View File

@ -36,6 +36,7 @@ HWTEST_F(RSUIShareContextTest, GetInstance001, TestSize.Level1)
{
auto& rs = RSUIShareContext::GetInstance();
(void)(rs);
ASSERT_FALSE(RSUIShareContext::GetInstance().GetRsRenderContext() == nullptr);
}
/**
@ -47,5 +48,6 @@ HWTEST_F(RSUIShareContextTest, GetRsRenderContext001, TestSize.Level1)
{
auto context = RSUIShareContext::GetInstance().GetRsRenderContext();
(void)(context);
ASSERT_FALSE(context == nullptr);
}
} // namespace OHOS::Rosen