use of com.b3dgs.lionengine.game.feature.tile.map.MapTileRenderer in project lionengine by b3dgs.
the class MapTileViewerModelTest method testViewer.
/**
* Test the viewer functions.
*/
@Test
void testViewer() {
map.loadSheets(Arrays.asList(Drawable.loadSpriteTiled(new ImageBufferMock(80, 80), 40, 40)));
mapViewer.render(g);
map.create(40, 40, 2, 2);
map.setTile(0, 0, 0);
map.setTile(1, 1, 1);
final AtomicBoolean rendered = new AtomicBoolean();
final MapTileRenderer renderer = (g, tile, x, y) -> rendered.set(true);
mapViewer.render(g);
assertFalse(rendered.get());
mapViewer.addRenderer(renderer);
mapViewer.render(g);
assertTrue(rendered.get());
rendered.set(false);
mapViewer.removeRenderer(renderer);
mapViewer.render(g);
assertFalse(rendered.get());
mapViewer.addRenderer(renderer);
mapViewer.render(g);
assertTrue(rendered.get());
rendered.set(false);
mapViewer.clear();
mapViewer.render(g);
assertFalse(rendered.get());
map.clear();
mapViewer.render(g);
}
Aggregations