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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 EXPECT_STR_EQ("this is a test", model_->GetText()); | 354 EXPECT_STR_EQ("this is a test", model_->GetText()); |
355 EXPECT_STR_EQ("this is a test", textfield_->text()); | 355 EXPECT_STR_EQ("this is a test", textfield_->text()); |
356 EXPECT_TRUE(last_contents_.empty()); | 356 EXPECT_TRUE(last_contents_.empty()); |
357 | 357 |
358 EXPECT_EQ(string16(), textfield_->GetSelectedText()); | 358 EXPECT_EQ(string16(), textfield_->GetSelectedText()); |
359 textfield_->SelectAll(); | 359 textfield_->SelectAll(); |
360 EXPECT_STR_EQ("this is a test", textfield_->GetSelectedText()); | 360 EXPECT_STR_EQ("this is a test", textfield_->GetSelectedText()); |
361 EXPECT_TRUE(last_contents_.empty()); | 361 EXPECT_TRUE(last_contents_.empty()); |
362 } | 362 } |
363 | 363 |
| 364 TEST_F(NativeTextfieldViewsTest, ModelChangesTestLowerCase) { |
| 365 InitTextfield(Textfield::STYLE_LOWERCASE); |
| 366 |
| 367 last_contents_.clear(); |
| 368 textfield_->SetText(ASCIIToUTF16("THIS IS")); |
| 369 |
| 370 EXPECT_STR_EQ("this is", model_->GetText()); |
| 371 EXPECT_STR_EQ("THIS IS", textfield_->text()); |
| 372 EXPECT_TRUE(last_contents_.empty()); |
| 373 |
| 374 textfield_->AppendText(ASCIIToUTF16(" A TEST")); |
| 375 EXPECT_STR_EQ("this is a test", model_->GetText()); |
| 376 EXPECT_STR_EQ("THIS IS A TEST", textfield_->text()); |
| 377 EXPECT_TRUE(last_contents_.empty()); |
| 378 } |
| 379 |
| 380 TEST_F(NativeTextfieldViewsTest, ModelChangesTestLowerCaseI18n) { |
| 381 InitTextfield(Textfield::STYLE_LOWERCASE); |
| 382 |
| 383 last_contents_.clear(); |
| 384 // Zenkaku Japanese "ABCabc" |
| 385 textfield_->SetText(WideToUTF16(L"\xFF21\xFF22\xFF23\xFF41\xFF42\xFF43")); |
| 386 // Zenkaku Japanese "abcabc" |
| 387 EXPECT_EQ(WideToUTF16(L"\xFF41\xFF42\xFF43\xFF41\xFF42\xFF43"), |
| 388 model_->GetText()); |
| 389 // Zenkaku Japanese "ABCabc" |
| 390 EXPECT_EQ(WideToUTF16(L"\xFF21\xFF22\xFF23\xFF41\xFF42\xFF43"), |
| 391 textfield_->text()); |
| 392 EXPECT_TRUE(last_contents_.empty()); |
| 393 |
| 394 // Zenkaku Japanese "XYZxyz" |
| 395 textfield_->AppendText(WideToUTF16(L"\xFF38\xFF39\xFF3A\xFF58\xFF59\xFF5A")); |
| 396 // Zenkaku Japanese "abcabcxyzxyz" |
| 397 EXPECT_EQ(WideToUTF16(L"\xFF41\xFF42\xFF43\xFF41\xFF42\xFF43" |
| 398 L"\xFF58\xFF59\xFF5A\xFF58\xFF59\xFF5A"), |
| 399 model_->GetText()); |
| 400 // Zenkaku Japanese "ABCabcXYZxyz" |
| 401 EXPECT_EQ(WideToUTF16(L"\xFF21\xFF22\xFF23\xFF41\xFF42\xFF43" |
| 402 L"\xFF38\xFF39\xFF3A\xFF58\xFF59\xFF5A"), |
| 403 textfield_->text()); |
| 404 EXPECT_TRUE(last_contents_.empty()); |
| 405 } |
| 406 |
| 407 TEST_F(NativeTextfieldViewsTest, ModelChangesTestLowerCaseWithLocale) { |
| 408 std::string locale = l10n_util::GetApplicationLocale(""); |
| 409 base::i18n::SetICUDefaultLocale("tr"); |
| 410 |
| 411 InitTextfield(Textfield::STYLE_LOWERCASE); |
| 412 |
| 413 last_contents_.clear(); |
| 414 // Turkish 'I' should be converted to dotless 'i' (U+0131). |
| 415 textfield_->SetText(WideToUTF16(L"I")); |
| 416 EXPECT_EQ(WideToUTF16(L"\x0131"), model_->GetText()); |
| 417 EXPECT_EQ(WideToUTF16(L"I"), textfield_->text()); |
| 418 EXPECT_TRUE(last_contents_.empty()); |
| 419 |
| 420 base::i18n::SetICUDefaultLocale(locale); |
| 421 |
| 422 // On default (en) locale, 'I' should be converted to 'i'. |
| 423 textfield_->SetText(WideToUTF16(L"I")); |
| 424 EXPECT_EQ(WideToUTF16(L"i"), model_->GetText()); |
| 425 EXPECT_EQ(WideToUTF16(L"I"), textfield_->text()); |
| 426 EXPECT_TRUE(last_contents_.empty()); |
| 427 } |
| 428 |
364 TEST_F(NativeTextfieldViewsTest, KeyTest) { | 429 TEST_F(NativeTextfieldViewsTest, KeyTest) { |
365 InitTextfield(Textfield::STYLE_DEFAULT); | 430 InitTextfield(Textfield::STYLE_DEFAULT); |
366 SendKeyEvent(ui::VKEY_C, true, false); | 431 SendKeyEvent(ui::VKEY_C, true, false); |
367 EXPECT_STR_EQ("C", textfield_->text()); | 432 EXPECT_STR_EQ("C", textfield_->text()); |
368 EXPECT_STR_EQ("C", last_contents_); | 433 EXPECT_STR_EQ("C", last_contents_); |
369 last_contents_.clear(); | 434 last_contents_.clear(); |
370 | 435 |
371 SendKeyEvent(ui::VKEY_R, false, false); | 436 SendKeyEvent(ui::VKEY_R, false, false); |
372 EXPECT_STR_EQ("Cr", textfield_->text()); | 437 EXPECT_STR_EQ("Cr", textfield_->text()); |
373 EXPECT_STR_EQ("Cr", last_contents_); | 438 EXPECT_STR_EQ("Cr", last_contents_); |
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 #else | 1641 #else |
1577 EXPECT_EQ(500U, textfield_->GetCursorPosition()); | 1642 EXPECT_EQ(500U, textfield_->GetCursorPosition()); |
1578 #endif | 1643 #endif |
1579 #endif // !defined(OS_WIN) | 1644 #endif // !defined(OS_WIN) |
1580 | 1645 |
1581 // Reset locale. | 1646 // Reset locale. |
1582 base::i18n::SetICUDefaultLocale(locale); | 1647 base::i18n::SetICUDefaultLocale(locale); |
1583 } | 1648 } |
1584 | 1649 |
1585 } // namespace views | 1650 } // namespace views |
OLD | NEW |