use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class ImageTest method testOneEventOnly.
public void testOneEventOnly() {
final Image image = new Image("counting-forwards.png");
final TestLoadHandler loadHandler = new TestLoadHandler() {
@Override
public void onLoad(LoadEvent event) {
if (isFinished()) {
fail("LoadHandler fired multiple times.");
}
finish();
}
};
image.addErrorHandler(new TestErrorHandler(image));
image.addLoadHandler(loadHandler);
RootPanel.get().add(image);
delayTestFinish(DEFAULT_TEST_TIMEOUT);
new Timer() {
@Override
public void run() {
assertTrue(loadHandler.isFinished());
finishTest();
}
}.schedule(LOAD_EVENT_TIMEOUT);
}
use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class ImageTest method testChangeImageToClippedSynchronously.
/**
* Tests the transition from the unclipped state to the clipped state
* before a load event fires.
*/
public void testChangeImageToClippedSynchronously() {
final Image image = new Image("counting-forwards.png");
assertEquals("unclipped", getCurrentImageStateName(image));
image.addErrorHandler(new TestErrorHandler(image));
final TestLoadHandler loadHandler = new TestLoadHandler() {
@Override
public void onLoad(LoadEvent event) {
if (isFinished()) {
fail("LoadHandler fired twice. Expected it to fire only once.");
}
assertEquals("clipped", getCurrentImageStateName(image));
assertEquals(12, image.getOriginLeft());
assertEquals(13, image.getOriginTop());
assertEquals(8, image.getWidth());
assertEquals(8, image.getHeight());
finish();
}
};
image.addLoadHandler(loadHandler);
/*
* Change the image to a clipped image before a load event fires. We only
* expect one asynchronous load event to fire for the final state. This is
* consistent with the expected behavior of changing the source URL multiple
* times.
*/
RootPanel.get().add(image);
image.setVisibleRect(12, 13, 8, 8);
assertEquals("clipped", getCurrentImageStateName(image));
delayTestFinish(DEFAULT_TEST_TIMEOUT);
new Timer() {
@Override
public void run() {
assertTrue(loadHandler.isFinished());
finishTest();
}
}.schedule(SYNTHETIC_LOAD_EVENT_TIMEOUT);
}
use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class FormPanelTest method testWrappedForm.
public void testWrappedForm() {
// Create a form and frame in the document we can wrap.
final String iframeId = Document.get().createUniqueId();
final String iframeName = Document.get().createUniqueId();
final Element container = Document.get().createDivElement();
container.setInnerHTML("<form method='post' target='" + iframeName + "' action='" + "formHandler?sendHappyHtml'>" + "<input type='hidden' name='foo' value='bar'></input></form>" + "<iframe src=\"javascript:\'\'\" id='" + iframeId + "' " + "name='" + iframeName + "'></iframe>");
Document.get().getBody().appendChild(container);
// Wrap the form and make sure its target frame is intact.
FormPanel form = FormPanel.wrap(container.getFirstChildElement());
assertEquals(iframeName, form.getTarget());
// Ensure that no synthesized iframe was created.
assertNull(form.getSynthesizedIFrame());
// Submit the form and make sure the target frame comes back with the right
// stuff (give it 2.5 s to complete).
delayTestFinish(TEST_DELAY);
form.submit();
new Timer() {
@Override
public void run() {
// Get the targeted frame and make sure it contains the requested
// 'happyElem'.
Frame frame = Frame.wrap(Document.get().getElementById(iframeId));
assertTrue(isHappyDivPresent(frame.getElement()));
finishTest();
}
}.schedule(TEST_DELAY - 2000);
}
use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class FormPanelTest method testSubmitFrame.
/**
* Tests submitting an alternate frame.
*/
public void testSubmitFrame() {
final NamedFrame frame = new NamedFrame("myFrame");
FormPanel form = new FormPanel(frame);
form.setMethod(FormPanel.METHOD_POST);
form.setAction("formHandler?sendHappyHtml");
RootPanel.get().add(form);
RootPanel.get().add(frame);
delayTestFinish(TEST_DELAY);
form.submit();
Timer t = new Timer() {
@Override
public void run() {
// Make sure the frame got the contents we expected.
assertTrue(isHappyDivPresent(frame.getElement()));
finishTest();
}
};
// Wait 5 seconds before checking the results.
t.schedule(TEST_DELAY - 2000);
}
use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class DisclosurePanelTest method testCoreFunctionality.
/**
* Test to ensure css style changes that control core functionality do change
* appropriately.
*/
public void testCoreFunctionality() {
final DisclosurePanel panel = createTestPanel();
assertTrue(DOM.getParent(panel.getContent().getElement()).getStyle().getProperty("display").equalsIgnoreCase("none"));
panel.setOpen(true);
delayTestFinish(5000);
// Allow the animation time to finish
Timer t = new Timer() {
@Override
public void run() {
assertTrue(DOM.getParent(panel.getContent().getElement()).getStyle().getProperty("display").trim().equals(""));
finishTest();
}
};
t.schedule(450);
}
Aggregations