Index: ui/views/bubble/bubble_frame_view_unittest.cc |
diff --git a/ui/views/bubble/bubble_frame_view_unittest.cc b/ui/views/bubble/bubble_frame_view_unittest.cc |
index 602d79f9de45a60cdcd131538db1cbfceff12aaa..b90615a6a5e81d2bde999e6307b264e59496f9af 100644 |
--- a/ui/views/bubble/bubble_frame_view_unittest.cc |
+++ b/ui/views/bubble/bubble_frame_view_unittest.cc |
@@ -228,6 +228,44 @@ TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsMirroringFails) { |
EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); |
} |
+TEST_F(BubbleFrameViewTest, TestMirroringForCenteredArrow) { |
+ TestBubbleFrameView frame; |
+ |
+ // Test bubble not fitting above the anchor. |
+ frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_CENTER); |
+ gfx::Rect window_bounds = frame.GetUpdatedWindowBounds( |
+ gfx::Rect(100, 100, 50, 50), // |anchor_rect| |
+ gfx::Size(500, 700), // |client_size| |
+ true); // |adjust_if_offscreen| |
+ EXPECT_EQ(BubbleBorder::TOP_CENTER, frame.bubble_border()->arrow_location()); |
+ |
+ // Test bubble not fitting below the anchor. |
+ frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_CENTER); |
+ window_bounds = frame.GetUpdatedWindowBounds( |
+ gfx::Rect(300, 800, 50, 50), // |anchor_rect| |
+ gfx::Size(500, 200), // |client_size| |
+ true); // |adjust_if_offscreen| |
+ EXPECT_EQ(BubbleBorder::BOTTOM_CENTER, |
+ frame.bubble_border()->arrow_location()); |
+ |
+ // Test bubble not fitting to the right of the anchor. |
+ frame.bubble_border()->set_arrow_location(BubbleBorder::LEFT_CENTER); |
+ window_bounds = frame.GetUpdatedWindowBounds( |
+ gfx::Rect(800, 300, 50, 50), // |anchor_rect| |
+ gfx::Size(200, 500), // |client_size| |
+ true); // |adjust_if_offscreen| |
+ EXPECT_EQ(BubbleBorder::RIGHT_CENTER, |
+ frame.bubble_border()->arrow_location()); |
+ |
+ // Test bubble not fitting to the left of the anchor. |
+ frame.bubble_border()->set_arrow_location(BubbleBorder::RIGHT_CENTER); |
+ window_bounds = frame.GetUpdatedWindowBounds( |
+ gfx::Rect(100, 300, 50, 50), // |anchor_rect| |
+ gfx::Size(500, 500), // |client_size| |
+ true); // |adjust_if_offscreen| |
+ EXPECT_EQ(BubbleBorder::LEFT_CENTER, frame.bubble_border()->arrow_location()); |
+} |
+ |
// Test that the arrow will not be mirrored when |adjust_if_offscreen| is false. |
TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsDontTryMirror) { |
TestBubbleFrameView frame; |