Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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_); | |
|
msw
2017/06/29 19:26:12
nit: test handling the action while the menu is sh
tapted
2017/06/30 06:04:47
doing this requires an interactive_ui_test (menus
| |
| 656 | |
| 657 combobox_->SetEnabled(false); | |
| 658 combobox_->HandleAccessibleAction(data); | |
| 659 EXPECT_EQ(1, menu_show_count_); // No change. | |
| 660 | |
| 661 data.action = ui::AX_ACTION_BLUR; | |
|
msw
2017/06/29 19:26:12
Should this also test AX_ACTION_SHOW_CONTEXT_MENU,
tapted
2017/06/30 06:04:47
AX_ACTION_SHOW_CONTEXT_MENU was actually tested in
| |
| 662 combobox_->HandleAccessibleAction(data); | |
|
msw
2017/06/29 19:26:12
Maybe test other actions, like blur, before disabl
tapted
2017/06/30 06:04:47
Done.
| |
| 663 EXPECT_EQ(1, menu_show_count_); // No change. | |
| 664 } | |
| 665 | |
| 645 TEST_F(ComboboxTest, NotifyOnClickWithSpaceKeyActionStyle) { | 666 TEST_F(ComboboxTest, NotifyOnClickWithSpaceKeyActionStyle) { |
| 646 InitCombobox(nullptr, Combobox::STYLE_ACTION); | 667 InitCombobox(nullptr, Combobox::STYLE_ACTION); |
| 647 | 668 |
| 648 TestComboboxListener listener; | 669 TestComboboxListener listener; |
| 649 combobox_->set_listener(&listener); | 670 combobox_->set_listener(&listener); |
| 650 | 671 |
| 651 // With STYLE_ACTION, the click event is notified after releasing and the menu | 672 // With STYLE_ACTION, the click event is notified after releasing and the menu |
| 652 // is not shown. On Mac, the menu should be shown. | 673 // is not shown. On Mac, the menu should be shown. |
| 653 PressKey(ui::VKEY_SPACE); | 674 PressKey(ui::VKEY_SPACE); |
| 654 #if defined(OS_MACOSX) | 675 #if defined(OS_MACOSX) |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 916 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(0)); | 937 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(0)); |
| 917 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(1)); | 938 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(1)); |
| 918 | 939 |
| 919 EXPECT_EQ(ASCIIToUTF16("PEANUT BUTTER"), menu_model->GetLabelAt(0)); | 940 EXPECT_EQ(ASCIIToUTF16("PEANUT BUTTER"), menu_model->GetLabelAt(0)); |
| 920 EXPECT_EQ(ASCIIToUTF16("JELLY"), menu_model->GetLabelAt(1)); | 941 EXPECT_EQ(ASCIIToUTF16("JELLY"), menu_model->GetLabelAt(1)); |
| 921 EXPECT_FALSE(menu_model->IsVisibleAt(0)); | 942 EXPECT_FALSE(menu_model->IsVisibleAt(0)); |
| 922 EXPECT_TRUE(menu_model->IsVisibleAt(1)); | 943 EXPECT_TRUE(menu_model->IsVisibleAt(1)); |
| 923 } | 944 } |
| 924 | 945 |
| 925 } // namespace views | 946 } // namespace views |
| OLD | NEW |