Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c9ee05b

Browse files
authored
use min/max sandwich test on unit test bounds (#38435)
1 parent 28f344c commit c9ee05b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

display_list/display_list_unittests.cc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,13 +1226,17 @@ TEST(DisplayList, FlutterSvgIssue661BoundsWereEmpty) {
12261226
sk_sp<DisplayList> display_list = builder.Build();
12271227
// Prior to the fix, the bounds were empty.
12281228
EXPECT_FALSE(display_list->bounds().isEmpty());
1229-
// These are the expected bounds, but testing float values can be
1230-
// flaky wrt minor changes in the bounds calculations. If this
1231-
// line has to be revised too often as the DL implementation is
1232-
// improved and maintained, then we can eliminate this test and
1233-
// just rely on the "rounded out" bounds test that follows.
1234-
EXPECT_EQ(display_list->bounds(),
1235-
SkRect::MakeLTRB(0, 0.00189208984375, 99.9839630127, 100));
1229+
// These are just inside and outside of the expected bounds, but
1230+
// testing float values can be flaky wrt minor changes in the bounds
1231+
// calculations. If these lines have to be revised too often as the DL
1232+
// implementation is improved and maintained, then we can eliminate
1233+
// this test and just rely on the "rounded out" bounds test that follows.
1234+
SkRect min_bounds = SkRect::MakeLTRB(0, 0.00191, 99.983, 100);
1235+
SkRect max_bounds = SkRect::MakeLTRB(0, 0.00189, 99.985, 100);
1236+
ASSERT_TRUE(max_bounds.contains(min_bounds));
1237+
EXPECT_TRUE(max_bounds.contains(display_list->bounds()));
1238+
EXPECT_TRUE(display_list->bounds().contains(min_bounds));
1239+
12361240
// This is the more practical result. The bounds are "almost" 0,0,100x100
12371241
EXPECT_EQ(display_list->bounds().roundOut(), SkIRect::MakeWH(100, 100));
12381242
EXPECT_EQ(display_list->op_count(), 19u);

0 commit comments

Comments
 (0)