summaryrefslogtreecommitdiffstats
path: root/ui/views/view_unittest.cc
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-13 04:44:55 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-13 04:44:55 +0000
commitf5f0c2acc32a94ba0035bb316aa6b66d212bf3cf (patch)
tree5c6e7928ca754c123cfa82d21778427536f4326c /ui/views/view_unittest.cc
parent24cddd42154b07c6559846b2159a88a3feabb5d5 (diff)
downloadchromium_src-f5f0c2acc32a94ba0035bb316aa6b66d212bf3cf.zip
chromium_src-f5f0c2acc32a94ba0035bb316aa6b66d212bf3cf.tar.gz
chromium_src-f5f0c2acc32a94ba0035bb316aa6b66d212bf3cf.tar.bz2
Add and specify Views::Textfield::SelectAll |reversed| flag, etc.
SelectAll should be consistent and explicit with range reversal. This dictates if leading or trailing text is shown when textfields overflow. Currently, NativeTextfield[Win|Views]::SelectAll behavior is implicit and differs. (Windows native reverses the selection, while ChromeOS/Views doesn't) Revise SelectAll in RenderText, NativeTextfieldWin, and OmniboxViewViews. Add the |reversed| parameter and plumbing to related interfaces/functions. Add/update RenderTextTest.SelectAll and TextfieldViewsModelTest.Selection. Specify explicit reversal behavior in all the following cases: 1) Use reversed selection (changes ChromeOS/Views behavior) in: a) BookmarkBubbleView::ShowBubble (focus on bookmark title when shown). b) BookmarkEditorView::Accept (focus on invalid bookmark URL on "Save"). c) BookmarkEditorView::Show (focus on bookmark title when shown). d) FindBarView::UpdateForResult (find bar matches are found/iterated). e) FindBarView::SetFocusAndSelection (find bar shown, etc.). f) FindBarView::SearchTextfieldView::RequestFocus (click find bar parts, etc.). g) EditSearchEngineDialog::Show (focus on search engine title when shown). h) LoginView::OnAutofillDataAvailable (HTTP/FTP auth window shown). i) MessageBoxView::ViewHierarchyChanged (JS dialog with text input shown). 2) Use forward selection (changes Windows native behavior) in: a) NativeTextfieldWin::ExecuteCommand (textfield context menu "Select All"). (note: the Omnibox context menu "Select All" already uses forward selection) b) Textfield::AboutToRequestFocusFromTabTraversal (focus via tab-traversal). (note1: THIS IS CONTENTIOUS! Though OmniBoxViewWin is unaffected) (note2: OmniboxViewViews should be fixed later as per crbug.com/134701#c9) c) TreeView::StartEditing (editing tree view nodes ex/ collected cookies). d) NativeTextfieldViewsTest.* and ViewTest.* (changes inconsequential to tests) 3) Formally specify existing implicit behavior (no behavioral change): a) NativeTextfieldWin::OnAfterPossibleChange (temporary selection is reversed). b) NativeTextfieldViews::OnGestureEvent (double tap is forwards). c) NativeTextfieldViews::ExecuteCommand (context menu "Select All" is forwards). d) NativeTextfieldViews::HandleKeyEvent (CTRL-A is forwards). e) NativeTextfieldViews::HandleMousePressEvent (triple-click is forwards). f) TextfieldViewsModel::SetText (temporary selection is forwards). g) TextfieldViewsModelTest.* is mostly forwards, |Selection| tests reversed. TBR=ben@chromium.org BUG=134762 TEST=New RenderTextTest.SelectAll, updated TextfieldViewsModelTest.Selection, other unit tests, manual. Review URL: https://chromiumcodereview.appspot.com/10693160 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/view_unittest.cc')
-rw-r--r--ui/views/view_unittest.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc
index 1ccd2dc..4fd87b3 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -1044,7 +1044,7 @@ TEST_F(ViewTest, Textfield) {
// Test selection related methods.
textfield->SetText(kText);
EXPECT_EQ(kEmptyString, textfield->GetSelectedText());
- textfield->SelectAll();
+ textfield->SelectAll(false);
EXPECT_EQ(kText, textfield->text());
textfield->ClearSelection();
EXPECT_EQ(kEmptyString, textfield->GetSelectedText());
@@ -1085,7 +1085,7 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
// Test cut.
//
ASSERT_TRUE(normal->GetTestingHandle());
- normal->SelectAll();
+ normal->SelectAll(false);
::SendMessage(normal->GetTestingHandle(), WM_CUT, 0, 0);
string16 result;
@@ -1094,7 +1094,7 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
normal->SetText(kNormalText); // Let's revert to the original content.
ASSERT_TRUE(read_only->GetTestingHandle());
- read_only->SelectAll();
+ read_only->SelectAll(false);
::SendMessage(read_only->GetTestingHandle(), WM_CUT, 0, 0);
result.clear();
clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
@@ -1102,7 +1102,7 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
EXPECT_EQ(kNormalText, result);
ASSERT_TRUE(password->GetTestingHandle());
- password->SelectAll();
+ password->SelectAll(false);
::SendMessage(password->GetTestingHandle(), WM_CUT, 0, 0);
result.clear();
clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
@@ -1115,19 +1115,19 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
// Let's start with read_only as the clipboard already contains the content
// of normal.
- read_only->SelectAll();
+ read_only->SelectAll(false);
::SendMessage(read_only->GetTestingHandle(), WM_COPY, 0, 0);
result.clear();
clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
EXPECT_EQ(kReadOnlyText, result);
- normal->SelectAll();
+ normal->SelectAll(false);
::SendMessage(normal->GetTestingHandle(), WM_COPY, 0, 0);
result.clear();
clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
EXPECT_EQ(kNormalText, result);
- password->SelectAll();
+ password->SelectAll(false);
::SendMessage(password->GetTestingHandle(), WM_COPY, 0, 0);
result.clear();
clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result);
@@ -1143,22 +1143,22 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
// WM_KEYDOWN messages that we are not simulating here.
// Attempting to copy kNormalText in a read-only text-field should fail.
- read_only->SelectAll();
+ read_only->SelectAll(false);
::SendMessage(read_only->GetTestingHandle(), WM_KEYDOWN, 0, 0);
wchar_t buffer[1024] = { 0 };
::GetWindowText(read_only->GetTestingHandle(), buffer, 1024);
EXPECT_EQ(kReadOnlyText, string16(buffer));
- password->SelectAll();
+ password->SelectAll(false);
::SendMessage(password->GetTestingHandle(), WM_PASTE, 0, 0);
::GetWindowText(password->GetTestingHandle(), buffer, 1024);
EXPECT_EQ(kNormalText, string16(buffer));
// Copy from read_only so the string we are pasting is not the same as the
// current one.
- read_only->SelectAll();
+ read_only->SelectAll(false);
::SendMessage(read_only->GetTestingHandle(), WM_COPY, 0, 0);
- normal->SelectAll();
+ normal->SelectAll(false);
::SendMessage(normal->GetTestingHandle(), WM_PASTE, 0, 0);
::GetWindowText(normal->GetTestingHandle(), buffer, 1024);
EXPECT_EQ(kReadOnlyText, string16(buffer));