use of org.gwtproject.dom.client.Element in project gwtproject by treblereel.
the class GwtElementBuilderImplTestBase method testStyleProperties.
/**
* Element with style properties.
*
* <pre>
* <div style="color:red;position:absolute;">hello world</div>.
* </pre>
*/
public void testStyleProperties() {
DivBuilder divBuilder = factory.createDivBuilder();
divBuilder.style().trustedColor("red").position(Position.ABSOLUTE).endStyle();
Element div = divBuilder.text("hello world").finish();
assertTrue("div".equalsIgnoreCase(div.getTagName()));
assertEquals("hello world", div.getInnerText());
assertEquals("red", div.getStyle().getColor());
assertEquals("absolute", div.getStyle().getPosition());
}
use of org.gwtproject.dom.client.Element in project gwtproject by treblereel.
the class GwtElementBuilderImplTestBase method testNestedChildElements.
/**
* Children nested at multiple levels.
*
* <pre>
* <div id="root">
* <div id="child">
* <div id="grandchild">grandchild</div>
* </div>
* </div>
* </pre>
*/
public void testNestedChildElements() {
DivBuilder builder = factory.createDivBuilder().id("root");
builder.startDiv().id("child").startDiv().id("grandchild").text("grandchild");
Element div = builder.finish();
assertTrue("div".equalsIgnoreCase(div.getTagName()));
assertEquals("root", div.getId());
assertEquals(1, div.getChildCount());
Element child = div.getFirstChildElement();
assertTrue("div".equalsIgnoreCase(child.getTagName()));
assertEquals("child", child.getId());
assertEquals(1, child.getChildCount());
Element grandchild = child.getFirstChildElement();
assertTrue("div".equalsIgnoreCase(grandchild.getTagName()));
assertEquals("grandchild", grandchild.getId());
assertNull(grandchild.getFirstChildElement());
}
use of org.gwtproject.dom.client.Element in project gwtproject by treblereel.
the class J2clElementBuilderImplTestBase method testNestedChildElements.
/**
* Children nested at multiple levels.
*
* <pre>
* <div id="root">
* <div id="child">
* <div id="grandchild">grandchild</div>
* </div>
* </div>
* </pre>
*/
@Test
public void testNestedChildElements() {
DivBuilder builder = factory.createDivBuilder().id("root");
builder.startDiv().id("child").startDiv().id("grandchild").text("grandchild");
Element div = builder.finish();
assertTrue("div".equalsIgnoreCase(div.getTagName()));
assertEquals("root", div.getId());
assertEquals(1, div.getChildCount());
Element child = div.getFirstChildElement();
assertTrue("div".equalsIgnoreCase(child.getTagName()));
assertEquals("child", child.getId());
assertEquals(1, child.getChildCount());
Element grandchild = child.getFirstChildElement();
assertTrue("div".equalsIgnoreCase(grandchild.getTagName()));
assertEquals("grandchild", grandchild.getId());
assertNull(grandchild.getFirstChildElement());
}
use of org.gwtproject.dom.client.Element in project gwtproject by treblereel.
the class J2clElementBuilderImplTestBase method testAttributes.
/**
* Attributes on an element.
*
* <pre>
* <div id="myId" title="myTitle">hello world</div>
* </pre>
*/
@Test
public void testAttributes() {
Element div = factory.createDivBuilder().id("myId").title("myTitle").text("hello world").finish();
assertTrue("div".equalsIgnoreCase(div.getTagName()));
assertEquals("hello world", div.getInnerText());
assertEquals("myId", div.getId());
assertEquals("myTitle", div.getTitle());
}
use of org.gwtproject.dom.client.Element in project gwtproject by treblereel.
the class J2clElementBuilderImplTestBase method testNestedSiblingElements.
/**
* Multiple children beneath root.
*
* <pre>
* <div>
* <div>div0</div>
* <div>div1</div>
* <div>div2</div>
* </div>
* </pre>
*/
@Test
public void testNestedSiblingElements() {
DivBuilder builder = factory.createDivBuilder();
for (int i = 0; i < 3; i++) {
builder.startDiv().text("div" + i).endDiv();
}
Element div = builder.finish();
assertTrue("div".equalsIgnoreCase(div.getTagName()));
assertEquals(3, div.getChildCount());
Element child = div.getFirstChildElement();
assertEquals("div0", child.getInnerText());
child = child.getNextSiblingElement();
assertEquals("div1", child.getInnerText());
child = child.getNextSiblingElement();
assertEquals("div2", child.getInnerText());
}
Aggregations