use of com.b3dgs.lionengine.ViewerMock in project lionengine by b3dgs.
the class SpriteFontTest method testSetLocationViewer.
/**
* Test set location with viewer.
*/
@Test
void testSetLocationViewer() {
final SpriteFontImpl sprite = new SpriteFontImpl(media, font, 6, 7);
sprite.load();
final ViewerMock viewer = new ViewerMock();
sprite.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
assertEquals(0.0, sprite.getX());
assertEquals(0.0, sprite.getY());
viewer.set(10, 20);
sprite.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
assertEquals(0.0, sprite.getX());
assertEquals(0.0, sprite.getY());
sprite.dispose();
}
use of com.b3dgs.lionengine.ViewerMock in project lionengine by b3dgs.
the class SpriteTest method testSetLocationViewer.
/**
* Test set location with viewer.
*/
@Test
void testSetLocationViewer() {
final SpriteImpl sprite = new SpriteImpl(Graphics.createImageBuffer(64, 32));
final ViewerMock viewer = new ViewerMock();
sprite.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
assertEquals(1.5, sprite.getX());
assertEquals(237.5, sprite.getY());
assertEquals(2, sprite.getRenderX());
assertEquals(238, sprite.getRenderY());
viewer.set(10, 20);
sprite.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
assertEquals(-8.5, sprite.getX());
assertEquals(257.5, sprite.getY());
assertEquals(-8, sprite.getRenderX());
assertEquals(258, sprite.getRenderY());
}
use of com.b3dgs.lionengine.ViewerMock in project lionengine by b3dgs.
the class ImageTest method testSetLocationViewer.
/**
* Test set location with viewer.
*/
@Test
void testSetLocationViewer() {
final ImageImpl image = new ImageImpl(Graphics.createImageBuffer(64, 32));
final ViewerMock viewer = new ViewerMock();
image.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
assertEquals(1.5, image.getX());
assertEquals(237.5, image.getY());
assertEquals(2, image.getRenderX());
assertEquals(238, image.getRenderY());
viewer.set(10, 20);
image.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
assertEquals(-8.5, image.getX());
assertEquals(257.5, image.getY());
assertEquals(-8, image.getRenderX());
assertEquals(258, image.getRenderY());
image.dispose();
}
use of com.b3dgs.lionengine.ViewerMock in project lionengine by b3dgs.
the class CursorTest method testSetViewer.
/**
* Test set viewer.
*/
@Test
void testSetViewer() {
final Cursor cursor = new Cursor(services);
final MouseMock mouse = new MouseMock();
mouse.move(1, 2);
cursor.setSync(mouse);
final ViewerMock viewer = new ViewerMock();
cursor.setViewer(viewer);
viewer.set(100, 200);
cursor.update(1.0);
assertEquals(101.0, cursor.getX());
assertEquals(438.0, cursor.getY());
assertEquals(1.0, cursor.getScreenX());
assertEquals(2.0, cursor.getScreenY());
}
use of com.b3dgs.lionengine.ViewerMock in project lionengine by b3dgs.
the class TextGameTest method testLocation.
/**
* Test location.
*/
@Test
void testLocation() {
final TextGame text = new TextGame(Constant.FONT_DIALOG, 8, TextStyle.NORMAL);
assertEquals(0, text.getLocationX());
assertEquals(0, text.getLocationY());
final ViewerMock viewer = new ViewerMock();
viewer.set(1, 2);
text.update(viewer);
assertEquals(0, text.getLocationX());
assertEquals(0, text.getLocationY());
text.setLocation(3, 4);
assertEquals(3, text.getLocationX());
assertEquals(4, text.getLocationY());
}
Aggregations