use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class NoDoubleTokenUnEscapingTest method testNoDoubleTokenUnEscaping.
/**
* Verify that no events are issued via newItem if there were not reqeuested.
*/
// @Test(timeout = 5000)
public Promise<Void> testNoDoubleTokenUnEscaping() {
return new Promise<>((resolve, reject) -> {
final String shouldBeEncoded = "abc%20abc";
History.newItem(shouldBeEncoded);
History.newItem("someOtherToken");
History.back();
// allow browser to update the url
timer = new Timer() {
@Override
public void run() {
// make sure that value in url actually matches the original token
assertEquals(shouldBeEncoded, History.getToken());
resolve.onInvoke((Void) null);
}
};
timer.schedule(500);
});
}
use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class ReplaceItemNoEventTest method testReplaceItemNoEvent.
/**
* Verify that no events are issued via newItem if there were not reqeuested.
*/
@Test(timeout = 5000)
public Promise<Void> testReplaceItemNoEvent() {
return new Promise<>((resolve, reject) -> {
/*
* Sentinel token which should only be seen if tokens are lost during the rest of the test.
* Without this, History.back() might send the browser too far back, i.e. back to before the web
* app containing our test module.
*/
History.newItem("if-you-see-this-then-history-went-back-too-far");
final String historyToken1 = "token1";
final String historyToken2 = "token 2";
final String historyToken2_encoded = "token%202";
History.newItem(historyToken1);
addHistoryListenerImpl(event -> fail("No event expected"));
History.replaceItem(historyToken2, false);
assertEquals(historyToken2, History.getToken());
timer = new Timer() {
@Override
public void run() {
// Make sure that we have updated the URL properly.
assertEquals(historyToken2_encoded, getCurrentLocationHash());
resolve.onInvoke((Void) null);
}
};
timer.schedule(500);
});
}
use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class TokenWithQuestionmarkTest method testTokenWithQuestionmark.
/**
* Test that using an empty history token works properly. There have been problems (see issue
* 2905) with this in the past on Safari.
*
* <p>Seems like a HtmlUnit bug. Need more investigation.
*/
@Test(timeout = 5000)
public Promise<Void> testTokenWithQuestionmark() {
return new Promise<>((resolve, reject) -> {
final String token = "foo?bar";
timer = new Timer() {
@Override
public void run() {
History.newItem(token);
}
};
addHistoryListenerImpl(event -> {
String historyToken = event.getValue();
if (historyToken == null) {
fail("historyToken should not be null");
}
assertEquals(token, historyToken);
timer.cancel();
resolve.onInvoke((Void) null);
});
History.newItem(token);
});
}
use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class ResizeLayoutPanelTest method testResizeContainer.
/**
* Test that resizing the outer container triggers a resize event.
*
* @param container the container that will hold the panel
* @param resizeCommand the command that resizes the container
*/
private void testResizeContainer(final SimplePanel container, final Command resizeCommand) {
// Create a panel and add a handler.
ResizeLayoutPanel panel = createPanel();
panel.setWidget(new Label("hello world"));
panel.setWidth("100%");
panel.setHeight("100%");
final CustomResizeHandler handler = new CustomResizeHandler();
panel.addResizeHandler(handler);
handler.assertResizeFired(false);
// Create an outer container and attach it.
container.setWidget(panel);
RootPanel.get().add(container);
// Wait for the resize event from attaching.
delayTestFinish(10000);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
// Triggered by attach.
handler.assertResizeFired(true);
// Change the size of the container.
resizeCommand.execute();
new Timer() {
@Override
public void run() {
handler.assertResizeFired(true);
container.removeFromParent();
finishTest();
}
}.schedule(250);
}
});
}
use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class ImageTest method testAttachDetach.
/**
* Test that attaching and immediately detaching an element does not cause an
* error.
*/
public void testAttachDetach() {
final Image image = new Image("counting-forwards.png");
RootPanel.get().add(image);
RootPanel.get().remove(image);
// Wait for the synthetic event to attempt to fire.
delayTestFinish(DEFAULT_TEST_TIMEOUT);
new Timer() {
@Override
public void run() {
// The synthetic event did not cause an error.
finishTest();
}
}.schedule(SYNTHETIC_LOAD_EVENT_TIMEOUT);
}
Aggregations