diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-31 23:44:19 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-31 23:44:19 +0000 |
commit | 7307ecdb60d6a4e8e575bbc2e2f8949cfb8d09f8 (patch) | |
tree | 3dda28c09d55f076505854857cd446f0659afe1c /ui/gfx/point_unittest.cc | |
parent | 4fd37058660780f82ea76292efaa96673c5c0479 (diff) | |
download | chromium_src-7307ecdb60d6a4e8e575bbc2e2f8949cfb8d09f8.zip chromium_src-7307ecdb60d6a4e8e575bbc2e2f8949cfb8d09f8.tar.gz chromium_src-7307ecdb60d6a4e8e575bbc2e2f8949cfb8d09f8.tar.bz2 |
ui: Add gfx::ToRoundedPoint() method.
This acts like ToRoundedSize, it returns a Point from a PointF, where each
component is rounded to the nearest integer.
Tests:
ui_unittests:PointTest.ToRoundedPoint
BUG=147395
R=sky
Review URL: https://codereview.chromium.org/11369013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165261 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/point_unittest.cc')
-rw-r--r-- | ui/gfx/point_unittest.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/ui/gfx/point_unittest.cc b/ui/gfx/point_unittest.cc index ea42b53..a95b6cf 100644 --- a/ui/gfx/point_unittest.cc +++ b/ui/gfx/point_unittest.cc @@ -7,6 +7,7 @@ #include "base/basictypes.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/point.h" +#include "ui/gfx/point_conversions.h" #include "ui/gfx/point_f.h" namespace ui { @@ -80,4 +81,39 @@ TEST(PointTest, OffsetFromPoint) { (b - a).ToString()); } +TEST(PointTest, ToRoundedPoint) { + EXPECT_EQ(gfx::Point(0, 0), + gfx::ToRoundedPoint(gfx::PointF(0, 0))); + EXPECT_EQ(gfx::Point(0, 0), + gfx::ToRoundedPoint(gfx::PointF(0.0001f, 0.0001f))); + EXPECT_EQ(gfx::Point(0, 0), + gfx::ToRoundedPoint(gfx::PointF(0.4999f, 0.4999f))); + EXPECT_EQ(gfx::Point(1, 1), + gfx::ToRoundedPoint(gfx::PointF(0.5f, 0.5f))); + EXPECT_EQ(gfx::Point(1, 1), + gfx::ToRoundedPoint(gfx::PointF(0.9999f, 0.9999f))); + + EXPECT_EQ(gfx::Point(10, 10), + gfx::ToRoundedPoint(gfx::PointF(10, 10))); + EXPECT_EQ(gfx::Point(10, 10), + gfx::ToRoundedPoint(gfx::PointF(10.0001f, 10.0001f))); + EXPECT_EQ(gfx::Point(10, 10), + gfx::ToRoundedPoint(gfx::PointF(10.4999f, 10.4999f))); + EXPECT_EQ(gfx::Point(11, 11), + gfx::ToRoundedPoint(gfx::PointF(10.5f, 10.5f))); + EXPECT_EQ(gfx::Point(11, 11), + gfx::ToRoundedPoint(gfx::PointF(10.9999f, 10.9999f))); + + EXPECT_EQ(gfx::Point(-10, -10), + gfx::ToRoundedPoint(gfx::PointF(-10, -10))); + EXPECT_EQ(gfx::Point(-10, -10), + gfx::ToRoundedPoint(gfx::PointF(-10.0001f, -10.0001f))); + EXPECT_EQ(gfx::Point(-10, -10), + gfx::ToRoundedPoint(gfx::PointF(-10.4999f, -10.4999f))); + EXPECT_EQ(gfx::Point(-11, -11), + gfx::ToRoundedPoint(gfx::PointF(-10.5f, -10.5f))); + EXPECT_EQ(gfx::Point(-11, -11), + gfx::ToRoundedPoint(gfx::PointF(-10.9999f, -10.9999f))); +} + } // namespace ui |