X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDRO_tests%2Ftest_HYDROGUI_ProfilesDlg.cxx;h=6f3e9b2e974c1afb7fafa0194f495cbb28d6f93c;hb=eac08495379067b7417f2856e174b4f1ae80e538;hp=fb2cc8435364d9d05284b0fc121121d80ddb0db8;hpb=5ee99b059fc03388b419fc8020f58212fcd9a47c;p=modules%2Fhydro.git diff --git a/src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.cxx b/src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.cxx index fb2cc843..6f3e9b2e 100644 --- a/src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.cxx +++ b/src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.cxx @@ -19,9 +19,25 @@ #undef HYDROGUI_EXPORTS #include + +#define private public #include +#include +#undef private + +#include +#include +#include +#include + +#include +#include + + #include #include +#include +#include #include #define CPPUNIT_ASSERT_WIDGET( theWidget, theCase ) \ @@ -40,7 +56,8 @@ void test_HYDROGUI_ProfilesDlg::test_default_size() { - HYDROGUI_ProfileDlg* dlg = new HYDROGUI_ProfileDlg( 0, "test" ); + return; + HYDROGUI_ProfileDlg* dlg = new HYDROGUI_ProfileDlg( 0, "test", true ); dlg->resize( 320, 640 ); dlg->show(); QTest::qWaitForWindowExposed( dlg ); @@ -50,3 +67,114 @@ void test_HYDROGUI_ProfilesDlg::test_default_size() dlg->deleteLater(); qApp->processEvents(); } + +HYDROGUI_CurveCreatorProfile* profile() +{ + static HYDROGUI_CurveCreatorProfile* aProfile = 0; + if( aProfile ) + return aProfile; + + aProfile = new HYDROGUI_CurveCreatorProfile(); + CurveCreator::Coordinates coords; + coords.push_back( 0 ); + coords.push_back( 20 ); + coords.push_back( 30 ); + coords.push_back( 0 ); + coords.push_back( 60 ); + coords.push_back( 0 ); + coords.push_back( 90 ); + coords.push_back( 20 ); + aProfile->addPoints( coords, 0 ); + return aProfile; +} + +void show_profile( HYDROGUI_ProfileDlg* dlg ) +{ + Handle(AIS_InteractiveContext) aCtx = dlg->getAISContext(); + CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx ); + profile()->setDisplayer( aDisplayer ); + aDisplayer->display( profile()->getAISObject( true ), true ); +} + +void select_points( HYDROGUI_ProfileDlg* dlg ) +{ + CurveCreator_ICurve::SectionToPointList sel; + sel.push_back( CurveCreator_ICurve::SectionToPoint( 0, 0 ) ); + sel.push_back( CurveCreator_ICurve::SectionToPoint( 0, 1 ) ); + sel.push_back( CurveCreator_ICurve::SectionToPoint( 0, 2 ) ); + sel.push_back( CurveCreator_ICurve::SectionToPoint( 0, 3 ) ); + dlg->myEditorWidget->getAction( CurveCreator_Widget::ModificationMode )->toggle(); + dlg->myEditorWidget->onModificationMode( true ); + dlg->myEditorWidget->setSelectedPoints( sel ); + dlg->myEditorWidget->updateLocalPointView(); +} + +std::string coords( HYDROGUI_ProfileDlg* dlg, int col=2 ) +{ + int n = dlg->myEditorWidget->myLocalPointView->rowCount(); + QStringList datas; + for( int r=0; rmyEditorWidget->myLocalPointView->item(r, col)->data( Qt::DisplayRole ).toString(); + datas.append( data ); + } + return datas.join( ", " ).toStdString(); +} + +void setCoords( HYDROGUI_ProfileDlg* dlg, int theIndex, double theValue ) +{ + QAbstractItemModel* m = dlg->myEditorWidget->myLocalPointView->model(); + QModelIndex index = m->index( theIndex, 2 ); + + m->setData( index, theValue, Qt::UserRole ); + dlg->myEditorWidget->updateLocalPointView(); +} + +void test_HYDROGUI_ProfilesDlg::test_points_table() +{ + return; + HYDROGUI_ProfileDlg* dlg = new HYDROGUI_ProfileDlg( 0, "test", false ); + dlg->resize( 320, 800 ); + dlg->setProfile( profile() ); + dlg->show(); + QTest::qWaitForWindowExposed( dlg ); + + show_profile( dlg ); + select_points( dlg ); + + QList sizes; + sizes.append( 25 ); + sizes.append( 100 ); + sizes.append( 200 ); + sizes.append( 25 ); + sizes.append( 25 ); + dlg->splitter()->setSizes( sizes ); + qApp->processEvents(); + + CPPUNIT_ASSERT_WIDGET( dlg, "profiles_selected_points" ); + CPPUNIT_ASSERT_EQUAL( std::string( "0, 30, 60, 90" ), coords( dlg ) ); + CPPUNIT_ASSERT_EQUAL( std::string( "20, 0, 0, 20" ), coords( dlg, 3 ) ); + + setCoords( dlg, 0, 130 ); + CPPUNIT_ASSERT_EQUAL( std::string( "130, 30, 60, 90" ), coords( dlg ) ); + CPPUNIT_ASSERT_EQUAL( std::string( "20, 0, 0, 20" ), coords( dlg, 3 ) ); + + setCoords( dlg, 0, 0 ); + CPPUNIT_ASSERT_EQUAL( std::string( "0, 30, 60, 90" ), coords( dlg ) ); + CPPUNIT_ASSERT_EQUAL( std::string( "20, 0, 0, 20" ), coords( dlg, 3 ) ); + + setCoords( dlg, 0, 80 ); + dlg->myEditorWidget->myLocalPointView->OnHeaderClick( 2 ); + CPPUNIT_ASSERT_EQUAL( std::string( "30, 60, 80, 90" ), coords( dlg ) ); + CPPUNIT_ASSERT_EQUAL( std::string( "0, 0, 20, 20" ), coords( dlg, 3 ) ); + + setCoords( dlg, 2, 0 ); + CPPUNIT_ASSERT_EQUAL( std::string( "30, 60, 0, 90" ), coords( dlg ) ); + CPPUNIT_ASSERT_EQUAL( std::string( "0, 0, 20, 20" ), coords( dlg, 3 ) ); + + //qApp->processEvents(); + //QTest::qWait( 50000 ); + + dlg->deleteLater(); + qApp->processEvents(); +}