final int none=MapMouseEvent.NONE;
final int ctrl = MapMouseEvent.CTRL_DOWN_MASK;
final int shift = MapMouseEvent.SHIFT_DOWN_MASK;
final int button1 = MapMouseEvent.BUTTON1;
TestHandler handler=new TestHandler();
handler.getBehaviours().add(mode);
handler.getTestEditBlackboard().util.setVertexRadius(4);
handler.setCurrentShape(handler.getEditBlackboard().getGeoms().get(0).getShell());
handler.getEditBlackboard().addPoint(10,10, handler.getCurrentGeom().getShell());
handler.getEditBlackboard().addPoint(15,15, handler.getCurrentGeom().getShell());
handler.getEditBlackboard().addPoint(20,15, handler.getCurrentGeom().getShell());
handler.getEditBlackboard().addPoint(30,25, handler.getCurrentGeom().getShell());
//test click on point
handler.handleEvent(new MapMouseEvent(null, 9, 10, none, none, button1), EventType.RELEASED);
assertEquals(1, handler.getEditBlackboard().getSelection().size());
assertEquals(Point.valueOf(10,10), handler.getEditBlackboard().getSelection().iterator().next());
//test click on same point
handler.handleEvent(new MapMouseEvent(null, 10, 10, none, none, button1), EventType.RELEASED);
assertEquals(Point.valueOf(10,10), handler.getEditBlackboard().getSelection().iterator().next());
assertEquals(1, handler.getEditBlackboard().getSelection().size());
//test click on new point
handler.handleEvent( new MapMouseEvent(null, 15, 15, none, none, button1), EventType.RELEASED);
assertEquals(Point.valueOf(15,15), handler.getEditBlackboard().getSelection().iterator().next());
assertEquals(1, handler.getEditBlackboard().getSelection().size());
//test add to selection via SHIFT-click
MapMouseEvent event = new MapMouseEvent(null, 10, 10, shift, none, button1);
handler.handleEvent( event, EventType.RELEASED);
assertEquals(2, handler.getEditBlackboard().getSelection().size());
assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(10,10)));
assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(15,15)));
//test no change to selection if SHIFT-click on selected vertex
event= new MapMouseEvent(null, 15, 15, shift, none, button1);
handler.handleEvent( event, EventType.RELEASED);
assertEquals(2, handler.getEditBlackboard().getSelection().size());
assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(10,10)));
assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(15,15)));
//test add to selection via CTRL-click
event= new MapMouseEvent(null, 20, 15, ctrl, none, button1);
handler.handleEvent( event, EventType.RELEASED);
assertEquals(3, handler.getEditBlackboard().getSelection().size());
assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(10,10)));
assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(15,15)));
assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(20,15)));
//test remove from selection via CTRL-click
event= new MapMouseEvent(null, 15, 15, ctrl, none, button1);
handler.handleEvent( event, EventType.RELEASED);
assertEquals(2, handler.getEditBlackboard().getSelection().size());
assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(10,10)));
assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(20,15)));
//test no change when SHIFT-click and CTRL-click on nothing
event= new MapMouseEvent(null, 300, 300, shift, none, button1);
handler.handleEvent( event, EventType.RELEASED);
assertEquals(2, handler.getEditBlackboard().getSelection().size());
assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(10,10)));
assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(20,15)));
event= new MapMouseEvent(null, 300, 300, ctrl, none, button1);
handler.handleEvent( event, EventType.RELEASED);
assertEquals(2, handler.getEditBlackboard().getSelection().size());
assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(10,10)));
assertTrue(handler.getEditBlackboard().getSelection().contains(Point.valueOf(20,15)));
handler.getEditBlackboard().selectionClear();
//test no add when click SHIFT-click and CTRL-click on nothing
event= new MapMouseEvent(null, 300, 300, shift, none, button1);
handler.handleEvent( event, EventType.RELEASED);
assertEquals(0, handler.getEditBlackboard().getSelection().size());
event= new MapMouseEvent(null, 300, 300, ctrl, none, button1);
handler.handleEvent( event, EventType.RELEASED);
assertEquals(0, handler.getEditBlackboard().getSelection().size());
}