Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/VexWidgetTest.java')
-rw-r--r--org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/VexWidgetTest.java36
1 files changed, 18 insertions, 18 deletions
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/VexWidgetTest.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/VexWidgetTest.java
index 861d8fbc..c7cea2f6 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/VexWidgetTest.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/widget/VexWidgetTest.java
@@ -20,12 +20,10 @@ import java.util.List;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.vex.core.internal.css.StyleSheet;
-import org.eclipse.vex.core.internal.dom.CommentElement;
import org.eclipse.vex.core.internal.dom.Document;
import org.eclipse.vex.core.internal.dom.DocumentFragment;
import org.eclipse.vex.core.internal.dom.Element;
import org.eclipse.vex.core.internal.dom.Node;
-import org.eclipse.vex.core.internal.dom.RootElement;
import org.eclipse.vex.core.internal.dom.Text;
import org.eclipse.vex.core.internal.dom.Validator;
import org.eclipse.vex.core.internal.validator.WTPVEXValidator;
@@ -38,11 +36,11 @@ public class VexWidgetTest {
final VexWidgetImpl widget = new VexWidgetImpl(new MockHostComponent());
widget.setDocument(createDocumentWithDTD(TEST_DTD, "section"), StyleSheet.NULL);
assertCanInsertOnly(widget, "title", "para");
- widget.insertElement(new Element("title"));
+ widget.insertElement(new QualifiedName(null, "title"));
assertCanInsertOnly(widget);
widget.moveBy(1);
assertCanInsertOnly(widget, "para");
- widget.insertElement(new Element("para"));
+ widget.insertElement(new QualifiedName(null, "para"));
widget.moveBy(1);
assertCanInsertOnly(widget, "para");
}
@@ -52,7 +50,7 @@ public class VexWidgetTest {
final VexWidgetImpl widget = new VexWidgetImpl(new MockHostComponent());
widget.setDocument(createDocument(CONTENT_NS, "p"), StyleSheet.NULL);
assertCanInsertOnly(widget, "b", "i");
- widget.insertElement(new Element(new QualifiedName(CONTENT_NS, "b")));
+ widget.insertElement(new QualifiedName(CONTENT_NS, "b"));
assertCanInsertOnly(widget, "b", "i");
widget.moveBy(1);
assertCanInsertOnly(widget, "b", "i");
@@ -63,11 +61,11 @@ public class VexWidgetTest {
final VexWidgetImpl widget = new VexWidgetImpl(new MockHostComponent());
widget.setDocument(createDocument(STRUCTURE_NS, "chapter"), StyleSheet.NULL);
assertCanInsertOnly(widget, "title", "chapter", "p");
- widget.insertElement(new Element(new QualifiedName(STRUCTURE_NS, "title")));
+ widget.insertElement(new QualifiedName(STRUCTURE_NS, "title"));
assertCanInsertOnly(widget);
widget.moveBy(1);
// assertCanInsertOnly(widget, "chapter", "p");
- widget.insertElement(new Element(new QualifiedName(CONTENT_NS, "p")));
+ widget.insertElement(new QualifiedName(CONTENT_NS, "p"));
assertCanInsertOnly(widget, "b", "i");
widget.moveBy(1);
// assertCanInsertOnly(widget, "p");
@@ -78,25 +76,27 @@ public class VexWidgetTest {
public void undoRemoveCommentTag() throws Exception {
final VexWidgetImpl widget = new VexWidgetImpl(new MockHostComponent());
widget.setDocument(createDocument(STRUCTURE_NS, "chapter"), StyleSheet.NULL);
- widget.insertElement(new Element(new QualifiedName(CONTENT_NS, "p")));
- widget.insertText("text before comment");
- widget.insertElement(new CommentElement());
- final Element commentElement = widget.getDocument().getElementAt(widget.getCaretOffset());
- widget.insertText("comment text");
+ widget.insertElement(new QualifiedName(CONTENT_NS, "p"));
+ widget.insertText("1text before comment1");
+ widget.insertComment();
+ final Node comment = widget.getDocument().getChildNodeAt(widget.getCaretOffset());
+ widget.insertText("2comment text2");
widget.moveBy(1);
- widget.insertText("text after comment");
+ widget.insertText("3text after comment3");
final String expectedContentStructure = getContentStructure(widget.getDocument().getRootElement());
widget.doWork(new Runnable() {
public void run() {
- widget.moveTo(commentElement.getStartOffset() + 1, false);
- widget.moveTo(commentElement.getEndOffset(), true);
+ widget.moveTo(comment.getStartOffset() + 1, false);
+ widget.moveTo(comment.getEndOffset() - 1, true);
final DocumentFragment fragment = widget.getSelectedFragment();
widget.deleteSelection();
+
widget.moveBy(-1, false);
- widget.moveBy(2, true);
+ widget.moveBy(1, true);
widget.deleteSelection();
+
widget.insertFragment(fragment);
}
});
@@ -108,14 +108,14 @@ public class VexWidgetTest {
private static Document createDocumentWithDTD(final String dtdIdentifier, final String rootElementName) {
final Validator validator = new WTPVEXValidator(dtdIdentifier);
- final Document document = new Document(new RootElement(rootElementName));
+ final Document document = new Document(new Element(rootElementName));
document.setValidator(validator);
return document;
}
private static Document createDocument(final String rootSchemaIdentifier, final String rootElementName) {
final Validator validator = new WTPVEXValidator();
- final Document document = new Document(new RootElement(new QualifiedName(rootSchemaIdentifier, rootElementName)));
+ final Document document = new Document(new Element(new QualifiedName(rootSchemaIdentifier, rootElementName)));
document.setValidator(validator);
return document;
}

Back to the top