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/window/dialog_client_view.h" | 5 #include "ui/views/window/dialog_client_view.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 // Remove |extra_button| from the View hierarchy so that it can be replaced. | 413 // Remove |extra_button| from the View hierarchy so that it can be replaced. |
414 delete extra_button; | 414 delete extra_button; |
415 | 415 |
416 // Non-buttons should always be sized to their preferred size. | 416 // Non-buttons should always be sized to their preferred size. |
417 View* boring_view = new StaticSizedView(gfx::Size(20, 20)); | 417 View* boring_view = new StaticSizedView(gfx::Size(20, 20)); |
418 SetExtraView(boring_view); | 418 SetExtraView(boring_view); |
419 CheckContentsIsSetToPreferredSize(); | 419 CheckContentsIsSetToPreferredSize(); |
420 EXPECT_EQ(20, boring_view->width()); | 420 EXPECT_EQ(20, boring_view->width()); |
421 } | 421 } |
422 | 422 |
| 423 TEST_F(DialogClientViewTest, ButtonPosition) { |
| 424 constexpr int button_row_inset = 13; |
| 425 client_view()->SetButtonRowInsets(gfx::Insets(button_row_inset)); |
| 426 constexpr int contents_height = 37; |
| 427 constexpr int contents_width = 222; |
| 428 SetSizeConstraints(gfx::Size(), gfx::Size(contents_width, contents_height), |
| 429 gfx::Size(666, 666)); |
| 430 SetDialogButtons(ui::DIALOG_BUTTON_OK); |
| 431 client_view()->SizeToPreferredSize(); |
| 432 client_view()->Layout(); |
| 433 EXPECT_EQ(contents_width - button_row_inset, |
| 434 client_view()->ok_button()->bounds().right()); |
| 435 EXPECT_EQ(contents_height + button_row_inset, |
| 436 height() + client_view()->ok_button()->y()); |
| 437 } |
| 438 |
423 } // namespace views | 439 } // namespace views |
OLD | NEW |