| 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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 // paste action did not change the content. So |new_contents| may match | 389 // paste action did not change the content. So |new_contents| may match |
| 390 // |last_contents_|. For more info, see http://crbug.com/79002 | 390 // |last_contents_|. For more info, see http://crbug.com/79002 |
| 391 last_contents_ = new_contents; | 391 last_contents_ = new_contents; |
| 392 } | 392 } |
| 393 | 393 |
| 394 void OnBeforeUserAction(Textfield* sender) override { | 394 void OnBeforeUserAction(Textfield* sender) override { |
| 395 ++on_before_user_action_; | 395 ++on_before_user_action_; |
| 396 } | 396 } |
| 397 | 397 |
| 398 void OnAfterUserAction(Textfield* sender) override { | 398 void OnAfterUserAction(Textfield* sender) override { |
| 399 textfield_->SetCursorEnabled(true); |
| 399 ++on_after_user_action_; | 400 ++on_after_user_action_; |
| 400 } | 401 } |
| 401 | 402 |
| 402 void OnAfterCutOrCopy(ui::ClipboardType clipboard_type) override { | 403 void OnAfterCutOrCopy(ui::ClipboardType clipboard_type) override { |
| 403 copied_to_clipboard_ = clipboard_type; | 404 copied_to_clipboard_ = clipboard_type; |
| 404 } | 405 } |
| 405 | 406 |
| 406 void InitTextfield() { | 407 void InitTextfield() { |
| 407 InitTextfields(1); | 408 InitTextfields(1); |
| 408 } | 409 } |
| (...skipping 2696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3105 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | 3106 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
| 3106 ui::AXNodeData node_data_protected; | 3107 ui::AXNodeData node_data_protected; |
| 3107 node_data_protected.state = 0; | 3108 node_data_protected.state = 0; |
| 3108 textfield_->GetAccessibleNodeData(&node_data_protected); | 3109 textfield_->GetAccessibleNodeData(&node_data_protected); |
| 3109 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, node_data_protected.role); | 3110 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, node_data_protected.role); |
| 3110 EXPECT_EQ(ASCIIToUTF16("********"), | 3111 EXPECT_EQ(ASCIIToUTF16("********"), |
| 3111 node_data_protected.GetString16Attribute(ui::AX_ATTR_VALUE)); | 3112 node_data_protected.GetString16Attribute(ui::AX_ATTR_VALUE)); |
| 3112 EXPECT_TRUE(node_data_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); | 3113 EXPECT_TRUE(node_data_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); |
| 3113 } | 3114 } |
| 3114 | 3115 |
| 3115 // Test if the cursor visibility is controlled by |cursor_enabled_| in | 3116 // Verifies if the cursor visibility is controlled by |cursor_enabled_| in |
| 3116 // RenderText. | 3117 // RenderText. |
| 3117 TEST_F(TextfieldTest, CursorVisibility) { | 3118 TEST_F(TextfieldTest, CursorVisibility) { |
| 3118 InitTextfield(); | 3119 InitTextfield(); |
| 3119 gfx::RenderText* render_text = test_api_->GetRenderText(); | 3120 gfx::RenderText* render_text = test_api_->GetRenderText(); |
| 3120 | 3121 |
| 3121 render_text->SetCursorEnabled(false); | 3122 render_text->SetCursorEnabled(false); |
| 3122 textfield_->OnBlur(); | 3123 textfield_->OnBlur(); |
| 3123 textfield_->OnFocus(); | 3124 textfield_->OnFocus(); |
| 3124 EXPECT_FALSE(test_api_->IsCursorVisible()); | 3125 EXPECT_FALSE(test_api_->IsCursorVisible()); |
| 3125 | 3126 |
| 3126 render_text->SetCursorEnabled(true); | 3127 render_text->SetCursorEnabled(true); |
| 3127 textfield_->OnBlur(); | 3128 textfield_->OnBlur(); |
| 3128 textfield_->OnFocus(); | 3129 textfield_->OnFocus(); |
| 3129 EXPECT_TRUE(test_api_->IsCursorVisible()); | 3130 EXPECT_TRUE(test_api_->IsCursorVisible()); |
| 3130 } | 3131 } |
| 3131 | 3132 |
| 3133 // Verifies if the cursor visibility is changed to true from false after insert |
| 3134 // charactor in textfield. |
| 3135 TEST_F(TextfieldTest, CursorVisibilityChangeAfterInserting) { |
| 3136 InitTextfield(); |
| 3137 |
| 3138 test_api_->GetRenderText()->SetCursorEnabled(false); |
| 3139 textfield_->OnBlur(); |
| 3140 textfield_->OnFocus(); |
| 3141 EXPECT_FALSE(test_api_->IsCursorVisible()); |
| 3142 SendKeyEvent('a'); |
| 3143 EXPECT_TRUE(test_api_->IsCursorVisible()); |
| 3144 } |
| 3145 |
| 3132 } // namespace views | 3146 } // namespace views |
| OLD | NEW |