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

Commit b11a61d

Browse files
committed
Add tests
1 parent e00247f commit b11a61d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

impeller/aiks/aiks_unittests.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
#include "impeller/aiks/paint_pass_delegate.h"
1919
#include "impeller/aiks/testing/context_spy.h"
2020
#include "impeller/entity/contents/color_source_contents.h"
21+
#include "impeller/entity/contents/conical_gradient_contents.h"
2122
#include "impeller/entity/contents/filters/inputs/filter_input.h"
23+
#include "impeller/entity/contents/linear_gradient_contents.h"
2224
#include "impeller/entity/contents/scene_contents.h"
2325
#include "impeller/entity/contents/solid_color_contents.h"
2426
#include "impeller/entity/contents/tiled_texture_contents.h"
@@ -2851,5 +2853,35 @@ TEST_P(AiksTest, CanCanvasDrawPicture) {
28512853
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
28522854
}
28532855

2856+
TEST_P(AiksTest, SolidColorApplyColorFilter) {
2857+
auto contents = SolidColorContents();
2858+
contents.SetColor(Color::CornflowerBlue().WithAlpha(0.75));
2859+
auto result = contents.ApplyColorFilter([](const Color& color) {
2860+
return color.Blend(Color::LimeGreen().WithAlpha(0.75), BlendMode::kScreen);
2861+
});
2862+
ASSERT_TRUE(result);
2863+
ASSERT_COLOR_NEAR(contents.GetColor(),
2864+
Color(0.433247, 0.879523, 0.825324, 0.75));
2865+
}
2866+
2867+
#define APPLY_COLOR_FILTER_GRADIENT_TEST(name) \
2868+
TEST_P(AiksTest, name##GradientApplyColorFilter) { \
2869+
auto contents = name##GradientContents(); \
2870+
contents.SetColors({Color::CornflowerBlue().WithAlpha(0.75)}); \
2871+
auto result = contents.ApplyColorFilter([](const Color& color) { \
2872+
return color.Blend(Color::LimeGreen().WithAlpha(0.75), \
2873+
BlendMode::kScreen); \
2874+
}); \
2875+
ASSERT_TRUE(result); \
2876+
\
2877+
std::vector<Color> expected = {Color(0.433247, 0.879523, 0.825324, 0.75)}; \
2878+
ASSERT_COLORS_NEAR(contents.GetColors(), expected); \
2879+
}
2880+
2881+
APPLY_COLOR_FILTER_GRADIENT_TEST(Linear);
2882+
APPLY_COLOR_FILTER_GRADIENT_TEST(Radial);
2883+
APPLY_COLOR_FILTER_GRADIENT_TEST(Conical);
2884+
APPLY_COLOR_FILTER_GRADIENT_TEST(Sweep);
2885+
28542886
} // namespace testing
28552887
} // namespace impeller

0 commit comments

Comments
 (0)