55#include < memory>
66#include " flutter/testing/testing.h"
77#include " gtest/gtest.h"
8+ #include " impeller/entity/contents/filters/color_filter_contents.h"
89#include " impeller/entity/contents/filters/inputs/filter_input.h"
910#include " impeller/entity/entity.h"
11+ #include " impeller/geometry/color.h"
1012#include " impeller/geometry/geometry_asserts.h"
1113
1214namespace impeller {
@@ -25,5 +27,41 @@ TEST(FilterInputTest, CanSetLocalTransformForTexture) {
2527 Matrix::MakeTranslation ({1.0 , 2.0 , 0.0 }));
2628}
2729
30+ TEST (FilterInputTest, IsLeaf) {
31+ std::shared_ptr<FilterContents> leaf =
32+ ColorFilterContents::MakeBlend (BlendMode::kSource , {});
33+ ASSERT_TRUE (leaf->IsLeaf ());
34+
35+ auto base = ColorFilterContents::MakeMatrixFilter (
36+ FilterInput::Make (leaf), Matrix (), {}, Matrix (), false );
37+
38+ ASSERT_TRUE (leaf->IsLeaf ());
39+ ASSERT_FALSE (base->IsLeaf ());
40+ }
41+
42+ TEST (FilterInputTest, SetCoverageInputs) {
43+ std::shared_ptr<FilterContents> leaf =
44+ ColorFilterContents::MakeBlend (BlendMode::kSource , {});
45+ ASSERT_TRUE (leaf->IsLeaf ());
46+
47+ auto base = ColorFilterContents::MakeMatrixFilter (
48+ FilterInput::Make (leaf), Matrix (), {}, Matrix (), false );
49+
50+ {
51+ auto result = base->GetCoverage ({});
52+ ASSERT_FALSE (result.has_value ());
53+ }
54+
55+ auto coverage_rect = Rect::MakeLTRB (100 , 100 , 200 , 200 );
56+ base->SetLeafInputs (FilterInput::Make ({coverage_rect}));
57+
58+ {
59+ auto result = base->GetCoverage ({});
60+ ASSERT_TRUE (result.has_value ());
61+ // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
62+ ASSERT_RECT_NEAR (result.value (), coverage_rect);
63+ }
64+ }
65+
2866} // namespace testing
2967} // namespace impeller
0 commit comments