]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
dependencies tests
authorasl <asl@opencascade.com>
Thu, 15 Oct 2015 15:15:00 +0000 (18:15 +0300)
committerasl <asl@opencascade.com>
Thu, 15 Oct 2015 15:15:00 +0000 (18:15 +0300)
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDRO_tests/CMakeLists.txt
src/HYDRO_tests/test_Dependencies.cxx [new file with mode: 0644]
src/HYDRO_tests/test_Dependencies.h [new file with mode: 0644]

index 89adcee4354315a6732900602a0d09cfc77898d6..6d0facdebc964cb098a194c8bbd8066c98a08049 100644 (file)
@@ -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 );
index 08731d0fa169e5ce7e19f774e2a0597eb5858be9..8916171a50ea7a892ec1e935be4b59ac7648c54c 100644 (file)
@@ -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 (file)
index 0000000..7bbc96b
--- /dev/null
@@ -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 <test_Dependencies.h>
+#include <HYDROData_Bathymetry.h>
+#include <HYDROData_CalculationCase.h>
+#include <HYDROData_Channel.h>
+#include <HYDROData_Document.h>
+#include <HYDROData_ImmersibleZone.h>
+#include <HYDROData_Polyline3D.h>
+#include <HYDROData_PolylineXY.h>
+
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+
+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 (file)
index 0000000..1784031
--- /dev/null
@@ -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 <cppunit/extensions/HelperMacros.h>
+
+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