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

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

Issue 1690133003: DialogClientView: Correct the order in which subviews are focused. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 4 years, 10 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
« no previous file with comments | « ui/views/window/dialog_client_view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b264793d232c29dd3956877aedaca37263c320d1..751b21ce5793b7e20133462b5806d16714c6aa22 100644
--- a/ui/views/window/dialog_client_view_unittest.cc
+++ b/ui/views/window/dialog_client_view_unittest.cc
@@ -176,6 +176,45 @@ TEST_F(DialogClientViewTest, RemoveAndUpdateButtons) {
EXPECT_FALSE(client_view()->cancel_button()->is_default());
}
+// Test that views inside the dialog client view have the correct focus order.
+TEST_F(DialogClientViewTest, SetupFocusChain) {
+#if defined(OS_WIN) || defined(OS_CHROMEOS)
+ const bool kIsOkButtonOnLeftSide = true;
+#else
+ const bool kIsOkButtonOnLeftSide = false;
+#endif
+
+ // Initially the dialog client view only contains the content view.
+ EXPECT_EQ(nullptr, client_view()->GetContentsView()->GetNextFocusableView());
+
+ // Add OK and cancel buttons.
+ SetDialogButtons(ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL);
+
+ if (kIsOkButtonOnLeftSide) {
+ EXPECT_EQ(client_view()->ok_button(),
+ client_view()->GetContentsView()->GetNextFocusableView());
+ EXPECT_EQ(client_view()->cancel_button(),
+ client_view()->ok_button()->GetNextFocusableView());
+ EXPECT_EQ(nullptr, client_view()->cancel_button()->GetNextFocusableView());
+ } else {
+ EXPECT_EQ(client_view()->cancel_button(),
+ client_view()->GetContentsView()->GetNextFocusableView());
+ EXPECT_EQ(client_view()->ok_button(),
+ client_view()->cancel_button()->GetNextFocusableView());
+ EXPECT_EQ(nullptr, client_view()->ok_button()->GetNextFocusableView());
+ }
+
+ // Add extra view and remove OK button.
+ View* extra_view = new StaticSizedView(gfx::Size(200, 200));
+ SetExtraView(extra_view);
+ SetDialogButtons(ui::DIALOG_BUTTON_CANCEL);
+
+ EXPECT_EQ(extra_view,
+ client_view()->GetContentsView()->GetNextFocusableView());
+ EXPECT_EQ(client_view()->cancel_button(), extra_view->GetNextFocusableView());
+ EXPECT_EQ(nullptr, client_view()->cancel_button()->GetNextFocusableView());
+}
+
// Test that the contents view gets its preferred size in the basic dialog
// configuration.
TEST_F(DialogClientViewTest, ContentsSize) {
« no previous file with comments | « 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