use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class AbstractSelectionModelTest method testResolveChanges.
/**
* Test that resolving changes doesn't prevent an event from firing.
*/
public void testResolveChanges() {
AbstractSelectionModel<String> model = createSelectionModel(null);
final MockSelectionChangeHandler handler = new MockSelectionChangeHandler();
model.addSelectionChangeHandler(handler);
model.setSelected("test1", true);
handler.assertEventFired(false);
model.isSelected("test1");
new Timer() {
@Override
public void run() {
handler.assertEventFired(true);
finishTest();
}
}.schedule(1000);
}
use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class DefaultSelectionModelTest method testNoDuplicateChangeEvent.
public void testNoDuplicateChangeEvent() {
delayTestFinish(2000);
final DefaultSelectionModel<String> model = createSelectionModel(null);
final MockSelectionChangeHandler handler = new AssertOneSelectionChangeEventOnlyHandler();
model.addSelectionChangeHandler(handler);
model.setSelected("selected999", false);
// selection events fire at the end of current event loop (finally command)
handler.assertEventFired(false);
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
handler.assertEventFired(true);
// No further selection events should be fired
model.addSelectionChangeHandler(new FailingSelectionChangeEventHandler());
model.setSelected("selected999", false);
model.setSelected("selected999", false);
}
});
new Timer() {
@Override
public void run() {
finishTest();
}
}.schedule(1000);
}
use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class MultiSelectionModelTest method testNoDuplicateChangeEventWithKeyProvider.
/**
* Tests that reselecting the same key from a different item does not fire a
* change event.
*/
public void testNoDuplicateChangeEventWithKeyProvider() {
delayTestFinish(2000);
ProvidesKey<String> keyProvider = item -> item.toUpperCase(Locale.ROOT);
MultiSelectionModel<String> model = createSelectionModel(keyProvider);
model.setSelected("test1", true);
assertTrue(model.isSelected("test1"));
// Selecting a different item with the same key should not be seen as a
// selection change
String replacement = "TEST1";
model.addSelectionChangeHandler(new FailingSelectionChangeEventHandler());
model.setSelected(replacement, true);
assertTrue(model.isSelected(replacement));
assertEquals(1, model.getSelectedSet().size());
assertSame(replacement, model.getSelectedSet().iterator().next());
new Timer() {
@Override
public void run() {
finishTest();
}
}.schedule(1000);
}
use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class SingleSelectionModelTest method testNoDuplicateChangeEvent.
public void testNoDuplicateChangeEvent() {
delayTestFinish(2000);
SingleSelectionModel<String> model = createSelectionModel(null);
MockSelectionChangeHandler handler = new AssertOneSelectionChangeEventOnlyHandler();
model.addSelectionChangeHandler(handler);
model.setSelected("test", true);
// selection events fire at the end of current event loop (finally command)
handler.assertEventFired(false);
Scheduler.get().scheduleDeferred(() -> {
handler.assertEventFired(true);
// No further selection events should be fired
model.addSelectionChangeHandler(new FailingSelectionChangeEventHandler());
model.setSelected("test", true);
model.setSelected("test", true);
});
new Timer() {
@Override
public void run() {
finishTest();
}
}.schedule(1000);
}
use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.
the class SingleSelectionModelTest method testNoDuplicateChangeEvent2.
public void testNoDuplicateChangeEvent2() {
delayTestFinish(2000);
SingleSelectionModel<String> model = createSelectionModel(null);
// no event at all should be fired, as selection events fire at the end of current event loop
// and at that point no state has been effectively changed.
model.addSelectionChangeHandler(new FailingSelectionChangeEventHandler());
model.setSelected("test", true);
model.setSelected("test", false);
model.setSelected("test", false);
model.setSelected("test", false);
new Timer() {
@Override
public void run() {
finishTest();
}
}.schedule(1000);
}
Aggregations