| 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" |
| 11 #include "ui/base/ui_base_types.h" | 11 #include "ui/base/ui_base_types.h" |
| 12 #include "ui/views/controls/button/checkbox.h" |
| 12 #include "ui/views/controls/button/label_button.h" | 13 #include "ui/views/controls/button/label_button.h" |
| 13 #include "ui/views/style/platform_style.h" | 14 #include "ui/views/style/platform_style.h" |
| 14 #include "ui/views/test/test_views.h" | 15 #include "ui/views/test/test_views.h" |
| 15 #include "ui/views/test/widget_test.h" | 16 #include "ui/views/test/widget_test.h" |
| 16 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 17 #include "ui/views/window/dialog_delegate.h" | 18 #include "ui/views/window/dialog_delegate.h" |
| 18 | 19 |
| 19 namespace views { | 20 namespace views { |
| 20 | 21 |
| 21 // Base class for tests. Also acts as the dialog delegate and contents view for | 22 // Base class for tests. Also acts as the dialog delegate and contents view for |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 // OK button should now match the bigger, cancel button. | 383 // OK button should now match the bigger, cancel button. |
| 383 EXPECT_EQ(cancel_button_width, client_view()->ok_button()->width()); | 384 EXPECT_EQ(cancel_button_width, client_view()->ok_button()->width()); |
| 384 | 385 |
| 385 // But not under non-MD. | 386 // But not under non-MD. |
| 386 md_test_api.SetSecondaryUiMaterial(false); | 387 md_test_api.SetSecondaryUiMaterial(false); |
| 387 client_view()->UpdateDialogButtons(); | 388 client_view()->UpdateDialogButtons(); |
| 388 CheckContentsIsSetToPreferredSize(); | 389 CheckContentsIsSetToPreferredSize(); |
| 389 EXPECT_EQ(ok_button_only_width, client_view()->ok_button()->width()); | 390 EXPECT_EQ(ok_button_only_width, client_view()->ok_button()->width()); |
| 390 md_test_api.SetSecondaryUiMaterial(true); | 391 md_test_api.SetSecondaryUiMaterial(true); |
| 391 | 392 |
| 392 // The extra view should also match, if it's a button. | 393 // The extra view should also match, if it's a matching button type. |
| 393 LabelButton* extra_button = new LabelButton(nullptr, base::string16()); | 394 LabelButton* extra_button = new LabelButton(nullptr, base::string16()); |
| 394 SetExtraView(extra_button); | 395 SetExtraView(extra_button); |
| 395 CheckContentsIsSetToPreferredSize(); | 396 CheckContentsIsSetToPreferredSize(); |
| 396 EXPECT_EQ(cancel_button_width, extra_button->width()); | 397 EXPECT_EQ(cancel_button_width, extra_button->width()); |
| 397 | 398 |
| 398 // Remove |extra_button| from the View hierarchy so that it can be replaced. | 399 // Remove |extra_button| from the View hierarchy so that it can be replaced. |
| 399 delete extra_button; | 400 delete extra_button; |
| 400 | 401 |
| 402 // Checkbox extends LabelButton. It should not participate in linking. |
| 403 extra_button = new Checkbox(base::string16()); |
| 404 SetExtraView(extra_button); |
| 405 CheckContentsIsSetToPreferredSize(); |
| 406 EXPECT_NE(cancel_button_width, extra_button->width()); |
| 407 |
| 408 // Remove |extra_button| from the View hierarchy so that it can be replaced. |
| 409 delete extra_button; |
| 410 |
| 401 // Non-buttons should always be sized to their preferred size. | 411 // Non-buttons should always be sized to their preferred size. |
| 402 View* boring_view = new StaticSizedView(gfx::Size(20, 20)); | 412 View* boring_view = new StaticSizedView(gfx::Size(20, 20)); |
| 403 SetExtraView(boring_view); | 413 SetExtraView(boring_view); |
| 404 CheckContentsIsSetToPreferredSize(); | 414 CheckContentsIsSetToPreferredSize(); |
| 405 EXPECT_EQ(20, boring_view->width()); | 415 EXPECT_EQ(20, boring_view->width()); |
| 406 } | 416 } |
| 407 | 417 |
| 408 } // namespace views | 418 } // namespace views |
| OLD | NEW |