From 5ea677d377c96c60fbc546eb2381bb88f2d4b478 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Tue, 12 Mar 2013 18:34:18 +0200 Subject: Make TextArea.setCursorPosition work in all browsers (#8769) svn changeset:25579/svn branch:6.8 Conflicts: client/src/com/vaadin/client/ui/VTextField.java Change-Id: I3b53be8df4ce0564f34d8aa9bc1ce1c34648eadd --- .../tests/components/textarea/ScrollCursor.html | 169 +++++++++++++++++++++ .../tests/components/textarea/ScrollCursor.java | 89 +++++++++++ 2 files changed, 258 insertions(+) create mode 100644 uitest/src/com/vaadin/tests/components/textarea/ScrollCursor.html create mode 100644 uitest/src/com/vaadin/tests/components/textarea/ScrollCursor.java (limited to 'uitest') diff --git a/uitest/src/com/vaadin/tests/components/textarea/ScrollCursor.html b/uitest/src/com/vaadin/tests/components/textarea/ScrollCursor.html new file mode 100644 index 0000000000..9eaa1ceada --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/textarea/ScrollCursor.html @@ -0,0 +1,169 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.textarea.ScrollCursor?restartApplication
mouseClickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/domChild[0]/domChild[0]191,94
clickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
screenCapturewrap-start
clickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
screenCapturewrap-middle
clickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
screenCapturewrap-end
clickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
screenCapturewrap-end-start
clickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
screenCapturenowrap-start
clickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[4]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
screenCapturenowrap-middle
clickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[5]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
screenCapturenowrap-end
clickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[3]/VButton[0]/domChild[0]/domChild[0]
clickvaadin=runcomvaadintestscomponentstextareaScrollCursor::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]
screenCapturenowrap-end-start
+ + diff --git a/uitest/src/com/vaadin/tests/components/textarea/ScrollCursor.java b/uitest/src/com/vaadin/tests/components/textarea/ScrollCursor.java new file mode 100644 index 0000000000..c95731d94f --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/textarea/ScrollCursor.java @@ -0,0 +1,89 @@ +package com.vaadin.tests.components.textarea; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.TextArea; + +/** + * @author denis + * + */ +public class ScrollCursor extends TestBase { + + private TextArea textArea; + private int position; + + @Override + protected void setup() { + textArea = new TextArea(); + textArea.setValue("saddddddddddd fdgdfgfdgfd\n" + + "aasddddddddddd\n" + "dsaffffffdsf\n" + "sdf\n" + + "dsfsdfsdfsdfsd\n\n" + "ffffffffffffffffffff\n" + + "sdfdsfdsfsdfsdfsd xxxxxxxxxxxxxxxx\n" + "sdgfsd\n" + + "dsf\n" + "ds\n" + "fds\n" + "fds\nfs"); + addComponent(textArea); + Button button = new Button("Scroll"); + button.addListener(new ClickListener() { + + public void buttonClick(ClickEvent event) { + textArea.setCursorPosition(getPosition()); + } + }); + Button wrap = new Button("Set wrap"); + wrap.addListener(new ClickListener() { + + public void buttonClick(ClickEvent event) { + textArea.setWordwrap(false); + } + }); + + Button toBegin = new Button("To begin"); + toBegin.addListener(new ClickListener() { + + public void buttonClick(ClickEvent event) { + position = 3; + } + }); + + Button toMiddle = new Button("To middle"); + toMiddle.addListener(new ClickListener() { + + public void buttonClick(ClickEvent event) { + position = 130; + } + }); + + Button toEnd = new Button("To end"); + toEnd.addListener(new ClickListener() { + + public void buttonClick(ClickEvent event) { + position = textArea.getValue().toString().length(); + } + }); + + addComponent(button); + addComponent(wrap); + addComponent(toBegin); + addComponent(toMiddle); + addComponent(toEnd); + } + + @Override + protected String getDescription() { + return "Tests scrolling for TextArea with different word wrapping settings. " + + "Sets cursor position at the beginning, middle and the end " + + "of text and checks textarea is scrolled."; + } + + @Override + protected Integer getTicketNumber() { + return 8769; + } + + private int getPosition() { + return position; + } + +} -- cgit v1.2.3