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

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

Issue 2955963002: Update Chrome Upstream flow to reflect new UI mocks (Closed)
Patch Set: Actioning code review comments from Patch Set 4 Created 3 years, 5 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
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 dda52edc8549fa7c161bff9ae03cf6297ea32f42..d9db6177028676c4adc86b32af78d8efda9f3a15 100644
--- a/ui/views/bubble/bubble_frame_view_unittest.cc
+++ b/ui/views/bubble/bubble_frame_view_unittest.cc
@@ -168,6 +168,20 @@ TEST_F(BubbleFrameViewTest, GetBoundsForClientViewWithClose) {
frame.GetBoundsForClientView().y());
}
+TEST_F(BubbleFrameViewTest,
+ FootnoteContainerViewShouldMatchVisibilityOfFirstChild) {
+ TestBubbleFrameView frame(this);
+ View* footnote_dummy_view = new StaticSizedView(gfx::Size(200, 200));
+ footnote_dummy_view->SetVisible(false);
+ frame.SetFootnoteView(footnote_dummy_view);
+ View* footnote_container_view = footnote_dummy_view->parent();
+ EXPECT_FALSE(footnote_container_view->visible());
+ footnote_dummy_view->SetVisible(true);
+ EXPECT_TRUE(footnote_container_view->visible());
+ footnote_dummy_view->SetVisible(false);
+ EXPECT_FALSE(footnote_container_view->visible());
+}
+
// Tests that the arrow is mirrored as needed to better fit the screen.
TEST_F(BubbleFrameViewTest, GetUpdatedWindowBounds) {
TestBubbleFrameView frame(this);
@@ -465,14 +479,38 @@ TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsCenterArrows) {
}
TEST_F(BubbleFrameViewTest, GetPreferredSize) {
- TestBubbleFrameView frame(this);
- gfx::Rect preferred_rect(frame.GetPreferredSize());
- // Expect that a border has been added to the preferred size.
- preferred_rect.Inset(frame.bubble_border()->GetInsets());
-
- gfx::Size expected_size(kPreferredClientWidth + kExpectedAdditionalWidth,
- kPreferredClientHeight + kExpectedAdditionalHeight);
- EXPECT_EQ(expected_size, preferred_rect.size());
+ {
+ // Test border/insets.
+ TestBubbleFrameView frame(this);
+ gfx::Rect preferred_rect(frame.GetPreferredSize());
+ // Expect that a border has been added to the preferred size.
+ preferred_rect.Inset(frame.bubble_border()->GetInsets());
+
+ gfx::Size expected_size(kPreferredClientWidth + kExpectedAdditionalWidth,
+ kPreferredClientHeight + kExpectedAdditionalHeight);
+ EXPECT_EQ(expected_size, preferred_rect.size());
+ }
+ {
msw 2017/07/10 19:02:24 nit: Make a separate new test fixture GetPreferred
Jared Saul 2017/07/10 19:24:40 Done.
+ // Test footnote view: adding a footnote should increase the preferred size,
+ // but only when the footnote is visible.
+ TestBubbleFrameView frame(this);
+
+ constexpr int kFootnoteHeight = 20;
+ const gfx::Size no_footnote_size = frame.GetPreferredSize();
tapted 2017/07/10 03:52:05 To cater for the border, probably something like
Jared Saul 2017/07/10 19:24:40 Done.
+ View* footnote = new StaticSizedView(gfx::Size(10, kFootnoteHeight));
+ footnote->SetVisible(false);
+ frame.SetFootnoteView(footnote);
+ EXPECT_EQ(no_footnote_size, frame.GetPreferredSize()); // No change.
+
+ footnote->SetVisible(true);
+ gfx::Size with_footnote_size = no_footnote_size;
+ with_footnote_size.Enlarge(
+ 0, kFootnoteHeight + frame.content_margins().height());
+ EXPECT_EQ(with_footnote_size, frame.GetPreferredSize());
+
+ footnote->SetVisible(false);
+ EXPECT_EQ(no_footnote_size, frame.GetPreferredSize());
+ }
}
TEST_F(BubbleFrameViewTest, GetMinimumSize) {
« 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