| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/keyboard_codes.h" | 5 #include "app/keyboard_codes.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "views/controls/textfield/native_textfield_views.h" | 9 #include "views/controls/textfield/native_textfield_views.h" |
| 10 #include "views/controls/textfield/textfield.h" | 10 #include "views/controls/textfield/textfield.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 // Delete using delete key and check resulting string. | 243 // Delete using delete key and check resulting string. |
| 244 for (int i = 0; i < 5; i++) { | 244 for (int i = 0; i < 5; i++) { |
| 245 SendKeyEventToTextfieldViews(app::VKEY_DELETE); | 245 SendKeyEventToTextfieldViews(app::VKEY_DELETE); |
| 246 } | 246 } |
| 247 EXPECT_STR_EQ("this is ", textfield_->text()); | 247 EXPECT_STR_EQ("this is ", textfield_->text()); |
| 248 | 248 |
| 249 // Select all and replace with "k". | 249 // Select all and replace with "k". |
| 250 textfield_->SelectAll(); | 250 textfield_->SelectAll(); |
| 251 SendKeyEventToTextfieldViews(app::VKEY_K); | 251 SendKeyEventToTextfieldViews(app::VKEY_K); |
| 252 EXPECT_STR_EQ("k", textfield_->text()); | 252 EXPECT_STR_EQ("k", textfield_->text()); |
| 253 |
| 254 // Delete the previous word from cursor. |
| 255 textfield_->SetText(ASCIIToUTF16("one two three four")); |
| 256 SendKeyEventToTextfieldViews(app::VKEY_END); |
| 257 SendKeyEventToTextfieldViews(app::VKEY_BACK, false, true, false); |
| 258 EXPECT_STR_EQ("one two three ", textfield_->text()); |
| 259 |
| 260 // Delete upto the beginning of the buffer from cursor. |
| 261 SendKeyEventToTextfieldViews(app::VKEY_LEFT, false, true, false); |
| 262 SendKeyEventToTextfieldViews(app::VKEY_BACK, true, true, false); |
| 263 EXPECT_STR_EQ("three ", textfield_->text()); |
| 253 } | 264 } |
| 254 | 265 |
| 255 TEST_F(NativeTextfieldViewsTest, PasswordTest) { | 266 TEST_F(NativeTextfieldViewsTest, PasswordTest) { |
| 256 InitTextfield(Textfield::STYLE_PASSWORD); | 267 InitTextfield(Textfield::STYLE_PASSWORD); |
| 257 textfield_->SetText(ASCIIToUTF16("my password")); | 268 textfield_->SetText(ASCIIToUTF16("my password")); |
| 258 // Just to make sure the text() and callback returns | 269 // Just to make sure the text() and callback returns |
| 259 // the actual text instead of "*". | 270 // the actual text instead of "*". |
| 260 EXPECT_STR_EQ("my password", textfield_->text()); | 271 EXPECT_STR_EQ("my password", textfield_->text()); |
| 261 EXPECT_STR_EQ("my password", last_contents_); | 272 EXPECT_STR_EQ("my password", last_contents_); |
| 262 } | 273 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 // Cycle back to the last textfield. | 353 // Cycle back to the last textfield. |
| 343 widget_->GetFocusManager()->AdvanceFocus(true); | 354 widget_->GetFocusManager()->AdvanceFocus(true); |
| 344 EXPECT_EQ(3, GetFocusedView()->GetID()); | 355 EXPECT_EQ(3, GetFocusedView()->GetID()); |
| 345 | 356 |
| 346 // Request focus should still work. | 357 // Request focus should still work. |
| 347 textfield_->RequestFocus(); | 358 textfield_->RequestFocus(); |
| 348 EXPECT_EQ(1, GetFocusedView()->GetID()); | 359 EXPECT_EQ(1, GetFocusedView()->GetID()); |
| 349 } | 360 } |
| 350 | 361 |
| 351 } // namespace views | 362 } // namespace views |
| OLD | NEW |