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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 protected: | 50 protected: |
51 virtual gfx::Rect GetMonitorBounds(const gfx::Rect& rect) OVERRIDE; | 51 virtual gfx::Rect GetMonitorBounds(const gfx::Rect& rect) OVERRIDE; |
52 | 52 |
53 private: | 53 private: |
54 gfx::Rect monitor_bounds_; | 54 gfx::Rect monitor_bounds_; |
55 | 55 |
56 DISALLOW_COPY_AND_ASSIGN(TestBubbleFrameView); | 56 DISALLOW_COPY_AND_ASSIGN(TestBubbleFrameView); |
57 }; | 57 }; |
58 | 58 |
59 TestBubbleFrameView::TestBubbleFrameView(const gfx::Rect& bounds) | 59 TestBubbleFrameView::TestBubbleFrameView(const gfx::Rect& bounds) |
60 : BubbleFrameView(kArrow, kBackgroundColor, | 60 : BubbleFrameView(gfx::Insets(kDefaultMargin, |
61 gfx::Insets(kDefaultMargin, | 61 kDefaultMargin, |
62 kDefaultMargin, | 62 kDefaultMargin, |
63 kDefaultMargin, | 63 kDefaultMargin)), |
64 kDefaultMargin)), | |
65 monitor_bounds_(bounds) { | 64 monitor_bounds_(bounds) { |
65 BubbleBorder* bubble_border = | |
66 new BubbleBorder(kArrow, BubbleBorder::NO_SHADOW); | |
67 bubble_border->set_background_color(kBackgroundColor); | |
68 SetBubbleBorder(bubble_border); | |
66 } | 69 } |
67 | 70 |
68 TestBubbleFrameView::~TestBubbleFrameView() {} | 71 TestBubbleFrameView::~TestBubbleFrameView() {} |
69 | 72 |
70 gfx::Rect TestBubbleFrameView::GetMonitorBounds(const gfx::Rect& rect) { | 73 gfx::Rect TestBubbleFrameView::GetMonitorBounds(const gfx::Rect& rect) { |
71 return monitor_bounds_; | 74 return monitor_bounds_; |
72 } | 75 } |
73 | 76 |
74 } // namespace | 77 } // namespace |
75 | 78 |
76 TEST_F(BubbleFrameViewTest, GetBoundsForClientView) { | 79 TEST_F(BubbleFrameViewTest, GetBoundsForClientView) { |
77 BubbleFrameView frame( | 80 TestBubbleFrameView frame(gfx::Rect(0, 0, 1000, 1000)); |
msw
2012/07/23 22:20:49
Why change the margins from kDefaultMargin?
stevenjb
2012/07/23 23:32:06
TestBubbleFrameView sets the insets using kDefault
msw
2012/07/24 00:32:44
Ah, you're right, thanks.
| |
78 kArrow, | |
79 kBackgroundColor, | |
80 gfx::Insets(kDefaultMargin, kDefaultMargin, kDefaultMargin, | |
81 kDefaultMargin)); | |
82 EXPECT_EQ(kArrow, frame.bubble_border()->arrow_location()); | 81 EXPECT_EQ(kArrow, frame.bubble_border()->arrow_location()); |
83 EXPECT_EQ(kBackgroundColor, frame.bubble_border()->background_color()); | 82 EXPECT_EQ(kBackgroundColor, frame.bubble_border()->background_color()); |
84 | 83 |
85 int margin_x = frame.content_margins().left(); | 84 int margin_x = frame.content_margins().left(); |
86 int margin_y = frame.content_margins().top(); | 85 int margin_y = frame.content_margins().top(); |
87 gfx::Insets insets; | 86 gfx::Insets insets; |
88 frame.bubble_border()->GetInsets(&insets); | 87 frame.bubble_border()->GetInsets(&insets); |
89 EXPECT_EQ(insets.left() + margin_x, frame.GetBoundsForClientView().x()); | 88 EXPECT_EQ(insets.left() + margin_x, frame.GetBoundsForClientView().x()); |
90 EXPECT_EQ(insets.top() + margin_y, frame.GetBoundsForClientView().y()); | 89 EXPECT_EQ(insets.top() + margin_y, frame.GetBoundsForClientView().y()); |
91 } | 90 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 gfx::Size(500, 500), // |client_size| | 235 gfx::Size(500, 500), // |client_size| |
237 false); // |try_mirroring_arrow| | 236 false); // |try_mirroring_arrow| |
238 EXPECT_EQ(BubbleBorder::TOP_RIGHT, frame.bubble_border()->arrow_location()); | 237 EXPECT_EQ(BubbleBorder::TOP_RIGHT, frame.bubble_border()->arrow_location()); |
239 // The coordinates should be pointing to anchor_rect from TOP_RIGHT. | 238 // The coordinates should be pointing to anchor_rect from TOP_RIGHT. |
240 EXPECT_LT(window_bounds.x(), 100 + 50 - 500); | 239 EXPECT_LT(window_bounds.x(), 100 + 50 - 500); |
241 EXPECT_GT(window_bounds.y(), 900 + 50 - 10); // -10 to roughly compensate for | 240 EXPECT_GT(window_bounds.y(), 900 + 50 - 10); // -10 to roughly compensate for |
242 // arrow overlap. | 241 // arrow overlap. |
243 } | 242 } |
244 | 243 |
245 } // namespace views | 244 } // namespace views |
OLD | NEW |