Chromium Code Reviews| 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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 InitTextfield(Textfield::STYLE_PASSWORD); | 502 InitTextfield(Textfield::STYLE_PASSWORD); |
| 503 | 503 |
| 504 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, GetTextInputType()); | 504 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, GetTextInputType()); |
| 505 | 505 |
| 506 last_contents_.clear(); | 506 last_contents_.clear(); |
| 507 textfield_->SetText(ASCIIToUTF16("my password")); | 507 textfield_->SetText(ASCIIToUTF16("my password")); |
| 508 // Just to make sure the text() and callback returns | 508 // Just to make sure the text() and callback returns |
| 509 // the actual text instead of "*". | 509 // the actual text instead of "*". |
| 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 | |
| 513 // Cut and copy should be disabled in the context menu. | |
| 514 model_->SelectAll(); | |
| 515 EXPECT_FALSE(IsCommandIdEnabled(IDS_APP_CUT)); | |
| 516 EXPECT_FALSE(IsCommandIdEnabled(IDS_APP_COPY)); | |
|
oshima
2011/12/02 23:15:54
can you also add ctrl-c/ctrl-x?
benrg
2011/12/06 17:21:30
Done.
| |
| 512 } | 517 } |
| 513 | 518 |
| 514 TEST_F(NativeTextfieldViewsTest, InputTypeSetsPassword) { | 519 TEST_F(NativeTextfieldViewsTest, InputTypeSetsPassword) { |
| 515 InitTextfield(Textfield::STYLE_DEFAULT); | 520 InitTextfield(Textfield::STYLE_DEFAULT); |
| 516 | 521 |
| 517 // Defaults to TEXT | 522 // Defaults to TEXT |
| 518 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType()); | 523 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType()); |
| 519 | 524 |
| 520 // Setting to passwords also sets password state of textfield. | 525 // Setting to passwords also sets password state of textfield. |
| 521 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | 526 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 815 // Ensure that disabled textfields do not support drag operations. | 820 // Ensure that disabled textfields do not support drag operations. |
| 816 textfield_->SetEnabled(false); | 821 textfield_->SetEnabled(false); |
| 817 EXPECT_EQ(ui::DragDropTypes::DRAG_NONE, | 822 EXPECT_EQ(ui::DragDropTypes::DRAG_NONE, |
| 818 textfield_view_->GetDragOperationsForView(NULL, kStringPoint)); | 823 textfield_view_->GetDragOperationsForView(NULL, kStringPoint)); |
| 819 textfield_->SetEnabled(true); | 824 textfield_->SetEnabled(true); |
| 820 // Ensure that textfields without selections do not support drag operations. | 825 // Ensure that textfields without selections do not support drag operations. |
| 821 textfield_->ClearSelection(); | 826 textfield_->ClearSelection(); |
| 822 EXPECT_EQ(ui::DragDropTypes::DRAG_NONE, | 827 EXPECT_EQ(ui::DragDropTypes::DRAG_NONE, |
| 823 textfield_view_->GetDragOperationsForView(NULL, kStringPoint)); | 828 textfield_view_->GetDragOperationsForView(NULL, kStringPoint)); |
| 824 textfield_->SelectRange(kStringRange); | 829 textfield_->SelectRange(kStringRange); |
| 830 // Ensure that password textfields do not support drag operations. | |
| 831 textfield_->SetIsPassword(true); | |
| 832 EXPECT_EQ(ui::DragDropTypes::DRAG_NONE, | |
| 833 textfield_view_->GetDragOperationsForView(NULL, kStringPoint)); | |
| 834 textfield_->SetIsPassword(false); | |
| 825 // Ensure that textfields only initiate drag operations inside the selection. | 835 // Ensure that textfields only initiate drag operations inside the selection. |
| 826 EXPECT_EQ(ui::DragDropTypes::DRAG_NONE, | 836 EXPECT_EQ(ui::DragDropTypes::DRAG_NONE, |
| 827 textfield_view_->GetDragOperationsForView(NULL, gfx::Point())); | 837 textfield_view_->GetDragOperationsForView(NULL, gfx::Point())); |
| 828 EXPECT_FALSE(textfield_view_->CanStartDragForView(NULL, gfx::Point(), | 838 EXPECT_FALSE(textfield_view_->CanStartDragForView(NULL, gfx::Point(), |
| 829 gfx::Point())); | 839 gfx::Point())); |
| 830 EXPECT_EQ(ui::DragDropTypes::DRAG_COPY, | 840 EXPECT_EQ(ui::DragDropTypes::DRAG_COPY, |
| 831 textfield_view_->GetDragOperationsForView(NULL, kStringPoint)); | 841 textfield_view_->GetDragOperationsForView(NULL, kStringPoint)); |
| 832 EXPECT_TRUE(textfield_view_->CanStartDragForView(NULL, kStringPoint, | 842 EXPECT_TRUE(textfield_view_->CanStartDragForView(NULL, kStringPoint, |
| 833 gfx::Point())); | 843 gfx::Point())); |
| 834 // Ensure that textfields support local moves. | 844 // Ensure that textfields support local moves. |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1565 #else | 1575 #else |
| 1566 EXPECT_EQ(500U, textfield_->GetCursorPosition()); | 1576 EXPECT_EQ(500U, textfield_->GetCursorPosition()); |
| 1567 #endif | 1577 #endif |
| 1568 #endif // !defined(OS_WIN) | 1578 #endif // !defined(OS_WIN) |
| 1569 | 1579 |
| 1570 // Reset locale. | 1580 // Reset locale. |
| 1571 base::i18n::SetICUDefaultLocale(locale); | 1581 base::i18n::SetICUDefaultLocale(locale); |
| 1572 } | 1582 } |
| 1573 | 1583 |
| 1574 } // namespace views | 1584 } // namespace views |
| OLD | NEW |