Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: ui/views/controls/textfield/native_textfield_views_unittest.cc

Issue 8747001: Reintroduce password support to NativeTextfieldViews (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, const syntax, password->obscured, dead methods, DCHECK, Ctrl+[CX] tests, fix other tests Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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));
517
518 // Cut and copy keyboard shortcuts should do nothing.
519 SetClipboardText("foo");
520 SendKeyEvent(ui::VKEY_C, false, true);
521 EXPECT_STR_EQ("foo", string16(GetClipboardText()));
522 SendKeyEvent(ui::VKEY_X, false, true);
523 EXPECT_STR_EQ("foo", string16(GetClipboardText()));
oshima 2011/12/06 23:57:18 check if textfield still has the same text.
benrg 2011/12/08 21:40:55 Done.
512 } 524 }
513 525
514 TEST_F(NativeTextfieldViewsTest, InputTypeSetsPassword) { 526 TEST_F(NativeTextfieldViewsTest, InputTypeSetsPassword) {
515 InitTextfield(Textfield::STYLE_DEFAULT); 527 InitTextfield(Textfield::STYLE_DEFAULT);
516 528
517 // Defaults to TEXT 529 // Defaults to TEXT
518 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType()); 530 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, GetTextInputType());
519 531
520 // Setting to passwords also sets password state of textfield. 532 // Setting to passwords also sets password state of textfield.
521 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 533 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 // Ensure that disabled textfields do not support drag operations. 827 // Ensure that disabled textfields do not support drag operations.
816 textfield_->SetEnabled(false); 828 textfield_->SetEnabled(false);
817 EXPECT_EQ(ui::DragDropTypes::DRAG_NONE, 829 EXPECT_EQ(ui::DragDropTypes::DRAG_NONE,
818 textfield_view_->GetDragOperationsForView(NULL, kStringPoint)); 830 textfield_view_->GetDragOperationsForView(NULL, kStringPoint));
819 textfield_->SetEnabled(true); 831 textfield_->SetEnabled(true);
820 // Ensure that textfields without selections do not support drag operations. 832 // Ensure that textfields without selections do not support drag operations.
821 textfield_->ClearSelection(); 833 textfield_->ClearSelection();
822 EXPECT_EQ(ui::DragDropTypes::DRAG_NONE, 834 EXPECT_EQ(ui::DragDropTypes::DRAG_NONE,
823 textfield_view_->GetDragOperationsForView(NULL, kStringPoint)); 835 textfield_view_->GetDragOperationsForView(NULL, kStringPoint));
824 textfield_->SelectRange(kStringRange); 836 textfield_->SelectRange(kStringRange);
837 // Ensure that password textfields do not support drag operations.
838 textfield_->SetIsPassword(true);
839 EXPECT_EQ(ui::DragDropTypes::DRAG_NONE,
840 textfield_view_->GetDragOperationsForView(NULL, kStringPoint));
841 textfield_->SetIsPassword(false);
825 // Ensure that textfields only initiate drag operations inside the selection. 842 // Ensure that textfields only initiate drag operations inside the selection.
826 EXPECT_EQ(ui::DragDropTypes::DRAG_NONE, 843 EXPECT_EQ(ui::DragDropTypes::DRAG_NONE,
827 textfield_view_->GetDragOperationsForView(NULL, gfx::Point())); 844 textfield_view_->GetDragOperationsForView(NULL, gfx::Point()));
828 EXPECT_FALSE(textfield_view_->CanStartDragForView(NULL, gfx::Point(), 845 EXPECT_FALSE(textfield_view_->CanStartDragForView(NULL, gfx::Point(),
829 gfx::Point())); 846 gfx::Point()));
830 EXPECT_EQ(ui::DragDropTypes::DRAG_COPY, 847 EXPECT_EQ(ui::DragDropTypes::DRAG_COPY,
831 textfield_view_->GetDragOperationsForView(NULL, kStringPoint)); 848 textfield_view_->GetDragOperationsForView(NULL, kStringPoint));
832 EXPECT_TRUE(textfield_view_->CanStartDragForView(NULL, kStringPoint, 849 EXPECT_TRUE(textfield_view_->CanStartDragForView(NULL, kStringPoint,
833 gfx::Point())); 850 gfx::Point()));
834 // Ensure that textfields support local moves. 851 // Ensure that textfields support local moves.
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 #else 1582 #else
1566 EXPECT_EQ(500U, textfield_->GetCursorPosition()); 1583 EXPECT_EQ(500U, textfield_->GetCursorPosition());
1567 #endif 1584 #endif
1568 #endif // !defined(OS_WIN) 1585 #endif // !defined(OS_WIN)
1569 1586
1570 // Reset locale. 1587 // Reset locale.
1571 base::i18n::SetICUDefaultLocale(locale); 1588 base::i18n::SetICUDefaultLocale(locale);
1572 } 1589 }
1573 1590
1574 } // namespace views 1591 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698