Chromium Code Reviews| Index: ui/views/controls/textfield/textfield_unittest.cc |
| diff --git a/ui/views/controls/textfield/textfield_unittest.cc b/ui/views/controls/textfield/textfield_unittest.cc |
| index 03c8e580bf48f8e1387d10c588a320bbabae80f5..1236c9575d7843b52f7f33eabec61f3b14d73560 100644 |
| --- a/ui/views/controls/textfield/textfield_unittest.cc |
| +++ b/ui/views/controls/textfield/textfield_unittest.cc |
| @@ -951,6 +951,31 @@ TEST_F(TextfieldTest, PasswordTest) { |
| EXPECT_STR_EQ("foofoofoo", textfield_->text()); |
| } |
| +// Check that text insertion works appropriately for password and read-only |
| +// textfields. |
| +TEST_F(TextfieldTest, TextInputType_InsertionTest) { |
| + InitTextfield(); |
| + textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
| + EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, textfield_->GetTextInputType()); |
| + |
| + SendKeyEvent('a'); |
|
msw
2016/06/29 17:26:40
Use ui::VKEY_A here, etc. below for 'b' and 'c' (v
karandeepb
2016/06/30 06:03:24
Done.
|
| + SendKeyEvent(0x05E1); |
| + SendKeyEvent('b'); |
| + |
| + EXPECT_EQ(WideToUTF16(L"a\x05E1" |
| + L"b"), |
| + textfield_->text()); |
| + |
| + textfield_->SetReadOnly(true); |
| + EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, textfield_->GetTextInputType()); |
| + SendKeyEvent('c'); |
| + |
| + // No text should be inserted for read only textfields. |
| + EXPECT_EQ(WideToUTF16(L"a\x05E1" |
| + L"b"), |
| + textfield_->text()); |
| +} |
| + |
| TEST_F(TextfieldTest, TextInputType) { |
| InitTextfield(); |