Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 0ac81bf5..d8afe3bf 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()));

Back to the top