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

Unified Diff: ui/views/bubble/bubble_frame_view_unittest.cc

Issue 12545040: A couple of fixes to bubble view: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/bubble/bubble_frame_view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « ui/views/bubble/bubble_frame_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698