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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/window/dialog_client_view.h" 5 #include "ui/views/window/dialog_client_view.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "ui/base/test/material_design_controller_test_api.h" 10 #include "ui/base/test/material_design_controller_test_api.h"
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 // Remove |extra_button| from the View hierarchy so that it can be replaced. 398 // Remove |extra_button| from the View hierarchy so that it can be replaced.
399 delete extra_button; 399 delete extra_button;
400 400
401 // Non-buttons should always be sized to their preferred size. 401 // Non-buttons should always be sized to their preferred size.
402 View* boring_view = new StaticSizedView(gfx::Size(20, 20)); 402 View* boring_view = new StaticSizedView(gfx::Size(20, 20));
403 SetExtraView(boring_view); 403 SetExtraView(boring_view);
404 CheckContentsIsSetToPreferredSize(); 404 CheckContentsIsSetToPreferredSize();
405 EXPECT_EQ(20, boring_view->width()); 405 EXPECT_EQ(20, boring_view->width());
406 } 406 }
407 407
408 // Ensures that the focus of the button remains after a dialog update.
409 TEST_F(DialogClientViewTest, FocusUpdate) {
410 // Test with just an ok button.
411 SetDialogButtons(ui::DIALOG_BUTTON_OK);
412 EXPECT_FALSE(client_view()->ok_button()->HasFocus());
413 client_view()->ok_button()->RequestFocus(); // Set focus.
414 EXPECT_TRUE(client_view()->ok_button()->HasFocus());
415 client_view()->UpdateDialogButtons();
416 EXPECT_TRUE(client_view()->ok_button()->HasFocus());
417 }
418
419 // Ensures that the focus of the button remains after a dialog update that
420 // contains multiple buttons.
421 TEST_F(DialogClientViewTest, FocusMultipleButtons) {
422 // Test with ok and cancel buttons.
423 SetDialogButtons(ui::DIALOG_BUTTON_CANCEL | ui::DIALOG_BUTTON_OK);
424 EXPECT_FALSE(client_view()->ok_button()->HasFocus());
425 EXPECT_FALSE(client_view()->cancel_button()->HasFocus());
426 client_view()->cancel_button()->RequestFocus(); // Set focus.
427 EXPECT_FALSE(client_view()->ok_button()->HasFocus());
428 EXPECT_TRUE(client_view()->cancel_button()->HasFocus());
429 client_view()->UpdateDialogButtons();
430 EXPECT_TRUE(client_view()->cancel_button()->HasFocus());
431 }
432
408 } // namespace views 433 } // namespace views
OLDNEW
« 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