}
public void testBehaviour() {
// Ignore own cursor
me.extractor.writeSelection(
cxt.document(), new FocusedRange(2, 4), "wo", handlerTimer.currentTimeMillis());
assertTrue(markerFactory.markers.isEmpty());
check("abcdefghij");
joe.extractor.writeSelection(
cxt.document(), new FocusedRange(1, 3), "ni", handlerTimer.currentTimeMillis());
assertFalse(markerFactory.markers.isEmpty());
CaretView joeUi = handler.getUiForSession(joe.id);
verify(joeUi).setName("Joe");
verify(joeUi).setCompositionState("ni");
assertFalse(markerFactory.isAttached(joeUi));
painterTimer.tick(10);
assertTrue(markerFactory.isAttached(joeUi));
check("a<s>bc</s><b/>defghij");
joe.setName("Jimbo");
verify(joeUi).setName("Jimbo");
assertEquals(2, painterRegistry.getKeys().countEntries());
handlerTimer.tick(STALE_CARET_TIMEOUT_MS / 2);
joe.setName("Jimbo2");
verify(joeUi, atMost(1)).setName("Jimbo2");
// check cleanup after timeout
handlerTimer.tick(STALE_CARET_TIMEOUT_MS);
joe.setName("Jimbo3");
verify(joeUi, never()).setName("Jimbo3");
assertEquals(0, painterRegistry.getKeys().countEntries());
joe.extractor.writeSelection(
cxt.document(), new FocusedRange(2, 4), "ni", handlerTimer.currentTimeMillis());
handlerTimer.tick(STALE_CARET_TIMEOUT_MS - 1);
painterTimer.tick(10);
joe.setName("Jimbo4");
verify(joeUi).setName("Jimbo4");
joe.extractor.writeSelection(
cxt.document(), new FocusedRange(2, 4), "ni", handlerTimer.currentTimeMillis());
handlerTimer.tick(STALE_CARET_TIMEOUT_MS - 1);
painterTimer.tick(10);
joe.setName("Jimbo5");
verify(joeUi).setName("Jimbo5");
}