| 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 45abeecdbe3bf527902236758f8841cefb57b56f..f8e33e923256f478a21f9930530ebdbb459200e8 100644
|
| --- a/ui/views/controls/textfield/textfield_unittest.cc
|
| +++ b/ui/views/controls/textfield/textfield_unittest.cc
|
| @@ -253,6 +253,7 @@ void MockInputMethod::ClearComposition() {
|
| }
|
|
|
| // A Textfield wrapper to intercept OnKey[Pressed|Released]() ressults.
|
| +// After user event, the textfield sets cursor_enabled in RenderText to true.
|
| class TestTextfield : public views::Textfield {
|
| public:
|
| TestTextfield()
|
| @@ -396,6 +397,7 @@ class TextfieldTest : public ViewsTestBase, public TextfieldController {
|
| }
|
|
|
| void OnAfterUserAction(Textfield* sender) override {
|
| + textfield_->SetCursorEnabled(true);
|
| ++on_after_user_action_;
|
| }
|
|
|
| @@ -3112,7 +3114,7 @@ TEST_F(TextfieldTest, AccessiblePasswordTest) {
|
| EXPECT_TRUE(node_data_protected.HasStateFlag(ui::AX_STATE_PROTECTED));
|
| }
|
|
|
| -// Test if the cursor visibility is controlled by |cursor_enabled_| in
|
| +// Verifies if the cursor visibility is controlled by |cursor_enabled_| in
|
| // RenderText.
|
| TEST_F(TextfieldTest, CursorVisibility) {
|
| InitTextfield();
|
| @@ -3129,4 +3131,38 @@ TEST_F(TextfieldTest, CursorVisibility) {
|
| EXPECT_TRUE(test_api_->IsCursorVisible());
|
| }
|
|
|
| +// Verifies if the cursor visibility is changed to true from false after insert
|
| +// charactor in textfield.
|
| +TEST_F(TextfieldTest, CursorVisibilityChangeAfterInserting) {
|
| + InitTextfield();
|
| +
|
| + test_api_->GetRenderText()->SetCursorEnabled(false);
|
| + textfield_->OnBlur();
|
| + textfield_->OnFocus();
|
| + EXPECT_FALSE(test_api_->IsCursorVisible());
|
| + SendKeyEvent('a');
|
| + EXPECT_TRUE(test_api_->IsCursorVisible());
|
| +
|
| + SetClipboardText(ui::CLIPBOARD_TYPE_COPY_PASTE, "abc");
|
| + textfield_->SetText(base::string16());
|
| + SendKeyEvent(ui::VKEY_V, false, true);
|
| + EXPECT_STR_EQ("abc", textfield_->text());
|
| + EXPECT_TRUE(test_api_->IsCursorVisible());
|
| +}
|
| +
|
| +// Verifies if the cursor visibility is changed to true from false after paste
|
| +// some text to the textfield.
|
| +TEST_F(TextfieldTest, CursorVisibilityChangeAfterPaste) {
|
| + InitTextfield();
|
| +
|
| + test_api_->GetRenderText()->SetCursorEnabled(false);
|
| + textfield_->OnBlur();
|
| + textfield_->OnFocus();
|
| + SetClipboardText(ui::CLIPBOARD_TYPE_COPY_PASTE, "abc");
|
| + textfield_->SetText(base::string16());
|
| + SendKeyEvent(ui::VKEY_V, false, true);
|
| + EXPECT_STR_EQ("abc", textfield_->text());
|
| + EXPECT_TRUE(test_api_->IsCursorVisible());
|
| +}
|
| +
|
| } // namespace views
|
|
|