| 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 // Ensures that the focus of the button remains after a dialog update. |
| 409 TEST_F(DialogClientViewTest, FocusUpdate) { |
| 410 // Test with just an ok button. |
| 411 SetDialogButtons(ui::DIALOG_BUTTON_OK); |
| 412 EXPECT_FALSE(client_view()->ok_button()->HasFocus()); |
| 413 client_view()->ok_button()->RequestFocus(); // Set focus. |
| 414 EXPECT_TRUE(client_view()->ok_button()->HasFocus()); |
| 415 client_view()->UpdateDialogButtons(); |
| 416 EXPECT_TRUE(client_view()->ok_button()->HasFocus()); |
| 417 } |
| 418 |
| 419 // Ensures that the focus of the button remains after a dialog update that |
| 420 // contains multiple buttons. |
| 421 TEST_F(DialogClientViewTest, FocusMultipleButtons) { |
| 422 // Test with ok and cancel buttons. |
| 423 SetDialogButtons(ui::DIALOG_BUTTON_CANCEL | ui::DIALOG_BUTTON_OK); |
| 424 EXPECT_FALSE(client_view()->ok_button()->HasFocus()); |
| 425 EXPECT_FALSE(client_view()->cancel_button()->HasFocus()); |
| 426 client_view()->cancel_button()->RequestFocus(); // Set focus. |
| 427 EXPECT_FALSE(client_view()->ok_button()->HasFocus()); |
| 428 EXPECT_TRUE(client_view()->cancel_button()->HasFocus()); |
| 429 client_view()->UpdateDialogButtons(); |
| 430 EXPECT_TRUE(client_view()->cancel_button()->HasFocus()); |
| 431 } |
| 432 |
| 408 } // namespace views | 433 } // namespace views |
| OLD | NEW |