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

Side by Side 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 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 EXPECT_EQ(kColor, frame.bubble_border()->background_color()); 161 EXPECT_EQ(kColor, frame.bubble_border()->background_color());
162 162
163 gfx::Insets frame_insets = frame.GetInsets(); 163 gfx::Insets frame_insets = frame.GetInsets();
164 gfx::Insets border_insets = frame.bubble_border()->GetInsets(); 164 gfx::Insets border_insets = frame.bubble_border()->GetInsets();
165 EXPECT_EQ(border_insets.left() + frame_insets.left(), 165 EXPECT_EQ(border_insets.left() + frame_insets.left(),
166 frame.GetBoundsForClientView().x()); 166 frame.GetBoundsForClientView().x());
167 EXPECT_EQ(border_insets.top() + frame_insets.top(), 167 EXPECT_EQ(border_insets.top() + frame_insets.top(),
168 frame.GetBoundsForClientView().y()); 168 frame.GetBoundsForClientView().y());
169 } 169 }
170 170
171 TEST_F(BubbleFrameViewTest,
172 FootnoteContainerViewShouldMatchVisibilityOfFirstChild) {
173 TestBubbleFrameView frame(this);
174 View* footnote_dummy_view = new StaticSizedView(gfx::Size(200, 200));
175 footnote_dummy_view->SetVisible(false);
176 frame.SetFootnoteView(footnote_dummy_view);
177 View* footnote_container_view = footnote_dummy_view->parent();
178 EXPECT_FALSE(footnote_container_view->visible());
179 footnote_dummy_view->SetVisible(true);
180 EXPECT_TRUE(footnote_container_view->visible());
181 footnote_dummy_view->SetVisible(false);
182 EXPECT_FALSE(footnote_container_view->visible());
183 }
184
171 // Tests that the arrow is mirrored as needed to better fit the screen. 185 // Tests that the arrow is mirrored as needed to better fit the screen.
172 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBounds) { 186 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBounds) {
173 TestBubbleFrameView frame(this); 187 TestBubbleFrameView frame(this);
174 gfx::Rect window_bounds; 188 gfx::Rect window_bounds;
175 189
176 gfx::Insets insets = frame.bubble_border()->GetInsets(); 190 gfx::Insets insets = frame.bubble_border()->GetInsets();
177 int xposition = 95 - insets.width(); 191 int xposition = 95 - insets.width();
178 192
179 // Test that the info bubble displays normally when it fits. 193 // Test that the info bubble displays normally when it fits.
180 frame.bubble_border()->set_arrow(BubbleBorder::TOP_LEFT); 194 frame.bubble_border()->set_arrow(BubbleBorder::TOP_LEFT);
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 gfx::Rect(900, 900, 50, 50), // |anchor_rect| 472 gfx::Rect(900, 900, 50, 50), // |anchor_rect|
459 gfx::Size(500, 500), // |client_size| 473 gfx::Size(500, 500), // |client_size|
460 true); // |adjust_if_offscreen| 474 true); // |adjust_if_offscreen|
461 EXPECT_EQ(BubbleBorder::RIGHT_CENTER, frame.bubble_border()->arrow()); 475 EXPECT_EQ(BubbleBorder::RIGHT_CENTER, frame.bubble_border()->arrow());
462 EXPECT_EQ(window_bounds.bottom(), 1000); 476 EXPECT_EQ(window_bounds.bottom(), 1000);
463 EXPECT_EQ(window_bounds.y() + 477 EXPECT_EQ(window_bounds.y() +
464 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 925); 478 frame.bubble_border()->GetArrowOffset(window_bounds.size()), 925);
465 } 479 }
466 480
467 TEST_F(BubbleFrameViewTest, GetPreferredSize) { 481 TEST_F(BubbleFrameViewTest, GetPreferredSize) {
468 TestBubbleFrameView frame(this); 482 {
469 gfx::Rect preferred_rect(frame.GetPreferredSize()); 483 // Test border/insets.
470 // Expect that a border has been added to the preferred size. 484 TestBubbleFrameView frame(this);
471 preferred_rect.Inset(frame.bubble_border()->GetInsets()); 485 gfx::Rect preferred_rect(frame.GetPreferredSize());
486 // Expect that a border has been added to the preferred size.
487 preferred_rect.Inset(frame.bubble_border()->GetInsets());
472 488
473 gfx::Size expected_size(kPreferredClientWidth + kExpectedAdditionalWidth, 489 gfx::Size expected_size(kPreferredClientWidth + kExpectedAdditionalWidth,
474 kPreferredClientHeight + kExpectedAdditionalHeight); 490 kPreferredClientHeight + kExpectedAdditionalHeight);
475 EXPECT_EQ(expected_size, preferred_rect.size()); 491 EXPECT_EQ(expected_size, preferred_rect.size());
492 }
493 {
msw 2017/07/10 19:02:24 nit: Make a separate new test fixture GetPreferred
Jared Saul 2017/07/10 19:24:40 Done.
494 // Test footnote view: adding a footnote should increase the preferred size,
495 // but only when the footnote is visible.
496 TestBubbleFrameView frame(this);
497
498 constexpr int kFootnoteHeight = 20;
499 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.
500 View* footnote = new StaticSizedView(gfx::Size(10, kFootnoteHeight));
501 footnote->SetVisible(false);
502 frame.SetFootnoteView(footnote);
503 EXPECT_EQ(no_footnote_size, frame.GetPreferredSize()); // No change.
504
505 footnote->SetVisible(true);
506 gfx::Size with_footnote_size = no_footnote_size;
507 with_footnote_size.Enlarge(
508 0, kFootnoteHeight + frame.content_margins().height());
509 EXPECT_EQ(with_footnote_size, frame.GetPreferredSize());
510
511 footnote->SetVisible(false);
512 EXPECT_EQ(no_footnote_size, frame.GetPreferredSize());
513 }
476 } 514 }
477 515
478 TEST_F(BubbleFrameViewTest, GetMinimumSize) { 516 TEST_F(BubbleFrameViewTest, GetMinimumSize) {
479 TestBubbleFrameView frame(this); 517 TestBubbleFrameView frame(this);
480 gfx::Rect minimum_rect(frame.GetMinimumSize()); 518 gfx::Rect minimum_rect(frame.GetMinimumSize());
481 // Expect that a border has been added to the minimum size. 519 // Expect that a border has been added to the minimum size.
482 minimum_rect.Inset(frame.bubble_border()->GetInsets()); 520 minimum_rect.Inset(frame.bubble_border()->GetInsets());
483 521
484 gfx::Size expected_size(kMinimumClientWidth + kExpectedAdditionalWidth, 522 gfx::Size expected_size(kMinimumClientWidth + kExpectedAdditionalWidth,
485 kMinimumClientHeight + kExpectedAdditionalHeight); 523 kMinimumClientHeight + kExpectedAdditionalHeight);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 // If the DialogDelegate asks not to snap, it should not snap. 612 // If the DialogDelegate asks not to snap, it should not snap.
575 delegate.set_override_snap(false); 613 delegate.set_override_snap(false);
576 Widget* w2 = BubbleDialogDelegateView::CreateBubble(&delegate); 614 Widget* w2 = BubbleDialogDelegateView::CreateBubble(&delegate);
577 w2->Show(); 615 w2->Show();
578 EXPECT_EQ(delegate.GetPreferredSize().width(), 616 EXPECT_EQ(delegate.GetPreferredSize().width(),
579 w2->GetWindowBoundsInScreen().width()); 617 w2->GetWindowBoundsInScreen().width());
580 w2->CloseNow(); 618 w2->CloseNow();
581 } 619 }
582 620
583 } // namespace views 621 } // 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