| 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 245 |
| 246 bool MockInputMethod::HasComposition() { | 246 bool MockInputMethod::HasComposition() { |
| 247 return composition_.text.length() || result_text_.length(); | 247 return composition_.text.length() || result_text_.length(); |
| 248 } | 248 } |
| 249 | 249 |
| 250 void MockInputMethod::ClearComposition() { | 250 void MockInputMethod::ClearComposition() { |
| 251 composition_.Clear(); | 251 composition_.Clear(); |
| 252 result_text_.clear(); | 252 result_text_.clear(); |
| 253 } | 253 } |
| 254 | 254 |
| 255 // A Textfield wrapper to intercept OnKey[Pressed|Released]() ressults. | 255 // A Textfield wrapper to intercept OnKey[Pressed|Released]() results. |
| 256 class TestTextfield : public views::Textfield { | 256 class TestTextfield : public views::Textfield { |
| 257 public: | 257 public: |
| 258 TestTextfield() | 258 TestTextfield() |
| 259 : Textfield(), | 259 : Textfield(), |
| 260 key_handled_(false), | 260 key_handled_(false), |
| 261 key_received_(false), | 261 key_received_(false), |
| 262 weak_ptr_factory_(this) {} | 262 weak_ptr_factory_(this) {} |
| 263 | 263 |
| 264 // ui::TextInputClient overrides: | 264 // ui::TextInputClient overrides: |
| 265 void InsertChar(const ui::KeyEvent& e) override { | 265 void InsertChar(const ui::KeyEvent& e) override { |
| (...skipping 2839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3105 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | 3105 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
| 3106 ui::AXNodeData node_data_protected; | 3106 ui::AXNodeData node_data_protected; |
| 3107 node_data_protected.state = 0; | 3107 node_data_protected.state = 0; |
| 3108 textfield_->GetAccessibleNodeData(&node_data_protected); | 3108 textfield_->GetAccessibleNodeData(&node_data_protected); |
| 3109 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, node_data_protected.role); | 3109 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, node_data_protected.role); |
| 3110 EXPECT_EQ(ASCIIToUTF16("********"), | 3110 EXPECT_EQ(ASCIIToUTF16("********"), |
| 3111 node_data_protected.GetString16Attribute(ui::AX_ATTR_VALUE)); | 3111 node_data_protected.GetString16Attribute(ui::AX_ATTR_VALUE)); |
| 3112 EXPECT_TRUE(node_data_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); | 3112 EXPECT_TRUE(node_data_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); |
| 3113 } | 3113 } |
| 3114 | 3114 |
| 3115 // Test if the cursor visibility is controlled by |cursor_enabled_| in | 3115 // Verify that cursor visibility is controlled by SetCursorEnabled. |
| 3116 // RenderText. | |
| 3117 TEST_F(TextfieldTest, CursorVisibility) { | 3116 TEST_F(TextfieldTest, CursorVisibility) { |
| 3118 InitTextfield(); | 3117 InitTextfield(); |
| 3119 gfx::RenderText* render_text = test_api_->GetRenderText(); | |
| 3120 | 3118 |
| 3121 render_text->SetCursorEnabled(false); | 3119 textfield_->SetCursorEnabled(false); |
| 3122 textfield_->OnBlur(); | |
| 3123 textfield_->OnFocus(); | |
| 3124 EXPECT_FALSE(test_api_->IsCursorVisible()); | 3120 EXPECT_FALSE(test_api_->IsCursorVisible()); |
| 3125 | 3121 |
| 3126 render_text->SetCursorEnabled(true); | 3122 textfield_->SetCursorEnabled(true); |
| 3127 textfield_->OnBlur(); | |
| 3128 textfield_->OnFocus(); | |
| 3129 EXPECT_TRUE(test_api_->IsCursorVisible()); | 3123 EXPECT_TRUE(test_api_->IsCursorVisible()); |
| 3130 } | 3124 } |
| 3131 | 3125 |
| 3132 } // namespace views | 3126 } // namespace views |
| OLD | NEW |