Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test fixes
  • Loading branch information
flar committed Jul 3, 2024
commit 0139868b7d29fc5e76bc7adf56bfdc72d7795fe4
3 changes: 2 additions & 1 deletion impeller/display_list/dl_golden_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ TEST_P(DlGoldenTest, FastVsGeneralGaussianMaskBlur) {
DlColor::kMaroon(),
};

auto make_rrect_path = [](const SkRect& rect, DlScalar rx, DlScalar ry) {
auto make_rrect_path = [](const SkRect& rect, DlScalar rx,
DlScalar ry) -> SkPath {
auto add_corner = [](SkPath& path, SkPoint rCorner, SkPoint rEnd) {
static const auto magic = impeller::PathBuilder::kArcApproximationMagic;
path.rCubicTo(rCorner.fX * (1.0f - magic), rCorner.fY * (1.0f - magic),
Expand Down
27 changes: 26 additions & 1 deletion impeller/display_list/skia_conversions_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,33 @@ TEST(SkiaConversionsTest, IsNearlySimpleRRect) {
SkRRect::MakeRectXY(SkRect::MakeLTRB(0, 0, 10, 10), 10, 10)));
EXPECT_TRUE(skia_conversions::IsNearlySimpleRRect(
SkRRect::MakeRectXY(SkRect::MakeLTRB(0, 0, 10, 10), 10, 9.999)));
EXPECT_FALSE(skia_conversions::IsNearlySimpleRRect(
EXPECT_TRUE(skia_conversions::IsNearlySimpleRRect(
SkRRect::MakeRectXY(SkRect::MakeLTRB(0, 0, 10, 10), 10, 9)));
EXPECT_TRUE(skia_conversions::IsNearlySimpleRRect(
SkRRect::MakeRectXY(SkRect::MakeLTRB(0, 0, 10, 10), 10, 5)));
SkRect rect = SkRect::MakeLTRB(0, 0, 10, 10);
SkRRect rrect;
union {
SkPoint radii[4] = {
{10.0f, 9.0f},
{10.0f, 9.0f},
{10.0f, 9.0f},
{10.0f, 9.0f},
};
SkScalar values[8];
} test;
rrect.setRectRadii(rect, test.radii);
EXPECT_TRUE(skia_conversions::IsNearlySimpleRRect(rrect));
for (int i = 0; i < 8; i++) {
auto save = test.values[i];
test.values[i] -= kEhCloseEnough * 0.5f;
rrect.setRectRadii(rect, test.radii);
EXPECT_TRUE(skia_conversions::IsNearlySimpleRRect(rrect));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is in a loop the line number isn't sufficient to know where the failure happened. Can you also print out the radii?

something like:

Suggested change
EXPECT_TRUE(skia_conversions::IsNearlySimpleRRect(rrect));
EXPECT_TRUE(skia_conversions::IsNearlySimpleRRect(rrect)) << "radii: " << test.radii;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it will print the array but I can print the index and the substituted value...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the array just prints out the address, but I can do this (temporarily sabotaging the test to get error output):

../../flutter/impeller/display_list/skia_conversions_unittests.cc:204: Failure
Value of: skia_conversions::IsNearlySimpleRRect(rrect)
  Actual: true
Expected: false
values[7] == 8.9995002746582031

../../flutter/impeller/display_list/skia_conversions_unittests.cc:208: Failure
Value of: skia_conversions::IsNearlySimpleRRect(rrect)
  Actual: false
Expected: true
values[7] == 8.9975004196166992

test.values[i] -= kEhCloseEnough * 2.0f;
rrect.setRectRadii(rect, test.radii);
EXPECT_FALSE(skia_conversions::IsNearlySimpleRRect(rrect));
test.values[i] = save;
}
}

} // namespace testing
Expand Down
3 changes: 3 additions & 0 deletions testing/impeller_golden_tests_output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,9 @@ impeller_Play_DlGoldenTest_CanRenderImage_Vulkan.png
impeller_Play_DlGoldenTest_DashedLinesTest_Metal.png
impeller_Play_DlGoldenTest_DashedLinesTest_OpenGLES.png
impeller_Play_DlGoldenTest_DashedLinesTest_Vulkan.png
impeller_Play_DlGoldenTest_FastVsGeneralGaussianMaskBlur_Metal.png
impeller_Play_DlGoldenTest_FastVsGeneralGaussianMaskBlur_OpenGLES.png
impeller_Play_DlGoldenTest_FastVsGeneralGaussianMaskBlur_Vulkan.png
impeller_Play_DlGoldenTest_GaussianVsRRectBlurScaledRotated_Metal.png
impeller_Play_DlGoldenTest_GaussianVsRRectBlurScaledRotated_OpenGLES.png
impeller_Play_DlGoldenTest_GaussianVsRRectBlurScaledRotated_Vulkan.png
Expand Down