5 #include "gtest/gtest.h"
16 TEST(UberSDFContentsTest, ApplyColorFilter) {
20 auto geometry = std::make_unique<UberSDFGeometry>(params);
32 TEST(UberSDFContentsTest, AsBackgroundColor) {
36 auto geometry = std::make_unique<UberSDFGeometry>(params);
42 EXPECT_EQ(contents->AsBackgroundColor(entity,
ISize(500, 500)),
Color::Red());
44 auto small_bg_color = contents->AsBackgroundColor(entity,
ISize(400, 400));
45 EXPECT_TRUE(small_bg_color.has_value());
46 if (small_bg_color.has_value()) {
47 EXPECT_EQ(small_bg_color.value(),
Color::Red());
50 auto huge_bg_color = contents->AsBackgroundColor(entity,
ISize(600, 600));
51 EXPECT_FALSE(huge_bg_color.has_value());
54 TEST(UberSDFContentsTest, AsBackgroundColorExactSize) {
58 auto geometry = std::make_unique<UberSDFGeometry>(params);
64 auto bg_color = contents->AsBackgroundColor(entity,
ISize(500, 500));
67 EXPECT_TRUE(bg_color.has_value());
68 if (bg_color.has_value()) {
73 TEST(UberSDFContentsTest, AsBackgroundColorNonRect) {
80 auto circle_geometry = std::make_unique<UberSDFGeometry>(circle_params);
81 auto circle_contents =
84 auto circle_bg_color =
85 circle_contents->AsBackgroundColor(entity,
ISize(500, 500));
86 EXPECT_FALSE(circle_bg_color.has_value());
89 TEST(UberSDFContentsTest, AsBackgroundColorStrokedRect) {
93 auto geometry = std::make_unique<UberSDFGeometry>(params);
99 auto bg_color = contents->AsBackgroundColor(entity,
ISize(500, 500));
100 EXPECT_FALSE(bg_color.has_value());
void SetTransform(const Matrix &transform)
Set the global transform matrix for this Entity.
static std::unique_ptr< UberSDFContents > Make(const UberSDFParameters ¶ms, std::unique_ptr< Geometry > geometry)
TEST(AllocationSizeTest, CanCreateTypedAllocations)
static constexpr Color Red()
static constexpr Color Blue()
A 4x4 matrix using column-major storage.
A structure to store all of the parameters related to stroking a path or basic geometry object.
constexpr static TRect MakeXYWH(Type x, Type y, Type width, Type height)
static UberSDFParameters MakeCircle(Color color, const Point ¢er, Scalar radius, std::optional< StrokeParameters > stroke)
Creates UberSDFParameters for a circle.
static UberSDFParameters MakeRect(Color color, const Rect &rect, std::optional< StrokeParameters > stroke)
Creates UberSDFParameters for a rectangle.