Salome HOME
[Code coverage Config]: Unit test for Config_PropManager
authorazv <azv@opencascade.com>
Sun, 9 Dec 2018 09:43:17 +0000 (12:43 +0300)
committerazv <azv@opencascade.com>
Sun, 9 Dec 2018 09:43:17 +0000 (12:43 +0300)
lcov_reports.sh
src/Config/CMakeLists.txt
src/Config/ConfigAPI.i
src/Config/Test/TestConfig.py [new file with mode: 0644]

index 6a1f43b64cd0a7f182ac1e08fa0d3477e71dc20a..098afcdd3fe81354334507e93515ec73812d5615 100755 (executable)
@@ -68,6 +68,11 @@ done
 # remove SketchPlugin's Ellipse feature (unsupported yet)
 lcov -r covElse SketchPlugin*Ellipse* --output-file covElse_res -q
 mv -f covElse_res covElse
+# remove GUI related files from Config plugin
+for MASK in 'DataModelReader' 'Translator' 'PointerMessage'; do
+lcov -r covElse *Config_${MASK}API* --output-file covElse_res -q
+mv -f covElse_res covElse
+done
 rm -rf lcov_htmlElse
 genhtml covElse --output-directory lcov_htmlElse -q
 
index 05bafb324a93a8baff93cdcc2706b9aa02ba3209..1918d4fa454c4afc1bd6982a90451637cebfa4ee 100644 (file)
@@ -19,6 +19,7 @@
 ##
 
 INCLUDE(Common)
+INCLUDE(UnitTest)
 INCLUDE(XMLProcessing)
 FIND_PACKAGE(SWIG REQUIRED)
 INCLUDE(${SWIG_USE_FILE})
@@ -150,3 +151,8 @@ INSTALL(FILES ${XML_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
 
 INSTALL(TARGETS _ConfigAPI DESTINATION ${SHAPER_INSTALL_SWIG})
 INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION ${SHAPER_INSTALL_SWIG})
+
+
+ADD_UNIT_TESTS(
+  TestConfig.py
+)
index 2bf42f1a044bdbab5330e527da8cfb1d5dde10c8..f5fb5461a90ffd1f97ed64e6efdd742bb91aa47d 100644 (file)
 #define CONFIG_EXPORT
 
 %include "typemaps.i"
+%include "std_list.i"
 %include "std_string.i"
+%include "std_vector.i"
 
 %include "Config_ModuleReader.h"
 %include "Config_PropManager.h"
 %include "Config_Prop.h"
+
+// std::list -> []
+%template(ListOfString) std::list< std::string >;
+%template(listOfProp) std::list< Config_Prop* >;
+// std::vector -> []
+%template(VectorOfInteger) std::vector<int>;
diff --git a/src/Config/Test/TestConfig.py b/src/Config/Test/TestConfig.py
new file mode 100644 (file)
index 0000000..a98d534
--- /dev/null
@@ -0,0 +1,42 @@
+## Copyright (C) 2018-20xx  CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
+from ModelAPI import *
+from ConfigAPI import *
+
+# register boolean property
+Config_PropManager().registerProp("TestSection", "PropBool", "PropTitle", Config_Prop.Boolean)
+# check property once again
+Config_PropManager().registerProp("TestSection", "PropBool", "PropTitle", Config_Prop.Boolean, "true")
+# check property value
+assert(Config_PropManager().boolean("TestSection", "PropBool"))
+
+# register real property
+Config_PropManager().registerProp("TestSection", "PropDouble", "PropTitle", Config_Prop.Double, "12,5")
+# check property (',' should be substituted by ".")
+assert(Config_PropManager().real("TestSection", "PropDouble") == 12.5)
+
+# register color property
+Config_PropManager().registerProp("TestSection", "PropColor", "PropTitle", Config_Prop.Color, "#B00F00")
+assert(len(Config_PropManager().color("TestSection", "PropColor")) == 3)
+
+# check sections and properties are not empty
+assert(len(Config_PropManager().getSections()) > 0)
+assert(len(Config_PropManager().getProperties()) > 0)