@Test
public void onlyOneCellSelectedAtAnyTime() {
this.selectionLayer.getSelectionModel().setMultipleSelectionAllowed(false);
this.selectionLayer.clear();
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 1, 0,
false, true));
Collection<PositionCoordinate> cells = ArrayUtil
.asCollection(this.selectionLayer.getSelectedCellPositions());
Assert.assertEquals(1, cells.size());
Assert.assertTrue(cells.contains(new PositionCoordinate(this.selectionLayer,
1, 0)));
// select another cell with control mask
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 2, 0,
false, true));
cells = ArrayUtil.asCollection(this.selectionLayer
.getSelectedCellPositions());
Assert.assertEquals(1, cells.size());
Assert.assertTrue(cells.contains(new PositionCoordinate(this.selectionLayer,
2, 0)));
// select additional cells with shift mask
// only the first cell should be selected afterwards
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 2, 10,
true, false));
cells = ArrayUtil.asCollection(this.selectionLayer
.getSelectedCellPositions());
Assert.assertEquals(1, cells.size());
Assert.assertTrue(cells.contains(new PositionCoordinate(this.selectionLayer,
2, 0)));
// select additional cells with shift mask
// only the first cell should be selected afterwards
this.selectionLayer.doCommand(new SelectCellCommand(this.selectionLayer, 10, 0,
true, false));
cells = ArrayUtil.asCollection(this.selectionLayer
.getSelectedCellPositions());
Assert.assertEquals(1, cells.size());