net.sf.gridarta.model.mapcursor
public class MapCursorTest extends Object
MapCursor
.Modifier and Type | Class and Description |
---|---|
private static class |
MapCursorTest.TestMapCursorListener
A
MapCursorListener that counts the number of event callbacks. |
Modifier and Type | Field and Description |
---|---|
private static int |
ENTER_X
The enter x coordinate of newly created maps.
|
private static int |
ENTER_Y
The enter y coordinate of newly created maps.
|
private static Size2D |
gridSize
The size of the map grid for the tested cursor.
|
private static MapCursorTest.TestMapCursorListener |
listener
A
MapCursorTest.TestMapCursorListener that counts the number of callbacks. |
Constructor and Description |
---|
MapCursorTest() |
Modifier and Type | Method and Description |
---|---|
private static void |
assertPreSelection(MapGrid grid,
Point start,
Point end)
Checks that a
MapGrid includes a rectangle of MapGrid.GRID_FLAG_SELECTING . |
private static void |
assertSelection(MapGrid grid,
Point start,
Point end,
boolean flag)
Checks that a
MapGrid includes a rectangle of MapGrid.GRID_FLAG_SELECTION . |
private static MapCursor<TestGameObject,TestMapArchObject,TestArchetype> |
createCursor(MapGrid grid)
Creates a new
MapCursor instance. |
void |
dragging()
Checks the dragging related functions of
MapCursor . |
private static void |
dragTo(MapCursor<TestGameObject,TestMapArchObject,TestArchetype> cursor,
MapGrid grid,
Direction dir,
Point start,
Point p,
Dimension offset)
Calls
MapCursor.dragTo(Point) and checks for expected results. |
void |
selecting()
Checks for correct behavior of
MapGrid.GRID_FLAG_SELECTING flags
during selecting. |
void |
setInside()
Checks that settings the cursor within the map grid behaves as expected.
|
void |
setLocationSafe()
Checks
MapCursor.setLocationSafe(Point) . |
void |
setOutside()
Checks that settings the cursor outside of the grid behaves as expected.
|
void |
setSameLocation()
Checks that settings the cursor to the same location does not generate
excess events.
|
static junit.framework.Test |
suite()
Returns a new test suite containing this test.
|
private static void |
testEvents(int nPos,
int nMode)
Checks if the number of events fired is correct.
|
void |
testGoTo()
|
void |
testIsOnGrid()
Checks
MapCursor.isOnGrid(Point) . |
private static final int ENTER_X
private static final int ENTER_Y
@NotNull private static final Size2D gridSize
@NotNull private static final MapCursorTest.TestMapCursorListener listener
MapCursorTest.TestMapCursorListener
that counts the number of callbacks.public MapCursorTest()
@NotNull private static MapCursor<TestGameObject,TestMapArchObject,TestArchetype> createCursor(@NotNull MapGrid grid)
MapCursor
instance. No more than one instance may
exist concurrently.grid
- the underlying map gridpublic void setOutside()
public void setInside()
public void setSameLocation()
public void setLocationSafe()
MapCursor.setLocationSafe(Point)
.public void testIsOnGrid()
MapCursor.isOnGrid(Point)
.public void testGoTo()
private static void dragTo(@NotNull MapCursor<TestGameObject,TestMapArchObject,TestArchetype> cursor, @NotNull MapGrid grid, @NotNull Direction dir, @NotNull Point start, @NotNull Point p, @NotNull Dimension offset)
MapCursor.dragTo(Point)
and checks for expected results.cursor
- the map cursor to affectgrid
- the associated map griddir
- the direction to dragstart
- the starting locationp
- the destination locationoffset
- the expected dragging offsetprivate static void assertPreSelection(@NotNull MapGrid grid, @NotNull Point start, @NotNull Point end)
MapGrid
includes a rectangle of MapGrid.GRID_FLAG_SELECTING
.grid
- the map grid to checkstart
- one corner of the rectangleend
- the diagonally opposite corner of the rectangleprivate static void assertSelection(@NotNull MapGrid grid, @NotNull Point start, @NotNull Point end, boolean flag)
MapGrid
includes a rectangle of MapGrid.GRID_FLAG_SELECTION
. Squares outside the rectangle are not
checked.grid
- the map grid to checkstart
- one corner of the rectangleend
- the diagonally opposite corner of the rectangleflag
- the expected selection statepublic void selecting()
MapGrid.GRID_FLAG_SELECTING
flags
during selecting.private static void testEvents(int nPos, int nMode)
nPos
- the expected number of position eventsnMode
- the expected number of mode events@NotNull public static junit.framework.Test suite()
Feedback: webmaster
© 2003-2010 The Gridarta Developers. All rights reserved.