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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/geometry/insets.h" 5 #include "ui/gfx/geometry/insets.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/gfx/geometry/insets_f.h" 8 #include "ui/gfx/geometry/insets_f.h"
9 #include "ui/gfx/geometry/rect.h"
10 #include "ui/gfx/geometry/vector2d.h"
9 11
10 TEST(InsetsTest, InsetsDefault) { 12 TEST(InsetsTest, InsetsDefault) {
11 gfx::Insets insets; 13 gfx::Insets insets;
12 EXPECT_EQ(0, insets.top()); 14 EXPECT_EQ(0, insets.top());
13 EXPECT_EQ(0, insets.left()); 15 EXPECT_EQ(0, insets.left());
14 EXPECT_EQ(0, insets.bottom()); 16 EXPECT_EQ(0, insets.bottom());
15 EXPECT_EQ(0, insets.right()); 17 EXPECT_EQ(0, insets.right());
16 EXPECT_EQ(0, insets.width()); 18 EXPECT_EQ(0, insets.width());
17 EXPECT_EQ(0, insets.height()); 19 EXPECT_EQ(0, insets.height());
18 EXPECT_TRUE(insets.IsEmpty()); 20 EXPECT_TRUE(insets.IsEmpty());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 108
107 insets2.Set(1, 2, 3, 4); 109 insets2.Set(1, 2, 3, 4);
108 EXPECT_TRUE(insets1 == insets2); 110 EXPECT_TRUE(insets1 == insets2);
109 EXPECT_FALSE(insets1 != insets2); 111 EXPECT_FALSE(insets1 != insets2);
110 } 112 }
111 113
112 TEST(InsetsTest, ToString) { 114 TEST(InsetsTest, ToString) {
113 gfx::Insets insets(1, 2, 3, 4); 115 gfx::Insets insets(1, 2, 3, 4);
114 EXPECT_EQ("1,2,3,4", insets.ToString()); 116 EXPECT_EQ("1,2,3,4", insets.ToString());
115 } 117 }
118
119 TEST(InsetsTest, Offset) {
120 const gfx::Insets insets(1, 2, 3, 4);
121 const gfx::Rect rect(5, 6, 7, 8);
122 const gfx::Vector2d vector(9, 10);
123
124 // Whether you inset then offset the rect, offset then inset the rect, or
125 // offset the insets then apply to the rect, the outcome should be the same.
126 gfx::Rect inset_first = rect;
127 inset_first.Inset(insets);
128 inset_first.Offset(vector);
129
130 gfx::Rect offset_first = rect;
131 offset_first.Offset(vector);
132 offset_first.Inset(insets);
133
134 gfx::Rect inset_by_offset = rect;
135 inset_by_offset.Inset(insets.Offset(vector));
136
137 EXPECT_EQ(inset_first, offset_first);
138 EXPECT_EQ(inset_by_offset, inset_first);
139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698