Package org.waveprotocol.wave.model.document.raw.impl

Examples of org.waveprotocol.wave.model.document.raw.impl.Element


        XmlStringBuilder.innerXml(doc).toString());
  }

  public void testGetRelatedLineElement() {
    LineTestState s = new LineTestState();
    Element line1 = DocHelper.getElementWithTagName(doc, "line");
    Element line2 = DocHelper.findElementById(doc, "2");
    Element line3 = DocHelper.findElementById(doc, "3");

    getDocWithoutSchema("<lc><line/>abc<x>def<line id=\"bad\"/></x>."
        + "<line id=\"2\"/><line id=\"3\"/>ghi</lc>jkl");

    assertNull(LineContainers.getRelatedLineElement(doc, Point.start(doc, s.lc)));
View Full Code Here


  private void checkInsertLineish(Point<Node> expectedPoint,
      Rounding rounding, Point<Node> location, boolean useParagraphs, int add) {
    int expectedLocation = doc.getLocation(expectedPoint) + add;

    Element el = LineContainers.insertLine(doc, rounding, location);

    assertTrue(LineContainers.isLineElement(doc, el));
    assertEquals(expectedLocation, doc.getLocation(el));
  }
View Full Code Here

  private void checkAppendLineish(Point<Node> expectedPoint, XmlStringBuilder content,
      boolean useParagraphs) {
    int expectedLocation = doc.getLocation(expectedPoint);

    Element el = LineContainers.appendLine(doc, content);

    if (content == null) {
      content = XmlStringBuilder.createEmpty();
    }

    assertTrue(LineContainers.isLineElement(doc, el));
    XmlStringBuilderDoc<Node, Element, Text> siblingContent = XmlStringBuilder.createEmpty(doc);
    for (Node n = el.getNextSibling(); n != null; n = n.getNextSibling()) {
      siblingContent.appendNode(n);
    }
    assertEquals(content, siblingContent);
    assertEquals(expectedLocation, doc.getLocation(el));
  }
View Full Code Here

  protected void checkConstruction(String xml) {
    try {
      String outerXml = "<DOC a=\"b\">" + xml + "</DOC>";

      RawDocumentImpl doc = RawDocumentImpl.PROVIDER.parse(outerXml);
      Element element = doc.getDocumentElement();

      int size = element.calculateSize();

      check(size - 2, xml, XmlStringBuilder.createChildren(doc, element));
      check(size, outerXml, XmlStringBuilder.createNode(doc, element));

    } catch (Exception e) {
View Full Code Here

    MutableDocument<Node, Element, Text> doc = cxt.document();
    Text first = (Text) doc.getFirstChild(doc.getDocumentElement());
    Text text = organiser.splitText(first, 1);
    LocalDocument<Node, Element, Text> local = cxt.annotatableContent();

    Element tr = local.transparentCreate("l", Attributes.EMPTY_MAP, doc.getDocumentElement(), text);
    local.transparentMove(tr, text, null, null);

    assertNull(cxt.getIndexedDoc().splitText(first, 1));
    assertNull(organiser.splitText(first, 1));
View Full Code Here

    indexedDoc.consume(DocProviders.POJO.parse(docXml).asOperation());

    Point<Node> n = indexedDoc.locate(nodeLocation);

    if (!n.isInTextNode()) {
      Element newNode =
          persistentDoc.transparentCreate("abc", Collections.<String, String> emptyMap(),
              (Element) n.getContainer(), n.getNodeAfter());
      Element newNode2 =
          persistentDoc.transparentCreate("def", Collections.<String, String> emptyMap(), newNode,
              null);
      Element newNode3 =
          persistentDoc.transparentCreate("ghi", Collections.<String, String> emptyMap(), newNode,
              newNode2);

      assertEquals(expectedLocation, DocHelper.getFilteredLocation(indexedDoc, persistentDoc,
          Point.<Node> inElement(newNode, null)));
      assertEquals(pointBox.boxed, Point.<Node> inElement(newNode, null));

      assertEquals(expectedLocation, DocHelper.getFilteredLocation(indexedDoc, persistentDoc,
          Point.<Node> inElement(newNode.getParentElement(), newNode)));
      assertEquals(pointBox.boxed, Point.<Node> inElement(newNode.getParentElement(), newNode));

      assertEquals(expectedLocation, DocHelper.getFilteredLocation(indexedDoc, persistentDoc,
          Point.<Node> inElement(newNode.getParentElement(), newNode.getNextSibling())));
      assertEquals(pointBox.boxed,
          Point.<Node> inElement(newNode.getParentElement(), newNode.getNextSibling()));

      assertEquals(expectedLocation, DocHelper.getFilteredLocation(indexedDoc, persistentDoc,
          Point.<Node> inElement(newNode2, null)));
      assertEquals(pointBox.boxed, Point.<Node> inElement(newNode2, null));

      assertEquals(expectedLocation, DocHelper.getFilteredLocation(indexedDoc, persistentDoc,
          Point.<Node> inElement(newNode2.getParentElement(), newNode2)));
      assertEquals(pointBox.boxed, Point.<Node> inElement(newNode2.getParentElement(), newNode2));

      assertEquals(expectedLocation, DocHelper.getFilteredLocation(indexedDoc, persistentDoc,
          Point.<Node> inElement(newNode3, null)));
      assertEquals(pointBox.boxed, Point.<Node> inElement(newNode3, null));

      assertEquals(expectedLocation, DocHelper.getFilteredLocation(indexedDoc, persistentDoc,
          Point.<Node> inElement(newNode3.getParentElement(), newNode3)));
      assertEquals(pointBox.boxed, Point.<Node> inElement(newNode3.getParentElement(), newNode3));
    }
  }
View Full Code Here

  /**
   * Test normalize point between two text nodes, i.e. "hello""world"
   */
  public void testNormalizePointBetweenTwoTextNodes() {
    MutableDocument<Node, Element, Text> doc = initializeMutableDoc();
    Element p = doc.asElement(doc.getFirstChild(doc.getDocumentElement()));
    assert p != null;

    doc.insertText(Point.<Node> end(p), "hello");
    insertTextInNewTextNodeHelper(doc, Point.<Node> end(p), "world");

View Full Code Here

  /**
   * Test normalize points between an element and a text node <a>stuff</a>"hi"
   */
  public void testNormalizePointElementFollowedByTextNode() {
    MutableDocument<Node, Element, Text> doc = initializeMutableDoc();
    Element p = doc.asElement(doc.getFirstChild(doc.getDocumentElement()));
    assert p != null;

    Element aElement =
        doc.createElement(Point.start(doc, p), "a", Collections.<String, String> emptyMap());
    doc.insertText(Point.start(doc, aElement), "stuff");
    doc.insertText(Point.<Node> end(p), "hi");
    Text hi = doc.asText(doc.getLastChild(p));
    Text stuff = doc.asText(aElement.getFirstChild());

    assertEquals(Point.inText(hi, 0), DocHelper.normalizePoint(Point.<Node> inText(hi, 0), doc));
    assertEquals(Point.inText(hi, 0), DocHelper.normalizePoint(Point.<Node>inElement(p, hi), doc));
    // In the future, we might want to move the caret out from inline elements.
    assertEquals(Point.inText(stuff, stuff.getLength()), DocHelper.normalizePoint(Point
View Full Code Here

  /**
   * Test normalize points between text node and element "hi"<a>stuff</a>
   */
  public void testNormalizePointTextNodeFollowedByElement() {
    MutableDocument<Node, Element, Text> doc = initializeMutableDoc();
    Element p = doc.asElement(doc.getFirstChild(doc.getDocumentElement()));
    assert p != null;

    doc.insertText(Point.<Node> end(p), "hi");
    Element aElement =
      doc.createElement(Point.<Node>end(p), "a", Collections.<String, String> emptyMap());
    doc.insertText(Point.start(doc, aElement), "stuff");

    Text hi = doc.asText(doc.getFirstChild(p));
    Text stuff = doc.asText(aElement.getFirstChild());

    assertEquals(Point.inText(hi, 2), DocHelper.normalizePoint(Point.<Node> inText(hi, 2), doc));
    assertEquals(Point.inText(hi, 2), DocHelper.normalizePoint(Point.<Node> inElement(p, aElement),
        doc));
    // In the future, we might want to move the caret out from inline elements.
View Full Code Here

    at = Point.start(doc, doc.getDocumentElement().getFirstChild().getNextSibling().asElement());
    other = DocHelper.leftAlign(at, doc, cxt.hardView());
    assertEquals(at, other); // no change

    // check when the point is to the right of shallow transparent elements
    Element p2 = doc.getDocumentElement().getFirstChild().getNextSibling().asElement();
    at = Point.end((Node) p2);
    other = DocHelper.leftAlign(at, doc, cxt.hardView());
    assertEquals(Point.end(p2.getFirstChild()), other);
    // nb: normalization to text node occurs externally

    // check when the point is to the left of deep transparent elements
    at = Point.start(doc, doc.getDocumentElement().getLastChild().asElement());
    other = DocHelper.leftAlign(at, doc, cxt.hardView());
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.document.raw.impl.Element

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.