@Override public void onDocumentEvents(DocHandler.EventBundle<Doc.N, Doc.E, Doc.T> event) { listener.onDocumentEvents(new MutableDocumentEvent(doc, event)); } }
/** Test adding two overlapping settings of the same annotation */ public void testTwoOverlappingAnnotations() { init("<p>abcdef</p>"); doc.setAnnotation(2, 4, "style/color", "charlie"); doc.setAnnotation(3, 6, "style/color", "charlie"); assertOperationResult( "<p>a<?a \"style/color\"=\"charlie\"?>bcde<?a \"style/color\"?>f</p>"); }
/** Test a simple reset annotation */ public void testResetAnnotation() { init("<p>abcdef</p>"); doc.resetAnnotation(3, 6, "style/color", "pocoyo"); assertOperationResult( "<p>ab<?a \"style/color\"=\"pocoyo\"?>cde<?a \"style/color\"?>f</p>"); }
/** Test a simple set and reset annotation */ public void testSetAndResetAnnotation() { init("<p>abcdef</p>"); doc.setAnnotation(0, doc.size(), "style/color", "pato"); doc.resetAnnotation(3, 6, "style/color", "pato"); assertOperationResult( "<p>ab<?a \"style/color\"=\"pato\"?>cde<?a \"style/color\"?>f</p>"); }
/** * Test basic get attribute. */ public void testGetAttributes() { init("<p t=\"0\" s=\"hi\">hello</p>"); Element e = (Element) doc.getFirstChild(doc.getDocumentElement()); assertEquals("0", doc.getAttribute(e, "t")); assertEquals("hi", doc.getAttribute(e, "s")); }
protected void expectFinished(AnnotationCursor cursor) { assertFalse(cursor.hasNext()); try { cursor.nextLocation(); fail("Expected NoSuchElementException"); } catch (NoSuchElementException e) { // OK } }
<D extends ModifiableDocument> void run(DocumentParser<D> parser) { D document = parser.parseDocument(initialDocument); for (TestComponent component : testComponents) { component.run(document, parser); } } }
/** Test a simple set and unset of an annotation */ public void testSetAndUnsetAnnotation() { init("<p>abcdef</p>"); doc.setAnnotation(3, 6, "style/color", "maisy"); doc.setAnnotation(0, doc.size(), "style/color", null); assertOperationResult("<p>abcdef</p>"); }
/** * Test basic get attribute. */ public void testGetAttributes() { init("<p t=\"0\" s=\"hi\">hello</p>"); Element e = (Element) doc.getFirstChild(doc.getDocumentElement()); assertEquals("0", doc.getAttribute(e, "t")); assertEquals("hi", doc.getAttribute(e, "s")); }
/** Test adding two overlapping settings of the same annotation */ public void testTwoOverlappingAnnotations() { init("<p>abcdef</p>"); doc.setAnnotation(2, 4, "style/color", "charlie"); doc.setAnnotation(3, 6, "style/color", "charlie"); assertOperationResult( "<p>a<?a \"style/color\"=\"charlie\"?>bcde<?a \"style/color\"?>f</p>"); }
protected void expectFinished(AnnotationCursor cursor) { assertFalse(cursor.hasNext()); try { cursor.nextLocation(); fail("Expected NoSuchElementException"); } catch (NoSuchElementException e) { // OK } }
/** Test a simple reset annotation */ public void testResetAnnotation() { init("<p>abcdef</p>"); doc.resetAnnotation(3, 6, "style/color", "pocoyo"); assertOperationResult( "<p>ab<?a \"style/color\"=\"pocoyo\"?>cde<?a \"style/color\"?>f</p>"); }
/** Test adding an annotation over the whole document */ public void testSetAnnotationOverWholeDocument() { init("<p>abcdef</p>"); doc.setAnnotation(0, doc.size(), "style/color", "flim"); assertOperationResult( "<?a \"style/color\"=\"flim\"?><p>abcdef</p><?a \"style/color\"?>"); }
/** Test a simple set annotation */ public void testSetAnnotation() { init("<p>abcdef</p>"); doc.setAnnotation(3, 6, "style/color", "stix"); assertOperationResult( "<p>ab<?a \"style/color\"=\"stix\"?>cde<?a \"style/color\"?>f</p>"); }
/** Test adding an annotation over the whole document */ public void testSetAnnotationOverWholeDocument() { init("<p>abcdef</p>"); doc.setAnnotation(0, doc.size(), "style/color", "flim"); assertOperationResult( "<?a \"style/color\"=\"flim\"?><p>abcdef</p><?a \"style/color\"?>"); }
/** Test adding two non-overlapping settings of the same annotation */ public void testTwoNonOverlappingAnnotations() { init("<p>abcdef</p>"); doc.setAnnotation(2, 4, "style/color", "lola"); doc.setAnnotation(5, 6, "style/color", "lola"); assertOperationResult( "<p>a<?a \"style/color\"=\"lola\"?>bc<?a \"style/color\"?>d" + "<?a \"style/color\"=\"lola\"?>e<?a \"style/color\"?>f</p>"); }
/** Test a simple set and unset of an annotation */ public void testSetAndUnsetAnnotation() { init("<p>abcdef</p>"); doc.setAnnotation(3, 6, "style/color", "maisy"); doc.setAnnotation(0, doc.size(), "style/color", null); assertOperationResult("<p>abcdef</p>"); }
/** Test adding two non-overlapping settings of the same annotation */ public void testTwoNonOverlappingAnnotations() { init("<p>abcdef</p>"); doc.setAnnotation(2, 4, "style/color", "lola"); doc.setAnnotation(5, 6, "style/color", "lola"); assertOperationResult( "<p>a<?a \"style/color\"=\"lola\"?>bc<?a \"style/color\"?>d" + "<?a \"style/color\"=\"lola\"?>e<?a \"style/color\"?>f</p>"); }
/** Test a simple set annotation */ public void testSetAnnotation() { init("<p>abcdef</p>"); doc.setAnnotation(3, 6, "style/color", "stix"); assertOperationResult( "<p>ab<?a \"style/color\"=\"stix\"?>cde<?a \"style/color\"?>f</p>"); }
/** Test that trying to add a zero range annotation does nothing */ public void testZeroRangeSetAnnotation() { init("<p>abcdef</p>"); doc.setAnnotation(3, 3, "style/color", "blum"); assertOperationResult("<p>abcdef</p>"); }