Gridarta Editor
net.sf.gridarta.model.mapcursor.MapCursorTest Class Reference

Unit test for MapCursor. More...

+ Collaboration diagram for net.sf.gridarta.model.mapcursor.MapCursorTest:

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, TestArchetypecreateCursor (@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...
 

Detailed Description

Unit test for MapCursor.

Author
Christian Hujer
Daniel Viegas
Andreas Kirschbaum

Definition at line 46 of file MapCursorTest.java.

Member Function Documentation

◆ assertPreSelection()

static void net.sf.gridarta.model.mapcursor.MapCursorTest.assertPreSelection ( @NotNull final MapGrid  grid,
@NotNull final Point  start,
@NotNull final Point  end 
)
staticprivate

Checks that a MapGrid includes a rectangle of {}.

Parameters
gridthe map grid to check
startone corner of the rectangle
endthe 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assertSelection()

static void net.sf.gridarta.model.mapcursor.MapCursorTest.assertSelection ( @NotNull final MapGrid  grid,
@NotNull final Point  start,
@NotNull final Point  end,
final boolean  flag 
)
staticprivate

Checks that a MapGrid includes a rectangle of {}.

Squares outside the rectangle are not checked.

Parameters
gridthe map grid to check
startone corner of the rectangle
endthe diagonally opposite corner of the rectangle
flagthe 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().

+ Here is the caller graph for this function:

◆ createCursor()

static MapCursor<TestGameObject, TestMapArchObject, TestArchetype> net.sf.gridarta.model.mapcursor.MapCursorTest.createCursor ( @NotNull final MapGrid  grid)
staticprivate

Creates a new MapCursor instance.

No more than one instance may exist concurrently.

Parameters
gridthe underlying map grid
Returns
the new map cursor instance

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dragging()

◆ dragTo()

static void net.sf.gridarta.model.mapcursor.MapCursorTest.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 
)
staticprivate

Calls MapCursor#dragTo(Point) and checks for expected results.

Parameters
cursorthe map cursor to affect
gridthe associated map grid
dirthe direction to drag
startthe starting location
pthe destination location
offsetthe 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ selecting()

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().

+ Here is the call graph for this function:

◆ setInside()

◆ setLocationSafe()

◆ setOutside()

◆ setSameLocation()

void net.sf.gridarta.model.mapcursor.MapCursorTest.setSameLocation ( )

◆ suite()

static junit.framework.Test net.sf.gridarta.model.mapcursor.MapCursorTest.suite ( )
static

Returns a new test suite containing this test.

Returns
the new test suite

Definition at line 451 of file MapCursorTest.java.

◆ testEvents()

◆ testGoTo()

◆ testIsOnGrid()

Member Data Documentation

◆ ENTER_X

final int net.sf.gridarta.model.mapcursor.MapCursorTest.ENTER_X = 1
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().

◆ ENTER_Y

final int net.sf.gridarta.model.mapcursor.MapCursorTest.ENTER_Y = 2
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().

◆ GRID_SIZE

◆ LISTENER

final TestMapCursorListener net.sf.gridarta.model.mapcursor.MapCursorTest.LISTENER = new TestMapCursorListener()
staticprivate

The documentation for this class was generated from the following file: