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

Unified 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: comments, Utf16OffsetToPointer bug Created 8 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/textfield/native_textfield_views_unittest.cc
diff --git a/ui/views/controls/textfield/native_textfield_views_unittest.cc b/ui/views/controls/textfield/native_textfield_views_unittest.cc
index 069b544a23bb07393dff7f8b15bb92189918f190..4633ff0169f70135171ee780c8ac62ef6e3d2de3 100644
--- a/ui/views/controls/textfield/native_textfield_views_unittest.cc
+++ b/ui/views/controls/textfield/native_textfield_views_unittest.cc
@@ -14,6 +14,7 @@
#include "base/string16.h"
#include "base/utf_string_conversions.h"
#include "googleurl/src/gurl.h"
+#include "grit/ui_strings.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
@@ -495,6 +496,20 @@ TEST_F(NativeTextfieldViewsTest, PasswordTest) {
// the actual text instead of "*".
EXPECT_STR_EQ("my password", textfield_->text());
EXPECT_TRUE(last_contents_.empty());
+
+ // Cut and copy should be disabled in the context menu.
+ model_->SelectAll();
+ EXPECT_FALSE(IsCommandIdEnabled(IDS_APP_CUT));
+ EXPECT_FALSE(IsCommandIdEnabled(IDS_APP_COPY));
+
+ // Cut and copy keyboard shortcuts and menu commands should do nothing.
+ SetClipboardText("foo");
+ SendKeyEvent(ui::VKEY_C, false, true);
+ SendKeyEvent(ui::VKEY_X, false, true);
+ ExecuteCommand(IDS_APP_COPY);
+ ExecuteCommand(IDS_APP_CUT);
+ EXPECT_STR_EQ("foo", string16(GetClipboardText()));
+ EXPECT_STR_EQ("my password", textfield_->text());
}
TEST_F(NativeTextfieldViewsTest, InputTypeSetsObscured) {
@@ -811,6 +826,11 @@ TEST_F(NativeTextfieldViewsTest, DragAndDrop_InitiateDrag) {
EXPECT_EQ(ui::DragDropTypes::DRAG_NONE,
textfield_view_->GetDragOperationsForView(NULL, kStringPoint));
textfield_->SelectRange(kStringRange);
+ // Ensure that password textfields do not support drag operations.
+ textfield_->SetObscured(true);
+ EXPECT_EQ(ui::DragDropTypes::DRAG_NONE,
+ textfield_view_->GetDragOperationsForView(NULL, kStringPoint));
+ textfield_->SetObscured(false);
// Ensure that textfields only initiate drag operations inside the selection.
EXPECT_EQ(ui::DragDropTypes::DRAG_NONE,
textfield_view_->GetDragOperationsForView(NULL, gfx::Point()));

Powered by Google App Engine
This is Rietveld 408576698