// creation
updateUI(new RequestHandler() {
@Override
public void onRequest() {
final PCheckBox checkbox1 = new PCheckBox("A checkbox");
checkbox1.ensureDebugId("checkbox1");
PRootPanel.get().add(checkbox1);
checkbox1.addValueChangeHandler(eventsListener);
register(checkbox1);
}
});
WebElement element = findElementById("checkbox1-label");
Assert.assertEquals("A checkbox", element.getText());
element = findElementById("checkbox1-input");
element.click();
// check event
final PValueChangeEvent<Boolean> e1 = eventsListener.poll();
Assert.assertEquals(Boolean.TRUE, e1.getValue());
// check server-side value
final PCheckBox checkbox1 = get("checkbox1");
Assert.assertEquals(Boolean.TRUE, checkbox1.getValue());
// toggle
element.click();
// check event
final PValueChangeEvent<Boolean> e2 = eventsListener.poll();
Assert.assertEquals(Boolean.FALSE, e2.getValue());
// check server-side value
Assert.assertEquals(Boolean.FALSE, checkbox1.getValue());
}