Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Unified Diff: ui/views/window/dialog_client_view_unittest.cc

Issue 2807653002: Ensure default dialog button focus remains after a dialog update. (Closed)
Patch Set: Addressing comments. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..996b423e595e010e2bafc22a4c158078a3c70f79 100644
--- a/ui/views/window/dialog_client_view_unittest.cc
+++ b/ui/views/window/dialog_client_view_unittest.cc
@@ -405,4 +405,29 @@ TEST_F(DialogClientViewTest, LinkedWidths) {
EXPECT_EQ(20, boring_view->width());
}
+// Ensures that the focus of the button remains after a dialog update.
+TEST_F(DialogClientViewTest, FocusUpdate) {
+ // Test with just an ok button.
+ 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.
+ 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
« ui/views/window/dialog_client_view.cc ('K') | « ui/views/window/dialog_client_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698