From: azv Date: Wed, 23 Oct 2019 05:52:56 +0000 (+0300) Subject: Increase code coverage for the FiltersPlugin. X-Git-Tag: V9_5_0a1~167^2~24 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=318e99074321945f6845c9c65ec1c89ebdee3a5d;p=modules%2Fshaper.git Increase code coverage for the FiltersPlugin. --- diff --git a/src/Config/ConfigAPI.i b/src/Config/ConfigAPI.i index 5efdefab5..92372e3c3 100644 --- a/src/Config/ConfigAPI.i +++ b/src/Config/ConfigAPI.i @@ -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 >; diff --git a/src/Config/Config_ValidatorReader.h b/src/Config/Config_ValidatorReader.h index dac03e090..e38626234 100644 --- a/src/Config/Config_ValidatorReader.h +++ b/src/Config/Config_ValidatorReader.h @@ -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. diff --git a/src/Config/Config_swig.h b/src/Config/Config_swig.h index b39d5add8..6e435181f 100644 --- a/src/Config/Config_swig.h +++ b/src/Config/Config_swig.h @@ -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_ */ diff --git a/src/FiltersPlugin/CMakeLists.txt b/src/FiltersPlugin/CMakeLists.txt index 2c856188d..1f01c4e44 100644 --- a/src/FiltersPlugin/CMakeLists.txt +++ b/src/FiltersPlugin/CMakeLists.txt @@ -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 index 000000000..66f9d3391 --- /dev/null +++ b/src/FiltersPlugin/Test/TestFilters_Validator.py @@ -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()