Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: views/controls/textfield/native_textfield_views_unittest.cc

Issue 6675005: Integrate the new input method API for Views into Chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/auto_reset.h" 5 #include "base/auto_reset.h"
6 #include "base/bind.h"
7 #include "base/bind_helpers.h"
8 #include "base/callback.h"
6 #include "base/message_loop.h" 9 #include "base/message_loop.h"
7 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/base/clipboard/clipboard.h" 12 #include "ui/base/clipboard/clipboard.h"
10 #include "ui/base/clipboard/scoped_clipboard_writer.h" 13 #include "ui/base/clipboard/scoped_clipboard_writer.h"
11 #include "ui/base/keycodes/keyboard_codes.h" 14 #include "ui/base/keycodes/keyboard_codes.h"
12 #include "views/controls/menu/menu_2.h" 15 #include "views/controls/menu/menu_2.h"
13 #include "views/controls/textfield/native_textfield_views.h" 16 #include "views/controls/textfield/native_textfield_views.h"
14 #include "views/controls/textfield/textfield.h" 17 #include "views/controls/textfield/textfield.h"
15 #include "views/controls/textfield/textfield_controller.h" 18 #include "views/controls/textfield/textfield_controller.h"
16 #include "views/controls/textfield/textfield_views_model.h" 19 #include "views/controls/textfield/textfield_views_model.h"
17 #include "views/events/event.h" 20 #include "views/events/event.h"
18 #include "views/focus/focus_manager.h" 21 #include "views/focus/focus_manager.h"
22 #include "views/ime/mock_input_method.h"
23 #include "views/ime/text_input_client.h"
19 #include "views/test/test_views_delegate.h" 24 #include "views/test/test_views_delegate.h"
20 #include "views/test/views_test_base.h" 25 #include "views/test/views_test_base.h"
21 #include "views/views_delegate.h" 26 #include "views/views_delegate.h"
27 #include "views/widget/native_widget.h"
22 #include "views/widget/widget.h" 28 #include "views/widget/widget.h"
23 29
30 namespace {
31
32 // A wrapper of Textfield to intercept the result of OnKeyPressed() and
33 // OnKeyReleased() methods.
34 class TestTextfield : public views::Textfield {
35 public:
36 TestTextfield()
37 : key_handled_(false),
38 key_received_(false) {
39 }
40
41 explicit TestTextfield(StyleFlags style)
42 : Textfield(style),
43 key_handled_(false),
44 key_received_(false) {
45 }
46
47 virtual bool OnKeyPressed(const views::KeyEvent& e) OVERRIDE {
48 key_received_ = true;
49 key_handled_ = views::Textfield::OnKeyPressed(e);
50 return key_handled_;
51 }
52
53 virtual bool OnKeyReleased(const views::KeyEvent& e) OVERRIDE {
54 key_received_ = true;
55 key_handled_ = views::Textfield::OnKeyReleased(e);
56 return key_handled_;
57 }
58
59 bool key_handled() const { return key_handled_; }
60 bool key_received() const { return key_received_; }
61
62 void clear() {
63 key_received_ = key_handled_ = false;
64 }
65
66 private:
67 bool key_handled_;
68 bool key_received_;
oshima 2011/03/22 01:50:39 DISALLOW_COPY_AND_ASSIGN
James Su 2011/03/22 08:41:14 Done.
69 };
70
71 // A helper class for use with TextInputClient::GetTextFromRange().
72 class GetTextHelper {
73 public:
74 GetTextHelper() {
75 }
76
77 void set_text(const string16& text) { text_ = text; }
78 const string16& text() const { return text_; }
79
80 private:
81 string16 text_;
oshima 2011/03/22 01:50:39 DISALLOW_COPY_AND_ASSIGN
James Su 2011/03/22 08:41:14 Done.
82 };
83
84 } // namespace
85
24 namespace views { 86 namespace views {
25 87
26 // Convert to Wide so that the printed string will be readable when 88 // Convert to Wide so that the printed string will be readable when
27 // check fails. 89 // check fails.
28 #define EXPECT_STR_EQ(ascii, utf16) \ 90 #define EXPECT_STR_EQ(ascii, utf16) \
29 EXPECT_EQ(ASCIIToWide(ascii), UTF16ToWide(utf16)) 91 EXPECT_EQ(ASCIIToWide(ascii), UTF16ToWide(utf16))
30 #define EXPECT_STR_NE(ascii, utf16) \ 92 #define EXPECT_STR_NE(ascii, utf16) \
31 EXPECT_NE(ASCIIToWide(ascii), UTF16ToWide(utf16)) 93 EXPECT_NE(ASCIIToWide(ascii), UTF16ToWide(utf16))
32 94
33 // TODO(oshima): Move tests that are independent of TextfieldViews to 95 // TODO(oshima): Move tests that are independent of TextfieldViews to
34 // textfield_unittests.cc once we move the test utility functions 96 // textfield_unittests.cc once we move the test utility functions
35 // from chrome/browser/automation/ to app/test/. 97 // from chrome/browser/automation/ to app/test/.
36 class NativeTextfieldViewsTest : public ViewsTestBase, 98 class NativeTextfieldViewsTest : public ViewsTestBase,
37 public TextfieldController { 99 public TextfieldController {
38 public: 100 public:
39 NativeTextfieldViewsTest() 101 NativeTextfieldViewsTest()
40 : widget_(NULL), 102 : widget_(NULL),
41 textfield_(NULL), 103 textfield_(NULL),
42 textfield_view_(NULL), 104 textfield_view_(NULL),
43 model_(NULL) { 105 model_(NULL),
106 input_method_(NULL),
107 on_before_user_action_(0),
108 on_after_user_action_(0) {
44 } 109 }
45 110
46 // ::testing::Test: 111 // ::testing::Test:
47 virtual void SetUp() { 112 virtual void SetUp() {
48 NativeTextfieldViews::SetEnableTextfieldViews(true); 113 NativeTextfieldViews::SetEnableTextfieldViews(true);
49 } 114 }
50 115
51 virtual void TearDown() { 116 virtual void TearDown() {
52 NativeTextfieldViews::SetEnableTextfieldViews(false); 117 NativeTextfieldViews::SetEnableTextfieldViews(false);
53 if (widget_) 118 if (widget_)
54 widget_->Close(); 119 widget_->Close();
55 ViewsTestBase::TearDown(); 120 ViewsTestBase::TearDown();
56 } 121 }
57 122
58 // TextfieldController: 123 // TextfieldController:
59 virtual void ContentsChanged(Textfield* sender, 124 virtual void ContentsChanged(Textfield* sender,
60 const string16& new_contents){ 125 const string16& new_contents) {
126 ASSERT_NE(last_contents_, new_contents);
61 last_contents_ = new_contents; 127 last_contents_ = new_contents;
62 } 128 }
63 129
64 virtual bool HandleKeyEvent(Textfield* sender, 130 virtual bool HandleKeyEvent(Textfield* sender,
65 const KeyEvent& key_event) { 131 const KeyEvent& key_event) {
66 132
67 // TODO(oshima): figure out how to test the keystroke. 133 // TODO(oshima): figure out how to test the keystroke.
68 return false; 134 return false;
69 } 135 }
70 136
137 virtual void OnBeforeUserAction(Textfield* sender) {
138 ++on_before_user_action_;
139 }
140
141 virtual void OnAfterUserAction(Textfield* sender) {
142 ++on_after_user_action_;
143 }
144
71 void InitTextfield(Textfield::StyleFlags style) { 145 void InitTextfield(Textfield::StyleFlags style) {
72 InitTextfields(style, 1); 146 InitTextfields(style, 1);
73 } 147 }
74 148
75 void InitTextfields(Textfield::StyleFlags style, int count) { 149 void InitTextfields(Textfield::StyleFlags style, int count) {
76 ASSERT_FALSE(textfield_); 150 ASSERT_FALSE(textfield_);
77 textfield_ = new Textfield(style); 151 textfield_ = new TestTextfield(style);
78 textfield_->SetController(this); 152 textfield_->SetController(this);
79 widget_ = Widget::CreatePopupWidget( 153 widget_ = Widget::CreatePopupWidget(
80 Widget::NotTransparent, 154 Widget::NotTransparent,
81 Widget::AcceptEvents, 155 Widget::AcceptEvents,
82 Widget::DeleteOnDestroy, 156 Widget::DeleteOnDestroy,
83 Widget::DontMirrorOriginInRTL); 157 Widget::DontMirrorOriginInRTL);
84 widget_->Init(NULL, gfx::Rect(100, 100, 100, 100)); 158 widget_->Init(NULL, gfx::Rect(100, 100, 100, 100));
85 View* container = new View(); 159 View* container = new View();
86 widget_->SetContentsView(container); 160 widget_->SetContentsView(container);
87 container->AddChildView(textfield_); 161 container->AddChildView(textfield_);
88 162
89 textfield_view_ 163 textfield_view_
90 = static_cast<NativeTextfieldViews*>(textfield_->native_wrapper()); 164 = static_cast<NativeTextfieldViews*>(textfield_->native_wrapper());
91 textfield_->SetID(1); 165 textfield_->SetID(1);
92 166
93 for (int i = 1; i < count; i++) { 167 for (int i = 1; i < count; i++) {
94 Textfield* textfield = new Textfield(style); 168 Textfield* textfield = new Textfield(style);
95 container->AddChildView(textfield); 169 container->AddChildView(textfield);
96 textfield->SetID(i + 1); 170 textfield->SetID(i + 1);
97 } 171 }
98 172
99 DCHECK(textfield_view_); 173 DCHECK(textfield_view_);
100 model_ = textfield_view_->model_.get(); 174 model_ = textfield_view_->model_.get();
175
176 input_method_ = new MockInputMethod();
177 widget_->native_widget()->ReplaceInputMethod(input_method_);
178
179 textfield_->RequestFocus();
101 } 180 }
102 181
103 views::Menu2* GetContextMenu() { 182 views::Menu2* GetContextMenu() {
104 textfield_view_->InitContextMenuIfRequired(); 183 textfield_view_->InitContextMenuIfRequired();
105 return textfield_view_->context_menu_menu_.get(); 184 return textfield_view_->context_menu_menu_.get();
106 } 185 }
107 186
108 NativeTextfieldViews::ClickState GetClickState() { 187 NativeTextfieldViews::ClickState GetClickState() {
109 return textfield_view_->click_state_; 188 return textfield_view_->click_state_;
110 } 189 }
111 190
112 protected: 191 protected:
113 bool SendKeyEventToTextfieldViews(ui::KeyboardCode key_code, 192 void SendKeyEvent(ui::KeyboardCode key_code,
114 bool shift, 193 bool shift,
115 bool control, 194 bool control,
116 bool capslock) { 195 bool capslock) {
117 int flags = (shift ? ui::EF_SHIFT_DOWN : 0) | 196 int flags = (shift ? ui::EF_SHIFT_DOWN : 0) |
118 (control ? ui::EF_CONTROL_DOWN : 0) | 197 (control ? ui::EF_CONTROL_DOWN : 0) |
119 (capslock ? ui::EF_CAPS_LOCK_DOWN : 0); 198 (capslock ? ui::EF_CAPS_LOCK_DOWN : 0);
120 KeyEvent event(ui::ET_KEY_PRESSED, key_code, flags); 199 KeyEvent event(ui::ET_KEY_PRESSED, key_code, flags);
121 return textfield_->OnKeyPressed(event); 200 input_method_->DispatchKeyEvent(event);
122 } 201 }
123 202
124 bool SendKeyEventToTextfieldViews(ui::KeyboardCode key_code, 203 void SendKeyEvent(ui::KeyboardCode key_code, bool shift, bool control) {
125 bool shift, 204 SendKeyEvent(key_code, shift, control, false);
126 bool control) {
127 return SendKeyEventToTextfieldViews(key_code, shift, control, false);
128 } 205 }
129 206
130 bool SendKeyEventToTextfieldViews(ui::KeyboardCode key_code) { 207 void SendKeyEvent(ui::KeyboardCode key_code) {
131 return SendKeyEventToTextfieldViews(key_code, false, false); 208 SendKeyEvent(key_code, false, false);
132 } 209 }
133 210
134 View* GetFocusedView() { 211 View* GetFocusedView() {
135 return widget_->GetFocusManager()->GetFocusedView(); 212 return widget_->GetFocusManager()->GetFocusedView();
136 } 213 }
137 214
138 // We need widget to populate wrapper class. 215 // We need widget to populate wrapper class.
139 Widget* widget_; 216 Widget* widget_;
140 217
141 Textfield* textfield_; 218 TestTextfield* textfield_;
142 NativeTextfieldViews* textfield_view_; 219 NativeTextfieldViews* textfield_view_;
143 TextfieldViewsModel* model_; 220 TextfieldViewsModel* model_;
144 221
145 // The string from Controller::ContentsChanged callback. 222 // The string from Controller::ContentsChanged callback.
146 string16 last_contents_; 223 string16 last_contents_;
147 224
225 // For testing input method related behaviors.
226 MockInputMethod* input_method_;
227
228 // Indicates how many times OnBeforeUserAction() is called.
229 int on_before_user_action_;
230
231 // Indicates how many times OnAfterUserAction() is called.
232 int on_after_user_action_;
233
148 private: 234 private:
149 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViewsTest); 235 DISALLOW_COPY_AND_ASSIGN(NativeTextfieldViewsTest);
150 }; 236 };
151 237
152 TEST_F(NativeTextfieldViewsTest, ModelChangesTeset) { 238 TEST_F(NativeTextfieldViewsTest, ModelChangesTest) {
153 InitTextfield(Textfield::STYLE_DEFAULT); 239 InitTextfield(Textfield::STYLE_DEFAULT);
240
241 // TextfieldController::ContentsChanged() shouldn't be called when changing
242 // text programmatically.
243 last_contents_.clear();
154 textfield_->SetText(ASCIIToUTF16("this is")); 244 textfield_->SetText(ASCIIToUTF16("this is"));
155 245
156 EXPECT_STR_EQ("this is", model_->text()); 246 EXPECT_STR_EQ("this is", model_->text());
157 EXPECT_STR_EQ("this is", last_contents_); 247 EXPECT_STR_EQ("this is", textfield_->text());
158 last_contents_.clear(); 248 EXPECT_EQ(string16(), last_contents_);
159 249
160 textfield_->AppendText(ASCIIToUTF16(" a test")); 250 textfield_->AppendText(ASCIIToUTF16(" a test"));
161 EXPECT_STR_EQ("this is a test", model_->text()); 251 EXPECT_STR_EQ("this is a test", model_->text());
162 EXPECT_STR_EQ("this is a test", last_contents_); 252 EXPECT_STR_EQ("this is a test", textfield_->text());
163 last_contents_.clear();
164
165 // Cases where the callback should not be called.
166 textfield_->SetText(ASCIIToUTF16("this is a test"));
167 EXPECT_STR_EQ("this is a test", model_->text());
168 EXPECT_EQ(string16(), last_contents_);
169
170 textfield_->AppendText(string16());
171 EXPECT_STR_EQ("this is a test", model_->text());
172 EXPECT_EQ(string16(), last_contents_); 253 EXPECT_EQ(string16(), last_contents_);
173 254
174 EXPECT_EQ(string16(), textfield_->GetSelectedText()); 255 EXPECT_EQ(string16(), textfield_->GetSelectedText());
175 textfield_->SelectAll(); 256 textfield_->SelectAll();
176 EXPECT_STR_EQ("this is a test", textfield_->GetSelectedText()); 257 EXPECT_STR_EQ("this is a test", textfield_->GetSelectedText());
177 EXPECT_EQ(string16(), last_contents_); 258 EXPECT_EQ(string16(), last_contents_);
178 } 259 }
179 260
180 TEST_F(NativeTextfieldViewsTest, KeyTest) { 261 TEST_F(NativeTextfieldViewsTest, KeyTest) {
181 InitTextfield(Textfield::STYLE_DEFAULT); 262 InitTextfield(Textfield::STYLE_DEFAULT);
182 SendKeyEventToTextfieldViews(ui::VKEY_C, true, false); 263 SendKeyEvent(ui::VKEY_C, true, false);
183 EXPECT_STR_EQ("C", textfield_->text()); 264 EXPECT_STR_EQ("C", textfield_->text());
184 EXPECT_STR_EQ("C", last_contents_); 265 EXPECT_STR_EQ("C", last_contents_);
185 last_contents_.clear(); 266 last_contents_.clear();
186 267
187 SendKeyEventToTextfieldViews(ui::VKEY_R, false, false); 268 SendKeyEvent(ui::VKEY_R, false, false);
188 EXPECT_STR_EQ("Cr", textfield_->text()); 269 EXPECT_STR_EQ("Cr", textfield_->text());
189 EXPECT_STR_EQ("Cr", last_contents_); 270 EXPECT_STR_EQ("Cr", last_contents_);
190 271
191 textfield_->SetText(ASCIIToUTF16("")); 272 textfield_->SetText(ASCIIToUTF16(""));
192 SendKeyEventToTextfieldViews(ui::VKEY_C, true, false, true); 273 SendKeyEvent(ui::VKEY_C, true, false, true);
193 SendKeyEventToTextfieldViews(ui::VKEY_C, false, false, true); 274 SendKeyEvent(ui::VKEY_C, false, false, true);
194 SendKeyEventToTextfieldViews(ui::VKEY_1, false, false, true); 275 SendKeyEvent(ui::VKEY_1, false, false, true);
195 SendKeyEventToTextfieldViews(ui::VKEY_1, true, false, true); 276 SendKeyEvent(ui::VKEY_1, true, false, true);
196 SendKeyEventToTextfieldViews(ui::VKEY_1, true, false, false); 277 SendKeyEvent(ui::VKEY_1, true, false, false);
197 EXPECT_STR_EQ("cC1!!", textfield_->text()); 278 EXPECT_STR_EQ("cC1!!", textfield_->text());
198 EXPECT_STR_EQ("cC1!!", last_contents_); 279 EXPECT_STR_EQ("cC1!!", last_contents_);
199 } 280 }
200 281
201 TEST_F(NativeTextfieldViewsTest, ControlAndSelectTest) { 282 TEST_F(NativeTextfieldViewsTest, ControlAndSelectTest) {
202 // Insert a test string in a textfield. 283 // Insert a test string in a textfield.
203 InitTextfield(Textfield::STYLE_DEFAULT); 284 InitTextfield(Textfield::STYLE_DEFAULT);
204 textfield_->SetText(ASCIIToUTF16("one two three")); 285 textfield_->SetText(ASCIIToUTF16("one two three"));
205 SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, 286 SendKeyEvent(ui::VKEY_RIGHT,
206 true /* shift */, false /* control */); 287 true /* shift */, false /* control */);
207 SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, true, false); 288 SendKeyEvent(ui::VKEY_RIGHT, true, false);
208 SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, true, false); 289 SendKeyEvent(ui::VKEY_RIGHT, true, false);
209 290
210 EXPECT_STR_EQ("one", textfield_->GetSelectedText()); 291 EXPECT_STR_EQ("one", textfield_->GetSelectedText());
211 292
212 // Test word select. 293 // Test word select.
213 SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, true, true); 294 SendKeyEvent(ui::VKEY_RIGHT, true, true);
214 EXPECT_STR_EQ("one two", textfield_->GetSelectedText()); 295 EXPECT_STR_EQ("one two", textfield_->GetSelectedText());
215 SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, true, true); 296 SendKeyEvent(ui::VKEY_RIGHT, true, true);
216 EXPECT_STR_EQ("one two three", textfield_->GetSelectedText()); 297 EXPECT_STR_EQ("one two three", textfield_->GetSelectedText());
217 SendKeyEventToTextfieldViews(ui::VKEY_LEFT, true, true); 298 SendKeyEvent(ui::VKEY_LEFT, true, true);
218 EXPECT_STR_EQ("one two ", textfield_->GetSelectedText()); 299 EXPECT_STR_EQ("one two ", textfield_->GetSelectedText());
219 SendKeyEventToTextfieldViews(ui::VKEY_LEFT, true, true); 300 SendKeyEvent(ui::VKEY_LEFT, true, true);
220 EXPECT_STR_EQ("one ", textfield_->GetSelectedText()); 301 EXPECT_STR_EQ("one ", textfield_->GetSelectedText());
221 302
222 // Replace the selected text. 303 // Replace the selected text.
223 SendKeyEventToTextfieldViews(ui::VKEY_Z, true, false); 304 SendKeyEvent(ui::VKEY_Z, true, false);
224 SendKeyEventToTextfieldViews(ui::VKEY_E, true, false); 305 SendKeyEvent(ui::VKEY_E, true, false);
225 SendKeyEventToTextfieldViews(ui::VKEY_R, true, false); 306 SendKeyEvent(ui::VKEY_R, true, false);
226 SendKeyEventToTextfieldViews(ui::VKEY_O, true, false); 307 SendKeyEvent(ui::VKEY_O, true, false);
227 SendKeyEventToTextfieldViews(ui::VKEY_SPACE, false, false); 308 SendKeyEvent(ui::VKEY_SPACE, false, false);
228 EXPECT_STR_EQ("ZERO two three", textfield_->text()); 309 EXPECT_STR_EQ("ZERO two three", textfield_->text());
229 310
230 SendKeyEventToTextfieldViews(ui::VKEY_END, true, false); 311 SendKeyEvent(ui::VKEY_END, true, false);
231 EXPECT_STR_EQ("two three", textfield_->GetSelectedText()); 312 EXPECT_STR_EQ("two three", textfield_->GetSelectedText());
232 SendKeyEventToTextfieldViews(ui::VKEY_HOME, true, false); 313 SendKeyEvent(ui::VKEY_HOME, true, false);
233 EXPECT_STR_EQ("ZERO ", textfield_->GetSelectedText()); 314 EXPECT_STR_EQ("ZERO ", textfield_->GetSelectedText());
234 } 315 }
235 316
236 TEST_F(NativeTextfieldViewsTest, InsertionDeletionTest) { 317 TEST_F(NativeTextfieldViewsTest, InsertionDeletionTest) {
237 // Insert a test string in a textfield. 318 // Insert a test string in a textfield.
238 InitTextfield(Textfield::STYLE_DEFAULT); 319 InitTextfield(Textfield::STYLE_DEFAULT);
239 char test_str[] = "this is a test"; 320 char test_str[] = "this is a test";
240 for (size_t i = 0; i < sizeof(test_str); i++) { 321 for (size_t i = 0; i < sizeof(test_str); i++) {
241 // This is ugly and should be replaced by a utility standard function. 322 // This is ugly and should be replaced by a utility standard function.
242 // See comment in NativeTextfieldViews::GetPrintableChar. 323 // See comment in NativeTextfieldViews::GetPrintableChar.
243 char c = test_str[i]; 324 char c = test_str[i];
244 ui::KeyboardCode code = 325 ui::KeyboardCode code =
245 c == ' ' ? ui::VKEY_SPACE : 326 c == ' ' ? ui::VKEY_SPACE :
246 static_cast<ui::KeyboardCode>(ui::VKEY_A + c - 'a'); 327 static_cast<ui::KeyboardCode>(ui::VKEY_A + c - 'a');
247 SendKeyEventToTextfieldViews(code); 328 SendKeyEvent(code);
248 } 329 }
249 EXPECT_STR_EQ(test_str, textfield_->text()); 330 EXPECT_STR_EQ(test_str, textfield_->text());
250 331
251 // Move the cursor around. 332 // Move the cursor around.
252 for (int i = 0; i < 6; i++) { 333 for (int i = 0; i < 6; i++) {
253 SendKeyEventToTextfieldViews(ui::VKEY_LEFT); 334 SendKeyEvent(ui::VKEY_LEFT);
254 } 335 }
255 SendKeyEventToTextfieldViews(ui::VKEY_RIGHT); 336 SendKeyEvent(ui::VKEY_RIGHT);
256 337
257 // Delete using backspace and check resulting string. 338 // Delete using backspace and check resulting string.
258 SendKeyEventToTextfieldViews(ui::VKEY_BACK); 339 SendKeyEvent(ui::VKEY_BACK);
259 EXPECT_STR_EQ("this is test", textfield_->text()); 340 EXPECT_STR_EQ("this is test", textfield_->text());
260 341
261 // Delete using delete key and check resulting string. 342 // Delete using delete key and check resulting string.
262 for (int i = 0; i < 5; i++) { 343 for (int i = 0; i < 5; i++) {
263 SendKeyEventToTextfieldViews(ui::VKEY_DELETE); 344 SendKeyEvent(ui::VKEY_DELETE);
264 } 345 }
265 EXPECT_STR_EQ("this is ", textfield_->text()); 346 EXPECT_STR_EQ("this is ", textfield_->text());
266 347
267 // Select all and replace with "k". 348 // Select all and replace with "k".
268 textfield_->SelectAll(); 349 textfield_->SelectAll();
269 SendKeyEventToTextfieldViews(ui::VKEY_K); 350 SendKeyEvent(ui::VKEY_K);
270 EXPECT_STR_EQ("k", textfield_->text()); 351 EXPECT_STR_EQ("k", textfield_->text());
271 352
272 // Delete the previous word from cursor. 353 // Delete the previous word from cursor.
273 textfield_->SetText(ASCIIToUTF16("one two three four")); 354 textfield_->SetText(ASCIIToUTF16("one two three four"));
274 SendKeyEventToTextfieldViews(ui::VKEY_END); 355 SendKeyEvent(ui::VKEY_END);
275 SendKeyEventToTextfieldViews(ui::VKEY_BACK, false, true, false); 356 SendKeyEvent(ui::VKEY_BACK, false, true, false);
276 EXPECT_STR_EQ("one two three ", textfield_->text()); 357 EXPECT_STR_EQ("one two three ", textfield_->text());
277 358
278 // Delete upto the beginning of the buffer from cursor in chromeos, do nothing 359 // Delete upto the beginning of the buffer from cursor in chromeos, do nothing
279 // in windows. 360 // in windows.
280 SendKeyEventToTextfieldViews(ui::VKEY_LEFT, false, true, false); 361 SendKeyEvent(ui::VKEY_LEFT, false, true, false);
281 SendKeyEventToTextfieldViews(ui::VKEY_BACK, true, true, false); 362 SendKeyEvent(ui::VKEY_BACK, true, true, false);
282 #if defined(OS_WIN) 363 #if defined(OS_WIN)
283 EXPECT_STR_EQ("one two three ", textfield_->text()); 364 EXPECT_STR_EQ("one two three ", textfield_->text());
284 #else 365 #else
285 EXPECT_STR_EQ("three ", textfield_->text()); 366 EXPECT_STR_EQ("three ", textfield_->text());
286 #endif 367 #endif
287 368
288 // Delete the next word from cursor. 369 // Delete the next word from cursor.
289 textfield_->SetText(ASCIIToUTF16("one two three four")); 370 textfield_->SetText(ASCIIToUTF16("one two three four"));
290 SendKeyEventToTextfieldViews(ui::VKEY_HOME); 371 SendKeyEvent(ui::VKEY_HOME);
291 SendKeyEventToTextfieldViews(ui::VKEY_DELETE, false, true, false); 372 SendKeyEvent(ui::VKEY_DELETE, false, true, false);
292 EXPECT_STR_EQ(" two three four", textfield_->text()); 373 EXPECT_STR_EQ(" two three four", textfield_->text());
293 374
294 // Delete upto the end of the buffer from cursor in chromeos, do nothing 375 // Delete upto the end of the buffer from cursor in chromeos, do nothing
295 // in windows. 376 // in windows.
296 SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, false, true, false); 377 SendKeyEvent(ui::VKEY_RIGHT, false, true, false);
297 SendKeyEventToTextfieldViews(ui::VKEY_DELETE, true, true, false); 378 SendKeyEvent(ui::VKEY_DELETE, true, true, false);
298 #if defined(OS_WIN) 379 #if defined(OS_WIN)
299 EXPECT_STR_EQ(" two three four", textfield_->text()); 380 EXPECT_STR_EQ(" two three four", textfield_->text());
300 #else 381 #else
301 EXPECT_STR_EQ(" two", textfield_->text()); 382 EXPECT_STR_EQ(" two", textfield_->text());
302 #endif 383 #endif
303 } 384 }
304 385
305 TEST_F(NativeTextfieldViewsTest, PasswordTest) { 386 TEST_F(NativeTextfieldViewsTest, PasswordTest) {
306 InitTextfield(Textfield::STYLE_PASSWORD); 387 InitTextfield(Textfield::STYLE_PASSWORD);
307 textfield_->SetText(ASCIIToUTF16("my password")); 388 textfield_->SetText(ASCIIToUTF16("my password"));
308 // Just to make sure the text() and callback returns 389 // Just to make sure the text() and callback returns
309 // the actual text instead of "*". 390 // the actual text instead of "*".
310 EXPECT_STR_EQ("my password", textfield_->text()); 391 EXPECT_STR_EQ("my password", textfield_->text());
311 EXPECT_STR_EQ("my password", last_contents_);
312 } 392 }
313 393
314 TEST_F(NativeTextfieldViewsTest, OnKeyPressReturnValueTest) { 394 TEST_F(NativeTextfieldViewsTest, OnKeyPressReturnValueTest) {
315 InitTextfield(Textfield::STYLE_DEFAULT); 395 InitTextfield(Textfield::STYLE_DEFAULT);
316 EXPECT_TRUE(SendKeyEventToTextfieldViews(ui::VKEY_A)); 396
397 // Character keys will be handled by input method.
398 SendKeyEvent(ui::VKEY_A);
399 EXPECT_TRUE(textfield_->key_received());
400 EXPECT_FALSE(textfield_->key_handled());
401 textfield_->clear();
402
403 // Home will be handled.
404 SendKeyEvent(ui::VKEY_HOME);
405 EXPECT_TRUE(textfield_->key_received());
406 EXPECT_TRUE(textfield_->key_handled());
407 textfield_->clear();
408
317 // F24, up/down key won't be handled. 409 // F24, up/down key won't be handled.
318 EXPECT_FALSE(SendKeyEventToTextfieldViews(ui::VKEY_F24)); 410 SendKeyEvent(ui::VKEY_F24);
319 EXPECT_FALSE(SendKeyEventToTextfieldViews(ui::VKEY_UP)); 411 EXPECT_TRUE(textfield_->key_received());
320 EXPECT_FALSE(SendKeyEventToTextfieldViews(ui::VKEY_DOWN)); 412 EXPECT_FALSE(textfield_->key_handled());
413 textfield_->clear();
414
415 SendKeyEvent(ui::VKEY_UP);
416 EXPECT_TRUE(textfield_->key_received());
417 EXPECT_FALSE(textfield_->key_handled());
418 textfield_->clear();
419
420 SendKeyEvent(ui::VKEY_DOWN);
421 EXPECT_TRUE(textfield_->key_received());
422 EXPECT_FALSE(textfield_->key_handled());
321 } 423 }
322 424
323 TEST_F(NativeTextfieldViewsTest, CursorMovement) { 425 TEST_F(NativeTextfieldViewsTest, CursorMovement) {
324 InitTextfield(Textfield::STYLE_DEFAULT); 426 InitTextfield(Textfield::STYLE_DEFAULT);
325 427
326 // Test with trailing whitespace. 428 // Test with trailing whitespace.
327 textfield_->SetText(ASCIIToUTF16("one two hre ")); 429 textfield_->SetText(ASCIIToUTF16("one two hre "));
328 430
329 // Send the cursor at the end. 431 // Send the cursor at the end.
330 SendKeyEventToTextfieldViews(ui::VKEY_END); 432 SendKeyEvent(ui::VKEY_END);
331 433
332 // Ctrl+Left should move the cursor just before the last word. 434 // Ctrl+Left should move the cursor just before the last word.
333 SendKeyEventToTextfieldViews(ui::VKEY_LEFT, false, true); 435 SendKeyEvent(ui::VKEY_LEFT, false, true);
334 SendKeyEventToTextfieldViews(ui::VKEY_T); 436 SendKeyEvent(ui::VKEY_T);
335 EXPECT_STR_EQ("one two thre ", textfield_->text()); 437 EXPECT_STR_EQ("one two thre ", textfield_->text());
336 EXPECT_STR_EQ("one two thre ", last_contents_); 438 EXPECT_STR_EQ("one two thre ", last_contents_);
337 439
338 // Ctrl+Right should move the cursor to the end of the last word. 440 // Ctrl+Right should move the cursor to the end of the last word.
339 SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, false, true); 441 SendKeyEvent(ui::VKEY_RIGHT, false, true);
340 SendKeyEventToTextfieldViews(ui::VKEY_E); 442 SendKeyEvent(ui::VKEY_E);
341 EXPECT_STR_EQ("one two three ", textfield_->text()); 443 EXPECT_STR_EQ("one two three ", textfield_->text());
342 EXPECT_STR_EQ("one two three ", last_contents_); 444 EXPECT_STR_EQ("one two three ", last_contents_);
343 445
344 // Ctrl+Right again should move the cursor to the end. 446 // Ctrl+Right again should move the cursor to the end.
345 SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, false, true); 447 SendKeyEvent(ui::VKEY_RIGHT, false, true);
346 SendKeyEventToTextfieldViews(ui::VKEY_BACK); 448 SendKeyEvent(ui::VKEY_BACK);
347 EXPECT_STR_EQ("one two three", textfield_->text()); 449 EXPECT_STR_EQ("one two three", textfield_->text());
348 EXPECT_STR_EQ("one two three", last_contents_); 450 EXPECT_STR_EQ("one two three", last_contents_);
349 451
350 // Test with leading whitespace. 452 // Test with leading whitespace.
351 textfield_->SetText(ASCIIToUTF16(" ne two")); 453 textfield_->SetText(ASCIIToUTF16(" ne two"));
352 454
353 // Send the cursor at the beginning. 455 // Send the cursor at the beginning.
354 SendKeyEventToTextfieldViews(ui::VKEY_HOME); 456 SendKeyEvent(ui::VKEY_HOME);
355 457
356 // Ctrl+Right, then Ctrl+Left should move the cursor to the beginning of the 458 // Ctrl+Right, then Ctrl+Left should move the cursor to the beginning of the
357 // first word. 459 // first word.
358 SendKeyEventToTextfieldViews(ui::VKEY_RIGHT, false, true); 460 SendKeyEvent(ui::VKEY_RIGHT, false, true);
359 SendKeyEventToTextfieldViews(ui::VKEY_LEFT, false, true); 461 SendKeyEvent(ui::VKEY_LEFT, false, true);
360 SendKeyEventToTextfieldViews(ui::VKEY_O); 462 SendKeyEvent(ui::VKEY_O);
361 EXPECT_STR_EQ(" one two", textfield_->text()); 463 EXPECT_STR_EQ(" one two", textfield_->text());
362 EXPECT_STR_EQ(" one two", last_contents_); 464 EXPECT_STR_EQ(" one two", last_contents_);
363 465
364 // Ctrl+Left to move the cursor to the beginning of the first word. 466 // Ctrl+Left to move the cursor to the beginning of the first word.
365 SendKeyEventToTextfieldViews(ui::VKEY_LEFT, false, true); 467 SendKeyEvent(ui::VKEY_LEFT, false, true);
366 // Ctrl+Left again should move the cursor back to the very beginning. 468 // Ctrl+Left again should move the cursor back to the very beginning.
367 SendKeyEventToTextfieldViews(ui::VKEY_LEFT, false, true); 469 SendKeyEvent(ui::VKEY_LEFT, false, true);
368 SendKeyEventToTextfieldViews(ui::VKEY_DELETE); 470 SendKeyEvent(ui::VKEY_DELETE);
369 EXPECT_STR_EQ("one two", textfield_->text()); 471 EXPECT_STR_EQ("one two", textfield_->text());
370 EXPECT_STR_EQ("one two", last_contents_); 472 EXPECT_STR_EQ("one two", last_contents_);
371 } 473 }
372 474
373 #if defined(OS_WIN) 475 TEST_F(NativeTextfieldViewsTest, FocusTraversalTest) {
374 // TODO(oshima): Windows' FocusManager::ClearNativeFocus() resets the
375 // focused view to NULL, which causes crash in this test. Figure out
376 // why and fix this.
377 #define MAYBE_FocusTraversalTest DISABLED_FocusTraversalTest
378 #else
379 #define MAYBE_FocusTraversalTest FocusTraversalTest
380 #endif
381 TEST_F(NativeTextfieldViewsTest, MAYBE_FocusTraversalTest) {
382 InitTextfields(Textfield::STYLE_DEFAULT, 3); 476 InitTextfields(Textfield::STYLE_DEFAULT, 3);
383 textfield_->RequestFocus(); 477 textfield_->RequestFocus();
384 478
385 EXPECT_EQ(1, GetFocusedView()->GetID()); 479 EXPECT_EQ(1, GetFocusedView()->GetID());
386 widget_->GetFocusManager()->AdvanceFocus(false); 480 widget_->GetFocusManager()->AdvanceFocus(false);
387 EXPECT_EQ(2, GetFocusedView()->GetID()); 481 EXPECT_EQ(2, GetFocusedView()->GetID());
388 widget_->GetFocusManager()->AdvanceFocus(false); 482 widget_->GetFocusManager()->AdvanceFocus(false);
389 EXPECT_EQ(3, GetFocusedView()->GetID()); 483 EXPECT_EQ(3, GetFocusedView()->GetID());
390 // Cycle back to the first textfield. 484 // Cycle back to the first textfield.
391 widget_->GetFocusManager()->AdvanceFocus(false); 485 widget_->GetFocusManager()->AdvanceFocus(false);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 } 553 }
460 554
461 TEST_F(NativeTextfieldViewsTest, ReadOnlyTest) { 555 TEST_F(NativeTextfieldViewsTest, ReadOnlyTest) {
462 scoped_ptr<TestViewsDelegate> test_views_delegate(new TestViewsDelegate()); 556 scoped_ptr<TestViewsDelegate> test_views_delegate(new TestViewsDelegate());
463 AutoReset<views::ViewsDelegate*> auto_reset( 557 AutoReset<views::ViewsDelegate*> auto_reset(
464 &views::ViewsDelegate::views_delegate, test_views_delegate.get()); 558 &views::ViewsDelegate::views_delegate, test_views_delegate.get());
465 559
466 InitTextfield(Textfield::STYLE_DEFAULT); 560 InitTextfield(Textfield::STYLE_DEFAULT);
467 textfield_->SetText(ASCIIToUTF16(" one two three ")); 561 textfield_->SetText(ASCIIToUTF16(" one two three "));
468 textfield_->SetReadOnly(true); 562 textfield_->SetReadOnly(true);
469 SendKeyEventToTextfieldViews(ui::VKEY_HOME); 563 SendKeyEvent(ui::VKEY_HOME);
470 EXPECT_EQ(0U, textfield_->GetCursorPosition()); 564 EXPECT_EQ(0U, textfield_->GetCursorPosition());
471 565
472 SendKeyEventToTextfieldViews(ui::VKEY_END); 566 SendKeyEvent(ui::VKEY_END);
473 EXPECT_EQ(15U, textfield_->GetCursorPosition()); 567 EXPECT_EQ(15U, textfield_->GetCursorPosition());
474 568
475 SendKeyEventToTextfieldViews(ui::VKEY_LEFT, false, false); 569 SendKeyEvent(ui::VKEY_LEFT, false, false);
476 EXPECT_EQ(14U, textfield_->GetCursorPosition()); 570 EXPECT_EQ(14U, textfield_->GetCursorPosition());
477 571
478 SendKeyEventToTextfieldViews(ui::VKEY_LEFT, false, true); 572 SendKeyEvent(ui::VKEY_LEFT, false, true);
479 EXPECT_EQ(9U, textfield_->GetCursorPosition()); 573 EXPECT_EQ(9U, textfield_->GetCursorPosition());
480 574
481 SendKeyEventToTextfieldViews(ui::VKEY_LEFT, true, true); 575 SendKeyEvent(ui::VKEY_LEFT, true, true);
482 EXPECT_EQ(5U, textfield_->GetCursorPosition()); 576 EXPECT_EQ(5U, textfield_->GetCursorPosition());
483 EXPECT_STR_EQ("two ", textfield_->GetSelectedText()); 577 EXPECT_STR_EQ("two ", textfield_->GetSelectedText());
484 578
485 textfield_->SelectAll(); 579 textfield_->SelectAll();
486 EXPECT_STR_EQ(" one two three ", textfield_->GetSelectedText()); 580 EXPECT_STR_EQ(" one two three ", textfield_->GetSelectedText());
487 581
488 // CUT&PASTE does not work, but COPY works 582 // CUT&PASTE does not work, but COPY works
489 SendKeyEventToTextfieldViews(ui::VKEY_X, false, true); 583 SendKeyEvent(ui::VKEY_X, false, true);
490 EXPECT_STR_EQ(" one two three ", textfield_->GetSelectedText()); 584 EXPECT_STR_EQ(" one two three ", textfield_->GetSelectedText());
491 string16 str; 585 string16 str;
492 views::ViewsDelegate::views_delegate->GetClipboard()-> 586 views::ViewsDelegate::views_delegate->GetClipboard()->
493 ReadText(ui::Clipboard::BUFFER_STANDARD, &str); 587 ReadText(ui::Clipboard::BUFFER_STANDARD, &str);
494 EXPECT_STR_NE(" one two three ", str); 588 EXPECT_STR_NE(" one two three ", str);
495 589
496 SendKeyEventToTextfieldViews(ui::VKEY_C, false, true); 590 SendKeyEvent(ui::VKEY_C, false, true);
497 views::ViewsDelegate::views_delegate->GetClipboard()-> 591 views::ViewsDelegate::views_delegate->GetClipboard()->
498 ReadText(ui::Clipboard::BUFFER_STANDARD, &str); 592 ReadText(ui::Clipboard::BUFFER_STANDARD, &str);
499 EXPECT_STR_EQ(" one two three ", str); 593 EXPECT_STR_EQ(" one two three ", str);
500 594
501 // SetText should work even in read only mode. 595 // SetText should work even in read only mode.
502 textfield_->SetText(ASCIIToUTF16(" four five six ")); 596 textfield_->SetText(ASCIIToUTF16(" four five six "));
503 EXPECT_STR_EQ(" four five six ", textfield_->text()); 597 EXPECT_STR_EQ(" four five six ", textfield_->text());
504 598
505 // Paste shouldn't work. 599 // Paste shouldn't work.
506 SendKeyEventToTextfieldViews(ui::VKEY_V, false, true); 600 SendKeyEvent(ui::VKEY_V, false, true);
507 EXPECT_STR_EQ(" four five six ", textfield_->text()); 601 EXPECT_STR_EQ(" four five six ", textfield_->text());
508 EXPECT_TRUE(textfield_->GetSelectedText().empty()); 602 EXPECT_TRUE(textfield_->GetSelectedText().empty());
509 603
510 textfield_->SelectAll(); 604 textfield_->SelectAll();
511 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); 605 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText());
512 606
513 // Text field is unmodifiable and selection shouldn't change. 607 // Text field is unmodifiable and selection shouldn't change.
514 SendKeyEventToTextfieldViews(ui::VKEY_DELETE); 608 SendKeyEvent(ui::VKEY_DELETE);
515 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); 609 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText());
516 SendKeyEventToTextfieldViews(ui::VKEY_BACK); 610 SendKeyEvent(ui::VKEY_BACK);
517 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); 611 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText());
518 SendKeyEventToTextfieldViews(ui::VKEY_T); 612 SendKeyEvent(ui::VKEY_T);
519 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); 613 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText());
520 } 614 }
521 615
616 TEST_F(NativeTextfieldViewsTest, TextInputClientTest) {
617 InitTextfield(Textfield::STYLE_DEFAULT);
618 TextInputClient* client = textfield_->GetTextInputClient();
619 EXPECT_TRUE(client);
620 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, client->GetTextInputType());
621
622 textfield_->SetText(ASCIIToUTF16("0123456789"));
623 ui::Range range;
624 EXPECT_TRUE(client->GetTextRange(&range));
625 EXPECT_EQ(0U, range.start());
626 EXPECT_EQ(10U, range.end());
627
628 EXPECT_TRUE(client->SetSelectionRange(ui::Range(1, 4)));
629 EXPECT_TRUE(client->GetSelectionRange(&range));
630 EXPECT_EQ(ui::Range(1,4), range);
631
632 GetTextHelper helper;
633 base::Callback<void(string16)> callback =
634 base::Bind(&GetTextHelper::set_text, base::Unretained(&helper));
635
636 EXPECT_TRUE(client->GetTextFromRange(range, callback));
637 EXPECT_STR_EQ("123", helper.text());
638 EXPECT_TRUE(client->DeleteRange(range));
639 EXPECT_STR_EQ("0456789", textfield_->text());
640
641 ui::Composition composition;
642 composition.text = UTF8ToUTF16("321");
643 // Set composition through input method.
644 input_method_->Clear();
645 input_method_->SetCompositionForNextKey(composition);
646 textfield_->clear();
647
648 on_before_user_action_ = on_after_user_action_ = 0;
649 SendKeyEvent(ui::VKEY_A);
650 EXPECT_TRUE(textfield_->key_received());
651 EXPECT_FALSE(textfield_->key_handled());
652 EXPECT_TRUE(client->HasComposition());
653 EXPECT_TRUE(client->GetCompositionRange(&range));
654 EXPECT_STR_EQ("0321456789", textfield_->text());
655 EXPECT_EQ(ui::Range(1,4), range);
656 EXPECT_EQ(2, on_before_user_action_);
657 EXPECT_EQ(2, on_after_user_action_);
658
659 input_method_->SetResultForNextKey(UTF8ToUTF16("123"));
660 on_before_user_action_ = on_after_user_action_ = 0;
661 textfield_->clear();
662 SendKeyEvent(ui::VKEY_A);
663 EXPECT_TRUE(textfield_->key_received());
664 EXPECT_FALSE(textfield_->key_handled());
665 EXPECT_FALSE(client->HasComposition());
666 EXPECT_FALSE(input_method_->cancel_composition_called());
667 EXPECT_STR_EQ("0123456789", textfield_->text());
668 EXPECT_EQ(2, on_before_user_action_);
669 EXPECT_EQ(2, on_after_user_action_);
670
671 input_method_->Clear();
672 input_method_->SetCompositionForNextKey(composition);
673 textfield_->clear();
674 SendKeyEvent(ui::VKEY_A);
675 EXPECT_TRUE(client->HasComposition());
676 EXPECT_STR_EQ("0123321456789", textfield_->text());
677
678 on_before_user_action_ = on_after_user_action_ = 0;
679 textfield_->clear();
680 SendKeyEvent(ui::VKEY_RIGHT);
681 EXPECT_FALSE(client->HasComposition());
682 EXPECT_TRUE(input_method_->cancel_composition_called());
683 EXPECT_TRUE(textfield_->key_received());
684 EXPECT_TRUE(textfield_->key_handled());
685 EXPECT_STR_EQ("0123321456789", textfield_->text());
686 EXPECT_EQ(8U, textfield_->GetCursorPosition());
687 EXPECT_EQ(1, on_before_user_action_);
688 EXPECT_EQ(1, on_after_user_action_);
689
690 input_method_->Clear();
691 textfield_->SetReadOnly(true);
692 EXPECT_TRUE(input_method_->text_input_type_changed());
693 EXPECT_FALSE(textfield_->GetTextInputClient());
694
695 textfield_->SetReadOnly(false);
696 input_method_->Clear();
697 textfield_->SetPassword(true);
698 EXPECT_TRUE(input_method_->text_input_type_changed());
699 EXPECT_TRUE(textfield_->GetTextInputClient());
700 }
701
702
522 } // namespace views 703 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698