diff options
author | dpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-05 22:49:09 +0000 |
---|---|---|
committer | dpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-05 22:49:09 +0000 |
commit | fa742ee5562cf36b55dbd0f1f8ec5b9e131ca539 (patch) | |
tree | 7e5e9eea2197f2119f1d80b0c0a4531ad97570e9 /ui/gfx/rect_unittest.cc | |
parent | b95700e633f8e4aa280fdaffe7e761c62d377221 (diff) | |
download | chromium_src-fa742ee5562cf36b55dbd0f1f8ec5b9e131ca539.zip chromium_src-fa742ee5562cf36b55dbd0f1f8ec5b9e131ca539.tar.gz chromium_src-fa742ee5562cf36b55dbd0f1f8ec5b9e131ca539.tar.bz2 |
Adding gfx::Rect::SplitVertically() method.
1) Code was replicated in dragged_tab_controller_gtk.cc and
dragged_tab_controller.cc, this allows the same code to be reused. Also removing the corresponding TODO.
2) The old SplitRectangleInTwo() function was violating the styleguide by having not const references as parameters.
BUG=NONE
TEST=NONE
Review URL: http://codereview.chromium.org/8137018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104199 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/rect_unittest.cc')
-rw-r--r-- | ui/gfx/rect_unittest.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ui/gfx/rect_unittest.cc b/ui/gfx/rect_unittest.cc index 4ad3f74..4eefdd6 100644 --- a/ui/gfx/rect_unittest.cc +++ b/ui/gfx/rect_unittest.cc @@ -280,6 +280,30 @@ TEST(RectTest, IsEmpty) { EXPECT_FALSE(gfx::Rect(0, 0, 10, 10).size().IsEmpty()); } +TEST(RectTest, SplitVertically) { + gfx::Rect left_half, right_half; + + // Splitting when origin is (0, 0). + gfx::Rect(0, 0, 20, 20).SplitVertically(&left_half, &right_half); + EXPECT_TRUE(left_half.Equals(gfx::Rect(0, 0, 10, 20))); + EXPECT_TRUE(right_half.Equals(gfx::Rect(10, 0, 10, 20))); + + // Splitting when origin is arbitrary. + gfx::Rect(10, 10, 20, 10).SplitVertically(&left_half, &right_half); + EXPECT_TRUE(left_half.Equals(gfx::Rect(10, 10, 10, 10))); + EXPECT_TRUE(right_half.Equals(gfx::Rect(20, 10, 10, 10))); + + // Splitting a rectangle of zero width. + gfx::Rect(10, 10, 0, 10).SplitVertically(&left_half, &right_half); + EXPECT_TRUE(left_half.Equals(gfx::Rect(10, 10, 0, 10))); + EXPECT_TRUE(right_half.Equals(gfx::Rect(10, 10, 0, 10))); + + // Splitting a rectangle of odd width. + gfx::Rect(10, 10, 5, 10).SplitVertically(&left_half, &right_half); + EXPECT_TRUE(left_half.Equals(gfx::Rect(10, 10, 2, 10))); + EXPECT_TRUE(right_half.Equals(gfx::Rect(12, 10, 3, 10))); +} + TEST(RectTest, SharesEdgeWith) { gfx::Rect r(2, 3, 4, 5); |