![]() |
Gridarta Editor
|
Unit test for MapCursor. More...
Classes | |
class | TestMapCursorListener |
A MapCursorListener that counts the number of event callbacks. More... | |
Public Member Functions | |
void | dragging () |
Checks the dragging related functions of MapCursor. More... | |
void | selecting () |
Checks for correct behavior of MapGrid#GRID_FLAG_SELECTING flags during selecting. More... | |
void | setInside () |
Checks that settings the cursor within the map grid behaves as expected. More... | |
void | setLocationSafe () |
Checks MapCursor#setLocationSafe(Point). More... | |
void | setOutside () |
Checks that settings the cursor outside of the grid behaves as expected. More... | |
void | setSameLocation () |
Checks that settings the cursor to the same location does not generate excess events. More... | |
void | testGoTo () |
Checks MapCursor#goTo(boolean, Direction). More... | |
void | testIsOnGrid () |
Checks MapCursor#isOnGrid(Point). More... | |
Static Public Member Functions | |
static junit.framework.Test | suite () |
Returns a new test suite containing this test. More... | |
Static Private Member Functions | |
static void | assertPreSelection (@NotNull final MapGrid grid, @NotNull final Point start, @NotNull final Point end) |
Checks that a MapGrid includes a rectangle of {}. More... | |
static void | assertSelection (@NotNull final MapGrid grid, @NotNull final Point start, @NotNull final Point end, final boolean flag) |
Checks that a MapGrid includes a rectangle of {}. More... | |
static MapCursor< TestGameObject, TestMapArchObject, TestArchetype > | createCursor (@NotNull final MapGrid grid) |
Creates a new MapCursor instance. More... | |
static void | dragTo (@NotNull final MapCursor< TestGameObject, TestMapArchObject, TestArchetype > cursor, @NotNull final MapGrid grid, @NotNull final Direction dir, @NotNull final Point start, @NotNull final Point p, @NotNull final Dimension offset) |
Calls MapCursor#dragTo(Point) and checks for expected results. More... | |
static void | testEvents (final int nPos, final int nMode) |
Checks if the number of events fired is correct. More... | |
Static Private Attributes | |
static final int | ENTER_X = 1 |
The enter x coordinate of newly created maps. More... | |
static final int | ENTER_Y = 2 |
The enter y coordinate of newly created maps. More... | |
static final Size2D | GRID_SIZE = new Size2D(6, 7) |
The size of the map grid for the tested cursor. More... | |
static final TestMapCursorListener | LISTENER = new TestMapCursorListener() |
A MapCursorListener that counts the number of callbacks. More... | |
Unit test for MapCursor.
Definition at line 46 of file MapCursorTest.java.
|
staticprivate |
Checks that a MapGrid includes a rectangle of {}.
grid | the map grid to check |
start | one corner of the rectangle |
end | the diagonally opposite corner of the rectangle |
Definition at line 310 of file MapCursorTest.java.
References net.sf.gridarta.utils.Size2D.getHeight(), net.sf.gridarta.utils.Size2D.getWidth(), net.sf.gridarta.model.mapgrid.MapGrid.GRID_FLAG_SELECTING, and net.sf.gridarta.model.mapcursor.MapCursorTest.GRID_SIZE.
Referenced by net.sf.gridarta.model.mapcursor.MapCursorTest.dragTo(), and net.sf.gridarta.model.mapcursor.MapCursorTest.selecting().
|
staticprivate |
Checks that a MapGrid includes a rectangle of {}.
Squares outside the rectangle are not checked.
grid | the map grid to check |
start | one corner of the rectangle |
end | the diagonally opposite corner of the rectangle |
flag | the expected selection state |
Definition at line 340 of file MapCursorTest.java.
References net.sf.gridarta.model.mapgrid.MapGrid.GRID_FLAG_SELECTION.
Referenced by net.sf.gridarta.model.mapcursor.MapCursorTest.selecting().
|
staticprivate |
Creates a new MapCursor instance.
No more than one instance may exist concurrently.
grid | the underlying map grid |
Definition at line 77 of file MapCursorTest.java.
References net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.addMapCursorListener(), net.sf.gridarta.model.mapcursor.MapCursorTest.TestMapCursorListener.changedModeCounter, net.sf.gridarta.model.mapcursor.MapCursorTest.TestMapCursorListener.changedPosCounter, net.sf.gridarta.model.mapcursor.MapCursorTest.ENTER_X, net.sf.gridarta.model.mapcursor.MapCursorTest.ENTER_Y, net.sf.gridarta.utils.Size2D.getHeight(), net.sf.gridarta.model.mapmodel.MapModel< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getMapArchObject(), net.sf.gridarta.utils.Size2D.getWidth(), net.sf.gridarta.model.mapcursor.MapCursorTest.LISTENER, and net.sf.gridarta.model.mapmodel.TestMapModelCreator.newMapModel().
Referenced by net.sf.gridarta.model.mapcursor.MapCursorTest.dragging(), net.sf.gridarta.model.mapcursor.MapCursorTest.selecting(), net.sf.gridarta.model.mapcursor.MapCursorTest.setInside(), net.sf.gridarta.model.mapcursor.MapCursorTest.setLocationSafe(), net.sf.gridarta.model.mapcursor.MapCursorTest.setOutside(), net.sf.gridarta.model.mapcursor.MapCursorTest.setSameLocation(), net.sf.gridarta.model.mapcursor.MapCursorTest.testGoTo(), and net.sf.gridarta.model.mapcursor.MapCursorTest.testIsOnGrid().
void net.sf.gridarta.model.mapcursor.MapCursorTest.dragging | ( | ) |
Checks the dragging related functions of MapCursor.
Definition at line 245 of file MapCursorTest.java.
References net.sf.gridarta.model.mapcursor.MapCursorTest.createCursor(), net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.deactivate(), net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.dragStart, net.sf.gridarta.model.mapcursor.MapCursorTest.dragTo(), net.sf.gridarta.model.direction.Direction.EAST, net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getDragOffset(), net.sf.gridarta.model.mapcursor.MapCursorTest.GRID_SIZE, net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.isDragging(), net.sf.gridarta.model.direction.Direction.NORTH_EAST, net.sf.gridarta.model.direction.Direction.NORTH_WEST, net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setLocation(), net.sf.gridarta.model.direction.Direction.SOUTH, net.sf.gridarta.model.mapcursor.MapCursorTest.testEvents(), and net.sf.gridarta.model.direction.Direction.WEST.
|
staticprivate |
Calls MapCursor#dragTo(Point) and checks for expected results.
cursor | the map cursor to affect |
grid | the associated map grid |
dir | the direction to drag |
start | the starting location |
p | the destination location |
offset | the expected dragging offset |
Definition at line 289 of file MapCursorTest.java.
References net.sf.gridarta.model.mapcursor.MapCursorTest.assertPreSelection(), and net.sf.gridarta.model.mapcursor.MapCursorTest.testEvents().
Referenced by net.sf.gridarta.model.mapcursor.MapCursorTest.dragging().
void net.sf.gridarta.model.mapcursor.MapCursorTest.selecting | ( | ) |
Checks for correct behavior of MapGrid#GRID_FLAG_SELECTING flags during selecting.
Definition at line 357 of file MapCursorTest.java.
References net.sf.gridarta.model.mapgrid.SelectionMode.ADD, net.sf.gridarta.model.mapcursor.MapCursorTest.assertPreSelection(), net.sf.gridarta.model.mapcursor.MapCursorTest.assertSelection(), net.sf.gridarta.model.mapcursor.MapCursorTest.createCursor(), net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.deactivate(), net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.dragRelease(), net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.dragSelect(), net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.dragStart, net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.dragTo(), net.sf.gridarta.model.mapgrid.SelectionMode.FLIP, net.sf.gridarta.utils.Size2D.getHeight(), net.sf.gridarta.utils.Size2D.getWidth(), net.sf.gridarta.model.mapcursor.MapCursorTest.GRID_SIZE, net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.isDragging(), net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setLocation(), net.sf.gridarta.model.mapgrid.SelectionMode.SUB, and net.sf.gridarta.model.mapcursor.MapCursorTest.testEvents().
void net.sf.gridarta.model.mapcursor.MapCursorTest.setInside | ( | ) |
Checks that settings the cursor within the map grid behaves as expected.
Definition at line 130 of file MapCursorTest.java.
References net.sf.gridarta.model.mapcursor.MapCursorTest.createCursor(), net.sf.gridarta.utils.Size2D.getHeight(), net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getLocation(), net.sf.gridarta.utils.Size2D.getWidth(), net.sf.gridarta.model.mapcursor.MapCursorTest.GRID_SIZE, net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setLocation(), and net.sf.gridarta.model.mapcursor.MapCursorTest.testEvents().
void net.sf.gridarta.model.mapcursor.MapCursorTest.setLocationSafe | ( | ) |
Checks MapCursor#setLocationSafe(Point).
Definition at line 174 of file MapCursorTest.java.
References net.sf.gridarta.model.mapcursor.MapCursorTest.createCursor(), net.sf.gridarta.model.mapcursor.MapCursorTest.GRID_SIZE, net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setLocationSafe(), and net.sf.gridarta.model.mapcursor.MapCursorTest.testEvents().
void net.sf.gridarta.model.mapcursor.MapCursorTest.setOutside | ( | ) |
Checks that settings the cursor outside of the grid behaves as expected.
Definition at line 94 of file MapCursorTest.java.
References net.sf.gridarta.model.mapcursor.MapCursorTest.createCursor(), net.sf.gridarta.utils.Size2D.getHeight(), net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getLocation(), net.sf.gridarta.utils.Size2D.getWidth(), net.sf.gridarta.model.mapcursor.MapCursorTest.GRID_SIZE, net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setLocation(), and net.sf.gridarta.model.mapcursor.MapCursorTest.testEvents().
void net.sf.gridarta.model.mapcursor.MapCursorTest.setSameLocation | ( | ) |
Checks that settings the cursor to the same location does not generate excess events.
Definition at line 151 of file MapCursorTest.java.
References net.sf.gridarta.model.mapcursor.MapCursorTest.createCursor(), net.sf.gridarta.model.mapcursor.MapCursorTest.GRID_SIZE, net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setLocation(), and net.sf.gridarta.model.mapcursor.MapCursorTest.testEvents().
|
static |
Returns a new test suite containing this test.
Definition at line 451 of file MapCursorTest.java.
|
staticprivate |
Checks if the number of events fired is correct.
nPos | the expected number of position events |
nMode | the expected number of mode events |
Definition at line 439 of file MapCursorTest.java.
References net.sf.gridarta.model.mapcursor.MapCursorTest.TestMapCursorListener.changedModeCounter, net.sf.gridarta.model.mapcursor.MapCursorTest.TestMapCursorListener.changedPosCounter, and net.sf.gridarta.model.mapcursor.MapCursorTest.LISTENER.
Referenced by net.sf.gridarta.model.mapcursor.MapCursorTest.dragging(), net.sf.gridarta.model.mapcursor.MapCursorTest.dragTo(), net.sf.gridarta.model.mapcursor.MapCursorTest.selecting(), net.sf.gridarta.model.mapcursor.MapCursorTest.setInside(), net.sf.gridarta.model.mapcursor.MapCursorTest.setLocationSafe(), net.sf.gridarta.model.mapcursor.MapCursorTest.setOutside(), net.sf.gridarta.model.mapcursor.MapCursorTest.setSameLocation(), and net.sf.gridarta.model.mapcursor.MapCursorTest.testGoTo().
void net.sf.gridarta.model.mapcursor.MapCursorTest.testGoTo | ( | ) |
Checks MapCursor#goTo(boolean, Direction).
Definition at line 219 of file MapCursorTest.java.
References net.sf.gridarta.model.mapcursor.MapCursorTest.createCursor(), net.sf.gridarta.model.direction.Direction.DOWN, net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getLocation(), net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.goTo(), net.sf.gridarta.model.mapcursor.MapCursorTest.GRID_SIZE, net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setLocation(), net.sf.gridarta.model.mapcursor.MapCursorTest.testEvents(), and net.sf.gridarta.model.direction.Direction.UP.
void net.sf.gridarta.model.mapcursor.MapCursorTest.testIsOnGrid | ( | ) |
Checks MapCursor#isOnGrid(Point).
Definition at line 198 of file MapCursorTest.java.
References net.sf.gridarta.model.mapcursor.MapCursorTest.createCursor(), net.sf.gridarta.utils.Size2D.getHeight(), net.sf.gridarta.utils.Size2D.getWidth(), net.sf.gridarta.model.mapcursor.MapCursorTest.GRID_SIZE, and net.sf.gridarta.model.mapcursor.MapCursor< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.isOnGrid().
|
staticprivate |
The enter x coordinate of newly created maps.
Definition at line 51 of file MapCursorTest.java.
Referenced by net.sf.gridarta.model.mapcursor.MapCursorTest.createCursor().
|
staticprivate |
The enter y coordinate of newly created maps.
Definition at line 56 of file MapCursorTest.java.
Referenced by net.sf.gridarta.model.mapcursor.MapCursorTest.createCursor().
|
staticprivate |
The size of the map grid for the tested cursor.
Definition at line 62 of file MapCursorTest.java.
Referenced by net.sf.gridarta.model.mapcursor.MapCursorTest.assertPreSelection(), net.sf.gridarta.model.mapcursor.MapCursorTest.dragging(), net.sf.gridarta.model.mapcursor.MapCursorTest.selecting(), net.sf.gridarta.model.mapcursor.MapCursorTest.setInside(), net.sf.gridarta.model.mapcursor.MapCursorTest.setLocationSafe(), net.sf.gridarta.model.mapcursor.MapCursorTest.setOutside(), net.sf.gridarta.model.mapcursor.MapCursorTest.setSameLocation(), net.sf.gridarta.model.mapcursor.MapCursorTest.testGoTo(), and net.sf.gridarta.model.mapcursor.MapCursorTest.testIsOnGrid().
|
staticprivate |
A MapCursorListener that counts the number of callbacks.
Definition at line 68 of file MapCursorTest.java.
Referenced by net.sf.gridarta.model.mapcursor.MapCursorTest.createCursor(), and net.sf.gridarta.model.mapcursor.MapCursorTest.testEvents().