use of de.gurkenlabs.litiengine.graphics.StaticShadowLayer in project litiengine by gurkenlabs.
the class LightSourceTests method updateAmbientLayers_delegatesWhenLoaded.
@Test
void updateAmbientLayers_delegatesWhenLoaded() {
// arrange
when(lightSourceInactiveSpy.isLoaded()).thenReturn(true);
GameWorld actualWorld = spy(Game.world());
MockedStatic<Game> gameMockedStatic = mockStatic(Game.class);
gameMockedStatic.when(Game::world).thenReturn(// otherwise it is null because of the mock
actualWorld);
Environment environmentMock = mock(Environment.class);
when(actualWorld.environment()).thenReturn(environmentMock);
AmbientLight ambientLightMock = mock(AmbientLight.class);
when(environmentMock.getAmbientLight()).thenReturn(ambientLightMock);
StaticShadowLayer staticShadowLayerMock = mock(StaticShadowLayer.class);
when(environmentMock.getStaticShadowLayer()).thenReturn(staticShadowLayerMock);
// act
// means to trigger private method within
lightSourceInactiveSpy.setColor(Color.GREEN);
// assert
verify(lightSourceInactiveSpy, times(1)).isLoaded();
verify(ambientLightMock, times(1)).updateSection(any(Rectangle2D.class));
verify(staticShadowLayerMock, times(1)).updateSection(any(Rectangle2D.class));
// cleanup
gameMockedStatic.close();
}
use of de.gurkenlabs.litiengine.graphics.StaticShadowLayer in project litiengine by gurkenlabs.
the class LightSourceTests method updateAmbientLayers_doesNothingWithoutLayers.
@Test
void updateAmbientLayers_doesNothingWithoutLayers() {
// arrange
when(lightSourceInactiveSpy.isLoaded()).thenReturn(true);
GameWorld actualWorld = spy(Game.world());
MockedStatic<Game> gameMockedStatic = mockStatic(Game.class);
gameMockedStatic.when(Game::world).thenReturn(// otherwise it is null because of the mock
actualWorld);
Environment environmentMock = mock(Environment.class);
when(actualWorld.environment()).thenReturn(environmentMock);
AmbientLight ambientLightMock = mock(AmbientLight.class);
when(environmentMock.getAmbientLight()).thenReturn(null);
StaticShadowLayer staticShadowLayerMock = mock(StaticShadowLayer.class);
when(environmentMock.getStaticShadowLayer()).thenReturn(null);
// act
// means to trigger private method within
lightSourceInactiveSpy.setColor(Color.GREEN);
// assert
verify(lightSourceInactiveSpy, times(1)).isLoaded();
verify(ambientLightMock, times(0)).updateSection(any(Rectangle2D.class));
verify(staticShadowLayerMock, times(0)).updateSection(any(Rectangle2D.class));
// cleanup
gameMockedStatic.close();
}
use of de.gurkenlabs.litiengine.graphics.StaticShadowLayer in project litiengine by gurkenlabs.
the class Environment method addStaticShadows.
private void addStaticShadows() {
final Color color = this.getMap().getColorValue(MapProperty.SHADOWCOLOR, StaticShadow.DEFAULT_COLOR);
this.staticShadowLayer = new StaticShadowLayer(this, color);
}
use of de.gurkenlabs.litiengine.graphics.StaticShadowLayer in project litiengine by gurkenlabs.
the class LightSourceTests method updateAmbientLayers_doesNothingWhenNotLoaded.
@Test
void updateAmbientLayers_doesNothingWhenNotLoaded() {
// arrange
when(lightSourceInactiveSpy.isLoaded()).thenReturn(// should be default, just making sure
false);
GameWorld actualWorld = spy(Game.world());
MockedStatic<Game> gameMockedStatic = mockStatic(Game.class);
gameMockedStatic.when(Game::world).thenReturn(// otherwise it is null because of the mock
actualWorld);
Environment environmentMock = mock(Environment.class);
when(actualWorld.environment()).thenReturn(environmentMock);
AmbientLight ambientLightMock = mock(AmbientLight.class);
when(environmentMock.getAmbientLight()).thenReturn(ambientLightMock);
StaticShadowLayer staticShadowLayerMock = mock(StaticShadowLayer.class);
when(environmentMock.getStaticShadowLayer()).thenReturn(staticShadowLayerMock);
// act
// means to trigger private method within
lightSourceInactiveSpy.setColor(Color.GREEN);
// assert
verify(lightSourceInactiveSpy, times(1)).isLoaded();
verify(ambientLightMock, times(0)).updateSection(any(Rectangle2D.class));
verify(staticShadowLayerMock, times(0)).updateSection(any(Rectangle2D.class));
// cleanup
gameMockedStatic.close();
}
use of de.gurkenlabs.litiengine.graphics.StaticShadowLayer in project litiengine by gurkenlabs.
the class LightSourceTests method updateAmbientLayers_doesNothingWithoutGameEnvironment.
@Test
void updateAmbientLayers_doesNothingWithoutGameEnvironment() {
// arrange
when(lightSourceInactiveSpy.isLoaded()).thenReturn(true);
GameWorld actualWorld = spy(Game.world());
MockedStatic<Game> gameMockedStatic = mockStatic(Game.class);
gameMockedStatic.when(Game::world).thenReturn(// otherwise it is null because of the mock
actualWorld);
Environment environmentMock = mock(Environment.class);
when(actualWorld.environment()).thenReturn(null);
AmbientLight ambientLightMock = mock(AmbientLight.class);
when(environmentMock.getAmbientLight()).thenReturn(ambientLightMock);
StaticShadowLayer staticShadowLayerMock = mock(StaticShadowLayer.class);
when(environmentMock.getStaticShadowLayer()).thenReturn(staticShadowLayerMock);
// act
// means to trigger private method within
lightSourceInactiveSpy.setColor(Color.GREEN);
// assert
verify(lightSourceInactiveSpy, times(1)).isLoaded();
verify(actualWorld, times(2)).environment();
verify(ambientLightMock, times(0)).updateSection(any(Rectangle2D.class));
verify(staticShadowLayerMock, times(0)).updateSection(any(Rectangle2D.class));
// cleanup
gameMockedStatic.close();
}
Aggregations