7#include "gtest/gtest.h"
13TEST(InsetsTest, InsetsDefault) {
15 EXPECT_EQ(0, insets.
top());
16 EXPECT_EQ(0, insets.
left());
17 EXPECT_EQ(0, insets.
bottom());
18 EXPECT_EQ(0, insets.
right());
19 EXPECT_EQ(0, insets.
width());
20 EXPECT_EQ(0, insets.
height());
26 EXPECT_EQ(1, insets.
top());
27 EXPECT_EQ(2, insets.
left());
28 EXPECT_EQ(3, insets.
bottom());
29 EXPECT_EQ(4, insets.
right());
30 EXPECT_EQ(6, insets.
width());
31 EXPECT_EQ(4, insets.
height());
41TEST(InsetsTest, SetBottom) {
53TEST(InsetsTest, SetRight) {
61 insets.
Set(1, 2, 3, 4);
62 EXPECT_EQ(1, insets.
top());
63 EXPECT_EQ(2, insets.
left());
64 EXPECT_EQ(3, insets.
bottom());
65 EXPECT_EQ(4, insets.
right());
68TEST(InsetsTest, Operators) {
70 insets.
Set(1, 2, 3, 4);
72 EXPECT_EQ(6, insets.
top());
73 EXPECT_EQ(8, insets.
left());
74 EXPECT_EQ(10, insets.
bottom());
75 EXPECT_EQ(12, insets.
right());
78 EXPECT_EQ(7, insets.
top());
79 EXPECT_EQ(8, insets.
left());
80 EXPECT_EQ(9, insets.
bottom());
81 EXPECT_EQ(10, insets.
right());
84 EXPECT_EQ(15, insets.
top());
85 EXPECT_EQ(15, insets.
left());
86 EXPECT_EQ(10, insets.
bottom());
87 EXPECT_EQ(-10, insets.
right());
90 EXPECT_EQ(5, insets.
top());
91 EXPECT_EQ(5, insets.
left());
92 EXPECT_EQ(10, insets.
bottom());
93 EXPECT_EQ(30, insets.
right());
96TEST(InsetsFTest, Operators) {
98 insets.
Set(1.f, 2.5f, 3.3f, 4.1f);
100 EXPECT_FLOAT_EQ(6.8f, insets.
top());
101 EXPECT_FLOAT_EQ(9.2f, insets.
left());
102 EXPECT_FLOAT_EQ(10.9f, insets.
bottom());
103 EXPECT_FLOAT_EQ(12.6f, insets.
right());
106 EXPECT_FLOAT_EQ(7.8f, insets.
top());
107 EXPECT_FLOAT_EQ(9.2f, insets.
left());
108 EXPECT_FLOAT_EQ(9.8f, insets.
bottom());
109 EXPECT_FLOAT_EQ(10.4f, insets.
right());
113 EXPECT_FLOAT_EQ(15.5f, insets.
top());
114 EXPECT_FLOAT_EQ(15.1f, insets.
left());
115 EXPECT_FLOAT_EQ(10.01f, insets.
bottom());
116 EXPECT_FLOAT_EQ(-10.199f, insets.
right());
120 EXPECT_FLOAT_EQ(4.5f, insets.
top());
121 EXPECT_FLOAT_EQ(5.1f, insets.
left());
122 EXPECT_FLOAT_EQ(10.01f, insets.
bottom());
123 EXPECT_FLOAT_EQ(30.201f, insets.
right());
128 insets1.
Set(1, 2, 3, 4);
131 EXPECT_FALSE(insets1 == insets2);
134 insets2.
Set(1, 2, 3, 4);
136 EXPECT_FALSE(insets1 != insets2);
141 EXPECT_EQ(
"1,2,3,4", insets.
ToString());
152 inset_first.
Inset(insets);
153 inset_first.
Offset(vector);
156 offset_first.
Offset(vector);
157 offset_first.
Inset(insets);
162 EXPECT_EQ(inset_first, offset_first);
163 EXPECT_EQ(inset_by_offset, inset_first);
176TEST(InsetsTest, IntegerOverflow) {
181 EXPECT_EQ(int_max, width_height_test.
width());
182 EXPECT_EQ(int_max, width_height_test.
height());
192 scale_test = scale_test.
Scale(2.f, 2.f);
196TEST(InsetsTest, IntegerUnderflow) {
201 EXPECT_EQ(int_min, width_height_test.
width());
202 EXPECT_EQ(int_min, width_height_test.
height());
209 scale_test = scale_test.
Scale(2.f, 2.f);
213TEST(InsetsTest, IntegerOverflowSetVariants) {
218 EXPECT_EQ(int_max, set_test.
top());
219 EXPECT_EQ(0, set_test.
bottom());
222 EXPECT_EQ(int_max, set_test.
left());
223 EXPECT_EQ(0, set_test.
right());
227 EXPECT_EQ(int_max - 30, set_test.
bottom());
228 EXPECT_EQ(30, set_test.
top());
231 EXPECT_EQ(int_max - 30, set_test.
right());
232 EXPECT_EQ(30, set_test.
left());
235TEST(InsetsTest, IntegerUnderflowSetVariants) {
240 EXPECT_EQ(int_min, set_test.
top());
241 EXPECT_EQ(0, set_test.
bottom());
244 EXPECT_EQ(int_min, set_test.
left());
245 EXPECT_EQ(0, set_test.
right());
249 EXPECT_EQ(int_min + 30, set_test.
bottom());
250 EXPECT_EQ(-30, set_test.
top());
253 EXPECT_EQ(int_min + 30, set_test.
right());
254 EXPECT_EQ(-30, set_test.
left());
257TEST(InsetsTest, IntegerOverflowSet) {
261 set_all_test.
Set(10, 20, int_max, int_max);
262 EXPECT_EQ(
gfx::Insets(10, 20, int_max - 10, int_max - 20), set_all_test);
265TEST(InsetsTest, IntegerOverflowOffset) {
271 EXPECT_EQ(
gfx::Insets(int_max, int_max, 3 - int_max, 4 - int_max),
275TEST(InsetsTest, IntegerUnderflowOffset) {
281 EXPECT_EQ(
gfx::Insets(int_min, int_min, -10 - int_min, -10 - int_min),
constexpr float left() const
constexpr float bottom() const
constexpr float top() const
void Set(float top, float left, float bottom, float right)
constexpr float right() const
void Set(int top, int left, int bottom, int right)
constexpr int width() const
constexpr int right() const
void set_right(int right)
constexpr int bottom() const
Insets Scale(float scale) const
std::string ToString() const
constexpr Size size() const
void set_bottom(int bottom)
constexpr int top() const
constexpr int height() const
constexpr int left() const
Insets Offset(const gfx::Vector2d &vector) const
void Offset(int horizontal, int vertical)
void Inset(int horizontal, int vertical)
static float max(float r, float g, float b)
static float min(float r, float g, float b)
TEST(InsetsTest, InsetsDefault)
sk_sp< SkBlender > blender SkRect rect
static std::string ToString(CompilerBackend::Type type)
#define EXPECT_TRUE(handle)