Search in sources :

Example 41 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class FovableConfigTest method testExportsImportsNoNode.

/**
 * Test exports imports without node.
 */
@Test
void testExportsImportsNoNode() {
    final Xml root = new Xml("test");
    final Media media = Medias.create("Object.xml");
    root.save(media);
    assertEquals(0, FovableConfig.imports(new Xml(media)));
    assertEquals(0, FovableConfig.imports(new Configurer(media)));
    assertTrue(media.getFile().delete());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Configurer(com.b3dgs.lionengine.game.Configurer) Test(org.junit.jupiter.api.Test)

Example 42 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class CollisionGroupConfigTest method testExportsImportsMap.

/**
 * Test with map.
 */
@Test
void testExportsImportsMap() {
    final Xml root = new Xml("groups");
    CollisionGroupConfig.exports(root, group);
    final Media groupsConfig = Medias.create("groups.xml");
    root.save(groupsConfig);
    final Media formulasConfig = UtilConfig.createFormulaConfig(formula);
    mapCollision.loadCollisions(formulasConfig, groupsConfig);
    final CollisionGroupConfig groups = CollisionGroupConfig.imports(groupsConfig);
    assertEquals(group, groups.getGroups().values().iterator().next());
    assertTrue(groupsConfig.getFile().delete());
    assertTrue(formulasConfig.getFile().delete());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Test(org.junit.jupiter.api.Test)

Example 43 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class CollisionGroupConfigTest method testExportsImports.

/**
 * Test exports imports.
 */
@Test
void testExportsImports() {
    final Xml root = new Xml("groups");
    CollisionGroupConfig.exports(root, group);
    final Media config = Medias.create("groups.xml");
    root.save(config);
    final CollisionGroupConfig imported = CollisionGroupConfig.imports(config);
    assertEquals(group, imported.getGroups().values().iterator().next());
    assertEquals(group, imported.getGroup("group"));
    assertTrue(config.getFile().delete());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) Test(org.junit.jupiter.api.Test)

Example 44 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class CollisionRangeConfigTest method testInvalidAxis.

/**
 * Test with invalid axis.
 */
@Test
void testInvalidAxis() {
    final Xml root = new Xml("ranges");
    final CollisionRange range = new CollisionRange(Axis.X, 0, 1, 2, 3);
    CollisionRangeConfig.exports(root, range);
    root.getChildXml(CollisionRangeConfig.NODE_RANGE).writeString(CollisionRangeConfig.ATT_AXIS, "void");
    assertThrows(() -> CollisionRangeConfig.imports(root.getChild(CollisionRangeConfig.NODE_RANGE)), XmlReader.ERROR_ENUM + "void");
}
Also used : Xml(com.b3dgs.lionengine.Xml) Test(org.junit.jupiter.api.Test)

Example 45 with Xml

use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.

the class UtilConfig method createFormulaConfig.

/**
 * Create formula configuration.
 *
 * @param formulas The collision formulas.
 * @return The formula configuration.
 */
public static Media createFormulaConfig(CollisionFormula... formulas) {
    final Media media = Medias.create("formulas.xml");
    final Xml root = new Xml("formulas");
    for (final CollisionFormula formula : formulas) {
        CollisionFormulaConfig.exports(root, formula);
    }
    root.save(media);
    return media;
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media)

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