Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 EXPECT_STR_EQ("this is a test", model_->GetText()); | 366 EXPECT_STR_EQ("this is a test", model_->GetText()); |
| 367 EXPECT_STR_EQ("this is a test", textfield_->text()); | 367 EXPECT_STR_EQ("this is a test", textfield_->text()); |
| 368 EXPECT_TRUE(last_contents_.empty()); | 368 EXPECT_TRUE(last_contents_.empty()); |
| 369 | 369 |
| 370 EXPECT_EQ(string16(), textfield_->GetSelectedText()); | 370 EXPECT_EQ(string16(), textfield_->GetSelectedText()); |
| 371 textfield_->SelectAll(); | 371 textfield_->SelectAll(); |
| 372 EXPECT_STR_EQ("this is a test", textfield_->GetSelectedText()); | 372 EXPECT_STR_EQ("this is a test", textfield_->GetSelectedText()); |
| 373 EXPECT_TRUE(last_contents_.empty()); | 373 EXPECT_TRUE(last_contents_.empty()); |
| 374 } | 374 } |
| 375 | 375 |
| 376 TEST_F(NativeTextfieldViewsTest, ModelChangesTestLowerCase) { | |
| 377 InitTextfield(Textfield::STYLE_LOWERCASE); | |
| 378 | |
| 379 last_contents_.clear(); | |
| 380 textfield_->SetText(ASCIIToUTF16("THIS IS")); | |
| 381 | |
| 382 EXPECT_STR_EQ("this is", model_->GetText()); | |
| 383 EXPECT_STR_EQ("THIS IS", textfield_->text()); | |
| 384 EXPECT_TRUE(last_contents_.empty()); | |
| 385 | |
| 386 textfield_->AppendText(ASCIIToUTF16(" A TEST")); | |
| 387 EXPECT_STR_EQ("this is a test", model_->GetText()); | |
| 388 EXPECT_STR_EQ("THIS IS A TEST", textfield_->text()); | |
|
xji
2012/02/17 22:38:24
could you please add tests for all modified functi
| |
| 389 EXPECT_TRUE(last_contents_.empty()); | |
| 390 } | |
| 391 | |
| 376 TEST_F(NativeTextfieldViewsTest, KeyTest) { | 392 TEST_F(NativeTextfieldViewsTest, KeyTest) { |
| 377 InitTextfield(Textfield::STYLE_DEFAULT); | 393 InitTextfield(Textfield::STYLE_DEFAULT); |
| 378 SendKeyEvent(ui::VKEY_C, true, false); | 394 SendKeyEvent(ui::VKEY_C, true, false); |
| 379 EXPECT_STR_EQ("C", textfield_->text()); | 395 EXPECT_STR_EQ("C", textfield_->text()); |
| 380 EXPECT_STR_EQ("C", last_contents_); | 396 EXPECT_STR_EQ("C", last_contents_); |
| 381 last_contents_.clear(); | 397 last_contents_.clear(); |
| 382 | 398 |
| 383 SendKeyEvent(ui::VKEY_R, false, false); | 399 SendKeyEvent(ui::VKEY_R, false, false); |
| 384 EXPECT_STR_EQ("Cr", textfield_->text()); | 400 EXPECT_STR_EQ("Cr", textfield_->text()); |
| 385 EXPECT_STR_EQ("Cr", last_contents_); | 401 EXPECT_STR_EQ("Cr", last_contents_); |
| (...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1568 #else | 1584 #else |
| 1569 EXPECT_EQ(500U, textfield_->GetCursorPosition()); | 1585 EXPECT_EQ(500U, textfield_->GetCursorPosition()); |
| 1570 #endif | 1586 #endif |
| 1571 #endif // !defined(OS_WIN) | 1587 #endif // !defined(OS_WIN) |
| 1572 | 1588 |
| 1573 // Reset locale. | 1589 // Reset locale. |
| 1574 base::i18n::SetICUDefaultLocale(locale); | 1590 base::i18n::SetICUDefaultLocale(locale); |
| 1575 } | 1591 } |
| 1576 | 1592 |
| 1577 } // namespace views | 1593 } // namespace views |
| OLD | NEW |