use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class ActionsConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final ActionRef ref = new ActionRef("ref", false, new ArrayList<ActionRef>());
final ActionRef ref2 = new ActionRef("ref", false, Arrays.asList(ref));
final Collection<ActionRef> refs = Arrays.asList(new ActionRef("test", true, Arrays.asList(ref2)));
final Xml root = new Xml("test");
root.add(ActionsConfig.exports(refs));
final Media media = Medias.create("producer.xml");
root.save(media);
assertEquals(refs, ActionsConfig.imports(new Xml(media), null));
assertEquals(refs, ActionsConfig.imports(new Configurer(media), null));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class FovableConfig method exports.
/**
* Create the data from node.
*
* @param fov The field of view value.
* @return The node data.
* @throws LionEngineException If unable to write node.
*/
public static Xml exports(int fov) {
final Xml node = new Xml(NODE_FOVABLE);
node.writeInteger(ATT_FOV, fov);
return node;
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class AnimationConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final Xml root = new Xml("test");
final Animation animation1 = new Animation("anim1", 1, 2, 3.0, false, true);
final Animation animation2 = new Animation("anim2", 4, 5, 6.0, true, false);
AnimationConfig.exports(root, animation1);
AnimationConfig.exports(root, animation2);
final Media media = Medias.create("animations.xml");
root.save(media);
final AnimationConfig imported = AnimationConfig.imports(new Setup(media));
assertEquals(animation1, imported.getAnimation("anim1"));
assertEquals(animation2, imported.getAnimation("anim2"));
assertTrue(imported.getAnimations().containsAll(Arrays.asList(animation1, animation2)));
assertFalse(imported.hasAnimation("anim"));
assertTrue(imported.hasAnimation("anim1"));
assertTrue(imported.hasAnimation("anim2"));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class AnimationConfigTest method testNoNode.
/**
* Test with no node.
*/
@Test
void testNoNode() {
final Xml root = new Xml("test");
assertTrue(AnimationConfig.imports(root).getAnimations().isEmpty());
}
use of com.b3dgs.lionengine.Xml in project lionengine by b3dgs.
the class FeaturableConfigTest method testGetFeaturesCache.
/**
* Test with cached feature class.
*/
@Test
void testGetFeaturesCache() {
final Xml root = new Xml("test");
root.createChild(FeaturableConfig.NODE_FEATURES).createChild(FeaturableConfig.NODE_FEATURE).setText(FeatureModel.class.getName());
final Media media = Medias.create("Object.xml");
root.save(media);
final ClassLoader loader = ClassLoader.getSystemClassLoader();
final Services services = new Services();
final Setup setup = new Setup(media);
final List<Feature> a = FeaturableConfig.getFeatures(loader, services, setup);
final List<Feature> b = FeaturableConfig.getFeatures(loader, services, setup);
assertNotEquals(a.get(0), b.get(0));
}
Aggregations