use of com.b3dgs.lionengine.game.FeatureProvider in project lionengine by b3dgs.
the class FeaturableModelTest method testFeatureAnnotationNotFound.
/**
* Test with annotation and feature not found.
*/
@Test
void testFeatureAnnotationNotFound() {
final Featurable featurable = new FeaturableModel(services, setup);
final AtomicReference<String> unfilledType = new AtomicReference<>();
final Feature feature = new FeatureModel(services, setup) {
@FeatureGet
private String type;
@Override
public void prepare(FeatureProvider provider) {
super.prepare(provider);
unfilledType.set(type);
}
};
assertThrows(() -> featurable.addFeature(feature), "[transformable_FeaturableModelTest.xml] Class not found: " + String.class + " in " + feature);
}
use of com.b3dgs.lionengine.game.FeatureProvider in project lionengine by b3dgs.
the class ComponentDisplayableTest method testRemoveLayerable.
/**
* Test the component with layerable remove.
*/
@Test
void testRemoveLayerable() {
final AtomicBoolean called = new AtomicBoolean();
final ComponentDisplayable component = new ComponentDisplayable() {
@Override
public void notifyLayerChanged(FeatureProvider provider, Integer layerRefreshOld, Integer layerRefreshNew, Integer layerDisplayOld, Integer layerDisplayNew) {
super.notifyLayerChanged(provider, layerRefreshOld, layerRefreshNew, layerDisplayOld, layerDisplayNew);
called.set(true);
}
};
final Featurable featurable = new FeaturableModel(services, setup);
featurable.addFeature(new RefreshableModel(extrp -> {
// Mock
}));
final Layerable layerable = featurable.addFeatureAndGet(new LayerableModel(services, setup));
component.notifyHandlableAdded(featurable);
component.notifyHandlableRemoved(featurable);
layerable.setLayer(Integer.valueOf(1), Integer.valueOf(1));
assertFalse(called.get());
}
use of com.b3dgs.lionengine.game.FeatureProvider in project lionengine by b3dgs.
the class ComponentRefreshableTest method testRemoveLayerable.
/**
* Test the component with layerable remove.
*/
@Test
void testRemoveLayerable() {
final AtomicBoolean called = new AtomicBoolean();
final ComponentRefreshable component = new ComponentRefreshable() {
@Override
public void notifyLayerChanged(FeatureProvider provider, Integer layerRefreshOld, Integer layerRefreshNew, Integer layerDisplayOld, Integer layerDisplayNew) {
super.notifyLayerChanged(provider, layerRefreshOld, layerRefreshNew, layerDisplayOld, layerDisplayNew);
called.set(true);
}
};
final Featurable featurable = new FeaturableModel(services, setup);
featurable.addFeature(new RefreshableModel(extrp -> {
// Mock
}));
final Layerable layerable = featurable.addFeatureAndGet(new LayerableModel(services, setup));
component.notifyHandlableAdded(featurable);
component.notifyHandlableRemoved(featurable);
layerable.setLayer(Integer.valueOf(1), Integer.valueOf(1));
assertFalse(called.get());
}
use of com.b3dgs.lionengine.game.FeatureProvider in project lionengine by b3dgs.
the class LayerableModelTest method testLayer.
/**
* Test the layer functionality.
*/
@Test
void testLayer() {
final LayerableModel layerable = new LayerableModel(services, setup);
final AtomicReference<FeatureProvider> objectRef = new AtomicReference<>();
final AtomicInteger oldLayerRef = new AtomicInteger();
final AtomicInteger newLayerRef = new AtomicInteger();
final LayerableListener listener = (provider, layerRefreshOld, layerRefreshNew, layerDisplayOld, layerDisplayNew) -> {
objectRef.set(provider);
oldLayerRef.set(layerRefreshOld.intValue());
newLayerRef.set(layerRefreshNew.intValue());
};
layerable.addListener(listener);
services.add(new ComponentDisplayable());
final Featurable featurable = new FeaturableModel(services, setup);
layerable.prepare(featurable);
assertEquals(1, layerable.getLayerRefresh().intValue());
assertEquals(2, layerable.getLayerDisplay().intValue());
layerable.setLayer(Integer.valueOf(1), Integer.valueOf(2));
assertEquals(1, layerable.getLayerRefresh().intValue());
assertEquals(2, layerable.getLayerDisplay().intValue());
layerable.removeListener(listener);
objectRef.set(null);
layerable.setLayer(Integer.valueOf(1), Integer.valueOf(2));
assertNull(objectRef.get());
}
Aggregations