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" |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 | 690 |
691 TEST_F(ComboboxTest, TypingPrefixNotifiesListener) { | 691 TEST_F(ComboboxTest, TypingPrefixNotifiesListener) { |
692 InitCombobox(NULL); | 692 InitCombobox(NULL); |
693 | 693 |
694 TestComboboxListener listener; | 694 TestComboboxListener listener; |
695 combobox_->set_listener(&listener); | 695 combobox_->set_listener(&listener); |
696 ui::TextInputClient* input_client = | 696 ui::TextInputClient* input_client = |
697 widget_->GetInputMethod()->GetTextInputClient(); | 697 widget_->GetInputMethod()->GetTextInputClient(); |
698 | 698 |
699 // Type the first character of the second menu item ("JELLY"). | 699 // Type the first character of the second menu item ("JELLY"). |
700 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_J, ui::DomCode::KEY_J, 0, | 700 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_J, ui::DomCode::US_J, 0, |
701 ui::DomKey::FromCharacter('J'), ui::EventTimeForNow()); | 701 ui::DomKey::FromCharacter('J'), ui::EventTimeForNow()); |
702 | 702 |
703 input_client->InsertChar(key_event); | 703 input_client->InsertChar(key_event); |
704 EXPECT_EQ(1, listener.actions_performed()); | 704 EXPECT_EQ(1, listener.actions_performed()); |
705 EXPECT_EQ(1, listener.perform_action_index()); | 705 EXPECT_EQ(1, listener.perform_action_index()); |
706 | 706 |
707 // Type the second character of "JELLY", item shouldn't change and | 707 // Type the second character of "JELLY", item shouldn't change and |
708 // OnPerformAction() shouldn't be re-called. | 708 // OnPerformAction() shouldn't be re-called. |
709 key_event = | 709 key_event = |
710 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_E, ui::DomCode::KEY_E, 0, | 710 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_E, ui::DomCode::US_E, 0, |
711 ui::DomKey::FromCharacter('E'), ui::EventTimeForNow()); | 711 ui::DomKey::FromCharacter('E'), ui::EventTimeForNow()); |
712 input_client->InsertChar(key_event); | 712 input_client->InsertChar(key_event); |
713 EXPECT_EQ(1, listener.actions_performed()); | 713 EXPECT_EQ(1, listener.actions_performed()); |
714 EXPECT_EQ(1, listener.perform_action_index()); | 714 EXPECT_EQ(1, listener.perform_action_index()); |
715 | 715 |
716 // Clears the typed text. | 716 // Clears the typed text. |
717 combobox_->OnBlur(); | 717 combobox_->OnBlur(); |
718 combobox_->RequestFocus(); | 718 combobox_->RequestFocus(); |
719 | 719 |
720 // Type the first character of "PEANUT BUTTER", which should change the | 720 // Type the first character of "PEANUT BUTTER", which should change the |
721 // selected index and perform an action. | 721 // selected index and perform an action. |
722 key_event = | 722 key_event = |
723 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_E, ui::DomCode::KEY_P, 0, | 723 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_E, ui::DomCode::US_P, 0, |
724 ui::DomKey::FromCharacter('P'), ui::EventTimeForNow()); | 724 ui::DomKey::FromCharacter('P'), ui::EventTimeForNow()); |
725 input_client->InsertChar(key_event); | 725 input_client->InsertChar(key_event); |
726 EXPECT_EQ(2, listener.actions_performed()); | 726 EXPECT_EQ(2, listener.actions_performed()); |
727 EXPECT_EQ(2, listener.perform_action_index()); | 727 EXPECT_EQ(2, listener.perform_action_index()); |
728 } | 728 } |
729 | 729 |
730 // Test properties on the Combobox menu model. | 730 // Test properties on the Combobox menu model. |
731 TEST_F(ComboboxTest, MenuModel) { | 731 TEST_F(ComboboxTest, MenuModel) { |
732 const int kSeparatorIndex = 3; | 732 const int kSeparatorIndex = 3; |
733 std::set<int> separators; | 733 std::set<int> separators; |
(...skipping 25 matching lines...) Expand all Loading... |
759 EXPECT_EQ(ASCIIToUTF16("JELLY"), menu_model->GetLabelAt(1)); | 759 EXPECT_EQ(ASCIIToUTF16("JELLY"), menu_model->GetLabelAt(1)); |
760 | 760 |
761 // Check that with STYLE_ACTION, the first item (only) is not shown. | 761 // Check that with STYLE_ACTION, the first item (only) is not shown. |
762 EXPECT_TRUE(menu_model->IsVisibleAt(0)); | 762 EXPECT_TRUE(menu_model->IsVisibleAt(0)); |
763 combobox_->SetStyle(Combobox::STYLE_ACTION); | 763 combobox_->SetStyle(Combobox::STYLE_ACTION); |
764 EXPECT_FALSE(menu_model->IsVisibleAt(0)); | 764 EXPECT_FALSE(menu_model->IsVisibleAt(0)); |
765 EXPECT_TRUE(menu_model->IsVisibleAt(1)); | 765 EXPECT_TRUE(menu_model->IsVisibleAt(1)); |
766 } | 766 } |
767 | 767 |
768 } // namespace views | 768 } // namespace views |
OLD | NEW |