Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 gfx::Insets insets = frame.bubble_border()->GetInsets(); | 135 gfx::Insets insets = frame.bubble_border()->GetInsets(); |
| 136 EXPECT_EQ(insets.left() + margin_x, frame.GetBoundsForClientView().x()); | 136 EXPECT_EQ(insets.left() + margin_x, frame.GetBoundsForClientView().x()); |
| 137 EXPECT_EQ(insets.top() + margin_y, frame.GetBoundsForClientView().y()); | 137 EXPECT_EQ(insets.top() + margin_y, frame.GetBoundsForClientView().y()); |
| 138 } | 138 } |
| 139 | 139 |
| 140 TEST_F(BubbleFrameViewTest, RemoveFootnoteView) { | 140 TEST_F(BubbleFrameViewTest, RemoveFootnoteView) { |
| 141 TestBubbleFrameView frame(this); | 141 TestBubbleFrameView frame(this); |
| 142 EXPECT_EQ(nullptr, frame.footnote_container_); | 142 EXPECT_EQ(nullptr, frame.footnote_container_); |
| 143 View* footnote_dummy_view = new StaticSizedView(gfx::Size(200, 200)); | 143 View* footnote_dummy_view = new StaticSizedView(gfx::Size(200, 200)); |
| 144 frame.SetFootnoteView(footnote_dummy_view); | 144 frame.SetFootnoteView(footnote_dummy_view); |
| 145 EXPECT_EQ(footnote_dummy_view->parent(), frame.footnote_container_); | 145 EXPECT_EQ(footnote_dummy_view->parent(), (View*)frame.footnote_container_); |
|
msw
2017/07/05 20:45:30
nit: this cast shouldn't be needed or should use s
Jared Saul
2017/07/07 20:12:28
Yep; it's good now that I reverted it to a View*,
| |
| 146 View* container_view = footnote_dummy_view->parent(); | 146 View* container_view = footnote_dummy_view->parent(); |
| 147 delete footnote_dummy_view; | 147 delete footnote_dummy_view; |
| 148 footnote_dummy_view = nullptr; | 148 footnote_dummy_view = nullptr; |
| 149 EXPECT_FALSE(container_view->visible()); | 149 EXPECT_FALSE(container_view->visible()); |
| 150 EXPECT_EQ(nullptr, frame.footnote_container_); | 150 EXPECT_EQ(nullptr, frame.footnote_container_); |
| 151 } | 151 } |
| 152 | 152 |
| 153 TEST_F(BubbleFrameViewTest, GetBoundsForClientViewWithClose) { | 153 TEST_F(BubbleFrameViewTest, GetBoundsForClientViewWithClose) { |
| 154 TestBubbleFrameView frame(this); | 154 TestBubbleFrameView frame(this); |
| 155 // TestBubbleFrameView::GetWidget() is responsible for creating the widget and | 155 // TestBubbleFrameView::GetWidget() is responsible for creating the widget and |
| 156 // widget delegate at first call, so it is called here for that side-effect. | 156 // widget delegate at first call, so it is called here for that side-effect. |
| 157 ignore_result(frame.GetWidget()); | 157 ignore_result(frame.GetWidget()); |
| 158 frame.widget_delegate()->SetShouldShowCloseButton(true); | 158 frame.widget_delegate()->SetShouldShowCloseButton(true); |
| 159 frame.ResetWindowControls(); | 159 frame.ResetWindowControls(); |
| 160 EXPECT_EQ(kArrow, frame.bubble_border()->arrow()); | 160 EXPECT_EQ(kArrow, frame.bubble_border()->arrow()); |
| 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 = (View*)frame.footnote_container_; | |
|
msw
2017/07/05 20:45:30
nit: this cast shouldn't be needed or should use s
Jared Saul
2017/07/07 20:12:28
Done.
| |
| 178 EXPECT_EQ(footnote_dummy_view->parent(), footnote_container_view); | |
|
msw
2017/07/05 20:45:30
Please just retrieve the footnote's container via
Jared Saul
2017/07/07 20:12:28
Done; thank you for the detailed instructions!
| |
| 179 EXPECT_FALSE(footnote_container_view->visible()); | |
| 180 footnote_dummy_view->SetVisible(true); | |
| 181 EXPECT_TRUE(footnote_container_view->visible()); | |
| 182 footnote_dummy_view->SetVisible(false); | |
| 183 EXPECT_FALSE(footnote_container_view->visible()); | |
| 184 } | |
|
tapted
2017/07/06 01:11:59
the visibility test is good..
I think I see the
| |
| 185 | |
| 171 // Tests that the arrow is mirrored as needed to better fit the screen. | 186 // Tests that the arrow is mirrored as needed to better fit the screen. |
| 172 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBounds) { | 187 TEST_F(BubbleFrameViewTest, GetUpdatedWindowBounds) { |
| 173 TestBubbleFrameView frame(this); | 188 TestBubbleFrameView frame(this); |
| 174 gfx::Rect window_bounds; | 189 gfx::Rect window_bounds; |
| 175 | 190 |
| 176 gfx::Insets insets = frame.bubble_border()->GetInsets(); | 191 gfx::Insets insets = frame.bubble_border()->GetInsets(); |
| 177 int xposition = 95 - insets.width(); | 192 int xposition = 95 - insets.width(); |
| 178 | 193 |
| 179 // Test that the info bubble displays normally when it fits. | 194 // Test that the info bubble displays normally when it fits. |
| 180 frame.bubble_border()->set_arrow(BubbleBorder::TOP_LEFT); | 195 frame.bubble_border()->set_arrow(BubbleBorder::TOP_LEFT); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 | 481 |
| 467 TEST_F(BubbleFrameViewTest, GetPreferredSize) { | 482 TEST_F(BubbleFrameViewTest, GetPreferredSize) { |
| 468 TestBubbleFrameView frame(this); | 483 TestBubbleFrameView frame(this); |
| 469 gfx::Rect preferred_rect(frame.GetPreferredSize()); | 484 gfx::Rect preferred_rect(frame.GetPreferredSize()); |
| 470 // Expect that a border has been added to the preferred size. | 485 // Expect that a border has been added to the preferred size. |
| 471 preferred_rect.Inset(frame.bubble_border()->GetInsets()); | 486 preferred_rect.Inset(frame.bubble_border()->GetInsets()); |
| 472 | 487 |
| 473 gfx::Size expected_size(kPreferredClientWidth + kExpectedAdditionalWidth, | 488 gfx::Size expected_size(kPreferredClientWidth + kExpectedAdditionalWidth, |
| 474 kPreferredClientHeight + kExpectedAdditionalHeight); | 489 kPreferredClientHeight + kExpectedAdditionalHeight); |
| 475 EXPECT_EQ(expected_size, preferred_rect.size()); | 490 EXPECT_EQ(expected_size, preferred_rect.size()); |
| 476 } | 491 } |
|
tapted
2017/07/06 01:11:59
I'd add some lines here like,
// Adding a footnot
Jared Saul
2017/07/07 20:12:28
Thanks for the code! There was about a 10x17-18 p
tapted
2017/07/10 03:52:04
Probably the line in SetFootnoteView:
footnote_
Jared Saul
2017/07/10 19:24:40
Hah, I skimmed right over it. Thanks!
| |
| 477 | 492 |
| 478 TEST_F(BubbleFrameViewTest, GetMinimumSize) { | 493 TEST_F(BubbleFrameViewTest, GetMinimumSize) { |
| 479 TestBubbleFrameView frame(this); | 494 TestBubbleFrameView frame(this); |
| 480 gfx::Rect minimum_rect(frame.GetMinimumSize()); | 495 gfx::Rect minimum_rect(frame.GetMinimumSize()); |
| 481 // Expect that a border has been added to the minimum size. | 496 // Expect that a border has been added to the minimum size. |
| 482 minimum_rect.Inset(frame.bubble_border()->GetInsets()); | 497 minimum_rect.Inset(frame.bubble_border()->GetInsets()); |
| 483 | 498 |
| 484 gfx::Size expected_size(kMinimumClientWidth + kExpectedAdditionalWidth, | 499 gfx::Size expected_size(kMinimumClientWidth + kExpectedAdditionalWidth, |
| 485 kMinimumClientHeight + kExpectedAdditionalHeight); | 500 kMinimumClientHeight + kExpectedAdditionalHeight); |
| 486 EXPECT_EQ(expected_size, minimum_rect.size()); | 501 EXPECT_EQ(expected_size, minimum_rect.size()); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 574 // If the DialogDelegate asks not to snap, it should not snap. | 589 // If the DialogDelegate asks not to snap, it should not snap. |
| 575 delegate.set_override_snap(false); | 590 delegate.set_override_snap(false); |
| 576 Widget* w2 = BubbleDialogDelegateView::CreateBubble(&delegate); | 591 Widget* w2 = BubbleDialogDelegateView::CreateBubble(&delegate); |
| 577 w2->Show(); | 592 w2->Show(); |
| 578 EXPECT_EQ(delegate.GetPreferredSize().width(), | 593 EXPECT_EQ(delegate.GetPreferredSize().width(), |
| 579 w2->GetWindowBoundsInScreen().width()); | 594 w2->GetWindowBoundsInScreen().width()); |
| 580 w2->CloseNow(); | 595 w2->CloseNow(); |
| 581 } | 596 } |
| 582 | 597 |
| 583 } // namespace views | 598 } // namespace views |
| OLD | NEW |