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" | |
39 #include "ui/gfx/render_text.h" | 40 #include "ui/gfx/render_text.h" |
40 #include "ui/strings/grit/ui_strings.h" | 41 #include "ui/strings/grit/ui_strings.h" |
41 #include "ui/views/controls/textfield/textfield_controller.h" | 42 #include "ui/views/controls/textfield/textfield_controller.h" |
42 #include "ui/views/controls/textfield/textfield_model.h" | 43 #include "ui/views/controls/textfield/textfield_model.h" |
43 #include "ui/views/controls/textfield/textfield_test_api.h" | 44 #include "ui/views/controls/textfield/textfield_test_api.h" |
44 #include "ui/views/focus/focus_manager.h" | 45 #include "ui/views/focus/focus_manager.h" |
45 #include "ui/views/style/platform_style.h" | 46 #include "ui/views/style/platform_style.h" |
46 #include "ui/views/test/test_views_delegate.h" | 47 #include "ui/views/test/test_views_delegate.h" |
47 #include "ui/views/test/views_test_base.h" | 48 #include "ui/views/test/views_test_base.h" |
48 #include "ui/views/test/widget_test.h" | 49 #include "ui/views/test/widget_test.h" |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
758 SendKeyEvent(ui::VKEY_1, false, true, false, true); | 759 SendKeyEvent(ui::VKEY_1, false, true, false, true); |
759 SendKeyEvent(ui::VKEY_1, false, false, false, true); | 760 SendKeyEvent(ui::VKEY_1, false, false, false, true); |
760 | 761 |
761 // On Mac, Caps+Shift remains uppercase. | 762 // On Mac, Caps+Shift remains uppercase. |
762 if (TestingNativeMac()) | 763 if (TestingNativeMac()) |
763 EXPECT_STR_EQ("TeXT!1!1", textfield_->text()); | 764 EXPECT_STR_EQ("TeXT!1!1", textfield_->text()); |
764 else | 765 else |
765 EXPECT_STR_EQ("TexT!1!1", textfield_->text()); | 766 EXPECT_STR_EQ("TexT!1!1", textfield_->text()); |
766 } | 767 } |
767 | 768 |
768 TEST_F(TextfieldTest, KeysWithModifiersTest) { | 769 #if defined(OS_WIN) || defined(OS_MACOSX) |
770 #define MAYBE_KeysWithModifiersTest KeysWithModifiersTest | |
771 #else | |
772 // TODO(crbug.com/633136): Test can fail with some keyboard layouts. Disable | |
773 // test for platforms where changing keyboard layout is not implemented (thus | |
774 // U.S. English layout cannot be forced). | |
Peter Kasting
2016/09/01 20:16:29
Nit: Hmm, this TODO says what's currently happenin
Tomasz Moniuszko
2016/09/08 14:44:41
I reported https://bugs.chromium.org/p/chromium/is
| |
775 #define MAYBE_KeysWithModifiersTest DISABLED_KeysWithModifiersTest | |
776 #endif | |
777 | |
778 TEST_F(TextfieldTest, MAYBE_KeysWithModifiersTest) { | |
779 // Activate U.S. English keyboard layout. Modifier keys in other layouts may | |
780 // change the text inserted into a texfield and cause this test to fail. | |
781 ui::ScopedKeyboardLayout keyboard_layout(ui::KEYBOARD_LAYOUT_ENGLISH_US); | |
782 | |
769 InitTextfield(); | 783 InitTextfield(); |
770 const int ctrl = ui::EF_CONTROL_DOWN; | 784 const int ctrl = ui::EF_CONTROL_DOWN; |
771 const int alt = ui::EF_ALT_DOWN; | 785 const int alt = ui::EF_ALT_DOWN; |
772 const int command = ui::EF_COMMAND_DOWN; | 786 const int command = ui::EF_COMMAND_DOWN; |
773 const int altgr = ui::EF_ALTGR_DOWN; | 787 const int altgr = ui::EF_ALTGR_DOWN; |
774 const int shift = ui::EF_SHIFT_DOWN; | 788 const int shift = ui::EF_SHIFT_DOWN; |
775 | 789 |
776 SendKeyPress(ui::VKEY_T, shift | alt | altgr); | 790 SendKeyPress(ui::VKEY_T, shift | alt | altgr); |
777 SendKeyPress(ui::VKEY_H, alt); | 791 SendKeyPress(ui::VKEY_H, alt); |
778 SendKeyPress(ui::VKEY_E, altgr); | 792 SendKeyPress(ui::VKEY_E, altgr); |
(...skipping 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2935 | 2949 |
2936 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | 2950 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
2937 ui::AXViewState state_protected; | 2951 ui::AXViewState state_protected; |
2938 textfield_->GetAccessibleState(&state_protected); | 2952 textfield_->GetAccessibleState(&state_protected); |
2939 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); | 2953 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); |
2940 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); | 2954 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); |
2941 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); | 2955 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); |
2942 } | 2956 } |
2943 | 2957 |
2944 } // namespace views | 2958 } // namespace views |
OLD | NEW |