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

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

Issue 2051343002: Make various gfx classes more amenable to use as compile-time constants. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delete destructor Created 4 years, 6 months 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
« no previous file with comments | « ui/gfx/geometry/insets_f.cc ('k') | ui/gfx/geometry/point.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/insets_unittest.cc
diff --git a/ui/gfx/geometry/insets_unittest.cc b/ui/gfx/geometry/insets_unittest.cc
index 0d334591def768f470ad07a36501caa61866d3e8..a57970fea7ae911a7eab4c04a6522f435c171688 100644
--- a/ui/gfx/geometry/insets_unittest.cc
+++ b/ui/gfx/geometry/insets_unittest.cc
@@ -5,6 +5,7 @@
#include "ui/gfx/geometry/insets.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/geometry/insets_f.h"
TEST(InsetsTest, InsetsDefault) {
gfx::Insets insets;
@@ -37,7 +38,7 @@ TEST(InsetsTest, Set) {
EXPECT_EQ(4, insets.right());
}
-TEST(InsetsTest, Add) {
+TEST(InsetsTest, Operators) {
gfx::Insets insets;
insets.Set(1, 2, 3, 4);
insets += gfx::Insets(5, 6, 7, 8);
@@ -45,6 +46,54 @@ TEST(InsetsTest, Add) {
EXPECT_EQ(8, insets.left());
EXPECT_EQ(10, insets.bottom());
EXPECT_EQ(12, insets.right());
+
+ insets -= gfx::Insets(-1, 0, 1, 2);
+ EXPECT_EQ(7, insets.top());
+ EXPECT_EQ(8, insets.left());
+ EXPECT_EQ(9, insets.bottom());
+ EXPECT_EQ(10, insets.right());
+
+ insets = gfx::Insets(10, 10, 10, 10) + gfx::Insets(5, 5, 0, -20);
+ EXPECT_EQ(15, insets.top());
+ EXPECT_EQ(15, insets.left());
+ EXPECT_EQ(10, insets.bottom());
+ EXPECT_EQ(-10, insets.right());
+
+ insets = gfx::Insets(10, 10, 10, 10) - gfx::Insets(5, 5, 0, -20);
+ EXPECT_EQ(5, insets.top());
+ EXPECT_EQ(5, insets.left());
+ EXPECT_EQ(10, insets.bottom());
+ EXPECT_EQ(30, insets.right());
+}
+
+TEST(InsetsFTest, Operators) {
+ gfx::InsetsF insets;
+ insets.Set(1.f, 2.5f, 3.3f, 4.1f);
+ insets += gfx::InsetsF(5.8f, 6.7f, 7.6f, 8.5f);
+ EXPECT_FLOAT_EQ(6.8f, insets.top());
+ EXPECT_FLOAT_EQ(9.2f, insets.left());
+ EXPECT_FLOAT_EQ(10.9f, insets.bottom());
+ EXPECT_FLOAT_EQ(12.6f, insets.right());
+
+ insets -= gfx::InsetsF(-1.f, 0, 1.1f, 2.2f);
+ EXPECT_FLOAT_EQ(7.8f, insets.top());
+ EXPECT_FLOAT_EQ(9.2f, insets.left());
+ EXPECT_FLOAT_EQ(9.8f, insets.bottom());
+ EXPECT_FLOAT_EQ(10.4f, insets.right());
+
+ insets = gfx::InsetsF(10, 10.1f, 10.01f, 10.001f) +
+ gfx::InsetsF(5.5f, 5.f, 0, -20.2f);
+ EXPECT_FLOAT_EQ(15.5f, insets.top());
+ EXPECT_FLOAT_EQ(15.1f, insets.left());
+ EXPECT_FLOAT_EQ(10.01f, insets.bottom());
+ EXPECT_FLOAT_EQ(-10.199f, insets.right());
+
+ insets = gfx::InsetsF(10, 10.1f, 10.01f, 10.001f) -
+ gfx::InsetsF(5.5f, 5.f, 0, -20.2f);
+ EXPECT_FLOAT_EQ(4.5f, insets.top());
+ EXPECT_FLOAT_EQ(5.1f, insets.left());
+ EXPECT_FLOAT_EQ(10.01f, insets.bottom());
+ EXPECT_FLOAT_EQ(30.201f, insets.right());
}
TEST(InsetsTest, Equality) {
« no previous file with comments | « ui/gfx/geometry/insets_f.cc ('k') | ui/gfx/geometry/point.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698