use of org.gwtproject.dom.client.Document in project gwtproject by treblereel.
the class HyperlinkTest method testLinkTraversal.
public void testLinkTraversal() {
final String testHistoryToken = TEST_HISTORY_TOKEN;
Hyperlink link = new Hyperlink("foobar", testHistoryToken);
HandlerRegistration registration = null;
try {
RootPanel.get().add(link);
registration = History.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
assertEquals(testHistoryToken, event.getValue());
assertEquals(testHistoryToken, History.getToken());
}
});
Document document = Document.get();
NativeEvent event = document.createClickEvent(1, 0, 0, 0, 0, false, false, false, false);
link.getElement().dispatchEvent(event);
} finally {
RootPanel.get().remove(link);
if (registration != null) {
registration.removeHandler();
}
}
}
use of org.gwtproject.dom.client.Document in project gwtproject by treblereel.
the class TextBoxTest method testNoNukeTabIndex.
public void testNoNukeTabIndex() {
Document doc = Document.get();
DivElement div = doc.createDivElement();
div.setInnerHTML("<input type='text' id='tb' tabindex='1'></input>");
doc.getBody().appendChild(div);
TextBox tb = TextBox.wrap(doc.getElementById("tb"));
assertEquals(1, tb.getTabIndex());
}
use of org.gwtproject.dom.client.Document in project gwtproject by treblereel.
the class LayoutJ2clTest method setUp.
@Before
public void setUp() throws Exception {
// ensure enough sizes for this test
ResizeHelper.resizeTo(800, 600);
enableScrolling(false);
Document doc = Document.get();
parent = doc.createDivElement();
child0 = doc.createDivElement();
child1 = doc.createDivElement();
doc.getBody().appendChild(parent);
layout = new Layout(parent);
layout.onAttach();
layout.fillParent();
layer0 = layout.attachChild(child0);
layer1 = layout.attachChild(child1);
wrapper0 = child0.getParentElement();
wrapper1 = child1.getParentElement();
}
use of org.gwtproject.dom.client.Document in project gwtproject by treblereel.
the class LayoutGwt2Test method testFillParent.
/**
* Test that fillParent() works properly when the outer div is a child of another div, and that it
* correctly follows that div's size.
*/
@DoNotRunWith(Platform.HtmlUnitLayout)
public void testFillParent() {
// We don't use the default elements created in gwtSetUp() because we need
// to test the behavior when the layout is contained by an element other
// than the <body>.
Document doc = Document.get();
DivElement container = doc.createDivElement();
DivElement parent = doc.createDivElement();
DivElement child = doc.createDivElement();
child.setInnerHTML(" ");
doc.getBody().appendChild(container);
container.appendChild(parent);
// The container has to be position:relative so that it serves as an offset
// parent.
container.getStyle().setPosition(Position.RELATIVE);
container.getStyle().setWidth(128, PX);
container.getStyle().setHeight(256, PX);
Layout layout = new Layout(parent);
layout.onAttach();
Layout.Layer layer = layout.attachChild(child);
layer.setTopBottom(0, PX, 0, PX);
layer.setLeftRight(0, PX, 0, PX);
layout.fillParent();
layout.layout();
// Test 128x256.
assertEquals(128, container.getOffsetWidth());
assertEquals(256, container.getOffsetHeight());
assertEquals(128, parent.getOffsetWidth());
assertEquals(256, parent.getOffsetHeight());
assertEquals(128, child.getOffsetWidth());
assertEquals(256, child.getOffsetHeight());
// Expand to 256x256. The layout should react automatically.
container.getStyle().setWidth(256, PX);
container.getStyle().setHeight(128, PX);
assertEquals(256, container.getOffsetWidth());
assertEquals(256, parent.getOffsetWidth());
assertEquals(256, child.getOffsetWidth());
layout.onDetach();
}
use of org.gwtproject.dom.client.Document in project gwtproject by treblereel.
the class RichTextAreaImplStandard method execCommandAssumingFocus.
void execCommandAssumingFocus(String cmd, String param) {
HTMLIFrameElement iframe = Js.uncheckedCast(elem);
Document document = Js.uncheckedCast(Js.asPropertyMap(iframe.contentWindow).get("document"));
((ExecCommand) Js.uncheckedCast(Js.asPropertyMap(document).get("execCommand"))).onInvoke(cmd, false, param);
}
Aggregations