Chromium Code Reviews| 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 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 763 SendKeyEvent(ui::VKEY_1, false, false, false, true); | 764 SendKeyEvent(ui::VKEY_1, false, false, false, true); |
| 764 | 765 |
| 765 // On Mac, Caps+Shift remains uppercase. | 766 // On Mac, Caps+Shift remains uppercase. |
| 766 if (TestingNativeMac()) | 767 if (TestingNativeMac()) |
| 767 EXPECT_STR_EQ("TeXT!1!1", textfield_->text()); | 768 EXPECT_STR_EQ("TeXT!1!1", textfield_->text()); |
| 768 else | 769 else |
| 769 EXPECT_STR_EQ("TexT!1!1", textfield_->text()); | 770 EXPECT_STR_EQ("TexT!1!1", textfield_->text()); |
| 770 } | 771 } |
| 771 | 772 |
| 772 TEST_F(TextfieldTest, KeysWithModifiersTest) { | 773 TEST_F(TextfieldTest, KeysWithModifiersTest) { |
| 774 #if defined(OS_WIN) || defined(OS_MACOSX) | |
| 775 // Activate U.S. English keyboard layout. Modifier keys in other layouts may | |
| 776 // change the text inserted into a texfield and cause this test to fail. | |
| 777 ui::ScopedKeyboardLayout keyboard_layout(ui::KEYBOARD_LAYOUT_ENGLISH_US); | |
| 778 #else | |
| 779 // TODO(crbug.com/633136): Switch keyboard layout on other platforms. | |
|
Peter Kasting
2016/08/26 18:54:33
Does this mean that for now, the test is potential
Tomasz Moniuszko
2016/08/31 15:29:42
Test fails only on machines with keyboard layouts
Peter Kasting
2016/08/31 21:16:15
I don't know that that answers my question. I rea
| |
| 780 #endif | |
| 781 | |
| 773 InitTextfield(); | 782 InitTextfield(); |
| 774 const int ctrl = ui::EF_CONTROL_DOWN; | 783 const int ctrl = ui::EF_CONTROL_DOWN; |
| 775 const int alt = ui::EF_ALT_DOWN; | 784 const int alt = ui::EF_ALT_DOWN; |
| 776 const int command = ui::EF_COMMAND_DOWN; | 785 const int command = ui::EF_COMMAND_DOWN; |
| 777 const int altgr = ui::EF_ALTGR_DOWN; | 786 const int altgr = ui::EF_ALTGR_DOWN; |
| 778 const int shift = ui::EF_SHIFT_DOWN; | 787 const int shift = ui::EF_SHIFT_DOWN; |
| 779 | 788 |
| 780 SendKeyPress(ui::VKEY_T, shift | alt | altgr); | 789 SendKeyPress(ui::VKEY_T, shift | alt | altgr); |
| 781 SendKeyPress(ui::VKEY_H, alt); | 790 SendKeyPress(ui::VKEY_H, alt); |
| 782 SendKeyPress(ui::VKEY_E, altgr); | 791 SendKeyPress(ui::VKEY_E, altgr); |
| (...skipping 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2939 | 2948 |
| 2940 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | 2949 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
| 2941 ui::AXViewState state_protected; | 2950 ui::AXViewState state_protected; |
| 2942 textfield_->GetAccessibleState(&state_protected); | 2951 textfield_->GetAccessibleState(&state_protected); |
| 2943 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); | 2952 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); |
| 2944 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); | 2953 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); |
| 2945 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); | 2954 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); |
| 2946 } | 2955 } |
| 2947 | 2956 |
| 2948 } // namespace views | 2957 } // namespace views |
| OLD | NEW |