| 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 bb8ec3647fdd6cf49ca65a1934b3cc2727ab9e95..3d933752f6a8a31467bfcf9a9cb069c0bac4e1ae 100644
|
| --- a/ui/views/window/dialog_client_view_unittest.cc
|
| +++ b/ui/views/window/dialog_client_view_unittest.cc
|
| @@ -141,6 +141,8 @@ class DialogClientViewTest : public test::WidgetTest,
|
|
|
| DialogClientView* client_view() { return client_view_; }
|
|
|
| + Widget* widget() { return widget_; }
|
| +
|
| private:
|
| // The dialog Widget.
|
| Widget* widget_ = nullptr;
|
| @@ -436,4 +438,31 @@ TEST_F(DialogClientViewTest, ButtonPosition) {
|
| height() + client_view()->ok_button()->y());
|
| }
|
|
|
| +// Ensures that the focus of the button remains after a dialog update.
|
| +TEST_F(DialogClientViewTest, FocusUpdate) {
|
| + // Test with just an ok button.
|
| + widget()->Show();
|
| + SetDialogButtons(ui::DIALOG_BUTTON_OK);
|
| + EXPECT_FALSE(client_view()->ok_button()->HasFocus());
|
| + client_view()->ok_button()->RequestFocus(); // Set focus.
|
| + EXPECT_TRUE(client_view()->ok_button()->HasFocus());
|
| + client_view()->UpdateDialogButtons();
|
| + EXPECT_TRUE(client_view()->ok_button()->HasFocus());
|
| +}
|
| +
|
| +// Ensures that the focus of the button remains after a dialog update that
|
| +// contains multiple buttons.
|
| +TEST_F(DialogClientViewTest, FocusMultipleButtons) {
|
| + // Test with ok and cancel buttons.
|
| + widget()->Show();
|
| + SetDialogButtons(ui::DIALOG_BUTTON_CANCEL | ui::DIALOG_BUTTON_OK);
|
| + EXPECT_FALSE(client_view()->ok_button()->HasFocus());
|
| + EXPECT_FALSE(client_view()->cancel_button()->HasFocus());
|
| + client_view()->cancel_button()->RequestFocus(); // Set focus.
|
| + EXPECT_FALSE(client_view()->ok_button()->HasFocus());
|
| + EXPECT_TRUE(client_view()->cancel_button()->HasFocus());
|
| + client_view()->UpdateDialogButtons();
|
| + EXPECT_TRUE(client_view()->cancel_button()->HasFocus());
|
| +}
|
| +
|
| } // namespace views
|
|
|