Commit 98f045a4 authored by Dana Fried's avatar Dana Fried Committed by Commit Bot

Add setters to gfx::Insets for completeness.

Analogous to similar methods in Point and Size.

These are used to simplify layout computation in a follow-up CL.

Change-Id: If509de376cd1395f1d85aa5abe1121662e94629c
Reviewed-on: https://chromium-review.googlesource.com/c/1351081
Commit-Queue: Dana Fried <dfried@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611363}
parent e1c8148f
......@@ -50,6 +50,11 @@ class GEOMETRY_EXPORT Insets {
// Returns true if the insets are empty.
bool IsEmpty() const { return width() == 0 && height() == 0; }
void set_top(int top) { top_ = top; }
void set_left(int left) { left_ = left; }
void set_bottom(int bottom) { bottom_ = bottom; }
void set_right(int right) { right_ = right; }
void Set(int top, int left, int bottom, int right) {
top_ = top;
left_ = left;
......
......@@ -31,6 +31,30 @@ TEST(InsetsTest, Insets) {
EXPECT_FALSE(insets.IsEmpty());
}
TEST(InsetsTest, SetTop) {
gfx::Insets insets(1);
insets.set_top(2);
EXPECT_EQ(gfx::Insets(2, 1, 1, 1), insets);
}
TEST(InsetsTest, SetBottom) {
gfx::Insets insets(1);
insets.set_bottom(2);
EXPECT_EQ(gfx::Insets(1, 1, 2, 1), insets);
}
TEST(InsetsTest, SetLeft) {
gfx::Insets insets(1);
insets.set_left(2);
EXPECT_EQ(gfx::Insets(1, 2, 1, 1), insets);
}
TEST(InsetsTest, SetRight) {
gfx::Insets insets(1);
insets.set_right(2);
EXPECT_EQ(gfx::Insets(1, 1, 1, 2), insets);
}
TEST(InsetsTest, Set) {
gfx::Insets insets;
insets.Set(1, 2, 3, 4);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment