OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/base/hit_test.h" | 5 #include "ui/base/hit_test.h" |
6 #include "ui/gfx/insets.h" | 6 #include "ui/gfx/insets.h" |
7 #include "ui/views/bubble/bubble_border.h" | 7 #include "ui/views/bubble/bubble_border.h" |
8 #include "ui/views/bubble/bubble_delegate.h" | 8 #include "ui/views/bubble/bubble_delegate.h" |
9 #include "ui/views/bubble/bubble_frame_view.h" | 9 #include "ui/views/bubble/bubble_frame_view.h" |
10 #include "ui/views/test/views_test_base.h" | 10 #include "ui/views/test/views_test_base.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsMirroringFails) { | 221 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsMirroringFails) { |
222 TestBubbleFrameView frame; | 222 TestBubbleFrameView frame; |
223 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT); | 223 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_LEFT); |
224 gfx::Rect window_bounds = frame.GetUpdatedWindowBounds( | 224 gfx::Rect window_bounds = frame.GetUpdatedWindowBounds( |
225 gfx::Rect(400, 100, 50, 50), // |anchor_rect| | 225 gfx::Rect(400, 100, 50, 50), // |anchor_rect| |
226 gfx::Size(500, 700), // |client_size| | 226 gfx::Size(500, 700), // |client_size| |
227 true); // |adjust_if_offscreen| | 227 true); // |adjust_if_offscreen| |
228 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); | 228 EXPECT_EQ(BubbleBorder::TOP_LEFT, frame.bubble_border()->arrow_location()); |
229 } | 229 } |
230 | 230 |
| 231 TEST_F(BubbleFrameViewTest, TestMirroringForCenteredArrow) { |
| 232 TestBubbleFrameView frame; |
| 233 |
| 234 // Test bubble not fitting above the anchor. |
| 235 frame.bubble_border()->set_arrow_location(BubbleBorder::BOTTOM_CENTER); |
| 236 gfx::Rect window_bounds = frame.GetUpdatedWindowBounds( |
| 237 gfx::Rect(100, 100, 50, 50), // |anchor_rect| |
| 238 gfx::Size(500, 700), // |client_size| |
| 239 true); // |adjust_if_offscreen| |
| 240 EXPECT_EQ(BubbleBorder::TOP_CENTER, frame.bubble_border()->arrow_location()); |
| 241 |
| 242 // Test bubble not fitting below the anchor. |
| 243 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_CENTER); |
| 244 window_bounds = frame.GetUpdatedWindowBounds( |
| 245 gfx::Rect(300, 800, 50, 50), // |anchor_rect| |
| 246 gfx::Size(500, 200), // |client_size| |
| 247 true); // |adjust_if_offscreen| |
| 248 EXPECT_EQ(BubbleBorder::BOTTOM_CENTER, |
| 249 frame.bubble_border()->arrow_location()); |
| 250 |
| 251 // Test bubble not fitting to the right of the anchor. |
| 252 frame.bubble_border()->set_arrow_location(BubbleBorder::LEFT_CENTER); |
| 253 window_bounds = frame.GetUpdatedWindowBounds( |
| 254 gfx::Rect(800, 300, 50, 50), // |anchor_rect| |
| 255 gfx::Size(200, 500), // |client_size| |
| 256 true); // |adjust_if_offscreen| |
| 257 EXPECT_EQ(BubbleBorder::RIGHT_CENTER, |
| 258 frame.bubble_border()->arrow_location()); |
| 259 |
| 260 // Test bubble not fitting to the left of the anchor. |
| 261 frame.bubble_border()->set_arrow_location(BubbleBorder::RIGHT_CENTER); |
| 262 window_bounds = frame.GetUpdatedWindowBounds( |
| 263 gfx::Rect(100, 300, 50, 50), // |anchor_rect| |
| 264 gfx::Size(500, 500), // |client_size| |
| 265 true); // |adjust_if_offscreen| |
| 266 EXPECT_EQ(BubbleBorder::LEFT_CENTER, frame.bubble_border()->arrow_location()); |
| 267 } |
| 268 |
231 // Test that the arrow will not be mirrored when |adjust_if_offscreen| is false. | 269 // Test that the arrow will not be mirrored when |adjust_if_offscreen| is false. |
232 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsDontTryMirror) { | 270 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsDontTryMirror) { |
233 TestBubbleFrameView frame; | 271 TestBubbleFrameView frame; |
234 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_RIGHT); | 272 frame.bubble_border()->set_arrow_location(BubbleBorder::TOP_RIGHT); |
235 gfx::Rect window_bounds = frame.GetUpdatedWindowBounds( | 273 gfx::Rect window_bounds = frame.GetUpdatedWindowBounds( |
236 gfx::Rect(100, 900, 50, 50), // |anchor_rect| | 274 gfx::Rect(100, 900, 50, 50), // |anchor_rect| |
237 gfx::Size(500, 500), // |client_size| | 275 gfx::Size(500, 500), // |client_size| |
238 false); // |adjust_if_offscreen| | 276 false); // |adjust_if_offscreen| |
239 EXPECT_EQ(BubbleBorder::TOP_RIGHT, frame.bubble_border()->arrow_location()); | 277 EXPECT_EQ(BubbleBorder::TOP_RIGHT, frame.bubble_border()->arrow_location()); |
240 // The coordinates should be pointing to anchor_rect from TOP_RIGHT. | 278 // The coordinates should be pointing to anchor_rect from TOP_RIGHT. |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 gfx::Size(500, 500), // |client_size| | 404 gfx::Size(500, 500), // |client_size| |
367 true); // |adjust_if_offscreen| | 405 true); // |adjust_if_offscreen| |
368 EXPECT_EQ(BubbleBorder::RIGHT_CENTER, | 406 EXPECT_EQ(BubbleBorder::RIGHT_CENTER, |
369 frame.bubble_border()->arrow_location()); | 407 frame.bubble_border()->arrow_location()); |
370 EXPECT_EQ(window_bounds.bottom(), 1000); | 408 EXPECT_EQ(window_bounds.bottom(), 1000); |
371 EXPECT_EQ(window_bounds.y() + | 409 EXPECT_EQ(window_bounds.y() + |
372 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 925); | 410 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 925); |
373 } | 411 } |
374 | 412 |
375 } // namespace views | 413 } // namespace views |
OLD | NEW |