summaryrefslogtreecommitdiff
path: root/modules/xcos/tests/java
diff options
context:
space:
mode:
Diffstat (limited to 'modules/xcos/tests/java')
-rwxr-xr-xmodules/xcos/tests/java/org/scilab/tests/modules/xcos/XcosTest.java33
-rwxr-xr-xmodules/xcos/tests/java/org/scilab/tests/modules/xcos/block/SortPortsTest.java167
-rwxr-xr-xmodules/xcos/tests/java/org/scilab/tests/modules/xcos/graph/DiagramComparatorTest.java334
-rwxr-xr-xmodules/xcos/tests/java/org/scilab/tests/modules/xcos/graph/ScicosParametersTest.java336
-rwxr-xr-xmodules/xcos/tests/java/org/scilab/tests/modules/xcos/port/command/CommandPortTest.java62
-rwxr-xr-xmodules/xcos/tests/java/org/scilab/tests/modules/xcos/port/control/ControlPortTest.java62
-rwxr-xr-xmodules/xcos/tests/java/org/scilab/tests/modules/xcos/port/input/ExplicitInputPortTest.java65
-rwxr-xr-xmodules/xcos/tests/java/org/scilab/tests/modules/xcos/port/input/ImplicitInputPortTest.java65
-rwxr-xr-xmodules/xcos/tests/java/org/scilab/tests/modules/xcos/port/output/ExplicitOutputPortTest.java65
-rwxr-xr-xmodules/xcos/tests/java/org/scilab/tests/modules/xcos/port/output/ImplicitOutputPortTest.java65
-rwxr-xr-xmodules/xcos/tests/java/org/scilab/tests/modules/xcos/utils/FileTypeTest.java91
-rwxr-xr-xmodules/xcos/tests/java/xcos-JAVA-tests.vcxproj155
-rwxr-xr-xmodules/xcos/tests/java/xcos-JAVA-tests.vcxproj.filters14
13 files changed, 1514 insertions, 0 deletions
diff --git a/modules/xcos/tests/java/org/scilab/tests/modules/xcos/XcosTest.java b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/XcosTest.java
new file mode 100755
index 000000000..cdaa0fe7d
--- /dev/null
+++ b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/XcosTest.java
@@ -0,0 +1,33 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Clement DAVID
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+package org.scilab.tests.modules.xcos;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.scilab.modules.xcos.Xcos;
+
+/**
+ * Test of the {@link XcosTest} class.
+ */
+public class XcosTest {
+
+ /**
+ * Be careful when modifying the tradename and version.
+ */
+ @Test
+ public void checkVersion() {
+ assertTrue(Xcos.TRADENAME.compareTo("Xcos") == 0);
+ assertTrue(Xcos.VERSION.compareTo("1.0") == 0);
+ }
+}
diff --git a/modules/xcos/tests/java/org/scilab/tests/modules/xcos/block/SortPortsTest.java b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/block/SortPortsTest.java
new file mode 100755
index 000000000..5cb1b232b
--- /dev/null
+++ b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/block/SortPortsTest.java
@@ -0,0 +1,167 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Clement DAVID
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+package org.scilab.tests.modules.xcos.block;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.scilab.modules.xcos.block.BasicBlock;
+import org.scilab.modules.xcos.port.BasicPort;
+import org.scilab.modules.xcos.port.command.CommandPort;
+import org.scilab.modules.xcos.port.control.ControlPort;
+import org.scilab.modules.xcos.port.input.ExplicitInputPort;
+import org.scilab.modules.xcos.port.input.ImplicitInputPort;
+import org.scilab.modules.xcos.port.input.InputPort;
+import org.scilab.modules.xcos.port.output.ExplicitOutputPort;
+import org.scilab.modules.xcos.port.output.ImplicitOutputPort;
+import org.scilab.modules.xcos.port.output.OutputPort;
+
+public class SortPortsTest {
+
+ @Test
+ public void checkEmpty() {
+ final ArrayList<Object> children = new ArrayList<Object>();
+ BasicBlock.sort(children);
+
+ Assert.assertEquals(children, Collections.EMPTY_LIST);
+ assertRightOrder(children);
+ }
+
+ @Test
+ public void checkAlone() {
+ checkSingleInstance(new ExplicitInputPort());
+ checkSingleInstance(new ExplicitOutputPort());
+ checkSingleInstance(new ControlPort());
+ checkSingleInstance(new CommandPort());
+ }
+
+ private void checkSingleInstance(Object instance) {
+ final ArrayList<Object> children = new ArrayList<Object>();
+ children.add(instance);
+
+ BasicBlock.sort(children);
+
+ Assert.assertEquals(children, Collections.singletonList(instance));
+ assertRightOrder(children);
+ }
+
+ @Test
+ public void checkMulti() throws InstantiationException, IllegalAccessException {
+ checkMultiInstance(ExplicitInputPort.class);
+ checkMultiInstance(ExplicitOutputPort.class);
+ checkMultiInstance(ControlPort.class);
+ checkMultiInstance(CommandPort.class);
+
+ }
+
+ private void checkMultiInstance(final Class <? extends BasicPort > klass) throws InstantiationException, IllegalAccessException {
+ final ArrayList<Object> children = new ArrayList<Object>();
+
+ final int size = (int) Math.random() * 10;
+ for (int i = 0; i < size; i++) {
+ children.add(klass.newInstance());
+ }
+
+ final ArrayList<Object> sorted = new ArrayList<Object>(children);
+ BasicBlock.sort(sorted);
+
+ Assert.assertEquals(children, sorted);
+ assertRightOrder(sorted);
+ }
+
+ @Test
+ public void sortPortsTwice() {
+ final ArrayList<Object> children = new ArrayList<Object>();
+ fillRandomly(children);
+
+ final ArrayList<Object> sorted = new ArrayList<Object>(children);
+ BasicBlock.sort(sorted);
+ assertRightOrder(sorted);
+
+ final ArrayList<Object> sortedTwice = new ArrayList<Object>(sorted);
+ BasicBlock.sort(sortedTwice);
+
+ Assert.assertEquals(sorted, sortedTwice);
+ }
+
+ private void fillRandomly(final List<Object> children) {
+ final int size = (int) (Math.random() * 10) + 3;
+
+ for (int i = 0; i < size; i++) {
+ final int type = (int) (Math.random() * 6);
+
+ final BasicPort p;
+ switch (type) {
+ case 0:
+ p = new ExplicitInputPort();
+ break;
+ case 1:
+ p = new ImplicitInputPort();
+ break;
+ case 2:
+ p = new ExplicitOutputPort();
+ break;
+ case 3:
+ p = new ImplicitOutputPort();
+ break;
+ case 4:
+ p = new ControlPort();
+ break;
+ case 5:
+ p = new CommandPort();
+ break;
+ default:
+ p = null;
+ break;
+ }
+
+ children.add(p);
+ }
+ }
+
+ private void assertRightOrder(final List<Object> children) {
+ int typeIndex = 0;
+
+ for (Object object : children) {
+ switch (typeIndex) {
+ case 0:
+ if (object instanceof InputPort) {
+ break;
+ }
+ typeIndex++;
+ case 1:
+ if (object instanceof OutputPort) {
+ break;
+ }
+ typeIndex++;
+ case 2:
+ if (object instanceof ControlPort) {
+ break;
+ }
+ typeIndex++;
+ case 3:
+ if (object instanceof CommandPort) {
+ break;
+ }
+ typeIndex++;
+
+ default:
+ Assert.fail("children is not ordered");
+ break;
+ }
+ }
+ }
+}
diff --git a/modules/xcos/tests/java/org/scilab/tests/modules/xcos/graph/DiagramComparatorTest.java b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/graph/DiagramComparatorTest.java
new file mode 100755
index 000000000..18a70314f
--- /dev/null
+++ b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/graph/DiagramComparatorTest.java
@@ -0,0 +1,334 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2011 - Scilab Enterprises - Clement DAVID
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+package org.scilab.tests.modules.xcos.graph;
+
+import java.awt.GraphicsEnvironment;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.PriorityQueue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.scilab.modules.xcos.Xcos;
+import org.scilab.modules.xcos.block.SuperBlock;
+import org.scilab.modules.xcos.graph.DiagramComparator;
+import org.scilab.modules.xcos.graph.SuperBlockDiagram;
+import org.scilab.modules.xcos.graph.XcosDiagram;
+
+public class DiagramComparatorTest {
+
+ @Before
+ public void loadLibrary() {
+ System.loadLibrary("scilab");
+ }
+
+ @Test
+ public void addXcosDiagrams() {
+ if (GraphicsEnvironment.isHeadless()) {
+ return;
+ }
+
+ final PriorityQueue<XcosDiagram> sorted = new PriorityQueue<XcosDiagram>(1, DiagramComparator.getInstance());
+ final ArrayList<XcosDiagram> testVector = new ArrayList<XcosDiagram>();
+
+ /*
+ * Init test vector
+ */
+ for (int i = 0; i < 20; i++) {
+ testVector.add(new XcosDiagram());
+ }
+
+ /*
+ * test
+ */
+ sorted.addAll(testVector);
+
+ assert sorted.size() == testVector.size();
+
+ /*
+ * Assert
+ */
+ for (XcosDiagram ref : testVector) {
+ assert sorted.contains(ref);
+ }
+
+ assertOnDiagramCollection(sorted);
+ }
+
+ @Test
+ public void addSuperBlocksDiagrams() {
+ if (GraphicsEnvironment.isHeadless()) {
+ return;
+ }
+
+ final PriorityQueue<XcosDiagram> sorted = new PriorityQueue<XcosDiagram>(1, DiagramComparator.getInstance());
+ final ArrayList<XcosDiagram> testVector = new ArrayList<XcosDiagram>();
+
+ /*
+ * Init test vector
+ */
+ for (int i = 0; i < 20; i++) {
+ testVector.add(new SuperBlockDiagram());
+ }
+
+ /*
+ * test
+ */
+ sorted.addAll(testVector);
+
+ assert sorted.size() == testVector.size();
+
+ /*
+ * Assert
+ */
+ for (XcosDiagram ref : testVector) {
+ assert sorted.contains(ref);
+ }
+ }
+
+ @Test
+ public void checkOneHierarchy() {
+ if (GraphicsEnvironment.isHeadless()) {
+ return;
+ }
+
+ final Collection<XcosDiagram> sorted = Xcos.getInstance().createDiagramCollection();
+ final ArrayList<XcosDiagram> testVector = new ArrayList<XcosDiagram>();
+
+ /*
+ * Init test vector
+ */
+ XcosDiagram root1 = new XcosDiagram();
+ root1.installListeners();
+ XcosDiagram root2 = new XcosDiagram();
+ root2.installListeners();
+
+ /*
+ * First child
+ */
+ SuperBlock r1b1 = new SuperBlock();
+ root1.addCell(r1b1);
+
+ SuperBlockDiagram r1diag1 = new SuperBlockDiagram(r1b1);
+ r1diag1.installListeners();
+ r1diag1.installSuperBlockListeners();
+
+ SuperBlock r1diag1b1 = new SuperBlock();
+ r1diag1.addCell(r1diag1b1);
+
+ SuperBlockDiagram r1diag1b1diag1 = new SuperBlockDiagram(r1diag1b1);
+ r1diag1b1diag1.installListeners();
+ r1diag1b1diag1.installSuperBlockListeners();
+
+ /*
+ * test vector
+ */
+ testVector.add(root1);
+ testVector.add(r1diag1);
+ testVector.add(r1diag1b1diag1);
+ testVector.add(root2);
+
+ /*
+ * test
+ */
+ sorted.addAll(testVector);
+
+ ArrayList<XcosDiagram> expected = new ArrayList<XcosDiagram>();
+ expected.add(root1);
+ expected.add(root2);
+ expected.add(r1diag1);
+ expected.add(r1diag1b1diag1);
+
+ assertOnDiagramCollection(sorted);
+
+ sorted.clear();
+ Collections.shuffle(testVector);
+ sorted.addAll(testVector);
+ assertOnDiagramCollection(sorted);
+ }
+
+ private void assertOnDiagramCollection(Collection<XcosDiagram> diags) {
+ int depth = 0;
+
+ for (XcosDiagram d : diags) {
+ int currentDepth = 0;
+
+ while (d instanceof SuperBlockDiagram) {
+ currentDepth++;
+ d = ((SuperBlockDiagram) d).getContainer().getParentDiagram();
+ }
+
+ assert currentDepth >= depth;
+ depth = currentDepth;
+ }
+ }
+
+ @Test
+ public void checkTwoFilesHierarchy() {
+ if (GraphicsEnvironment.isHeadless()) {
+ return;
+ }
+
+ final Collection<XcosDiagram> sorted = Xcos.getInstance().createDiagramCollection();
+ final ArrayList<XcosDiagram> testVector = new ArrayList<XcosDiagram>();
+
+ /*
+ * Init test vector
+ */
+ XcosDiagram root1 = new XcosDiagram();
+ root1.installListeners();
+ XcosDiagram root2 = new XcosDiagram();
+ root2.installListeners();
+
+ /*
+ * First child
+ */
+ SuperBlock r1b1 = new SuperBlock();
+ root1.addCell(r1b1);
+ SuperBlock r2b1 = new SuperBlock();
+ root1.addCell(r2b1);
+
+ SuperBlockDiagram r1diag1 = new SuperBlockDiagram(r1b1);
+ r1diag1.installListeners();
+ r1diag1.installSuperBlockListeners();
+ SuperBlockDiagram r2diag1 = new SuperBlockDiagram(r2b1);
+ r2diag1.installListeners();
+ r2diag1.installSuperBlockListeners();
+
+ /*
+ * Second child
+ */
+ SuperBlock r1b2 = new SuperBlock();
+ root1.addCell(r1b2);
+ SuperBlock r2b2 = new SuperBlock();
+ root1.addCell(r2b2);
+
+ SuperBlockDiagram r1diag2 = new SuperBlockDiagram(r1b2);
+ r1diag2.installListeners();
+ r1diag2.installSuperBlockListeners();
+ SuperBlockDiagram r2diag2 = new SuperBlockDiagram(r2b2);
+ r2diag2.installListeners();
+ r2diag2.installSuperBlockListeners();
+
+ /*
+ * test vector
+ */
+ testVector.add(root1);
+ testVector.add(r1diag1);
+ testVector.add(root2);
+ testVector.add(r1diag2);
+ testVector.add(r2diag1);
+ testVector.add(r2diag2);
+
+ /*
+ * test
+ */
+ sorted.addAll(testVector);
+ assert sorted.size() == testVector.size();
+
+ assertOnDiagramCollection(sorted);
+ assertOnTwoFilesHierarchy(sorted, root1, root2);
+
+ /*
+ * Shuffle then test n times
+ */
+ Collections.shuffle(testVector);
+ for (int i = 0; i < testVector.size(); i++) {
+ Collections.rotate(testVector, i);
+ sorted.clear();
+ sorted.addAll(testVector);
+
+ assertOnDiagramCollection(sorted);
+ assertOnTwoFilesHierarchy(sorted, root1, root2);
+ }
+
+ }
+
+ private void assertOnTwoFilesHierarchy(final Collection<XcosDiagram> sorted, XcosDiagram root1, XcosDiagram root2) {
+ final Iterator<XcosDiagram> it = sorted.iterator();
+ XcosDiagram first = it.next();
+ XcosDiagram second = it.next();
+
+ assert first == root1 || first == root2;
+ assert second == root1 || second == root2;
+
+ while (it.hasNext()) {
+ XcosDiagram diag = it.next();
+ assert diag instanceof SuperBlockDiagram;
+ }
+ }
+
+ @Test
+ public void checkValidHierarchy() {
+ if (GraphicsEnvironment.isHeadless()) {
+ return;
+ }
+
+ final Collection<XcosDiagram> sorted = Xcos.getInstance().createDiagramCollection();
+ final ArrayList<XcosDiagram> testVector = new ArrayList<XcosDiagram>();
+
+ /*
+ * Init test vector
+ */
+ XcosDiagram root = new XcosDiagram();
+ root.installListeners();
+
+ /*
+ * First child
+ */
+ SuperBlock b1 = new SuperBlock();
+ root.addCell(b1);
+
+ SuperBlockDiagram diag1 = new SuperBlockDiagram(b1);
+ diag1.installListeners();
+ diag1.installSuperBlockListeners();
+
+ /*
+ * Second child
+ */
+ SuperBlock b2 = new SuperBlock();
+ root.addCell(b2);
+
+ SuperBlockDiagram diag2 = new SuperBlockDiagram(b2);
+ diag2.installListeners();
+ diag2.installSuperBlockListeners();
+
+ /*
+ * test vector
+ */
+ testVector.add(root);
+ testVector.add(diag1);
+ testVector.add(diag2);
+
+ /*
+ * test
+ */
+ sorted.addAll(testVector);
+
+ assert sorted.size() == testVector.size();
+
+ /*
+ * Assert
+ */
+ final Iterator<XcosDiagram> it = sorted.iterator();
+ assert it.next() == root;
+ if (it.next() == diag1) {
+ assert it.next() == diag2;
+ } else {
+ assert it.next() == diag1;
+ }
+
+ assertOnDiagramCollection(sorted);
+ }
+}
diff --git a/modules/xcos/tests/java/org/scilab/tests/modules/xcos/graph/ScicosParametersTest.java b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/graph/ScicosParametersTest.java
new file mode 100755
index 000000000..ac1fdf67a
--- /dev/null
+++ b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/graph/ScicosParametersTest.java
@@ -0,0 +1,336 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - DIGITEO - Clement DAVID
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+package org.scilab.tests.modules.xcos.graph;
+
+import java.awt.GraphicsEnvironment;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyVetoException;
+import java.beans.VetoableChangeListener;
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.scilab.modules.xcos.graph.ScicosParameters;
+
+/**
+ * Test the behavior of the {@link ScicosParameters} class.
+ *
+ * We are checking the class behavior by using introspection.
+ */
+public class ScicosParametersTest {
+ private static final String[] FIELDS;
+ private static final Field[] DEFAULT_VALUES;
+ private static final Method[] GETTERS;
+ private static final Method[] SETTERS;
+
+ @Before
+ public void loadLibrary() {
+ System.loadLibrary("scilab");
+ }
+
+ /**
+ * Initialize FIELDS, GETTERS and SETTERS and DEFAULT_VALUES.
+ */
+ static {
+ ArrayList<String> fields = new ArrayList<String>();
+ ArrayList<Method> setters = new ArrayList<Method>();
+ ArrayList<Method> getters = new ArrayList<Method>();
+ ArrayList<Field> default_values = new ArrayList<Field>();
+ /*
+ * First pass for getting SETTERS and FIELDS
+ */
+ for (Method m : ScicosParameters.class.getMethods()) {
+ if (m.getName().startsWith("set")) {
+ char[] field = m.getName().replaceFirst("set", "").toCharArray();
+ char firstChar = field[0];
+ field[0] = Character.toLowerCase(firstChar);
+
+ fields.add(new String(field));
+ setters.add(m);
+ }
+ }
+
+ /*
+ * Second pass for getting GETTERS and DEFAULT_VALUES
+ */
+ for (String f : fields) {
+ /*
+ * Getters
+ */
+ StringBuilder getter = new StringBuilder(f);
+ char firstChar = f.charAt(0);
+ getter.delete(0, 1);
+ getter.insert(0, Character.toUpperCase(firstChar));
+ getter.insert(0, "get");
+ String name = getter.toString();
+
+ for (Method m : ScicosParameters.class.getMethods()) {
+ if (m.getName().equals(name)) {
+ getters.add(m);
+ break;
+ }
+ }
+
+ /*
+ * Default values
+ */
+ StringBuilder constant = new StringBuilder(f);
+ for (int i = 0; i < constant.length(); i++) {
+ char c = constant.charAt(i);
+ if (Character.isUpperCase(c)) {
+ constant.insert(i, "_");
+ i++;
+ }
+ }
+ String field = constant.toString().toUpperCase();
+ try {
+ Field defaultValue = ScicosParameters.class.getDeclaredField(field);
+ default_values.add(defaultValue);
+ } catch (SecurityException e) {
+ throw new IllegalAccessError(e.toString());
+ } catch (NoSuchFieldException e) {
+ throw new IllegalAccessError(e.toString());
+ }
+ }
+
+ FIELDS = fields.toArray(new String[fields.size()]);
+ SETTERS = setters.toArray(new Method[setters.size()]);
+ GETTERS = getters.toArray(new Method[getters.size()]);
+ DEFAULT_VALUES = default_values.toArray(new Field[default_values.size()]);
+ }
+
+ @Test
+ public void checkNumberOfField() {
+ assert FIELDS.length == SETTERS.length;
+ assert FIELDS.length == GETTERS.length;
+ assert FIELDS.length == DEFAULT_VALUES.length;
+ }
+
+ @Test
+ public void checkInitValues() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+ if (GraphicsEnvironment.isHeadless()) {
+ return;
+ }
+
+ ScicosParameters obj = new ScicosParameters();
+
+ for (int i = 0; i < DEFAULT_VALUES.length; i++) {
+ Field f = DEFAULT_VALUES[i];
+ Method m = GETTERS[i];
+
+ final Object result = m.invoke(obj, (Object[]) null);
+ final Object reference = f.get(null);
+ assert result.equals(reference);
+ }
+ }
+
+ @Test
+ public void checkBeansNamedProperties() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
+ if (GraphicsEnvironment.isHeadless()) {
+ return;
+ }
+
+ for (int i = 0; i < DEFAULT_VALUES.length; i++) {
+ Field f = DEFAULT_VALUES[i];
+ String field = FIELDS[i];
+
+ // Check existence (will throw an exception)
+ Field change = ScicosParameters.class.getDeclaredField(f.getName() + "_CHANGE");
+
+ // Check value (field)
+ assert change.get(null).equals(field);
+ }
+ }
+
+ @Test
+ public void checkBeansPropertyChangeEvent() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, InstantiationException {
+ if (GraphicsEnvironment.isHeadless()) {
+ return;
+ }
+
+ ScicosParameters obj = new ScicosParameters();
+ final List<PropertyChangeEvent> receivedEvents = new ArrayList<PropertyChangeEvent>();
+
+ obj.addPropertyChangeListener(new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ receivedEvents.add(evt);
+ }
+ });
+
+ /*
+ * Update fields
+ */
+ for (int i = 0; i < DEFAULT_VALUES.length; i++) {
+ final Method set = SETTERS[i];
+ final Field defaultValue = DEFAULT_VALUES[i];
+
+ Object newValue = null;
+ if (defaultValue.getType().equals(double.class)) {
+ newValue = defaultValue.getDouble(null) + 1;
+ } else if (defaultValue.getType().equals(int.class)) {
+ newValue = defaultValue.getInt(null) + 1;
+ } else if (defaultValue.getType().equals(String.class)) {
+ newValue = ((String) defaultValue.get(null)).concat("1");
+ } else if (defaultValue.getType().isArray()) {
+ Object array = defaultValue.get(null);
+ final Class <? extends Object > type = defaultValue.getType().getComponentType();
+ final Object value;
+
+ final int arrayLength = Array.getLength(array);
+ value = Array.newInstance(type, arrayLength + 1);
+
+ /*
+ * Copying values
+ */
+ for (int j = 0; j < arrayLength; j++) {
+ Array.set(value, j, Array.get(array, j));
+ }
+
+ /*
+ * The latest value must be equal to the previous one or to the
+ * type's default value
+ */
+ final Object o;
+ if (arrayLength > 0) {
+ o = Array.get(array, arrayLength - 1);
+ } else {
+ o = type.newInstance();
+ }
+ Array.set(value, arrayLength, o);
+
+ newValue = value;
+ }
+
+ set.invoke(obj, newValue);
+ }
+
+ /*
+ * Check for modification events
+ */
+ for (int i = 0; i < DEFAULT_VALUES.length; i++) {
+ final Method get = GETTERS[i];
+ final PropertyChangeEvent evt = receivedEvents.get(i);
+
+ Object newValue = get.invoke(obj);
+ assert newValue.equals(evt.getNewValue());
+ }
+ }
+
+ @Test
+ public void checkBeansVetoableChangeEvent() throws IllegalArgumentException, IllegalAccessException, InstantiationException {
+ if (GraphicsEnvironment.isHeadless()) {
+ return;
+ }
+
+ ScicosParameters obj = new ScicosParameters();
+ final List<PropertyVetoException> receivedExceptions = new ArrayList<PropertyVetoException>();
+
+ obj.addVetoableChangeListener(new VetoableChangeListener() {
+ @Override
+ public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
+ // always throw exception
+ throw new PropertyVetoException(evt.getPropertyName(), evt);
+ }
+ });
+
+ /*
+ * Update fields
+ */
+ for (int i = 0; i < DEFAULT_VALUES.length; i++) {
+ final Method set = SETTERS[i];
+ final Field defaultValue = DEFAULT_VALUES[i];
+
+ Object newValue = null;
+ if (defaultValue.getType().equals(double.class)) {
+ newValue = defaultValue.getDouble(null) + 1;
+ } else if (defaultValue.getType().equals(int.class)) {
+ newValue = defaultValue.getInt(null) + 1;
+ } else if (defaultValue.getType().equals(String.class)) {
+ newValue = ((String) defaultValue.get(null)).concat("1");
+ } else if (defaultValue.getType().isArray()) {
+ Object array = defaultValue.get(null);
+ final Class <? extends Object > type = defaultValue.getType().getComponentType();
+ final Object value;
+
+ final int arrayLength = Array.getLength(array);
+ value = Array.newInstance(type, arrayLength + 1);
+
+ /*
+ * Copying values
+ */
+ for (int j = 0; j < arrayLength; j++) {
+ Array.set(value, j, Array.get(array, j));
+ }
+
+ /*
+ * The latest value must be equal to the previous one or to the
+ * type's default value
+ */
+ final Object o;
+ if (arrayLength > 0) {
+ o = Array.get(array, arrayLength - 1);
+ } else {
+ o = type.newInstance();
+ }
+ Array.set(value, arrayLength, o);
+
+ newValue = value;
+ }
+
+ try {
+ set.invoke(obj, newValue);
+ } catch (InvocationTargetException e) {
+ receivedExceptions.add((PropertyVetoException) e.getTargetException());
+ }
+ }
+
+ /*
+ * Check for received PropertyVetoException
+ */
+ assert receivedExceptions.size() == DEFAULT_VALUES.length;
+ for (int i = 0; i < DEFAULT_VALUES.length; i++) {
+ final String field = FIELDS[i];
+ final PropertyVetoException e = receivedExceptions.get(i);
+
+ assert e.getMessage().equals(field);
+ }
+ }
+
+ /**
+ * Call all public methods through introspection
+ *
+ * @param args
+ * not used
+ * @throws InvocationTargetException
+ * @throws IllegalAccessException
+ * @throws IllegalArgumentException
+ */
+ public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+ Object obj = new ScicosParametersTest();
+ Method[] tests = ScicosParametersTest.class.getDeclaredMethods();
+ for (Method method : tests) {
+ int modifiers = method.getModifiers();
+ if ((modifiers | Modifier.STATIC) != modifiers) {
+ method.invoke(obj, (Object[]) null);
+ }
+ }
+ }
+}
diff --git a/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/command/CommandPortTest.java b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/command/CommandPortTest.java
new file mode 100755
index 000000000..7a9908cca
--- /dev/null
+++ b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/command/CommandPortTest.java
@@ -0,0 +1,62 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - DIGITEO - Clement DAVID
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+package org.scilab.tests.modules.xcos.port.command;
+
+import org.scilab.modules.xcos.port.BasicPort;
+import org.scilab.modules.xcos.port.Orientation;
+import org.scilab.modules.xcos.port.command.CommandPort;
+import org.junit.*;
+
+/**
+ * Unit test for {@link CommandPort}
+ */
+public class CommandPortTest {
+ public static final int DEFAULT_PORTSIZE = 8;
+
+ @Test
+ public void checkType() {
+ CommandPort port = new CommandPort();
+ assert port.getType() == null;
+ }
+
+ @Test
+ public void checkDefaultOrientation() {
+ CommandPort port = new CommandPort();
+ assert port.getOrientation() == Orientation.SOUTH;
+ }
+
+ @Test
+ public void checkStyle() {
+ CommandPort port = new CommandPort();
+ assert port.getStyle().contains("CommandPort");
+ }
+
+ @Test
+ public void checkTypeName() {
+ CommandPort port = new CommandPort();
+ assert port.getTypeName().equals("CommandPort");
+ }
+
+ @Test
+ public void checkClassHierarchy() {
+ CommandPort port = new CommandPort();
+ assert port instanceof BasicPort;
+ }
+
+ @Test
+ public void checkDefaultGeometry() {
+ CommandPort port = new CommandPort();
+ assert port.getGeometry().getWidth() == DEFAULT_PORTSIZE;
+ assert port.getGeometry().getHeight() == DEFAULT_PORTSIZE;
+ }
+}
diff --git a/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/control/ControlPortTest.java b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/control/ControlPortTest.java
new file mode 100755
index 000000000..cc0781819
--- /dev/null
+++ b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/control/ControlPortTest.java
@@ -0,0 +1,62 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - DIGITEO - Clement DAVID
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+package org.scilab.tests.modules.xcos.port.control;
+
+import org.scilab.modules.xcos.port.BasicPort;
+import org.scilab.modules.xcos.port.Orientation;
+import org.scilab.modules.xcos.port.control.ControlPort;
+import org.junit.*;
+
+/**
+ * Unit test for {@link ControlPort}
+ */
+public class ControlPortTest {
+ public static final int DEFAULT_PORTSIZE = 8;
+
+ @Test
+ public void checkType() {
+ ControlPort port = new ControlPort();
+ assert port.getType() == null;
+ }
+
+ @Test
+ public void checkDefaultOrientation() {
+ ControlPort port = new ControlPort();
+ assert port.getOrientation() == Orientation.NORTH;
+ }
+
+ @Test
+ public void checkStyle() {
+ ControlPort port = new ControlPort();
+ assert port.getStyle().contains("ControlPort");
+ }
+
+ @Test
+ public void checkTypeName() {
+ ControlPort port = new ControlPort();
+ assert port.getTypeName().equals("ControlPort");
+ }
+
+ @Test
+ public void checkClassHierarchy() {
+ ControlPort port = new ControlPort();
+ assert port instanceof BasicPort;
+ }
+
+ @Test
+ public void checkDefaultGeometry() {
+ ControlPort port = new ControlPort();
+ assert port.getGeometry().getWidth() == DEFAULT_PORTSIZE;
+ assert port.getGeometry().getHeight() == DEFAULT_PORTSIZE;
+ }
+}
diff --git a/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/input/ExplicitInputPortTest.java b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/input/ExplicitInputPortTest.java
new file mode 100755
index 000000000..84d875a64
--- /dev/null
+++ b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/input/ExplicitInputPortTest.java
@@ -0,0 +1,65 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - DIGITEO - Clement DAVID
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+package org.scilab.tests.modules.xcos.port.input;
+
+import org.scilab.modules.xcos.port.BasicPort;
+import org.scilab.modules.xcos.port.Orientation;
+import org.scilab.modules.xcos.port.BasicPort.Type;
+import org.scilab.modules.xcos.port.input.ExplicitInputPort;
+import org.scilab.modules.xcos.port.input.InputPort;
+import org.junit.*;
+
+/**
+ * Unit test for {@link ExplicitInputPort}
+ */
+public class ExplicitInputPortTest {
+ public static final int DEFAULT_PORTSIZE = 8;
+
+ @Test
+ public void checkType() {
+ ExplicitInputPort port = new ExplicitInputPort();
+ assert port.getType() == Type.EXPLICIT;
+ }
+
+ @Test
+ public void checkDefaultOrientation() {
+ ExplicitInputPort port = new ExplicitInputPort();
+ assert port.getOrientation() == Orientation.WEST;
+ }
+
+ @Test
+ public void checkStyle() {
+ ExplicitInputPort port = new ExplicitInputPort();
+ assert port.getStyle().contains("ExplicitInputPort");
+ }
+
+ @Test
+ public void checkTypeName() {
+ ExplicitInputPort port = new ExplicitInputPort();
+ assert port.getTypeName().equals("ExplicitInputPort");
+ }
+
+ @Test
+ public void checkClassHierarchy() {
+ ExplicitInputPort port = new ExplicitInputPort();
+ assert port instanceof InputPort;
+ assert port instanceof BasicPort;
+ }
+
+ @Test
+ public void checkDefaultGeometry() {
+ ExplicitInputPort port = new ExplicitInputPort();
+ assert port.getGeometry().getWidth() == DEFAULT_PORTSIZE;
+ assert port.getGeometry().getHeight() == DEFAULT_PORTSIZE;
+ }
+}
diff --git a/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/input/ImplicitInputPortTest.java b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/input/ImplicitInputPortTest.java
new file mode 100755
index 000000000..b65247bd2
--- /dev/null
+++ b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/input/ImplicitInputPortTest.java
@@ -0,0 +1,65 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - DIGITEO - Clement DAVID
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+package org.scilab.tests.modules.xcos.port.input;
+
+import org.scilab.modules.xcos.port.BasicPort;
+import org.scilab.modules.xcos.port.Orientation;
+import org.scilab.modules.xcos.port.BasicPort.Type;
+import org.scilab.modules.xcos.port.input.ImplicitInputPort;
+import org.scilab.modules.xcos.port.input.InputPort;
+import org.junit.*;
+
+/**
+ * Unit test for {@link ImplicitInputPort}
+ */
+public class ImplicitInputPortTest {
+ public static final int DEFAULT_PORTSIZE = 8;
+
+ @Test
+ public void checkType() {
+ ImplicitInputPort port = new ImplicitInputPort();
+ assert port.getType() == Type.IMPLICIT;
+ }
+
+ @Test
+ public void checkDefaultOrientation() {
+ ImplicitInputPort port = new ImplicitInputPort();
+ assert port.getOrientation() == Orientation.WEST;
+ }
+
+ @Test
+ public void checkStyle() {
+ ImplicitInputPort port = new ImplicitInputPort();
+ assert port.getStyle().contains("ImplicitInputPort");
+ }
+
+ @Test
+ public void checkTypeName() {
+ ImplicitInputPort port = new ImplicitInputPort();
+ assert port.getTypeName().equals("ImplicitInputPort");
+ }
+
+ @Test
+ public void checkClassHierarchy() {
+ ImplicitInputPort port = new ImplicitInputPort();
+ assert port instanceof InputPort;
+ assert port instanceof BasicPort;
+ }
+
+ @Test
+ public void checkDefaultGeometry() {
+ ImplicitInputPort port = new ImplicitInputPort();
+ assert port.getGeometry().getWidth() == DEFAULT_PORTSIZE;
+ assert port.getGeometry().getHeight() == DEFAULT_PORTSIZE;
+ }
+}
diff --git a/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/output/ExplicitOutputPortTest.java b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/output/ExplicitOutputPortTest.java
new file mode 100755
index 000000000..cdea844f3
--- /dev/null
+++ b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/output/ExplicitOutputPortTest.java
@@ -0,0 +1,65 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - DIGITEO - Clement DAVID
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+package org.scilab.tests.modules.xcos.port.output;
+
+import org.scilab.modules.xcos.port.BasicPort;
+import org.scilab.modules.xcos.port.Orientation;
+import org.scilab.modules.xcos.port.BasicPort.Type;
+import org.scilab.modules.xcos.port.output.ExplicitOutputPort;
+import org.scilab.modules.xcos.port.output.OutputPort;
+import org.junit.*;
+
+/**
+ * Unit test for {@link ExplicitOutputPort}
+ */
+public class ExplicitOutputPortTest {
+ public static final int DEFAULT_PORTSIZE = 8;
+
+ @Test
+ public void checkType() {
+ ExplicitOutputPort port = new ExplicitOutputPort();
+ assert port.getType() == Type.EXPLICIT;
+ }
+
+ @Test
+ public void checkDefaultOrientation() {
+ ExplicitOutputPort port = new ExplicitOutputPort();
+ assert port.getOrientation() == Orientation.EAST;
+ }
+
+ @Test
+ public void checkStyle() {
+ ExplicitOutputPort port = new ExplicitOutputPort();
+ assert port.getStyle().contains("ExplicitOutputPort");
+ }
+
+ @Test
+ public void checkTypeName() {
+ ExplicitOutputPort port = new ExplicitOutputPort();
+ assert port.getTypeName().equals("ExplicitOutputPort");
+ }
+
+ @Test
+ public void checkClassHierarchy() {
+ ExplicitOutputPort port = new ExplicitOutputPort();
+ assert port instanceof OutputPort;
+ assert port instanceof BasicPort;
+ }
+
+ @Test
+ public void checkDefaultGeometry() {
+ ExplicitOutputPort port = new ExplicitOutputPort();
+ assert port.getGeometry().getWidth() == DEFAULT_PORTSIZE;
+ assert port.getGeometry().getHeight() == DEFAULT_PORTSIZE;
+ }
+}
diff --git a/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/output/ImplicitOutputPortTest.java b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/output/ImplicitOutputPortTest.java
new file mode 100755
index 000000000..3b548c67d
--- /dev/null
+++ b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/port/output/ImplicitOutputPortTest.java
@@ -0,0 +1,65 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - DIGITEO - Clement DAVID
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+package org.scilab.tests.modules.xcos.port.output;
+
+import org.scilab.modules.xcos.port.BasicPort;
+import org.scilab.modules.xcos.port.Orientation;
+import org.scilab.modules.xcos.port.BasicPort.Type;
+import org.scilab.modules.xcos.port.output.ImplicitOutputPort;
+import org.scilab.modules.xcos.port.output.OutputPort;
+import org.junit.*;
+
+/**
+ * Unit test for {@link ImplicitOutputPort}
+ */
+public class ImplicitOutputPortTest {
+ public static final int DEFAULT_PORTSIZE = 8;
+
+ @Test
+ public void checkType() {
+ ImplicitOutputPort port = new ImplicitOutputPort();
+ assert port.getType() == Type.IMPLICIT;
+ }
+
+ @Test
+ public void checkDefaultOrientation() {
+ ImplicitOutputPort port = new ImplicitOutputPort();
+ assert port.getOrientation() == Orientation.EAST;
+ }
+
+ @Test
+ public void checkStyle() {
+ ImplicitOutputPort port = new ImplicitOutputPort();
+ assert port.getStyle().contains("ImplicitOutputPort");
+ }
+
+ @Test
+ public void checkTypeName() {
+ ImplicitOutputPort port = new ImplicitOutputPort();
+ assert port.getTypeName().equals("ImplicitOutputPort");
+ }
+
+ @Test
+ public void checkClassHierarchy() {
+ ImplicitOutputPort port = new ImplicitOutputPort();
+ assert port instanceof OutputPort;
+ assert port instanceof BasicPort;
+ }
+
+ @Test
+ public void checkDefaultGeometry() {
+ ImplicitOutputPort port = new ImplicitOutputPort();
+ assert port.getGeometry().getWidth() == DEFAULT_PORTSIZE;
+ assert port.getGeometry().getHeight() == DEFAULT_PORTSIZE;
+ }
+}
diff --git a/modules/xcos/tests/java/org/scilab/tests/modules/xcos/utils/FileTypeTest.java b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/utils/FileTypeTest.java
new file mode 100755
index 000000000..0208d5f31
--- /dev/null
+++ b/modules/xcos/tests/java/org/scilab/tests/modules/xcos/utils/FileTypeTest.java
@@ -0,0 +1,91 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009 - DIGITEO - Clement DAVID
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+package org.scilab.tests.modules.xcos.utils;
+
+import java.io.File;
+import java.io.IOException;
+import java.awt.GraphicsEnvironment;
+
+import org.junit.Test;
+import org.junit.Assume;
+
+import org.scilab.modules.xcos.graph.XcosDiagram;
+import org.scilab.modules.xcos.io.XcosFileType;
+
+
+/**
+ * Test the {@link XcosFileType} class.
+ */
+public class FileTypeTest {
+ private static final String XcosFileHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+
+ @Test
+ public void checkSupportedType() {
+ assert XcosFileType.values().length == 4;
+ assert XcosFileType.getAvailableSaveFormats().contains(XcosFileType.ZCOS);
+ assert XcosFileType.getAvailableSaveFormats().contains(XcosFileType.XCOS);
+ }
+
+ @Test
+ public void checkNullField() {
+ for (XcosFileType type : XcosFileType.values()) {
+ assert type.getExtension() != null;
+ assert type.getDescription() != null;
+ }
+ }
+
+ @Test
+ public void checkExtension() {
+ for (XcosFileType type : XcosFileType.values()) {
+ assert type.getDottedExtension().compareTo("." + type.getExtension()) == 0;
+ assert type.getFileMask().compareTo("*" + type.getDottedExtension()) == 0;
+ }
+ }
+
+ @Test
+ public void validateFindFileType() throws IOException {
+ for (XcosFileType type : XcosFileType.values()) {
+ File tmp = File.createTempFile("xcosTest", type.getDottedExtension());
+
+ if (type != XcosFileType.XCOS) {
+ assert type == XcosFileType.findFileType(tmp.getAbsolutePath());
+ } else {
+ assert XcosFileType.findFileType(tmp.getAbsolutePath()) == null;
+ }
+
+ tmp.delete();
+ }
+ }
+
+ @Test
+ public void validateXcosFindFileType() throws Exception {
+ Assume.assumeTrue(!GraphicsEnvironment.isHeadless());
+ File tmp = File.createTempFile("xcosTest", XcosFileType.XCOS.getDottedExtension());
+ XcosFileType.XCOS.save(tmp.getCanonicalPath(), new XcosDiagram());
+
+ assert XcosFileType.XCOS == XcosFileType.findFileType(tmp);
+
+ tmp.delete();
+ }
+
+ @Test
+ public void validateZcosFindFileType() throws Exception {
+ Assume.assumeTrue(!GraphicsEnvironment.isHeadless());
+ File tmp = File.createTempFile("xcosTest", XcosFileType.ZCOS.getDottedExtension());
+ XcosFileType.ZCOS.save(tmp.getCanonicalPath(), new XcosDiagram());
+
+ assert XcosFileType.ZCOS == XcosFileType.findFileType(tmp);
+
+ tmp.delete();
+ }
+}
diff --git a/modules/xcos/tests/java/xcos-JAVA-tests.vcxproj b/modules/xcos/tests/java/xcos-JAVA-tests.vcxproj
new file mode 100755
index 000000000..4ac79575b
--- /dev/null
+++ b/modules/xcos/tests/java/xcos-JAVA-tests.vcxproj
@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{DABDF840-2A2F-4B38-90B2-A4393E6DF38B}</ProjectGuid>
+ <RootNamespace>xcos-java-tests</RootNamespace>
+ <Keyword>MakeFileProj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Makefile</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Makefile</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Makefile</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Makefile</ConfigurationType>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)modules\xcos\jar\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Configuration)\</IntDir>
+ <NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">set JAVA_HOME=$(SolutionDir)java\jdk
+set PATH=$(SolutionDir)java\ant\bin;%PATH%;
+cd ..\..
+call ant test
+</NMakeBuildCommandLine>
+ <NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">set JAVA_HOME=$(SolutionDir)java\jdk
+set PATH=$(SolutionDir)java\ant\bin;%PATH%;
+cd ..\..
+call ant test
+
+</NMakeReBuildCommandLine>
+ <NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
+ <NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>
+ <NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(NMakeForcedIncludes)</NMakeForcedIncludes>
+ <NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath>
+ <NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)modules\xcos\jar\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)$(Configuration)\</IntDir>
+ <NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">set JAVA_HOME=$(SolutionDir)java\jdk
+set PATH=$(SolutionDir)java\ant\bin;%PATH%;
+cd ..\..
+call ant test
+</NMakeBuildCommandLine>
+ <NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">set JAVA_HOME=$(SolutionDir)java\jdk
+set PATH=$(SolutionDir)java\ant\bin;%PATH%;
+cd ..\..
+call ant test
+
+</NMakeReBuildCommandLine>
+ <NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
+ <NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>
+ <NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(NMakeForcedIncludes)</NMakeForcedIncludes>
+ <NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath>
+ <NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)modules\xcos\jar\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Configuration)\</IntDir>
+ <NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">set JAVA_HOME=$(SolutionDir)java\jdk
+set PATH=$(SolutionDir)java\ant\bin;%PATH%;
+cd ..\..
+call ant test
+</NMakeBuildCommandLine>
+ <NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">set JAVA_HOME=$(SolutionDir)java\jdk
+set PATH=$(SolutionDir)java\ant\bin;%PATH%;
+cd ..\..
+call ant test
+
+</NMakeReBuildCommandLine>
+ <NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">WIN32;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
+ <NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>
+ <NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedIncludes)</NMakeForcedIncludes>
+ <NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath>
+ <NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)modules\xcos\jar\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)$(Configuration)\</IntDir>
+ <NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|x64'">set JAVA_HOME=$(SolutionDir)java\jdk
+set PATH=$(SolutionDir)java\ant\bin;%PATH%;
+cd ..\..
+call ant test
+</NMakeBuildCommandLine>
+ <NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|x64'">set JAVA_HOME=$(SolutionDir)java\jdk
+set PATH=$(SolutionDir)java\ant\bin;%PATH%;
+cd ..\..
+call ant test
+
+</NMakeReBuildCommandLine>
+ <NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">WIN32;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
+ <NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>
+ <NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(NMakeForcedIncludes)</NMakeForcedIncludes>
+ <NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath>
+ <NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <None Include="org\scilab\tests\modules\xcos\XcosTest.java" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\..\Visual-Studio-settings\ant-all\ant-all.vcxproj">
+ <Project>{a9a2020d-5541-44f2-b080-df3c9426c409}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/modules/xcos/tests/java/xcos-JAVA-tests.vcxproj.filters b/modules/xcos/tests/java/xcos-JAVA-tests.vcxproj.filters
new file mode 100755
index 000000000..e1a7d04d9
--- /dev/null
+++ b/modules/xcos/tests/java/xcos-JAVA-tests.vcxproj.filters
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="org\scilab\tests\modules\xcos\XcosTest.java">
+ <Filter>Source Files</Filter>
+ </None>
+ </ItemGroup>
+</Project> \ No newline at end of file