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

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

Issue 2189123002: BubbleFrameView: add padding if platform dislikes close buttons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final fixups Created 4 years, 4 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') | ui/views/widget/widget_delegate.cc » ('j') | 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 9e338c563d8b20b58956405fa41e23649480f43c..bf955dd451c640273688efb5f36fae2e0198a691 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,9 +62,15 @@ class TestBubbleFrameViewWidgetDelegate : public WidgetDelegate {
return contents_view_;
}
+ bool ShouldShowCloseButton() const override { return should_show_close_; }
+ void SetShouldShowCloseButton(bool should_show_close) {
+ should_show_close_ = should_show_close;
+ }
+
private:
Widget* widget_;
View* contents_view_ = nullptr; // Owned by |widget_|.
+ bool should_show_close_ = false;
};
class TestBubbleFrameView : public BubbleFrameView {
@@ -98,6 +105,10 @@ class TestBubbleFrameView : public BubbleFrameView {
return available_bounds_;
}
+ TestBubbleFrameViewWidgetDelegate* widget_delegate() {
+ return widget_delegate_.get();
+ }
+
private:
ViewsTestBase* test_base_;
@@ -124,6 +135,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.
+ ignore_result(frame.GetWidget());
+ frame.widget_delegate()->SetShouldShowCloseButton(true);
+ frame.ResetWindowControls();
+ 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);
« no previous file with comments | « ui/views/bubble/bubble_frame_view.cc ('k') | ui/views/widget/widget_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698