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

Side by Side Diff: ui/gfx/geometry/size_unittest.cc

Issue 1357423009: gfx: Make conversions from Size to SizeF be explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sizefconvert-gfx: . Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « ui/gfx/geometry/size_f.h ('k') | ui/gfx/image/image_skia.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "ui/gfx/geometry/size.h" 6 #include "ui/gfx/geometry/size.h"
7 #include "ui/gfx/geometry/size_conversions.h" 7 #include "ui/gfx/geometry/size_conversions.h"
8 #include "ui/gfx/geometry/size_f.h" 8 #include "ui/gfx/geometry/size_f.h"
9 9
10 namespace gfx { 10 namespace gfx {
11 11
12 namespace { 12 namespace {
13 13
14 int TestSizeF(const SizeF& s) { 14 int TestSizeF(const SizeF& s) {
15 return s.width(); 15 return s.width();
16 } 16 }
17 17
18 } // namespace 18 } // namespace
19 19
20 TEST(SizeTest, ToSizeF) { 20 TEST(SizeTest, ToSizeF) {
21 // Check that implicit conversion from integer to float compiles. 21 // Check that explicit conversion from integer to float compiles.
22 Size a(10, 20); 22 Size a(10, 20);
23 float width = TestSizeF(a); 23 float width = TestSizeF(gfx::SizeF(a));
24 EXPECT_EQ(width, a.width()); 24 EXPECT_EQ(width, a.width());
25 25
26 SizeF b(10, 20); 26 SizeF b(10, 20);
27 27
28 EXPECT_EQ(a, b); 28 EXPECT_EQ(b, gfx::SizeF(a));
29 EXPECT_EQ(b, a);
30 } 29 }
31 30
32 TEST(SizeTest, ToFlooredSize) { 31 TEST(SizeTest, ToFlooredSize) {
33 EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0, 0))); 32 EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0, 0)));
34 EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0.0001f, 0.0001f))); 33 EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0.0001f, 0.0001f)));
35 EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0.4999f, 0.4999f))); 34 EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0.4999f, 0.4999f)));
36 EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0.5f, 0.5f))); 35 EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0.5f, 0.5f)));
37 EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0.9999f, 0.9999f))); 36 EXPECT_EQ(Size(0, 0), ToFlooredSize(SizeF(0.9999f, 0.9999f)));
38 37
39 EXPECT_EQ(Size(10, 10), ToFlooredSize(SizeF(10, 10))); 38 EXPECT_EQ(Size(10, 10), ToFlooredSize(SizeF(10, 10)));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 EXPECT_EQ(SizeF(8.5f, 10.5f).ToString(), a.ToString()); 116 EXPECT_EQ(SizeF(8.5f, 10.5f).ToString(), a.ToString());
118 a.SetToMin(SizeF(11.5f, 9.5f)); 117 a.SetToMin(SizeF(11.5f, 9.5f));
119 EXPECT_EQ(SizeF(8.5f, 9.5f).ToString(), a.ToString()); 118 EXPECT_EQ(SizeF(8.5f, 9.5f).ToString(), a.ToString());
120 a.SetToMin(SizeF(7.5f, 11.5f)); 119 a.SetToMin(SizeF(7.5f, 11.5f));
121 EXPECT_EQ(SizeF(7.5f, 9.5f).ToString(), a.ToString()); 120 EXPECT_EQ(SizeF(7.5f, 9.5f).ToString(), a.ToString());
122 a.SetToMin(SizeF(3.5f, 5.5f)); 121 a.SetToMin(SizeF(3.5f, 5.5f));
123 EXPECT_EQ(SizeF(3.5f, 5.5f).ToString(), a.ToString()); 122 EXPECT_EQ(SizeF(3.5f, 5.5f).ToString(), a.ToString());
124 } 123 }
125 124
126 } // namespace gfx 125 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/geometry/size_f.h ('k') | ui/gfx/image/image_skia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698