OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/textfield/textfield.h" | 5 #include "ui/views/controls/textfield/textfield.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "ui/base/ime/input_method_factory.h" | 29 #include "ui/base/ime/input_method_factory.h" |
30 #include "ui/base/ime/text_edit_commands.h" | 30 #include "ui/base/ime/text_edit_commands.h" |
31 #include "ui/base/ime/text_input_client.h" | 31 #include "ui/base/ime/text_input_client.h" |
32 #include "ui/base/ui_base_switches.h" | 32 #include "ui/base/ui_base_switches.h" |
33 #include "ui/base/ui_base_switches_util.h" | 33 #include "ui/base/ui_base_switches_util.h" |
34 #include "ui/events/event.h" | 34 #include "ui/events/event.h" |
35 #include "ui/events/event_processor.h" | 35 #include "ui/events/event_processor.h" |
36 #include "ui/events/event_utils.h" | 36 #include "ui/events/event_utils.h" |
37 #include "ui/events/keycodes/keyboard_codes.h" | 37 #include "ui/events/keycodes/keyboard_codes.h" |
38 #include "ui/events/test/event_generator.h" | 38 #include "ui/events/test/event_generator.h" |
39 #include "ui/events/test/keyboard_layout.h" | |
40 #include "ui/gfx/render_text.h" | 39 #include "ui/gfx/render_text.h" |
41 #include "ui/strings/grit/ui_strings.h" | 40 #include "ui/strings/grit/ui_strings.h" |
42 #include "ui/views/controls/textfield/textfield_controller.h" | 41 #include "ui/views/controls/textfield/textfield_controller.h" |
43 #include "ui/views/controls/textfield/textfield_model.h" | 42 #include "ui/views/controls/textfield/textfield_model.h" |
44 #include "ui/views/controls/textfield/textfield_test_api.h" | 43 #include "ui/views/controls/textfield/textfield_test_api.h" |
45 #include "ui/views/focus/focus_manager.h" | 44 #include "ui/views/focus/focus_manager.h" |
46 #include "ui/views/style/platform_style.h" | 45 #include "ui/views/style/platform_style.h" |
47 #include "ui/views/test/test_views_delegate.h" | 46 #include "ui/views/test/test_views_delegate.h" |
48 #include "ui/views/test/views_test_base.h" | 47 #include "ui/views/test/views_test_base.h" |
49 #include "ui/views/test/widget_test.h" | 48 #include "ui/views/test/widget_test.h" |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 SendKeyEvent(ui::VKEY_1, false, true, false, true); | 752 SendKeyEvent(ui::VKEY_1, false, true, false, true); |
754 SendKeyEvent(ui::VKEY_1, false, false, false, true); | 753 SendKeyEvent(ui::VKEY_1, false, false, false, true); |
755 | 754 |
756 // On Mac, Caps+Shift remains uppercase. | 755 // On Mac, Caps+Shift remains uppercase. |
757 if (TestingNativeMac()) | 756 if (TestingNativeMac()) |
758 EXPECT_STR_EQ("TeXT!1!1", textfield_->text()); | 757 EXPECT_STR_EQ("TeXT!1!1", textfield_->text()); |
759 else | 758 else |
760 EXPECT_STR_EQ("TexT!1!1", textfield_->text()); | 759 EXPECT_STR_EQ("TexT!1!1", textfield_->text()); |
761 } | 760 } |
762 | 761 |
763 #if defined(OS_WIN) || defined(OS_MACOSX) | 762 TEST_F(TextfieldTest, KeysWithModifiersTest) { |
764 #define MAYBE_KeysWithModifiersTest KeysWithModifiersTest | |
765 #else | |
766 // TODO(crbug.com/645104): Implement keyboard layout changing for other | |
767 // platforms. | |
768 #define MAYBE_KeysWithModifiersTest DISABLED_KeysWithModifiersTest | |
769 #endif | |
770 | |
771 TEST_F(TextfieldTest, MAYBE_KeysWithModifiersTest) { | |
772 // Activate U.S. English keyboard layout. Modifier keys in other layouts may | |
773 // change the text inserted into a texfield and cause this test to fail. | |
774 ui::ScopedKeyboardLayout keyboard_layout(ui::KEYBOARD_LAYOUT_ENGLISH_US); | |
775 | |
776 InitTextfield(); | 763 InitTextfield(); |
777 const int ctrl = ui::EF_CONTROL_DOWN; | 764 const int ctrl = ui::EF_CONTROL_DOWN; |
778 const int alt = ui::EF_ALT_DOWN; | 765 const int alt = ui::EF_ALT_DOWN; |
779 const int command = ui::EF_COMMAND_DOWN; | 766 const int command = ui::EF_COMMAND_DOWN; |
780 const int altgr = ui::EF_ALTGR_DOWN; | 767 const int altgr = ui::EF_ALTGR_DOWN; |
781 const int shift = ui::EF_SHIFT_DOWN; | 768 const int shift = ui::EF_SHIFT_DOWN; |
782 | 769 |
783 SendKeyPress(ui::VKEY_T, shift | alt | altgr); | 770 SendKeyPress(ui::VKEY_T, shift | alt | altgr); |
784 SendKeyPress(ui::VKEY_H, alt); | 771 SendKeyPress(ui::VKEY_H, alt); |
785 SendKeyPress(ui::VKEY_E, altgr); | 772 SendKeyPress(ui::VKEY_E, altgr); |
(...skipping 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2942 | 2929 |
2943 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | 2930 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
2944 ui::AXViewState state_protected; | 2931 ui::AXViewState state_protected; |
2945 textfield_->GetAccessibleState(&state_protected); | 2932 textfield_->GetAccessibleState(&state_protected); |
2946 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); | 2933 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); |
2947 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); | 2934 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); |
2948 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); | 2935 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); |
2949 } | 2936 } |
2950 | 2937 |
2951 } // namespace views | 2938 } // namespace views |
OLD | NEW |