use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.
the class ProducerConfigTest method testCancelOnRef.
/**
* Test cancel flag is not used on child reference.
*/
@Test
public void testCancelOnRef() {
final ActionRef ref = new ActionRef("ref", true, new ArrayList<ActionRef>());
final Collection<ActionRef> refs = Arrays.asList(new ActionRef("test", false, Arrays.asList(ref)));
final Xml root = new Xml("test");
root.add(ActionsConfig.exports(refs));
final Media media = Medias.create("producer.xml");
root.save(media);
Assert.assertNotEquals(refs, ActionsConfig.imports(new Xml(media)));
Assert.assertNotEquals(refs, ActionsConfig.imports(new Configurer(media)));
Assert.assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.
the class CollidableFramedConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final Map<Integer, Collection<Collision>> collisions = new HashMap<>();
collisions.put(Integer.valueOf(1), Arrays.asList(new Collision("anim%1", 0, 1, 2, 3, true)));
final CollidableFramedConfig config = new CollidableFramedConfig(collisions);
final Xml root = new Xml("test");
final Animation animation = new Animation("anim", 1, 2, 3.0, false, true);
AnimationConfig.exports(root, animation);
final Xml framed = root.getChildXml(AnimationConfig.NODE_ANIMATIONS).getChildXml(AnimationConfig.NODE_ANIMATION);
CollidableFramedConfig.exports(framed, collisions);
final Media media = Medias.create("Object.xml");
root.save(media);
assertEquals(config, CollidableFramedConfig.imports(new Configurer(media)));
assertEquals(collisions.values().iterator().next(), config.getCollisions());
assertEquals(collisions.get(Integer.valueOf(1)), config.getCollision(Integer.valueOf(1)));
assertTrue(config.getCollision(Integer.valueOf(2)).isEmpty());
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.
the class CollidableFramedConfigTest method testExportsImportsNumber.
/**
* Test exports imports with number.
*/
@Test
void testExportsImportsNumber() {
final Map<Integer, Collection<Collision>> collisions = new HashMap<>();
collisions.put(Integer.valueOf(1), Arrays.asList(new Collision("coll%anim%1", 0, 1, 2, 3, true)));
final Xml root = new Xml("test");
final Animation animation = new Animation("anim", 1, 2, 3.0, false, true);
AnimationConfig.exports(root, animation);
final Xml framed = root.getChildXml(AnimationConfig.NODE_ANIMATIONS).getChildXml(AnimationConfig.NODE_ANIMATION);
CollidableFramedConfig.exports(framed, collisions);
framed.getChildXml(CollidableFramedConfig.NODE_COLLISION_FRAMED).removeAttribute(CollidableFramedConfig.ATT_NUMBER);
framed.getChildXml(CollidableFramedConfig.NODE_COLLISION_FRAMED).writeString(CollidableFramedConfig.ATT_PREFIX, "coll");
final Media media = Medias.create("Object.xml");
root.save(media);
final CollidableFramedConfig imported = CollidableFramedConfig.imports(new Configurer(media));
assertEquals(collisions.get(Integer.valueOf(1)), imported.getCollision(Integer.valueOf(1)));
assertFalse(imported.getCollision(Integer.valueOf(2)).isEmpty());
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.
the class FeaturableConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final String clazz = "class";
final String setup = "setup";
final FeaturableConfig config = new FeaturableConfig(clazz, setup);
final Xml root = new Xml("test");
root.add(FeaturableConfig.exportClass(clazz));
root.add(FeaturableConfig.exportSetup(setup));
final Media media = Medias.create("Object.xml");
root.save(media);
assertEquals(config, FeaturableConfig.imports(new Xml(media)));
assertEquals(config, FeaturableConfig.imports(new Configurer(media)));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.
the class CollidableConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final int group = 1;
final Media media = Medias.create("Object.xml");
final Xml root = new Xml("test");
final Xml node = root.createChild(CollidableConfig.NODE_COLLIDABLE);
node.writeInteger(CollidableConfig.ATT_GROUP, group);
node.writeString(CollidableConfig.ATT_ACCEPTED, "1%2");
root.save(media);
final CollidableConfig config = CollidableConfig.imports(new Configurer(media));
assertEquals(1, config.getGroup().intValue());
assertIterableEquals(Arrays.asList(Integer.valueOf(1), Integer.valueOf(2)), config.getAccepted());
assertTrue(media.getFile().delete());
}
Aggregations