diff options
author | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-04 21:47:35 +0200 |
---|---|---|
committer | Jannis Harder <harder@informatik.uni-luebeck.de> | 2011-05-04 21:47:35 +0200 |
commit | 88766c6df209637ddb3e97a38e8a1aa45a8bd515 (patch) | |
tree | 111535a302e4990090333569493663fb81a5c441 /test/jrummikub/control | |
parent | fe019e5eae8d8e740d7620044727988c6d28a423 (diff) | |
download | JRummikub-88766c6df209637ddb3e97a38e8a1aa45a8bd515.tar JRummikub-88766c6df209637ddb3e97a38e8a1aa45a8bd515.zip |
Selecting/collecting on table (without range)
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@124 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'test/jrummikub/control')
-rw-r--r-- | test/jrummikub/control/TurnControlTest.java | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/test/jrummikub/control/TurnControlTest.java b/test/jrummikub/control/TurnControlTest.java index 60ff37f..befe8f6 100644 --- a/test/jrummikub/control/TurnControlTest.java +++ b/test/jrummikub/control/TurnControlTest.java @@ -7,8 +7,10 @@ import java.util.List; import java.util.ArrayList; import java.util.Arrays; +import jrummikub.model.MockTable; import jrummikub.model.Stone; import jrummikub.model.StoneColor; +import jrummikub.model.StoneSet; import jrummikub.util.Event; import jrummikub.util.IEvent; import jrummikub.util.IListener; @@ -42,12 +44,14 @@ public class TurnControlTest { MockView mockView; MockTimer mockTimer; + MockTable mockTable; boolean eventFired; @Before public void setUp() { mockView = new MockView(); mockTimer = new MockTimer(); + mockTable = new MockTable(); } @Test @@ -186,6 +190,91 @@ public class TurnControlTest { assertCollection(new ArrayList<Stone>()); } + @Test + public void selectStoneOnTable() { + TurnControl testControl = new TurnControl(null, null, mockView, + mockTimer); + + Stone firstStone = new Stone(StoneColor.RED); + + // Select first stone + mockView.tablePanel.stoneClickEvent.emit(firstStone, false); + + assertCollection(Arrays.asList(firstStone)); + + // Select second stone + Stone secondStone = new Stone(StoneColor.BLACK); + mockView.tablePanel.stoneClickEvent.emit(secondStone, false); + + assertCollection(Arrays.asList(secondStone)); + + } + + @Test + public void collectStoneOnTable() { + TurnControl testControl = new TurnControl(null, null, mockView, + mockTimer); + + Stone firstStone = new Stone(StoneColor.RED); + + // Select first stone + mockView.tablePanel.stoneClickEvent.emit(firstStone, true); + + assertCollection(Arrays.asList(firstStone)); + + // Select second stone + Stone secondStone = new Stone(StoneColor.BLACK); + mockView.tablePanel.stoneClickEvent.emit(secondStone, true); + + assertCollection(Arrays.asList(firstStone, secondStone)); + + // De-select first stone + mockView.tablePanel.stoneClickEvent.emit(firstStone, true); + + assertCollection(Arrays.asList(secondStone)); + } + + @Test + public void selectSetOnTable() { + TurnControl testControl = new TurnControl(null, mockTable, mockView, + mockTimer); + + Stone stone1 = new Stone(StoneColor.RED); + Stone stone2 = new Stone(StoneColor.BLACK); + StoneSet set1 = new StoneSet(Arrays.asList(stone1, stone2)); + Stone stone3 = new Stone(1, StoneColor.RED); + Stone stone4 = new Stone(1, StoneColor.BLACK); + StoneSet set2 = new StoneSet(Arrays.asList(stone3, stone4)); + + mockTable.findStoneSet.put(stone1, set1); + mockTable.findStoneSet.put(stone4, set2); + + mockView.tablePanel.setClickEvent.emit(stone1, false); + assertCollection(Arrays.asList(stone1, stone2)); + mockView.tablePanel.setClickEvent.emit(stone4, false); + assertCollection(Arrays.asList(stone3, stone4)); + } + + @Test + public void collectSetOnTable() { + TurnControl testControl = new TurnControl(null, mockTable, mockView, + mockTimer); + + Stone stone1 = new Stone(StoneColor.RED); + Stone stone2 = new Stone(StoneColor.BLACK); + StoneSet set1 = new StoneSet(Arrays.asList(stone1, stone2)); + Stone stone3 = new Stone(1, StoneColor.RED); + Stone stone4 = new Stone(1, StoneColor.BLACK); + StoneSet set2 = new StoneSet(Arrays.asList(stone3, stone4)); + + mockTable.findStoneSet.put(stone1, set1); + mockTable.findStoneSet.put(stone4, set2); + + mockView.tablePanel.setClickEvent.emit(stone1, true); + assertCollection(Arrays.asList(stone1, stone2)); + mockView.tablePanel.setClickEvent.emit(stone4, true); + assertCollection(Arrays.asList(stone1, stone2, stone3, stone4)); + } private void assertCollection(List<Stone> expected) { ArrayList<Stone> selectedStones = new ArrayList<Stone>( |