summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hiesserich2013-06-21 14:28:44 (EDT)
committer Florian Thienel2013-06-21 14:28:44 (EDT)
commit70608eb91838ee2b1cdb48a16c3df0f863cd6955 (patch)
treeeaa607df9e0b7e545f780397abaeb7b1699fbc3b
parentffaf9cc7752fa5b2f65d777f63f3c7f0af8ea799 (diff)
downloadorg.eclipse.mylyn.docs.vex-70608eb91838ee2b1cdb48a16c3df0f863cd6955.zip
org.eclipse.mylyn.docs.vex-70608eb91838ee2b1cdb48a16c3df0f863cd6955.tar.gz
org.eclipse.mylyn.docs.vex-70608eb91838ee2b1cdb48a16c3df0f863cd6955.tar.bz2
pasting at invalid position should not delete parts of the document
https://bugs.eclipse.org/bugs/show_bug.cgi?id=410659
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/L2SimpleEditingTest.java44
1 files changed, 43 insertions, 1 deletions
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/L2SimpleEditingTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/L2SimpleEditingTest.java
index 0ac81bf..d8afe3b 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/L2SimpleEditingTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/L2SimpleEditingTest.java
@@ -7,7 +7,7 @@
*
* Contributors:
* Florian Thienel - initial API and implementation
- * Carsten Hiesserich - additional test for newline handling (bug 407827)
+ * Carsten Hiesserich - additional tests (bug 407827, 409032)
*******************************************************************************/
package org.eclipse.vex.core.internal.widget;
@@ -306,6 +306,48 @@ public class L2SimpleEditingTest {
}
@Test
+ public void insertingTextAtInvalidPosition_shouldNotAlterDocument() throws Exception {
+ final IElement para1 = widget.insertElement(PARA);
+ widget.moveBy(1);
+ final IElement para2 = widget.insertElement(PARA);
+ widget.moveTo(para1.getEndOffset());
+ widget.insertText("Para1");
+ widget.moveTo(para2.getEndOffset());
+ widget.insertText("Para2");
+
+ // Insert position is invalid
+ widget.moveTo(para1.getEndOffset() + 1);
+ try {
+ widget.insertText("Test");
+ } catch (final Exception ex) {
+ } finally {
+ assertEquals("Para1", para1.getText());
+ assertEquals("Para2", para2.getText());
+ }
+ }
+
+ @Test
+ public void insertingElementAtInvalidPosition_shouldNotAlterDocument() throws Exception {
+ final IElement para1 = widget.insertElement(PARA);
+ widget.moveBy(1);
+ final IElement para2 = widget.insertElement(PARA);
+ widget.moveTo(para1.getEndOffset());
+ widget.insertText("Para1");
+ widget.moveTo(para2.getEndOffset());
+ widget.insertText("Para2");
+
+ // Insert position is invalid
+ widget.moveTo(para1.getEndOffset());
+ try {
+ widget.insertElement(PARA);
+ } catch (final Exception ex) {
+ } finally {
+ assertEquals("Para1", para1.getText());
+ assertEquals("Para2", para2.getText());
+ }
+ }
+
+ @Test
public void givenPreElement_whenInsertingTextWithNewline_shouldInsertNewline() throws Exception {
widget.setDocument(createDocumentWithDTD(TEST_DTD, "para"), readTestStyleSheet());
widget.setWhitespacePolicy(new CssWhitespacePolicy(widget.getStyleSheet()));