Search in sources :

Example 16 with Xml

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());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Test(org.junit.jupiter.api.Test)

Example 17 with Xml

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());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Test(org.junit.jupiter.api.Test)

Example 18 with Xml

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());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Test(org.junit.jupiter.api.Test)

Example 19 with Xml

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());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Test(org.junit.jupiter.api.Test)

Example 20 with Xml

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());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Test(org.junit.jupiter.api.Test)

Aggregations

Xml (com.b3dgs.lionengine.Xml)133 Test (org.junit.jupiter.api.Test)73 Media (com.b3dgs.lionengine.Media)63 Configurer (com.b3dgs.lionengine.game.Configurer)25 Setup (com.b3dgs.lionengine.game.feature.Setup)11 HashMap (java.util.HashMap)9 Collection (java.util.Collection)8 Animation (com.b3dgs.lionengine.Animation)4 Collision (com.b3dgs.lionengine.game.feature.collidable.Collision)4 Feature (com.b3dgs.lionengine.game.Feature)3 Force (com.b3dgs.lionengine.game.Force)3 SizeConfig (com.b3dgs.lionengine.game.SizeConfig)3 Services (com.b3dgs.lionengine.game.feature.Services)3 UtilSetup (com.b3dgs.lionengine.game.feature.UtilSetup)3 Map (java.util.Map)3 ViewerMock (com.b3dgs.lionengine.ViewerMock)2 Origin (com.b3dgs.lionengine.Origin)1 UtilAssert.assertThrows (com.b3dgs.lionengine.UtilAssert.assertThrows)1 XmlReader (com.b3dgs.lionengine.XmlReader)1 Orientation (com.b3dgs.lionengine.game.Orientation)1