From: asl Date: Thu, 15 Oct 2015 15:15:00 +0000 (+0300) Subject: dependencies tests X-Git-Tag: v1.5~109^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=58595cbf334d2c46a942fc41b19c861c4c3b81f1;p=modules%2Fhydro.git dependencies tests --- diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 89adcee4..6d0facde 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -261,6 +261,9 @@ HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetAllReferenceObjects() if ( !aBoundaryPolyline.IsNull() ) aResSeq.Append( aBoundaryPolyline ); + HYDROData_SequenceOfObjects aSeqOfGeomObjs = GetGeometryObjects(); + aResSeq.Append( aSeqOfGeomObjs ); + // Regions HYDROData_SequenceOfObjects aSeqOfRegions = GetRegions( false ); aResSeq.Append( aSeqOfRegions ); diff --git a/src/HYDRO_tests/CMakeLists.txt b/src/HYDRO_tests/CMakeLists.txt index 08731d0f..8916171a 100644 --- a/src/HYDRO_tests/CMakeLists.txt +++ b/src/HYDRO_tests/CMakeLists.txt @@ -13,6 +13,7 @@ set(PROJECT_HEADERS test_HYDROData_Profile.h test_HYDROData_StricklerTable.h test_HYDROGUI_ListModel.h + test_Dependencies.h TestViewer.h TestLib_Listener.h @@ -32,6 +33,7 @@ set(PROJECT_SOURCES test_HYDROData_Profile.cxx test_HYDROData_StricklerTable.cxx test_HYDROGUI_ListModel.cxx + test_Dependencies.cxx TestViewer.cxx TestLib_Listener.cxx @@ -48,7 +50,7 @@ ENDIF() SET( BOOST_INCLUDES $ENV{BOOST_ROOT_DIR}/include/boost-1_52 ) SET( CPPUNIT_INCLUDES $ENV{CPPUNIT_ROOT_DIR}/include ) -SET( CAS_INCLUDES $ENV{CASROOT_DIR}/inc ) +SET( CAS_INCLUDES $ENV{CAS_ROOT_DIR}/inc ) SET( QT_INCLUDES $ENV{QT4_ROOT_DIR}/include $ENV{QT4_ROOT_DIR}/include/QtCore $ENV{QT4_ROOT_DIR}/include/QtGui ) SET( GUI_INCLUDES $ENV{GUI_ROOT_DIR}/include/salome ) diff --git a/src/HYDRO_tests/test_Dependencies.cxx b/src/HYDRO_tests/test_Dependencies.cxx new file mode 100644 index 00000000..7bbc96bb --- /dev/null +++ b/src/HYDRO_tests/test_Dependencies.cxx @@ -0,0 +1,117 @@ +// Copyright (C) 2014-2015 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 +// + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +void test_Dependencies::test_dependencies_broad_cast() +{ + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + + Handle(HYDROData_Bathymetry) aBath = + Handle(HYDROData_Bathymetry)::DownCast( aDoc->CreateObject( KIND_BATHYMETRY ) ); + + Handle(HYDROData_PolylineXY) aPoly = + Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); + + Handle(HYDROData_Polyline3D) aPoly3d = + Handle(HYDROData_Polyline3D)::DownCast( aDoc->CreateObject( KIND_POLYLINE ) ); + + Handle(HYDROData_ImmersibleZone) aZone = + Handle(HYDROData_ImmersibleZone)::DownCast( aDoc->CreateObject( KIND_IMMERSIBLE_ZONE ) ); + + Handle(HYDROData_Channel) aChannel = + Handle(HYDROData_Channel)::DownCast( aDoc->CreateObject( KIND_CHANNEL ) ); + + Handle(HYDROData_CalculationCase) aCase = + Handle(HYDROData_CalculationCase)::DownCast( aDoc->CreateObject( KIND_CALCULATION ) ); + + aZone->SetPolyline( aPoly ); + aZone->SetAltitudeObject( aBath ); + aZone->Update(); + + aPoly3d->SetPolylineXY( aPoly ); + aPoly3d->SetAltitudeObject( aBath ); + aPoly3d->Update(); + + TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( gp_Pnt(), gp_Pnt( 1, 0, 0 ) ).Edge(); + TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( anEdge ).Wire(); + aPoly3d->SetTopShape( aWire ); + aPoly3d->SetShape3D( aWire ); + CPPUNIT_ASSERT_EQUAL( true, aChannel->SetGuideLine( aPoly3d ) ); + aChannel->Update(); + + aCase->AddGeometryObject( aZone ); + aCase->AddGeometryObject( aChannel ); + aCase->ClearChanged(); + + // 1. Change only Z values of the bathymetry + aBath->SetAltitudesInverted( true ); + + CPPUNIT_ASSERT_EQUAL( false, aZone->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ); + CPPUNIT_ASSERT_EQUAL( false, aPoly3d->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ); + CPPUNIT_ASSERT_EQUAL( true, aPoly3d->IsMustBeUpdated( HYDROData_Entity::Geom_Z ) ); + CPPUNIT_ASSERT_EQUAL( true, aPoly3d->IsMustBeUpdated( HYDROData_Entity::Geom_3d ) ); + CPPUNIT_ASSERT_EQUAL( false, aChannel->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ); + CPPUNIT_ASSERT_EQUAL( true, aChannel->IsMustBeUpdated( HYDROData_Entity::Geom_Z ) ); + CPPUNIT_ASSERT_EQUAL( true, aChannel->IsMustBeUpdated( HYDROData_Entity::Geom_3d ) ); + CPPUNIT_ASSERT_EQUAL( false, aCase->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ); + + aPoly3d->ClearChanged(); + aChannel->ClearChanged(); + + // 2. "Change" the polyline 2d + aPoly->Changed( HYDROData_Entity::Geom_2d ); + + CPPUNIT_ASSERT_EQUAL( true, aZone->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ); + CPPUNIT_ASSERT_EQUAL( true, aPoly3d->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ); + CPPUNIT_ASSERT_EQUAL( false, aPoly3d->IsMustBeUpdated( HYDROData_Entity::Geom_Z ) ); + CPPUNIT_ASSERT_EQUAL( true, aPoly3d->IsMustBeUpdated( HYDROData_Entity::Geom_3d ) ); + CPPUNIT_ASSERT_EQUAL( true, aChannel->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ); + CPPUNIT_ASSERT_EQUAL( false, aChannel->IsMustBeUpdated( HYDROData_Entity::Geom_Z ) ); + CPPUNIT_ASSERT_EQUAL( true, aChannel->IsMustBeUpdated( HYDROData_Entity::Geom_3d ) ); + CPPUNIT_ASSERT_EQUAL( true, aCase->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ); + + aDoc->Close(); +} + +void test_Dependencies::test_calc_case_ref_objects() +{ + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1); + + Handle(HYDROData_ImmersibleZone) aZone = + Handle(HYDROData_ImmersibleZone)::DownCast( aDoc->CreateObject( KIND_IMMERSIBLE_ZONE ) ); + + Handle(HYDROData_CalculationCase) aCase = + Handle(HYDROData_CalculationCase)::DownCast( aDoc->CreateObject( KIND_CALCULATION ) ); + + aCase->AddGeometryObject( aZone ); + CPPUNIT_ASSERT_EQUAL( 1, aCase->GetAllReferenceObjects().Size() ); + CPPUNIT_ASSERT_EQUAL( aZone->Label(), aCase->GetAllReferenceObjects().First()->Label() ); + + aDoc->Close(); +} diff --git a/src/HYDRO_tests/test_Dependencies.h b/src/HYDRO_tests/test_Dependencies.h new file mode 100644 index 00000000..17840312 --- /dev/null +++ b/src/HYDRO_tests/test_Dependencies.h @@ -0,0 +1,42 @@ +// Copyright (C) 2014-2015 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 +// + +#ifdef WIN32 + #pragma warning( disable: 4251 ) +#endif + +#include + +class test_Dependencies : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE( test_Dependencies ); + CPPUNIT_TEST( test_dependencies_broad_cast ); + CPPUNIT_TEST( test_calc_case_ref_objects ); + CPPUNIT_TEST_SUITE_END(); + +public: + void test_dependencies_broad_cast(); + void test_calc_case_ref_objects(); +}; + +CPPUNIT_TEST_SUITE_REGISTRATION( test_Dependencies ); +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( test_Dependencies, "Dependencies" ); + +#ifdef WIN32 + #pragma warning( default: 4251 ) +#endif