Salome HOME
Increase code coverage for the FiltersPlugin.
authorazv <azv@opencascade.com>
Wed, 23 Oct 2019 05:52:56 +0000 (08:52 +0300)
committervsv <vsv@opencascade.com>
Wed, 6 Nov 2019 08:27:39 +0000 (11:27 +0300)
src/Config/ConfigAPI.i
src/Config/Config_ValidatorReader.h
src/Config/Config_swig.h
src/FiltersPlugin/CMakeLists.txt
src/FiltersPlugin/Test/TestFilters_Validator.py [new file with mode: 0644]

index 5efdefab5133b79a0c053de8745fe3302909a43a..92372e3c3b0b41e22ac76865cd309ec4bd193ce4 100644 (file)
@@ -35,6 +35,8 @@
 %include "Config_ModuleReader.h"
 %include "Config_PropManager.h"
 %include "Config_Prop.h"
+%include "Config_ValidatorReader.h"
+%include "Config_XMLReader.h"
 
 // std::list -> []
 %template(ListOfString) std::list< std::string >;
index dac03e09086e2990071eae7c1d60f5d0ca44d72f..e386262347256d9e861c1b77edc002e9371c9a65 100644 (file)
@@ -46,6 +46,9 @@ class Config_ValidatorReader : public Config_XMLReader
   /// Set feature ID for cases when XML for validators is parsed from memory
   CONFIG_EXPORT void setFeatureId(const std::string& theId) { myExtFeatureId = theId; }
 
+  // for correct SWIG wrapping
+  using Config_XMLReader::readAll;
+
  protected:
   /*!
    * \brief Allows to customize reader's behavior for a node. Virtual.
index b39d5add81c03b605d462810e0f44c8009c00ba6..6e435181f4922b745295d3810976c99054afbbc4 100644 (file)
@@ -23,5 +23,7 @@
   #include "Config_ModuleReader.h"
   #include "Config_Prop.h"
   #include "Config_PropManager.h"
+  #include "Config_ValidatorReader.h"
+  #include "Config_XMLReader.h"
 
 #endif /* SRC_CONFIG_SWIG_H_ */
index 2c856188db730598fb3f6b7aa2a253c84201029b..1f01c4e4447535f7dd1b15fc0bb7370e6f3afdeb 100644 (file)
@@ -104,6 +104,7 @@ ADD_UNIT_TESTS(
   TestFilters_Mixed1.py
   TestFilters_Mixed2.py
   TestFilters_Supported.py
+  TestFilters_Validator.py
   TestFilters_Xml.py
   TestFilters_FilterName.py
   TestFilters_IsReversed.py
diff --git a/src/FiltersPlugin/Test/TestFilters_Validator.py b/src/FiltersPlugin/Test/TestFilters_Validator.py
new file mode 100644 (file)
index 0000000..66f9d33
--- /dev/null
@@ -0,0 +1,50 @@
+# Copyright (C) 2014-2019  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
+#
+
+from salome.shaper import model
+
+from ConfigAPI import *
+from ModelAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
+model.do()
+
+# load 'Filters' plugin
+FiltersFeature = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", args = [model.selection("FACE", "Box_1_1/Left")])])
+
+FiltersFactory = ModelAPI_Session.get().filters()
+Filter = FiltersFactory.filter("OnGeometry")
+
+# read XML representation to load validator
+ValidatorReader = Config_ValidatorReader(Filter.xmlRepresentation(), True)
+ValidatorReader.setFeatureId("FiltersSelection")
+ValidatorReader.readAll()
+
+aFactory = ModelAPI_Session.get().validators()
+# no Group, thus not valid yet
+assert(not aFactory.validate(FiltersFeature.feature()))
+
+Group_1 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Box_1_1/Left"), FiltersFeature])
+assert(aFactory.validate(FiltersFeature.feature()))
+
+model.end()