Chromium Code Reviews| Index: ui/views/window/dialog_delegate_unittest.cc |
| diff --git a/ui/views/window/dialog_delegate_unittest.cc b/ui/views/window/dialog_delegate_unittest.cc |
| index 648175d8d23eb5dca090e03ed87a97c4d3fa4972..dee804dfdf8cf29561bbf7458b08785f44cd1509 100644 |
| --- a/ui/views/window/dialog_delegate_unittest.cc |
| +++ b/ui/views/window/dialog_delegate_unittest.cc |
| @@ -7,6 +7,7 @@ |
| #include "base/macros.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "ui/base/hit_test.h" |
| +#include "ui/base/test/scoped_fake_full_keyboard_access.h" |
|
tapted
2017/01/12 15:30:50
This should be between #if defined(OS_MACOSX)
Patti Lor
2017/01/13 04:19:02
Done.
|
| #include "ui/events/event_processor.h" |
| #include "ui/views/bubble/bubble_border.h" |
| #include "ui/views/bubble/bubble_frame_view.h" |
| @@ -271,4 +272,35 @@ TEST_F(DialogTest, InitialFocus) { |
| EXPECT_EQ(dialog()->input(), dialog()->GetFocusManager()->GetFocusedView()); |
| } |
| +// If the initially focused View provided is unfocusable, check the next |
| +// available focusable View is focused. |
| +TEST_F(DialogTest, UnfocusableInitialFocus) { |
| +#if defined(OS_MACOSX) |
| + // On Mac, make all buttons unfocusable by turning off full keyboard access. |
|
tapted
2017/01/12 15:30:51
add "This is the more common configuration, and if
Patti Lor
2017/01/13 04:19:02
Done.
|
| + ui::test::ScopedFakeFullKeyboardAccess::GetInstance() |
| + ->set_full_keyboard_access_state(false); |
| +#endif |
| + |
| + DialogDelegateView* dialog = new DialogDelegateView(); |
| + Textfield* textfield = new Textfield(); |
| + dialog->AddChildView(textfield); |
| + Widget* dialog_widget = |
| + DialogDelegate::CreateDialogWidget(dialog, GetContext(), nullptr); |
| + |
| +#if !defined(OS_MACOSX) |
| + // For non-Mac, turn off focusability on all the dialog's buttons manually. |
|
tapted
2017/01/12 15:30:51
add "This achieves the same effect as disabling fu
Patti Lor
2017/01/13 04:19:02
Done.
|
| + DialogClientView* dcv = dialog->GetDialogClientView(); |
| + dcv->ok_button()->SetFocusBehavior(View::FocusBehavior::NEVER); |
| + dcv->cancel_button()->SetFocusBehavior(View::FocusBehavior::NEVER); |
| +#endif |
| + |
| + // On showing the dialog, the initially focused View will be the OK button. |
| + // Since it is no longer focusable, focus should advance to the next focusable |
| + // View, which is |textfield|. |
| + dialog_widget->Show(); |
| + EXPECT_TRUE(textfield->HasFocus()); |
| + EXPECT_EQ(textfield, dialog->GetFocusManager()->GetFocusedView()); |
| + dialog_widget->Close(); |
| +} |
| + |
| } // namespace views |