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

Side by Side Diff: ui/views/controls/combobox/combobox_unittest.cc

Issue 2944083004: MacViews a11y: Support the "Show menu" action in Textfield and Combobox. (Closed)
Patch Set: respond to comments Created 3 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/controls/combobox/combobox.h" 5 #include "ui/views/controls/combobox/combobox.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "ui/accessibility/ax_action_data.h"
12 #include "ui/base/ime/input_method.h" 13 #include "ui/base/ime/input_method.h"
13 #include "ui/base/ime/text_input_client.h" 14 #include "ui/base/ime/text_input_client.h"
14 #include "ui/base/models/combobox_model.h" 15 #include "ui/base/models/combobox_model.h"
15 #include "ui/base/models/menu_model.h" 16 #include "ui/base/models/menu_model.h"
16 #include "ui/events/event.h" 17 #include "ui/events/event.h"
17 #include "ui/events/event_constants.h" 18 #include "ui/events/event_constants.h"
18 #include "ui/events/event_utils.h" 19 #include "ui/events/event_utils.h"
19 #include "ui/events/keycodes/dom/dom_code.h" 20 #include "ui/events/keycodes/dom/dom_code.h"
20 #include "ui/events/keycodes/keyboard_codes.h" 21 #include "ui/events/keycodes/keyboard_codes.h"
21 #include "ui/events/test/event_generator.h" 22 #include "ui/events/test/event_generator.h"
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 // With STYLE_NORMAL, the click event is ignored. Instead the menu is shwon. 636 // With STYLE_NORMAL, the click event is ignored. Instead the menu is shwon.
636 PressKey(ui::VKEY_SPACE); 637 PressKey(ui::VKEY_SPACE);
637 EXPECT_EQ(1, menu_show_count_); 638 EXPECT_EQ(1, menu_show_count_);
638 EXPECT_FALSE(listener.on_perform_action_called()); 639 EXPECT_FALSE(listener.on_perform_action_called());
639 640
640 ReleaseKey(ui::VKEY_SPACE); 641 ReleaseKey(ui::VKEY_SPACE);
641 EXPECT_EQ(1, menu_show_count_); 642 EXPECT_EQ(1, menu_show_count_);
642 EXPECT_FALSE(listener.on_perform_action_called()); 643 EXPECT_FALSE(listener.on_perform_action_called());
643 } 644 }
644 645
646 // Test that accessibility action events show the combobox dropdown.
647 TEST_F(ComboboxTest, ShowViaAccessibleAction) {
648 InitCombobox(nullptr, Combobox::STYLE_NORMAL);
649
650 ui::AXActionData data;
651 data.action = ui::AX_ACTION_DO_DEFAULT;
652
653 EXPECT_EQ(0, menu_show_count_);
654 combobox_->HandleAccessibleAction(data);
655 EXPECT_EQ(1, menu_show_count_);
656
657 // AX_ACTION_SHOW_CONTEXT_MENU is specifically for a context menu (e.g. right-
658 // click). Combobox should ignore it.
659 data.action = ui::AX_ACTION_SHOW_CONTEXT_MENU;
660 combobox_->HandleAccessibleAction(data);
661 EXPECT_EQ(1, menu_show_count_); // No change.
662
663 data.action = ui::AX_ACTION_BLUR;
664 combobox_->HandleAccessibleAction(data);
665 EXPECT_EQ(1, menu_show_count_); // No change.
666
667 combobox_->SetEnabled(false);
668 combobox_->HandleAccessibleAction(data);
669 EXPECT_EQ(1, menu_show_count_); // No change.
670
671 data.action = ui::AX_ACTION_BLUR;
msw 2017/06/30 15:40:07 Change this to data.action = ui::AX_ACTION_DO_DEFA
tapted 2017/07/03 04:12:23 Done.
672 combobox_->HandleAccessibleAction(data);
673 EXPECT_EQ(1, menu_show_count_); // No change.
674 }
675
645 TEST_F(ComboboxTest, NotifyOnClickWithSpaceKeyActionStyle) { 676 TEST_F(ComboboxTest, NotifyOnClickWithSpaceKeyActionStyle) {
646 InitCombobox(nullptr, Combobox::STYLE_ACTION); 677 InitCombobox(nullptr, Combobox::STYLE_ACTION);
647 678
648 TestComboboxListener listener; 679 TestComboboxListener listener;
649 combobox_->set_listener(&listener); 680 combobox_->set_listener(&listener);
650 681
651 // With STYLE_ACTION, the click event is notified after releasing and the menu 682 // With STYLE_ACTION, the click event is notified after releasing and the menu
652 // is not shown. On Mac, the menu should be shown. 683 // is not shown. On Mac, the menu should be shown.
653 PressKey(ui::VKEY_SPACE); 684 PressKey(ui::VKEY_SPACE);
654 #if defined(OS_MACOSX) 685 #if defined(OS_MACOSX)
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(0)); 947 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(0));
917 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(1)); 948 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(1));
918 949
919 EXPECT_EQ(ASCIIToUTF16("PEANUT BUTTER"), menu_model->GetLabelAt(0)); 950 EXPECT_EQ(ASCIIToUTF16("PEANUT BUTTER"), menu_model->GetLabelAt(0));
920 EXPECT_EQ(ASCIIToUTF16("JELLY"), menu_model->GetLabelAt(1)); 951 EXPECT_EQ(ASCIIToUTF16("JELLY"), menu_model->GetLabelAt(1));
921 EXPECT_FALSE(menu_model->IsVisibleAt(0)); 952 EXPECT_FALSE(menu_model->IsVisibleAt(0));
922 EXPECT_TRUE(menu_model->IsVisibleAt(1)); 953 EXPECT_TRUE(menu_model->IsVisibleAt(1));
923 } 954 }
924 955
925 } // namespace views 956 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/combobox/combobox.cc ('k') | ui/views/controls/menu/menu_runner_impl_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698