Package com.google.gwt.dom.client

Examples of com.google.gwt.dom.client.DivElement


  }

  public void testFieldGetters() {
    assertTrue(renderer.isParentOrRenderer(docDiv));
    // Get root from parent
    DivElement root = renderer.getRoot(docDiv);
    assertTrue(renderer.isParentOrRenderer(root));
    assertNotNull(root);

    // For example, the rendered value should be inside
    assertSpanContainsRenderedValue(root);

    // Get nameSpan
    SpanElement nameSpan = renderer.getNameSpan(docDiv);
    assertSpanContainsRenderedValueText(RENDERED_VALUE, nameSpan.getFirstChild());

    // Getters also work from the root element
    DivElement root2 = renderer.getRoot(root);
    assertTrue(renderer.isParentOrRenderer(root2));
    assertNotNull(root2);
    assertSpanContainsRenderedValue(root2);
    nameSpan = renderer.getNameSpan(root);
    assertSpanContainsRenderedValueText(RENDERED_VALUE, nameSpan.getFirstChild());
View Full Code Here


    assertSpanContainsRenderedValueText(RENDERED_VALUE, nameSpan.getFirstChild());
  }

  public void testFieldGettersDetachedRoot() {
    // Detach root
    DivElement root = renderer.getRoot(docDiv);
    root.removeFromParent();

    // Getting the root element is still fine
    DivElement rootAgain = renderer.getRoot(root);
    assertEquals(root, rootAgain);

    if (GWT.isProdMode()) {
      // In prod mode we avoid checking whether the parent is attached
      try {
View Full Code Here

      fail("Expected NPE");
    } catch (NullPointerException e) {
      // Expected
    }

    DivElement root = renderer.getRoot(docDiv);
    SpanElement nameSpan = renderer.getNameSpan(docDiv);

    // remove nameSpan
    nameSpan.removeFromParent();
    try {
      renderer.getNameSpan(docDiv);
      fail("Expected IllegalStateException because nameSpan was removed");
    } catch (IllegalStateException e) {
      // In dev mode this is different from not being attached
      assertFalse(GWT.isProdMode());
    } catch (IllegalArgumentException e) {
      // Otherwise the same error as being not attached
      assertTrue(GWT.isProdMode());
    }

    // Add a a sibling to the root element and remove the root from the parent altogether
    SpanElement spanElement = Document.get().createSpanElement();
    docDiv.appendChild(spanElement);
    root.removeFromParent();

    assertFalse(renderer.isParentOrRenderer(docDiv));
    if (GWT.isProdMode()) {
      // In prod mode no attempt is made to check whether root is still attached
      assertTrue(renderer.isParentOrRenderer(root));
View Full Code Here

      // Expected
    }
  }

  public void testFieldGettersNotOnlyChild() {
    DivElement root = renderer.getRoot(docDiv);

    // Add a a sibling to the root element
    docDiv.appendChild(Document.get().createSpanElement());

    // Getting the root element is still fine
    DivElement rootAgain = renderer.getRoot(docDiv);
    assertEquals(root, rootAgain);

    if (GWT.isProdMode()) {
      // In prod mode we avoid checking for being the only child
      assertTrue(renderer.isParentOrRenderer(docDiv));
View Full Code Here

  public void testAttachToDomAndGetChildUnattached() {
    go();
  }

  public void testAttachToDomAndGetChildUnderUnattached() {
    DivElement div = Document.get().createDivElement();
    try {
      go(div);
    } finally {
      detach(div);
    }
View Full Code Here

      detach(div);
    }
  }

  public void testAttachToDomAndGetChildUnderHidden() {
    DivElement div = Document.get().createDivElement();
    try {
      RootPanel.getBodyElement().appendChild(div);
      div.getStyle().setVisibility(Visibility.HIDDEN);
      go(div);
    } finally {
      detach(div);
    }
  }
View Full Code Here

      detach(div);
    }
  }

  public void testAttachToDomAndGetChildUnderDisplayNone() {
    DivElement div = Document.get().createDivElement();
    try {
      RootPanel.getBodyElement().appendChild(div);
      div.getStyle().setDisplay(Display.NONE);
      go(div);
    } finally {
      detach(div);
    }
  }
View Full Code Here

      detach(div);
    }
  }

  public void testAttachToDomAndGetChildUnderAttachedThenUnattached() {
    DivElement div = Document.get().createDivElement();
    detach(div);
    try {
      RootPanel.getBodyElement().appendChild(div);
      go(div);
    } finally {
View Full Code Here

  /**
   * Make sure this test's clean up method actually works.
   */
  public void testDetach() {
    DivElement div = Document.get().createDivElement();
    RootPanel.getBodyElement().appendChild(div);
    detach(div);
    assertNull(div.getParentElement());
  }
View Full Code Here

  /**
   * Ensures that {@link RootPanel#get(String)} behaves properly.
   */
  public void testGetById() {
    Document doc = Document.get();
    DivElement div = doc.createDivElement();
    doc.getBody().appendChild(div);
    div.setInnerHTML("<div id='a'></div><div id='b'></div>");

    // You should get the same RootPanel for subsequent calls to get() with the
    // same id. But you should get *different* RootPanels for calls with
    // different ids.
    RootPanel aRoot = RootPanel.get("a");
View Full Code Here

TOP

Related Classes of com.google.gwt.dom.client.DivElement

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.