| 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 "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "ui/base/test/material_design_controller_test_api.h" | 10 #include "ui/base/test/material_design_controller_test_api.h" |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 // Remove |extra_button| from the View hierarchy so that it can be replaced. | 398 // Remove |extra_button| from the View hierarchy so that it can be replaced. |
| 399 delete extra_button; | 399 delete extra_button; |
| 400 | 400 |
| 401 // Non-buttons should always be sized to their preferred size. | 401 // Non-buttons should always be sized to their preferred size. |
| 402 View* boring_view = new StaticSizedView(gfx::Size(20, 20)); | 402 View* boring_view = new StaticSizedView(gfx::Size(20, 20)); |
| 403 SetExtraView(boring_view); | 403 SetExtraView(boring_view); |
| 404 CheckContentsIsSetToPreferredSize(); | 404 CheckContentsIsSetToPreferredSize(); |
| 405 EXPECT_EQ(20, boring_view->width()); | 405 EXPECT_EQ(20, boring_view->width()); |
| 406 } | 406 } |
| 407 | 407 |
| 408 TEST_F(DialogClientViewTest, ButtonPosition) { |
| 409 ui::test::MaterialDesignControllerTestAPI md_test_api( |
| 410 ui::MaterialDesignController::MATERIAL_NORMAL); |
| 411 md_test_api.SetSecondaryUiMaterial(true); |
| 412 |
| 413 constexpr int button_row_inset = 13; |
| 414 client_view()->set_button_row_insets(gfx::Insets(button_row_inset)); |
| 415 constexpr int contents_height = 37; |
| 416 constexpr int contents_width = 222; |
| 417 SetSizeConstraints(gfx::Size(), gfx::Size(contents_width, contents_height), |
| 418 gfx::Size(666, 666)); |
| 419 SetDialogButtons(ui::DIALOG_BUTTON_OK); |
| 420 client_view()->SizeToPreferredSize(); |
| 421 client_view()->Layout(); |
| 422 EXPECT_EQ(contents_width - button_row_inset, |
| 423 client_view()->ok_button()->bounds().right()); |
| 424 EXPECT_EQ(contents_height + button_row_inset, |
| 425 height() + client_view()->ok_button()->y()); |
| 426 } |
| 427 |
| 408 } // namespace views | 428 } // namespace views |
| OLD | NEW |