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

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

Issue 2299023003: Activate comboboxes (i.e. open dropdown menu) on Enter and Space. (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « ui/views/controls/combobox/combobox.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 PerformMousePress(left_point); 619 PerformMousePress(left_point);
620 PerformMouseRelease(left_point); 620 PerformMouseRelease(left_point);
621 621
622 EXPECT_EQ(1, menu_show_count); // Unchanged. 622 EXPECT_EQ(1, menu_show_count); // Unchanged.
623 EXPECT_EQ(0, listener.perform_action_index()); 623 EXPECT_EQ(0, listener.perform_action_index());
624 } 624 }
625 625
626 TEST_F(ComboboxTest, ConsumingPressKeyEvents) { 626 TEST_F(ComboboxTest, ConsumingPressKeyEvents) {
627 InitCombobox(nullptr, Combobox::STYLE_NORMAL); 627 InitCombobox(nullptr, Combobox::STYLE_NORMAL);
628 628
629 EXPECT_FALSE(combobox_->OnKeyPressed( 629 int menu_show_count = 0;
630 test_api_->InstallTestMenuRunner(&menu_show_count);
631 EXPECT_TRUE(combobox_->OnKeyPressed(
630 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE))); 632 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE)));
631 EXPECT_FALSE(combobox_->OnKeyPressed( 633 EXPECT_EQ(1, menu_show_count);
634 EXPECT_TRUE(combobox_->OnKeyPressed(
632 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_SPACE, ui::EF_NONE))); 635 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_SPACE, ui::EF_NONE)));
636 EXPECT_EQ(2, menu_show_count);
633 } 637 }
634 638
635 TEST_F(ComboboxTest, ConsumingKeyPressEventsActionStyle) { 639 TEST_F(ComboboxTest, ConsumingKeyPressEventsActionStyle) {
636 // When the combobox's style is STYLE_ACTION, pressing events of a space key 640 // When the combobox's style is STYLE_ACTION, pressing events of a space key
637 // or an enter key will be consumed. 641 // or an enter key will be consumed.
638 InitCombobox(nullptr, Combobox::STYLE_ACTION); 642 InitCombobox(nullptr, Combobox::STYLE_ACTION);
639 EXPECT_TRUE(combobox_->OnKeyPressed( 643 EXPECT_TRUE(combobox_->OnKeyPressed(
640 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE))); 644 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE)));
641 EXPECT_TRUE(combobox_->OnKeyPressed( 645 EXPECT_TRUE(combobox_->OnKeyPressed(
642 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_SPACE, ui::EF_NONE))); 646 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_SPACE, ui::EF_NONE)));
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(0)); 817 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(0));
814 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(1)); 818 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(1));
815 819
816 EXPECT_EQ(ASCIIToUTF16("PEANUT BUTTER"), menu_model->GetLabelAt(0)); 820 EXPECT_EQ(ASCIIToUTF16("PEANUT BUTTER"), menu_model->GetLabelAt(0));
817 EXPECT_EQ(ASCIIToUTF16("JELLY"), menu_model->GetLabelAt(1)); 821 EXPECT_EQ(ASCIIToUTF16("JELLY"), menu_model->GetLabelAt(1));
818 EXPECT_FALSE(menu_model->IsVisibleAt(0)); 822 EXPECT_FALSE(menu_model->IsVisibleAt(0));
819 EXPECT_TRUE(menu_model->IsVisibleAt(1)); 823 EXPECT_TRUE(menu_model->IsVisibleAt(1));
820 } 824 }
821 825
822 } // namespace views 826 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/combobox/combobox.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698