use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class TokenEscapingTest method testTokenEscaping.
/**
* Verify that no events are issued via newItem if there were not reqeuested.
*/
@Test(timeout = 5000)
public Promise<Void> testTokenEscaping() {
return new Promise<>((resolve, reject) -> {
final String shouldBeEncoded = "% ^[]|\"<>{}\\";
final String shouldBeEncodedAs = "%25%20%5E%5B%5D%7C%22%3C%3E%7B%7D%5C";
addHistoryListenerImpl(event -> {
assertEquals(shouldBeEncodedAs, getCurrentLocationHash());
assertEquals(shouldBeEncoded, event.getValue());
resolve.onInvoke((Void) null);
});
timer = new Timer() {
@Override
public void run() {
History.newItem(shouldBeEncoded);
}
};
timer.schedule(500);
});
}
use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class TokenNonescapingTest method testTokenNonescaping.
/**
* Verify that no events are issued via newItem if there were not reqeuested.
*/
@Test(timeout = 5000)
public Promise<Void> testTokenNonescaping() {
return new Promise<>((resolve, reject) -> {
final String shouldNotChange = "abc;,/?:@&=+$-_.!~*()ABC123foo";
addHistoryListenerImpl(event -> {
assertEquals(shouldNotChange, event.getValue());
resolve.onInvoke((Void) null);
});
timer = new Timer() {
@Override
public void run() {
History.newItem(shouldNotChange);
}
};
timer.schedule(500);
});
}
use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class NoEventsTest method testNoEvents.
/**
* Verify that no events are issued via newItem if there were not reqeuested.
*/
@Test(timeout = 5000)
public Promise<Void> testNoEvents() {
return new Promise<>((resolve, reject) -> {
timer = new Timer() {
@Override
public void run() {
resolve.onInvoke((Void) null);
}
};
addHistoryListenerImpl(event -> fail("onHistoryChanged should not have been called"));
History.newItem("testNoEvents", false);
timer.scheduleRepeating(500);
});
}
use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class ReplaceItemTest method testReplaceItem.
/**
* Verify that no events are issued via newItem if there were not reqeuested.
*/
@Test(timeout = 5000)
public Promise<Void> testReplaceItem() {
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 historyToken3 = "token3";
addHistoryListenerImpl(new ValueChangeHandler<String>() {
private int state = 0;
@Override
public void onValueChange(ValueChangeEvent<String> event) {
String historyToken = event.getValue();
switch(state) {
case 0:
{
if (!historyToken.equals(historyToken1)) {
fail("Expecting token '" + historyToken1 + "', but got: " + historyToken);
}
state = 1;
History.newItem(historyToken2);
break;
}
case 1:
{
if (!historyToken.equals(historyToken2)) {
fail("Expecting token '" + historyToken2 + "', but got: " + historyToken);
}
state = 2;
History.replaceItem(historyToken3, true);
break;
}
case 2:
{
if (!historyToken.equals(historyToken3)) {
fail("Expecting token '" + historyToken3 + "', but got: " + historyToken);
}
state = 3;
History.back();
break;
}
case 3:
{
if (!historyToken.equals(historyToken1)) {
fail("Expecting token '" + historyToken1 + "', but got: " + historyToken);
}
resolve.onInvoke((Void) null);
}
}
}
});
History.newItem(historyToken1);
timer = new Timer() {
@Override
public void run() {
History.newItem(historyToken1);
}
};
timer.schedule(500);
});
}
use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class ImageResourceTest method testAttachDetach.
/**
* Test that attaching and immediately detaching an element does not cause an error.
*/
public void testAttachDetach() {
final Image image = (Image) document.createElement("img");
document.body.appendChild(image);
document.body.removeChild(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