OLD | NEW |
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 <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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 EXPECT_STR_EQ("my password", textfield_->text()); | 510 EXPECT_STR_EQ("my password", textfield_->text()); |
511 EXPECT_TRUE(last_contents_.empty()); | 511 EXPECT_TRUE(last_contents_.empty()); |
512 } | 512 } |
513 | 513 |
514 TEST_F(NativeTextfieldViewsTest, InputTypeSetsPassword) { | 514 TEST_F(NativeTextfieldViewsTest, InputTypeSetsPassword) { |
515 InitTextfield(Textfield::STYLE_DEFAULT); | 515 InitTextfield(Textfield::STYLE_DEFAULT); |
516 | 516 |
517 // Defaults to TEXT | 517 // Defaults to TEXT |
518 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType()); | 518 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType()); |
519 | 519 |
520 // Setting to passwords also sets password state of textfield. | 520 // Setting text input type also sets password state of textfield. |
521 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | 521 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
522 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, GetTextInputType()); | 522 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, GetTextInputType()); |
523 EXPECT_TRUE(textfield_->IsPassword()); | 523 EXPECT_TRUE(textfield_->IsPassword()); |
524 } | 524 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_URL); |
525 | 525 EXPECT_FALSE(textfield_->IsPassword()); |
526 TEST_F(NativeTextfieldViewsTest, PasswordSetsInputType) { | |
527 InitTextfield(Textfield::STYLE_DEFAULT); | |
528 | |
529 // Defaults to TEXT | |
530 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType()); | |
531 | |
532 textfield_->SetPassword(true); | |
533 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, GetTextInputType()); | |
534 | |
535 textfield_->SetPassword(false); | |
536 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType()); | |
537 } | 526 } |
538 | 527 |
539 TEST_F(NativeTextfieldViewsTest, TextInputType) { | 528 TEST_F(NativeTextfieldViewsTest, TextInputType) { |
540 InitTextfield(Textfield::STYLE_DEFAULT); | 529 InitTextfield(Textfield::STYLE_DEFAULT); |
541 | 530 |
542 // Defaults to TEXT | 531 // Defaults to TEXT |
543 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType()); | 532 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType()); |
544 | 533 |
545 // And can be set. | 534 // And can be set. |
546 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_URL); | 535 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_URL); |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 EXPECT_EQ(1, on_before_user_action_); | 1093 EXPECT_EQ(1, on_before_user_action_); |
1105 EXPECT_EQ(1, on_after_user_action_); | 1094 EXPECT_EQ(1, on_after_user_action_); |
1106 | 1095 |
1107 input_method_->Clear(); | 1096 input_method_->Clear(); |
1108 textfield_->SetReadOnly(true); | 1097 textfield_->SetReadOnly(true); |
1109 EXPECT_TRUE(input_method_->text_input_type_changed()); | 1098 EXPECT_TRUE(input_method_->text_input_type_changed()); |
1110 EXPECT_FALSE(textfield_->GetTextInputClient()); | 1099 EXPECT_FALSE(textfield_->GetTextInputClient()); |
1111 | 1100 |
1112 textfield_->SetReadOnly(false); | 1101 textfield_->SetReadOnly(false); |
1113 input_method_->Clear(); | 1102 input_method_->Clear(); |
1114 textfield_->SetPassword(true); | 1103 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
1115 EXPECT_TRUE(input_method_->text_input_type_changed()); | 1104 EXPECT_TRUE(input_method_->text_input_type_changed()); |
1116 EXPECT_TRUE(textfield_->GetTextInputClient()); | 1105 EXPECT_TRUE(textfield_->GetTextInputClient()); |
1117 } | 1106 } |
1118 | 1107 |
1119 TEST_F(NativeTextfieldViewsTest, UndoRedoTest) { | 1108 TEST_F(NativeTextfieldViewsTest, UndoRedoTest) { |
1120 InitTextfield(Textfield::STYLE_DEFAULT); | 1109 InitTextfield(Textfield::STYLE_DEFAULT); |
1121 SendKeyEvent(ui::VKEY_A); | 1110 SendKeyEvent(ui::VKEY_A); |
1122 EXPECT_STR_EQ("a", textfield_->text()); | 1111 EXPECT_STR_EQ("a", textfield_->text()); |
1123 SendKeyEvent(ui::VKEY_Z, false, true); | 1112 SendKeyEvent(ui::VKEY_Z, false, true); |
1124 EXPECT_STR_EQ("", textfield_->text()); | 1113 EXPECT_STR_EQ("", textfield_->text()); |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1565 #else | 1554 #else |
1566 EXPECT_EQ(500U, textfield_->GetCursorPosition()); | 1555 EXPECT_EQ(500U, textfield_->GetCursorPosition()); |
1567 #endif | 1556 #endif |
1568 #endif // !defined(OS_WIN) | 1557 #endif // !defined(OS_WIN) |
1569 | 1558 |
1570 // Reset locale. | 1559 // Reset locale. |
1571 base::i18n::SetICUDefaultLocale(locale); | 1560 base::i18n::SetICUDefaultLocale(locale); |
1572 } | 1561 } |
1573 | 1562 |
1574 } // namespace views | 1563 } // namespace views |
OLD | NEW |