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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
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/views/bubble/bubble_frame_view.h" 5 #include "ui/views/bubble/bubble_frame_view.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 18 matching lines...) Expand all
29 const int kMinimumClientWidth = 100; 29 const int kMinimumClientWidth = 100;
30 const int kMinimumClientHeight = 200; 30 const int kMinimumClientHeight = 200;
31 const int kMaximumClientWidth = 300; 31 const int kMaximumClientWidth = 300;
32 const int kMaximumClientHeight = 300; 32 const int kMaximumClientHeight = 300;
33 const int kPreferredClientWidth = 150; 33 const int kPreferredClientWidth = 150;
34 const int kPreferredClientHeight = 250; 34 const int kPreferredClientHeight = 250;
35 35
36 // These account for non-client areas like the title bar, footnote etc. However 36 // These account for non-client areas like the title bar, footnote etc. However
37 // these do not take the bubble border into consideration. 37 // these do not take the bubble border into consideration.
38 const int kExpectedAdditionalWidth = 12; 38 const int kExpectedAdditionalWidth = 12;
39 #if defined(OS_MACOSX)
40 // On Mac, since the close button is never visible, dialogs get an extra top
41 // inset equal to the normal height of the close button, but this is considered
42 // part of the inset, while it isn't on other platforms, so on Mac we have to
43 // expect more additional height. Blech.
44 const int kExpectedAdditionalHeight = 12 + 16;
45 #else
39 const int kExpectedAdditionalHeight = 12; 46 const int kExpectedAdditionalHeight = 12;
47 #endif
40 48
41 class TestBubbleFrameViewWidgetDelegate : public WidgetDelegate { 49 class TestBubbleFrameViewWidgetDelegate : public WidgetDelegate {
42 public: 50 public:
43 TestBubbleFrameViewWidgetDelegate(Widget* widget) : widget_(widget) {} 51 TestBubbleFrameViewWidgetDelegate(Widget* widget) : widget_(widget) {}
44 52
45 ~TestBubbleFrameViewWidgetDelegate() override {} 53 ~TestBubbleFrameViewWidgetDelegate() override {}
46 54
47 // WidgetDelegate overrides: 55 // WidgetDelegate overrides:
48 Widget* GetWidget() override { return widget_; } 56 Widget* GetWidget() override { return widget_; }
49 const Widget* GetWidget() const override { return widget_; } 57 const Widget* GetWidget() const override { return widget_; }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } // namespace 121 } // namespace
114 122
115 TEST_F(BubbleFrameViewTest, GetBoundsForClientView) { 123 TEST_F(BubbleFrameViewTest, GetBoundsForClientView) {
116 TestBubbleFrameView frame(this); 124 TestBubbleFrameView frame(this);
117 EXPECT_EQ(kArrow, frame.bubble_border()->arrow()); 125 EXPECT_EQ(kArrow, frame.bubble_border()->arrow());
118 EXPECT_EQ(kColor, frame.bubble_border()->background_color()); 126 EXPECT_EQ(kColor, frame.bubble_border()->background_color());
119 127
120 int margin_x = frame.content_margins().left(); 128 int margin_x = frame.content_margins().left();
121 int margin_y = frame.content_margins().top(); 129 int margin_y = frame.content_margins().top();
122 gfx::Insets insets = frame.bubble_border()->GetInsets(); 130 gfx::Insets insets = frame.bubble_border()->GetInsets();
131 #if defined(OS_MACOSX)
132 // The insets are larger on Mac, to make up for the padding the close button
133 // would normally supply.
134 insets += gfx::Insets(16, 0, 0, 0);
135 #endif
123 EXPECT_EQ(insets.left() + margin_x, frame.GetBoundsForClientView().x()); 136 EXPECT_EQ(insets.left() + margin_x, frame.GetBoundsForClientView().x());
124 EXPECT_EQ(insets.top() + margin_y, frame.GetBoundsForClientView().y()); 137 EXPECT_EQ(insets.top() + margin_y, frame.GetBoundsForClientView().y());
125 } 138 }
126 139
127 // Tests that the arrow is mirrored as needed to better fit the screen. 140 // Tests that the arrow is mirrored as needed to better fit the screen.
128 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBounds) { 141 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBounds) {
129 TestBubbleFrameView frame(this); 142 TestBubbleFrameView frame(this);
130 gfx::Rect window_bounds; 143 gfx::Rect window_bounds;
131 144
132 gfx::Insets insets = frame.bubble_border()->GetInsets(); 145 gfx::Insets insets = frame.bubble_border()->GetInsets();
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 maximum_rect.Inset(frame.bubble_border()->GetInsets()); 466 maximum_rect.Inset(frame.bubble_border()->GetInsets());
454 467
455 // Should ignore the contents view's maximum size and use the preferred size. 468 // Should ignore the contents view's maximum size and use the preferred size.
456 gfx::Size expected_size(kPreferredClientWidth + kExpectedAdditionalWidth, 469 gfx::Size expected_size(kPreferredClientWidth + kExpectedAdditionalWidth,
457 kPreferredClientHeight + kExpectedAdditionalHeight); 470 kPreferredClientHeight + kExpectedAdditionalHeight);
458 EXPECT_EQ(expected_size, maximum_rect.size()); 471 EXPECT_EQ(expected_size, maximum_rect.size());
459 #endif 472 #endif
460 } 473 }
461 474
462 } // namespace views 475 } // namespace views
OLDNEW
« ui/views/bubble/bubble_frame_view.cc ('K') | « 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