From 8641164929f9c84bc927c656e81a15d948533009 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Wed, 4 May 2011 19:08:14 +0200 Subject: stone collection tests done git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@114 72836036-5685-4462-b002-a69064685172 --- test/jrummikub/control/TurnControlTest.java | 38 ++++++++++++++++++++++- test/jrummikub/view/MockStoneCollectionPanel.java | 4 +-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/test/jrummikub/control/TurnControlTest.java b/test/jrummikub/control/TurnControlTest.java index 840e83f..60ff37f 100644 --- a/test/jrummikub/control/TurnControlTest.java +++ b/test/jrummikub/control/TurnControlTest.java @@ -2,6 +2,7 @@ package jrummikub.control; import static org.junit.Assert.*; +import java.util.Collections; import java.util.List; import java.util.ArrayList; import java.util.Arrays; @@ -146,10 +147,45 @@ public class TurnControlTest { mockView.playerPanel.handPanel.stoneClickEvent.emit(secondStone, true); mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit( - firstStone, true); + firstStone, false); assertCollection(Arrays.asList(secondStone)); } + + @Test + public void reorderCollection() { + + TurnControl testControl = new TurnControl(null, null, mockView, + mockTimer); + Stone firstStone = new Stone(StoneColor.RED); + Stone secondStone = new Stone(StoneColor.BLACK); + + mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true); + mockView.playerPanel.handPanel.stoneClickEvent.emit(secondStone, true); + + mockView.tablePanel.stoneCollectionPanel.stoneClickEvent.emit( + firstStone, true); + + assertCollection(Arrays.asList(secondStone, firstStone)); + } + + @Test + public void deselectWholeCollection() { + + TurnControl testControl = new TurnControl(null, null, mockView, + mockTimer); + Stone firstStone = new Stone(StoneColor.RED); + Stone secondStone = new Stone(StoneColor.BLACK); + + mockView.playerPanel.handPanel.stoneClickEvent.emit(firstStone, true); + mockView.playerPanel.handPanel.stoneClickEvent.emit(secondStone, true); + + mockView.tablePanel.stoneCollectionPanel.setClickEvent.emit( + firstStone, true); + + assertCollection(new ArrayList()); + } + private void assertCollection(List expected) { ArrayList selectedStones = new ArrayList( diff --git a/test/jrummikub/view/MockStoneCollectionPanel.java b/test/jrummikub/view/MockStoneCollectionPanel.java index bec3734..70016e5 100644 --- a/test/jrummikub/view/MockStoneCollectionPanel.java +++ b/test/jrummikub/view/MockStoneCollectionPanel.java @@ -7,6 +7,7 @@ import jrummikub.util.IEvent2; public class MockStoneCollectionPanel implements IStoneCollectionPanel { public Event2 stoneClickEvent = new Event2(); + public Event2 setClickEvent = new Event2(); @Override public IEvent2 getStoneClickEvent() { @@ -21,8 +22,7 @@ public class MockStoneCollectionPanel implements IStoneCollectionPanel { @Override public IEvent2 getSetClickEvent() { - // TODO Auto-generated method stub - return null; + return setClickEvent; } } -- cgit v1.2.3