Chromium Code Reviews| Index: ui/views/window/dialog_client_view_unittest.cc |
| diff --git a/ui/views/window/dialog_client_view_unittest.cc b/ui/views/window/dialog_client_view_unittest.cc |
| index a8d3d8d79c222a876312009c96f65ee9328bfbb9..077233688a8a9963896cdd737091e603898117c7 100644 |
| --- a/ui/views/window/dialog_client_view_unittest.cc |
| +++ b/ui/views/window/dialog_client_view_unittest.cc |
| @@ -405,4 +405,33 @@ TEST_F(DialogClientViewTest, LinkedWidths) { |
| EXPECT_EQ(20, boring_view->width()); |
| } |
| +// Tests that the default focus of the button reamins after a dialog update. |
|
sky
2017/04/28 20:49:52
Just to be clear, does these tests fail without yo
ackermanb
2017/05/17 17:20:54
Yep, the tests do fail out without the patch.
|
| +TEST_F(DialogClientViewTest, DefaultFocus) { |
| + // Test with just an ok button. |
| + SetDialogButtons(ui::DIALOG_BUTTON_OK); |
| + EXPECT_EQ(client_view()->ok_button(), GetInitiallyFocusedView()); |
| + GetInitiallyFocusedView()->RequestFocus(); // Focus is not given by default. |
| + EXPECT_TRUE(client_view()->ok_button()->HasFocus()); |
| + client_view()->UpdateDialogButtons(); |
| + EXPECT_TRUE(client_view()->ok_button()->HasFocus()); |
| + |
| + // Test with just a cancel button. |
| + SetDialogButtons(ui::DIALOG_BUTTON_CANCEL); |
| + EXPECT_EQ(client_view()->cancel_button(), GetInitiallyFocusedView()); |
| + GetInitiallyFocusedView()->RequestFocus(); // Focus is not given by default. |
| + EXPECT_TRUE(client_view()->cancel_button()->HasFocus()); |
| + client_view()->UpdateDialogButtons(); |
| + EXPECT_TRUE(client_view()->cancel_button()->HasFocus()); |
| + |
| + // Test with both buttons, the ok button is default. |
| + SetDialogButtons(ui::DIALOG_BUTTON_CANCEL | ui::DIALOG_BUTTON_OK); |
| + EXPECT_EQ(client_view()->ok_button(), GetInitiallyFocusedView()); |
| + GetInitiallyFocusedView()->RequestFocus(); // Focus is not given by default. |
| + EXPECT_TRUE(client_view()->ok_button()->HasFocus()); |
| + EXPECT_FALSE(client_view()->cancel_button()->HasFocus()); |
| + client_view()->UpdateDialogButtons(); |
| + EXPECT_TRUE(client_view()->ok_button()->HasFocus()); |
| + EXPECT_FALSE(client_view()->cancel_button()->HasFocus()); |
| +} |
| + |
| } // namespace views |