Xcos MVC: fix MList import 68/17068/5
Paul Bignier [Thu, 9 Jul 2015 08:54:39 +0000 (10:54 +0200)]
 * Now loading both mlist (backward compatibility) and userType

Change-Id: I04fd3490c689434f87c0c727a29a77fc51f4bcf4

scilab/modules/scicos/src/cpp/view_scilab/DiagramAdapter.cpp
scilab/modules/xcos/tests/unit_tests/SimpleGENSINExport2.sod [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/SimpleGENSINSCOPE2.sod [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/xcos_simulate.tst

index a81f90e..5f966ab 100644 (file)
@@ -338,6 +338,9 @@ struct objs
 
                     diagramChildren.push_back(localAdaptee);
                     list->set(i, localAdaptor);
+
+                    // Do the linking in the next loop, in case the Link points to a Block that has not been added yet
+                    links.push_back(localAdaptor);
                 }
                 else
                 {
diff --git a/scilab/modules/xcos/tests/unit_tests/SimpleGENSINExport2.sod b/scilab/modules/xcos/tests/unit_tests/SimpleGENSINExport2.sod
new file mode 100644 (file)
index 0000000..1f83254
Binary files /dev/null and b/scilab/modules/xcos/tests/unit_tests/SimpleGENSINExport2.sod differ
diff --git a/scilab/modules/xcos/tests/unit_tests/SimpleGENSINSCOPE2.sod b/scilab/modules/xcos/tests/unit_tests/SimpleGENSINSCOPE2.sod
new file mode 100644 (file)
index 0000000..482f7f2
Binary files /dev/null and b/scilab/modules/xcos/tests/unit_tests/SimpleGENSINSCOPE2.sod differ
index 25c6966..e998b74 100644 (file)
@@ -1,13 +1,16 @@
 // ============================================================================
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2016 - Scilab Enterprises - Paul Bignier
 // Copyright (C) 2014 - Scilab Enterprises - Bruno JOFRET
 //
 //  This file is distributed under the same license as the Scilab package.
 // ============================================================================
-
+//
 // <-- XCOS TEST -->
-// <-- CLI SHELL MODE -->
+
+// Load diagram as mlist
 load(SCI+"/modules/xcos/tests/unit_tests/SimpleGENSINExport.sod");
+assert_checkequal(type(scs_m), 17);
 
 [%cpr, ok] = xcos_simulate(scs_m, 4);
 
@@ -16,6 +19,24 @@ assert_checkequal(data.time, (0:0.1:29.9)');
 assert_checkequal(data.values, sin(data.time));
 
 load(SCI+"/modules/xcos/tests/unit_tests/SimpleGENSINSCOPE.sod");
+assert_checkequal(type(scs_m), 17);
+
+[%cpr, ok] = xcos_simulate(scs_m, 4);
+assert_checkfalse(ok); // Cannot use scope in without graphics
+
+
+// Load diagram as userType
+load(SCI+"/modules/xcos/tests/unit_tests/SimpleGENSINExport2.sod");
+assert_checkequal(type(scs_m), 128);
+
+[%cpr, ok] = xcos_simulate(scs_m, 4);
+
+assert_checktrue(ok);
+assert_checkequal(data.time, (0:0.1:29.9)');
+assert_checkequal(data.values, sin(data.time));
+
+load(SCI+"/modules/xcos/tests/unit_tests/SimpleGENSINSCOPE2.sod");
+assert_checkequal(type(scs_m), 128);
 
 [%cpr, ok] = xcos_simulate(scs_m, 4);
-assert_checkfalse(ok);
\ No newline at end of file
+assert_checkfalse(ok); // Cannot use scope without graphics