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 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 944 | 944 |
| 945 // Paste should work normally. | 945 // Paste should work normally. |
| 946 EXPECT_TRUE(textfield_->IsCommandIdEnabled(IDS_APP_PASTE)); | 946 EXPECT_TRUE(textfield_->IsCommandIdEnabled(IDS_APP_PASTE)); |
| 947 textfield_->ExecuteCommand(IDS_APP_PASTE, 0); | 947 textfield_->ExecuteCommand(IDS_APP_PASTE, 0); |
| 948 SendKeyEvent(ui::VKEY_V, false, true); | 948 SendKeyEvent(ui::VKEY_V, false, true); |
| 949 SendAlternatePaste(); | 949 SendAlternatePaste(); |
| 950 EXPECT_STR_EQ("foo", GetClipboardText(ui::CLIPBOARD_TYPE_COPY_PASTE)); | 950 EXPECT_STR_EQ("foo", GetClipboardText(ui::CLIPBOARD_TYPE_COPY_PASTE)); |
| 951 EXPECT_STR_EQ("foofoofoo", textfield_->text()); | 951 EXPECT_STR_EQ("foofoofoo", textfield_->text()); |
| 952 } | 952 } |
| 953 | 953 |
| 954 // Check that text insertion works appropriately for password and read-only | |
| 955 // textfields. | |
| 956 TEST_F(TextfieldTest, TextInputType_InsertionTest) { | |
| 957 InitTextfield(); | |
| 958 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | |
| 959 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, textfield_->GetTextInputType()); | |
| 960 | |
| 961 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.
| |
| 962 SendKeyEvent(0x05E1); | |
| 963 SendKeyEvent('b'); | |
| 964 | |
| 965 EXPECT_EQ(WideToUTF16(L"a\x05E1" | |
| 966 L"b"), | |
| 967 textfield_->text()); | |
| 968 | |
| 969 textfield_->SetReadOnly(true); | |
| 970 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, textfield_->GetTextInputType()); | |
| 971 SendKeyEvent('c'); | |
| 972 | |
| 973 // No text should be inserted for read only textfields. | |
| 974 EXPECT_EQ(WideToUTF16(L"a\x05E1" | |
| 975 L"b"), | |
| 976 textfield_->text()); | |
| 977 } | |
| 978 | |
| 954 TEST_F(TextfieldTest, TextInputType) { | 979 TEST_F(TextfieldTest, TextInputType) { |
| 955 InitTextfield(); | 980 InitTextfield(); |
| 956 | 981 |
| 957 // Defaults to TEXT | 982 // Defaults to TEXT |
| 958 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, textfield_->GetTextInputType()); | 983 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, textfield_->GetTextInputType()); |
| 959 | 984 |
| 960 // And can be set. | 985 // And can be set. |
| 961 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_URL); | 986 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_URL); |
| 962 EXPECT_EQ(ui::TEXT_INPUT_TYPE_URL, textfield_->GetTextInputType()); | 987 EXPECT_EQ(ui::TEXT_INPUT_TYPE_URL, textfield_->GetTextInputType()); |
| 963 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | 988 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
| (...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2670 | 2695 |
| 2671 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | 2696 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
| 2672 ui::AXViewState state_protected; | 2697 ui::AXViewState state_protected; |
| 2673 textfield_->GetAccessibleState(&state_protected); | 2698 textfield_->GetAccessibleState(&state_protected); |
| 2674 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); | 2699 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); |
| 2675 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); | 2700 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); |
| 2676 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); | 2701 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); |
| 2677 } | 2702 } |
| 2678 | 2703 |
| 2679 } // namespace views | 2704 } // namespace views |
| OLD | NEW |