diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-10 00:38:23 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-10 00:38:23 +0000 |
commit | b8f0d0daa59b11aa8303952fe34a82471d6c3015 (patch) | |
tree | 29682e00e76d171b3a4779a444ea7d6c69fdfee9 | |
parent | acf2eb009a525699a4054e94a9455c1cc60091b6 (diff) | |
download | chromium_src-b8f0d0daa59b11aa8303952fe34a82471d6c3015.zip chromium_src-b8f0d0daa59b11aa8303952fe34a82471d6c3015.tar.gz chromium_src-b8f0d0daa59b11aa8303952fe34a82471d6c3015.tar.bz2 |
Revert 160976 - The center of a rect is x+width/2, y+height/2
If a rect is (0, 0, 5, 5) the center should be 2.5, 2.5, not 2, 2.
Tests:
ui_unittests:RectTest.CenterPoint
ui_unittests:RectTest.CenterPointF
BUG=147395
Review URL: https://chromiumcodereview.appspot.com/11065050
TBR=danakj@chromium.org
Review URL: https://codereview.chromium.org/11086037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160993 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/tooltips/tooltip_controller_unittest.cc | 8 | ||||
-rw-r--r-- | ui/aura/gestures/gesture_recognizer_unittest.cc | 12 | ||||
-rw-r--r-- | ui/aura/root_window_unittest.cc | 2 | ||||
-rw-r--r-- | ui/gfx/rect_base_impl.h | 2 | ||||
-rw-r--r-- | ui/gfx/rect_unittest.cc | 60 |
5 files changed, 12 insertions, 72 deletions
diff --git a/ash/tooltips/tooltip_controller_unittest.cc b/ash/tooltips/tooltip_controller_unittest.cc index d48db06..995f889 100644 --- a/ash/tooltips/tooltip_controller_unittest.cc +++ b/ash/tooltips/tooltip_controller_unittest.cc @@ -194,7 +194,7 @@ TEST_F(TooltipControllerTest, TooltipsInMultipleViews) { view1->bounds().CenterPoint()); FireTooltipTimer(); EXPECT_TRUE(IsTooltipVisible()); - for (int i = 0; i < 49; ++i) { + for (int i = 0; i < 50; i++) { generator.MoveMouseBy(1, 0); EXPECT_TRUE(IsTooltipVisible()); EXPECT_EQ(window, @@ -205,7 +205,7 @@ TEST_F(TooltipControllerTest, TooltipsInMultipleViews) { EXPECT_EQ(expected_tooltip, GetTooltipText()); EXPECT_EQ(window, GetTooltipWindow()); } - for (int i = 0; i < 49; ++i) { + for (int i = 0; i < 50; i++) { generator.MoveMouseBy(1, 0); EXPECT_FALSE(IsTooltipVisible()); EXPECT_EQ(window, @@ -397,7 +397,7 @@ TEST_F(TooltipControllerTest, TooltipHidesOnKeyPressAndStaysHiddenUntilChange) { // Moving the mouse inside |view1| should not change the state of the tooltip // or the timers. - for (int i = 0; i < 49; i++) { + for (int i = 0; i < 50; i++) { generator.MoveMouseBy(1, 0); EXPECT_FALSE(IsTooltipVisible()); EXPECT_FALSE(IsTooltipTimerRunning()); @@ -452,7 +452,7 @@ TEST_F(TooltipControllerTest, TooltipHidesOnTimeoutAndStaysHiddenUntilChange) { // Moving the mouse inside |view1| should not change the state of the tooltip // or the timers. - for (int i = 0; i < 49; ++i) { + for (int i = 0; i < 50; i++) { generator.MoveMouseBy(1, 0); EXPECT_FALSE(IsTooltipVisible()); EXPECT_FALSE(IsTooltipTimerRunning()); diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc index 22cab46..788fbf4 100644 --- a/ui/aura/gestures/gesture_recognizer_unittest.cc +++ b/ui/aura/gestures/gesture_recognizer_unittest.cc @@ -571,8 +571,8 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) { gfx::Point actual_point(delegate->tap_location()); EXPECT_EQ(24, delegate->bounding_box().width()); EXPECT_EQ(24, delegate->bounding_box().height()); - EXPECT_EQ(101, actual_point.x()); - EXPECT_EQ(201, actual_point.y()); + EXPECT_EQ(100, actual_point.x()); + EXPECT_EQ(200, actual_point.y()); } // Test with no ET_TOUCH_MOVED events but different touch points and radii. @@ -615,8 +615,8 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) { gfx::Point actual_point(delegate->tap_location()); EXPECT_EQ(40, delegate->bounding_box().width()); EXPECT_EQ(40, delegate->bounding_box().height()); - EXPECT_EQ(367, actual_point.x()); - EXPECT_EQ(291, actual_point.y()); + EXPECT_EQ(366, actual_point.x()); + EXPECT_EQ(290, actual_point.y()); } // Test with a single ET_TOUCH_MOVED event. @@ -678,7 +678,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) { EXPECT_EQ(25, delegate->bounding_box().width()); EXPECT_EQ(24, delegate->bounding_box().height()); EXPECT_EQ(48, actual_point.x()); - EXPECT_EQ(204, actual_point.y()); + EXPECT_EQ(203, actual_point.y()); } // Test with a few ET_TOUCH_MOVED events. @@ -773,7 +773,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) { EXPECT_EQ(33, delegate->bounding_box().width()); EXPECT_EQ(32, delegate->bounding_box().height()); EXPECT_EQ(397, actual_point.x()); - EXPECT_EQ(149, actual_point.y()); + EXPECT_EQ(148, actual_point.y()); } } diff --git a/ui/aura/root_window_unittest.cc b/ui/aura/root_window_unittest.cc index 5c8f3f7..cc7a729 100644 --- a/ui/aura/root_window_unittest.cc +++ b/ui/aura/root_window_unittest.cc @@ -360,7 +360,7 @@ TEST_F(RootWindowTest, CanProcessEventsWithinSubtree) { client.GetNonLockWindow()); w2->set_id(2); scoped_ptr<Window> w3( - test::CreateTestWindowWithDelegate(&d, 3, gfx::Rect(30, 30, 20, 20), + test::CreateTestWindowWithDelegate(&d, 3, gfx::Rect(20, 20, 20, 20), client.GetLockWindow())); w1->Focus(); diff --git a/ui/gfx/rect_base_impl.h b/ui/gfx/rect_base_impl.h index d592fde..84caa76 100644 --- a/ui/gfx/rect_base_impl.h +++ b/ui/gfx/rect_base_impl.h @@ -268,7 +268,7 @@ template<typename Class, typename Type> PointClass RectBase<Class, PointClass, SizeClass, InsetsClass, Type>:: CenterPoint() const { - return PointClass(x() + width() / 2, y() + height() / 2); + return PointClass(x() + (width() - 1) / 2, y() + (height() - 1) / 2); } template<typename Class, diff --git a/ui/gfx/rect_unittest.cc b/ui/gfx/rect_unittest.cc index 6233765..ff0c171 100644 --- a/ui/gfx/rect_unittest.cc +++ b/ui/gfx/rect_unittest.cc @@ -307,66 +307,6 @@ TEST(RectTest, SplitVertically) { EXPECT_TRUE(right_half.Equals(gfx::Rect(12, 10, 3, 10))); } -TEST(RectTest, CenterPoint) { - gfx::Point center; - - // When origin is (0, 0). - center = gfx::Rect(0, 0, 20, 20).CenterPoint(); - EXPECT_TRUE(center == gfx::Point(10, 10)); - - // When origin is even. - center = gfx::Rect(10, 10, 20, 20).CenterPoint(); - EXPECT_TRUE(center == gfx::Point(20, 20)); - - // When origin is odd. - center = gfx::Rect(11, 11, 20, 20).CenterPoint(); - EXPECT_TRUE(center == gfx::Point(21, 21)); - - // When 0 width or height. - center = gfx::Rect(10, 10, 0, 20).CenterPoint(); - EXPECT_TRUE(center == gfx::Point(10, 20)); - center = gfx::Rect(10, 10, 20, 0).CenterPoint(); - EXPECT_TRUE(center == gfx::Point(20, 10)); - - // When an odd size. - center = gfx::Rect(10, 10, 21, 21).CenterPoint(); - EXPECT_TRUE(center == gfx::Point(20, 20)); - - // When an odd size and position. - center = gfx::Rect(11, 11, 21, 21).CenterPoint(); - EXPECT_TRUE(center == gfx::Point(21, 21)); -} - -TEST(RectTest, CenterPointF) { - gfx::PointF center; - - // When origin is (0, 0). - center = gfx::RectF(0, 0, 20, 20).CenterPoint(); - EXPECT_TRUE(center == gfx::PointF(10, 10)); - - // When origin is even. - center = gfx::RectF(10, 10, 20, 20).CenterPoint(); - EXPECT_TRUE(center == gfx::PointF(20, 20)); - - // When origin is odd. - center = gfx::RectF(11, 11, 20, 20).CenterPoint(); - EXPECT_TRUE(center == gfx::PointF(21, 21)); - - // When 0 width or height. - center = gfx::RectF(10, 10, 0, 20).CenterPoint(); - EXPECT_TRUE(center == gfx::PointF(10, 20)); - center = gfx::RectF(10, 10, 20, 0).CenterPoint(); - EXPECT_TRUE(center == gfx::PointF(20, 10)); - - // When an odd size. - center = gfx::RectF(10, 10, 21, 21).CenterPoint(); - EXPECT_TRUE(center == gfx::PointF(20.5f, 20.5f)); - - // When an odd size and position. - center = gfx::RectF(11, 11, 21, 21).CenterPoint(); - EXPECT_TRUE(center == gfx::PointF(21.5f, 21.5f)); -} - TEST(RectTest, SharesEdgeWith) { gfx::Rect r(2, 3, 4, 5); |