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 // TODO(kochi): Add locale-specific lower-case conversion tests. | |
msw
2012/04/09 18:29:24
Did you mean to address this before landing?
kochi
2012/04/10 07:38:11
I'm not an expert of locale-specific case conversi
| |
407 } | |
408 | |
364 TEST_F(NativeTextfieldViewsTest, KeyTest) { | 409 TEST_F(NativeTextfieldViewsTest, KeyTest) { |
365 InitTextfield(Textfield::STYLE_DEFAULT); | 410 InitTextfield(Textfield::STYLE_DEFAULT); |
366 SendKeyEvent(ui::VKEY_C, true, false); | 411 SendKeyEvent(ui::VKEY_C, true, false); |
367 EXPECT_STR_EQ("C", textfield_->text()); | 412 EXPECT_STR_EQ("C", textfield_->text()); |
368 EXPECT_STR_EQ("C", last_contents_); | 413 EXPECT_STR_EQ("C", last_contents_); |
369 last_contents_.clear(); | 414 last_contents_.clear(); |
370 | 415 |
371 SendKeyEvent(ui::VKEY_R, false, false); | 416 SendKeyEvent(ui::VKEY_R, false, false); |
372 EXPECT_STR_EQ("Cr", textfield_->text()); | 417 EXPECT_STR_EQ("Cr", textfield_->text()); |
373 EXPECT_STR_EQ("Cr", last_contents_); | 418 EXPECT_STR_EQ("Cr", last_contents_); |
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1576 #else | 1621 #else |
1577 EXPECT_EQ(500U, textfield_->GetCursorPosition()); | 1622 EXPECT_EQ(500U, textfield_->GetCursorPosition()); |
1578 #endif | 1623 #endif |
1579 #endif // !defined(OS_WIN) | 1624 #endif // !defined(OS_WIN) |
1580 | 1625 |
1581 // Reset locale. | 1626 // Reset locale. |
1582 base::i18n::SetICUDefaultLocale(locale); | 1627 base::i18n::SetICUDefaultLocale(locale); |
1583 } | 1628 } |
1584 | 1629 |
1585 } // namespace views | 1630 } // namespace views |
OLD | NEW |