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

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


    Point<Node> t_here = splitPoints.get(1);
    Point<Node> there_ = splitPoints.get(2);
    Point<Node> how_ = splitPoints.get(3);

    Element a1 = cxt.annotatableContent().transparentCreate("a", Attributes.EMPTY_MAP,
        (Element) t_here.getContainer(), t_here.getNodeAfter());
    cxt.annotatableContent().transparentMove(
        a1, t_here.getNodeAfter(), how_.getNodeAfter(), null);

    Element a2 = cxt.annotatableContent().transparentCreate("b", Attributes.EMPTY_MAP,
        a1, t_here.getNodeAfter());
    cxt.annotatableContent().transparentMove(
        a2, t_here.getNodeAfter(), there_.getNodeAfter(), null);

    Element a3 = cxt.annotatableContent().transparentCreate("c", Attributes.EMPTY_MAP,
        a2, t_here.getNodeAfter());
    cxt.annotatableContent().transparentCreate("TT", a3, null);

    assertEquals("he^llo<x>t^<a><b><c>TT</c>here^</b> how^</a> are you</x>" +
        "y^eah<p><r></r><q></q></p>",
View Full Code Here


  }

  public void testGetNextNodeDepthFirst() {
    MutableDocument<Node, Element, Text> doc = getDoc(
        "<x>hello</x><y><yy>blah</yy>yeah</y><w/><z>final</z>");
    Element root = doc.getDocumentElement();
    Node x = root.getFirstChild();
    Node y = x.getNextSibling();
    Node w = y.getNextSibling();
    Node yy = y.getFirstChild();
    Node z = root.getLastChild();
    assertSame(y, DocHelper.getNextNodeDepthFirst(doc, x, null, false));
    assertSame(y, DocHelper.getNextNodeDepthFirst(doc, x, root, false));

    assertSame(x.getFirstChild(), DocHelper.getNextNodeDepthFirst(doc, x, x, true));
    assertSame(x.getFirstChild(), DocHelper.getNextNodeDepthFirst(doc, x, root, true));
View Full Code Here

  public void testFindById() {
    MutableDocument<Node, Element, Text> doc = getDoc(
        "<x id=\"x\">hello</x><y id=\"y\"><yy id=\"y\">blah</yy>yeah</y><z>final</z>");

    Element root = doc.getDocumentElement();
    Node x = root.getFirstChild();
    Node z = root.getLastChild();
    Node y = z.getPreviousSibling();

    int firstLoc = doc.getLocation(x);
    assertSame(firstLoc, DocHelper.findLocationById(doc, "x"));
    assertSame(x, DocHelper.findElementById(doc, "x"));
View Full Code Here

    MutableDocument<Node, Element, Text> doc = getDoc(
        "<x id=\"x\">hello</x>" +
        "<aroundy><y id=\"y\"><yy id=\"y\">blah</yy>yeah</y></aroundy>" +
        "<z>final</z>");

    Element root = doc.getDocumentElement();
    Node x = root.getFirstChild();
    Node z = root.getLastChild();
    Node aroundy = z.getPreviousSibling();
    Node y = aroundy.getFirstChild();
    Node yy = y.getFirstChild();

    assertSame(null, DocHelper.findElementById(doc, x.asElement(), "y"));
View Full Code Here

    }
  };

  public void testJumpOutJumpsReturnsNullWithNoMatch() {
    MutableDocument<Node, Element, Text> doc = getDoc("<w><y><z>abc</z>def</y>ghi</w>hello");
    Element z = DocHelper.getElementWithTagName(doc, "z");
    assertNull(DocHelper.jumpOut(doc, Point.start(doc, z), IS_X));

    doc = getDoc("<x><y><z>abc</z>def</y>ghi</x>hello");
    Element x = DocHelper.getElementWithTagName(doc, "x");
    assertNull(DocHelper.jumpOut(doc, Point.before(doc, x), IS_X));
    assertNull(DocHelper.jumpOut(doc, Point.after(doc, x), IS_X));
    assertNull(DocHelper.jumpOut(doc, Point.inText(x.getNextSibling(), 2), IS_X));
  }
View Full Code Here

    assertNull(DocHelper.jumpOut(doc, Point.inText(x.getNextSibling(), 2), IS_X));
  }

  public void testJumpOutJumpsOutRightwards() {
    MutableDocument<Node, Element, Text> doc = getDoc("<x><y><z>abc</z>def</y>ghi</x>hello");
    Element x = DocHelper.getElementWithTagName(doc, "x");
    Element y = DocHelper.getElementWithTagName(doc, "y");
    Element z = DocHelper.getElementWithTagName(doc, "z");

    Point<Node> afterY = Point.after(doc, y);
    assertEquals(afterY, DocHelper.jumpOut(doc, Point.inText(z.getFirstChild(), 1), IS_X));
    assertEquals(afterY, DocHelper.jumpOut(doc, Point.start(doc, z), IS_X));
    assertEquals(afterY, DocHelper.jumpOut(doc, Point.start(doc, y), IS_X));
    assertEquals(afterY, DocHelper.jumpOut(doc, Point.<Node>end(y), IS_X));
    assertSame(afterY, DocHelper.jumpOut(doc, afterY, IS_X));
  }
View Full Code Here

  }

  public void testExpectedGetSucceedsOnOldEmptyDocument() {
    MutableDocument<Node, Element, Text> doc = getDoc("");
    try {
      Element top = DocHelper.expectAndGetFirstTopLevelElement(doc, "foo");
      fail("this test is not expected to work with new ops.");
    } catch (IllegalArgumentException ex) {
      // Success
    }
  }
View Full Code Here

  }

  public void testGetOrCreateSucceedsOnOldEmptyDocument() {
    MutableDocument<Node, Element, Text> doc = getDoc("");

    Element top = DocHelper.getOrCreateFirstTopLevelElement(doc, "foo");
    assertEquals(doc.getFirstChild(doc.getDocumentElement()), top);
  }
View Full Code Here

  public void testNodeAtEnd() {
    TestDocumentContext<Node, Element, Text> cxt = createAnnotationContext();

    MutableDocument<Node, Element, Text> doc = cxt.document();
    Element e = doc.createChildElement(doc.getDocumentElement(), "p", Attributes.EMPTY_MAP);
    doc.insertText(Point.<Node>inElement(e, null), "Hi");

    doc.setAnnotation(3, 4, "x", "1");
    timerService.tick(100);

    ReadableDocument<Node, Element, Text> fullDoc = cxt.getFullRawDoc();
    Element boundary = fullDoc.asElement(fullDoc.getLastChild(e));
    assertNotNull(boundary);

    assertEquals("l:b", boundary.getTagName());

    doc.setAnnotation(3, 4, "x", null);
    timerService.tick(100);

    boundary = fullDoc.asElement(fullDoc.getLastChild(e));
View Full Code Here

  /** Tests bug 1839733 */
  public void testNestedPaintNodes() {
    TestDocumentContext<Node, Element, Text> cxt = createAnnotationContext();

    MutableDocument<Node, Element, Text> doc = cxt.document();
    Element e = doc.createChildElement(doc.getDocumentElement(), "p", Attributes.EMPTY_MAP);
    doc.insertText(doc.locate(1), "A");
    doc.insertText(doc.locate(2), "B");
    doc.setAnnotation(2, 3, "a", "1");
    timerService.tick(100);

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.