Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Unified Diff: ui/gfx/geometry/insets_unittest.cc

Issue 2440723003: Tweaks to ToggleButton details. (Closed)
Patch Set: remove a little more Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gfx/geometry/insets_unittest.cc
diff --git a/ui/gfx/geometry/insets_unittest.cc b/ui/gfx/geometry/insets_unittest.cc
index a57970fea7ae911a7eab4c04a6522f435c171688..6f607d9173e82dbd36df901ec7667ddb6ad385d7 100644
--- a/ui/gfx/geometry/insets_unittest.cc
+++ b/ui/gfx/geometry/insets_unittest.cc
@@ -6,6 +6,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/insets_f.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/vector2d.h"
TEST(InsetsTest, InsetsDefault) {
gfx::Insets insets;
@@ -113,3 +115,25 @@ TEST(InsetsTest, ToString) {
gfx::Insets insets(1, 2, 3, 4);
EXPECT_EQ("1,2,3,4", insets.ToString());
}
+
+TEST(InsetsTest, Offset) {
+ const gfx::Insets insets(1, 2, 3, 4);
+ const gfx::Rect rect(5, 6, 7, 8);
+ const gfx::Vector2d vector(9, 10);
+
+ // Whether you inset then offset the rect, offset then inset the rect, or
+ // offset the insets then apply to the rect, the outcome should be the same.
+ gfx::Rect inset_first = rect;
+ inset_first.Inset(insets);
+ inset_first.Offset(vector);
+
+ gfx::Rect offset_first = rect;
+ offset_first.Offset(vector);
+ offset_first.Inset(insets);
+
+ gfx::Rect inset_by_offset = rect;
+ inset_by_offset.Inset(insets.Offset(vector));
+
+ EXPECT_EQ(inset_first, offset_first);
+ EXPECT_EQ(inset_by_offset, inset_first);
+}

Powered by Google App Engine
This is Rietveld 408576698