use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class LayerableModelTest method testConstructorSetup.
/**
* Test constructor with setup.
*/
@Test
void testConstructorSetup() {
services.add(new ComponentDisplayable());
LayerableModel layerable = new LayerableModel(services, setup);
assertEquals(0, layerable.getLayerRefresh().intValue());
assertEquals(0, layerable.getLayerDisplay().intValue());
final Xml xml = new Xml(config);
xml.add(LayerableConfig.exports(new LayerableConfig(1, 2)));
xml.save(config);
layerable = new LayerableModel(services, new Setup(config));
assertEquals(1, layerable.getLayerRefresh().intValue());
assertEquals(2, layerable.getLayerDisplay().intValue());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class ConfigurerTest method testGetRoot.
/**
* Test the root getter.
*/
@Test
void testGetRoot() {
final Xml root = configurer.getRoot();
assertNotNull(root);
assertEquals("root", root.getNodeName());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class ForceConfigTest method testOptional.
/**
* Test with optional fields.
*/
@Test
void testOptional() {
final Xml root = new Xml("test");
final Xml node = root.createChild(ForceConfig.NODE_FORCE);
final Force force = new Force(1.0, 2.0, 0.0, 0.0);
node.writeDouble(ForceConfig.ATT_VX, force.getDirectionHorizontal());
node.writeDouble(ForceConfig.ATT_VY, force.getDirectionVertical());
final Media media = Medias.create("force.xml");
root.save(media);
assertEquals(force, ForceConfig.imports(new Xml(media)));
assertEquals(force, ForceConfig.imports(new Configurer(media)));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class SurfaceConfigTest method testExportsImports.
/**
* Test exports imports with image and icon.
*/
@Test
void testExportsImports() {
final Xml root = new Xml("test");
final SurfaceConfig config = new SurfaceConfig("image", "icon");
root.add(SurfaceConfig.exports(config));
final Media media = Medias.create("Object.xml");
root.save(media);
assertEquals(config, SurfaceConfig.imports(new Xml(media)));
assertEquals(config, SurfaceConfig.imports(new Configurer(media)));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class SurfaceConfigTest method testExportsImportsNoIcon.
/**
* Test exports imports with image without icon.
*/
@Test
void testExportsImportsNoIcon() {
final Xml root = new Xml("test");
final SurfaceConfig config = new SurfaceConfig("image", null);
root.add(SurfaceConfig.exports(config));
final Media media = Medias.create("Object.xml");
root.save(media);
assertEquals(config, SurfaceConfig.imports(new Xml(media)));
assertEquals(config, SurfaceConfig.imports(new Configurer(media)));
assertTrue(media.getFile().delete());
}
Aggregations