Chromium Code Reviews| 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 9e338c563d8b20b58956405fa41e23649480f43c..a865f109a91009d10cecf49d405fbd4375e20b69 100644 |
| --- a/ui/views/bubble/bubble_frame_view_unittest.cc |
| +++ b/ui/views/bubble/bubble_frame_view_unittest.cc |
| @@ -12,6 +12,7 @@ |
| #include "ui/gfx/geometry/rect.h" |
| #include "ui/gfx/geometry/size.h" |
| #include "ui/views/bubble/bubble_border.h" |
| +#include "ui/views/controls/button/label_button.h" |
| #include "ui/views/test/test_views.h" |
| #include "ui/views/test/views_test_base.h" |
| #include "ui/views/widget/widget.h" |
| @@ -61,6 +62,9 @@ class TestBubbleFrameViewWidgetDelegate : public WidgetDelegate { |
| return contents_view_; |
| } |
| + bool ShouldShowCloseButton() const override { return should_show_close_; } |
| + bool should_show_close_ = false; |
|
msw
2016/07/29 19:38:39
Make this private and add a setter.
Elly Fong-Jones
2016/08/02 17:49:29
Done.
|
| + |
| private: |
| Widget* widget_; |
| View* contents_view_ = nullptr; // Owned by |widget_|. |
| @@ -98,6 +102,10 @@ class TestBubbleFrameView : public BubbleFrameView { |
| return available_bounds_; |
| } |
| + TestBubbleFrameViewWidgetDelegate* widget_delegate() { |
| + return widget_delegate_.get(); |
| + } |
| + |
| private: |
| ViewsTestBase* test_base_; |
| @@ -124,6 +132,24 @@ TEST_F(BubbleFrameViewTest, GetBoundsForClientView) { |
| EXPECT_EQ(insets.top() + margin_y, frame.GetBoundsForClientView().y()); |
| } |
| +TEST_F(BubbleFrameViewTest, GetBoundsForClientViewWithClose) { |
| + TestBubbleFrameView frame(this); |
| + // TestBubbleFrameView::GetWidget() is responsible for creating the widget and |
| + // widget delegate at first call, so it is called here for that side-effect. |
| + (void)frame.GetWidget(); |
|
msw
2016/07/29 19:38:39
I think there's a more chrome-standard way of doin
msw
2016/07/29 19:40:59
Found it: https://cs.chromium.org/chromium/src/bas
Elly Fong-Jones
2016/08/02 17:49:29
Done.
Elly Fong-Jones
2016/08/02 17:49:29
Done.
|
| + frame.widget_delegate()->should_show_close_ = true; |
| + frame.OnThemeChanged(); |
| + EXPECT_EQ(kArrow, frame.bubble_border()->arrow()); |
| + EXPECT_EQ(kColor, frame.bubble_border()->background_color()); |
| + |
| + int margin_x = frame.content_margins().left(); |
| + int margin_y = frame.content_margins().top() + |
| + frame.GetCloseButtonForTest()->height(); |
| + gfx::Insets insets = frame.bubble_border()->GetInsets(); |
| + EXPECT_EQ(insets.left() + margin_x, frame.GetBoundsForClientView().x()); |
| + EXPECT_EQ(insets.top() + margin_y, frame.GetBoundsForClientView().y()); |
| +} |
| + |
| // Tests that the arrow is mirrored as needed to better fit the screen. |
| TEST_F(BubbleFrameViewTest, GetUpdatedWindowBounds) { |
| TestBubbleFrameView frame(this); |