From 01dec77eee8ce8da12c660feac632bebfc16f3e1 Mon Sep 17 00:00:00 2001 From: asl Date: Tue, 14 Nov 2017 16:51:55 +0300 Subject: [PATCH] refs #1341: adaptation of automatic tests for Linux --- src/HYDRO_tests/TestViewer.cxx | 14 +++++++--- src/HYDRO_tests/test_HYDROData_Main.cxx | 5 ++++ src/HYDRO_tests/test_HYDROData_ShapeFile.cxx | 28 ++++++++++---------- src/HYDRO_tests/test_HYDROData_Tool.cxx | 3 ++- src/HYDRO_tests/test_Overview.cxx | 1 + 5 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/HYDRO_tests/TestViewer.cxx b/src/HYDRO_tests/TestViewer.cxx index 5c143368..3f971a47 100644 --- a/src/HYDRO_tests/TestViewer.cxx +++ b/src/HYDRO_tests/TestViewer.cxx @@ -59,6 +59,8 @@ OCCViewer_ViewManager* TestViewer::myViewManager = 0; OCCViewer_ViewFrame* TestViewer::myViewWindow = 0; QString TestViewer::myKey = ""; +extern QString REF_DATA_PATH; + OCCViewer_ViewManager* TestViewer::viewManager() { if( myViewManager ) @@ -293,10 +295,11 @@ bool TestViewer::AssertImages( QString& theMessage, const QImage* theImage, cons if( theCase ) myKey = theCase; - QString anExpectedRefFilePath = qgetenv( "HYDRO_ROOT_DIR" ) + "/bin/salome/test/HYDRO"; + QString anExpectedRefFilePath = REF_DATA_PATH; anExpectedRefFilePath += "/" + myKey + ".png"; QImage anExpectedRefImage; anExpectedRefImage.load( anExpectedRefFilePath ); + std::cout << "Expected image loading: " << anExpectedRefFilePath.toStdString() << std::endl; if( AreImagesEqual( anActualImage, anExpectedRefImage, 0.001 ) ) { @@ -306,6 +309,8 @@ bool TestViewer::AssertImages( QString& theMessage, const QImage* theImage, cons QString aPath = QDir::tempPath() + "/" + myKey + ".png"; anActualImage.save( aPath ); + std::cout << "Actual image: " << aPath.toStdString() << std::endl; + //std::cout << anActualImage.width() << "x" << anActualImage.height() << std::endl; theMessage = "The viewer contents does not correspond to the reference image: " + myKey; @@ -317,8 +322,11 @@ bool TestViewer::AssertImages( QString& theMessage, const QImage* theImage, cons QString aDiffFilePath = QDir::tempPath() + "/" + myKey + "_diff.png"; aDiff.save( aDiffFilePath ); + std::cout << "Diff image: " << aDiffFilePath.toStdString() << std::endl; - anExpectedRefImage.save( QDir::tempPath() + "/" + myKey + "_1.png"); + QString anExpected = QDir::tempPath() + "/" + myKey + "_1.png"; + std::cout << "Expected image: " << anExpected.toStdString() << std::endl; + anExpectedRefImage.save( anExpected ); return false; } @@ -397,7 +405,7 @@ bool TestViewer::areScriptsEqual( const QString& theBaseName, int theLinesToOmit, QString& theMsg ) { - QString anExpectedRefFilePath = qgetenv( "HYDRO_ROOT_DIR" ) + "/bin/salome/test/HYDRO"; + QString anExpectedRefFilePath = REF_DATA_PATH; anExpectedRefFilePath += "/" + theBaseName; QString anActualFilePath = QDir::tempPath() + "/" + theBaseName; diff --git a/src/HYDRO_tests/test_HYDROData_Main.cxx b/src/HYDRO_tests/test_HYDROData_Main.cxx index 3b4d053f..b9fbf305 100644 --- a/src/HYDRO_tests/test_HYDROData_Main.cxx +++ b/src/HYDRO_tests/test_HYDROData_Main.cxx @@ -33,7 +33,12 @@ #define _DEVDEBUG_ #include "HYDRO_trace.hxx" +#ifdef WIN32 QString REF_DATA_PATH = qgetenv( "HYDRO_ROOT_DIR" ) + "/bin/salome/test/HYDRO"; +#else +QString REF_DATA_PATH = qgetenv( "HYDRO_ROOT_DIR" ) + "/bin/salome/test/HYDRO/HYDRO"; +#endif + int main( int argc, char* argv[] ) { diff --git a/src/HYDRO_tests/test_HYDROData_ShapeFile.cxx b/src/HYDRO_tests/test_HYDROData_ShapeFile.cxx index b4007cea..de1a1289 100644 --- a/src/HYDRO_tests/test_HYDROData_ShapeFile.cxx +++ b/src/HYDRO_tests/test_HYDROData_ShapeFile.cxx @@ -21,7 +21,7 @@ #include #include -const QString REF_PATH = qgetenv( "HYDRO_ROOT_DIR" ) + "/bin/salome/test/HYDRO"; +extern QString REF_DATA_PATH; bool test_HYDROData_ShapeFile::compare_two_files(const QString& File1, const QString& File2) { @@ -48,7 +48,7 @@ bool test_HYDROData_ShapeFile::compare_two_files(const QString& File1, const QSt void test_HYDROData_ShapeFile::test_openDbf() { - QString aDBFPath = REF_PATH + "/cyprus_natural.dbf"; + QString aDBFPath = REF_DATA_PATH + "/cyprus_natural.dbf"; HYDROData_ShapeFile aSHPFile; bool Stat = aSHPFile.DBF_OpenDBF(aDBFPath); CPPUNIT_ASSERT_EQUAL( true, Stat ); @@ -57,7 +57,7 @@ void test_HYDROData_ShapeFile::test_openDbf() void test_HYDROData_ShapeFile::test_NbFieldsDbf() { - QString aDBFPath = REF_PATH + "/cyprus_natural.dbf"; + QString aDBFPath = REF_DATA_PATH + "/cyprus_natural.dbf"; HYDROData_ShapeFile aSHPFile; CPPUNIT_ASSERT_EQUAL(true, aSHPFile.DBF_OpenDBF(aDBFPath)); int NbF = aSHPFile.DBF_GetNbFields(); @@ -67,7 +67,7 @@ void test_HYDROData_ShapeFile::test_NbFieldsDbf() void test_HYDROData_ShapeFile::test_FieldListDbf() { - QString aDBFPath = REF_PATH + "/cyprus_natural.dbf"; + QString aDBFPath = REF_DATA_PATH + "/cyprus_natural.dbf"; HYDROData_ShapeFile aSHPFile; CPPUNIT_ASSERT_EQUAL(true, aSHPFile.DBF_OpenDBF(aDBFPath)); @@ -79,7 +79,7 @@ void test_HYDROData_ShapeFile::test_FieldListDbf() void test_HYDROData_ShapeFile::test_FieldTypeListDbf() { - QString aDBFPath = REF_PATH + "/cyprus_natural.dbf"; + QString aDBFPath = REF_DATA_PATH + "/cyprus_natural.dbf"; HYDROData_ShapeFile aSHPFile; CPPUNIT_ASSERT_EQUAL(true, aSHPFile.DBF_OpenDBF(aDBFPath)); @@ -92,7 +92,7 @@ void test_HYDROData_ShapeFile::test_FieldTypeListDbf() void test_HYDROData_ShapeFile::test_NbRecordsDbf() { - QString aDBFPath = REF_PATH + "/cyprus_natural.dbf"; + QString aDBFPath = REF_DATA_PATH + "/cyprus_natural.dbf"; HYDROData_ShapeFile aSHPFile; CPPUNIT_ASSERT_EQUAL(true, aSHPFile.DBF_OpenDBF(aDBFPath)); int NbR = aSHPFile.DBF_GetNbRecords(); @@ -103,7 +103,7 @@ void test_HYDROData_ShapeFile::test_NbRecordsDbf() void test_HYDROData_ShapeFile::test_GetAttrListIndex() { { //cyprus_natural - QString aDBFPath = REF_PATH + "/cyprus_natural.dbf"; + QString aDBFPath = REF_DATA_PATH + "/cyprus_natural.dbf"; HYDROData_ShapeFile aSHPFile; CPPUNIT_ASSERT_EQUAL(true, aSHPFile.DBF_OpenDBF(aDBFPath)); std::vector theAttrV; @@ -134,7 +134,7 @@ void test_HYDROData_ShapeFile::test_GetAttrListIndex() aSHPFile.DBF_CloseDBF(); } { //CLC06 - QString aDBFPath = REF_PATH + "/CLC06.dbf"; + QString aDBFPath = REF_DATA_PATH + "/CLC06.dbf"; HYDROData_ShapeFile aSHPFile; CPPUNIT_ASSERT_EQUAL (true, aSHPFile.DBF_OpenDBF(aDBFPath)); std::vector theAttrV; @@ -163,8 +163,8 @@ void test_HYDROData_ShapeFile::test_DbfWrite() { { HYDROData_ShapeFile aSHPFile; - QString tempFN = REF_PATH + "/temp_dbf1.dbf"; - QString refFN = REF_PATH + "/ref_dbf1.dbf"; + QString tempFN = REF_DATA_PATH + "/temp_dbf1.dbf"; + QString refFN = REF_DATA_PATH + "/ref_dbf1.dbf"; std::vector theAttrV; HYDROData_ShapeFile::DBF_AttrValue theAttr1; theAttr1.myFieldType = HYDROData_ShapeFile::DBF_FieldType_String; @@ -187,8 +187,8 @@ void test_HYDROData_ShapeFile::test_DbfWrite() { HYDROData_ShapeFile aSHPFile; - QString tempFN = REF_PATH + "/temp_dbf2.dbf"; - QString refFN = REF_PATH + "/ref_dbf2.dbf"; + QString tempFN = REF_DATA_PATH + "/temp_dbf2.dbf"; + QString refFN = REF_DATA_PATH + "/ref_dbf2.dbf"; std::vector theAttrV; HYDROData_ShapeFile::DBF_AttrValue theAttr1; theAttr1.myFieldType = HYDROData_ShapeFile::DBF_FieldType_String; @@ -219,8 +219,8 @@ void test_HYDROData_ShapeFile::test_DbfWrite() { HYDROData_ShapeFile aSHPFile; - QString tempFN = REF_PATH + "/temp_dbf3.dbf"; - QString refFN = REF_PATH + "/ref_dbf3.dbf"; + QString tempFN = REF_DATA_PATH + "/temp_dbf3.dbf"; + QString refFN = REF_DATA_PATH + "/ref_dbf3.dbf"; std::vector theAttrV; HYDROData_ShapeFile::DBF_AttrValue theAttr1; theAttr1.myFieldType = HYDROData_ShapeFile::DBF_FieldType_Integer; diff --git a/src/HYDRO_tests/test_HYDROData_Tool.cxx b/src/HYDRO_tests/test_HYDROData_Tool.cxx index 9c410980..0d259ccd 100644 --- a/src/HYDRO_tests/test_HYDROData_Tool.cxx +++ b/src/HYDRO_tests/test_HYDROData_Tool.cxx @@ -34,10 +34,11 @@ #include #include +extern QString REF_DATA_PATH; void test_HYDROData_Tool::test_rebuild_cmp() { - QString RefPath = qgetenv( "HYDRO_ROOT_DIR" ) + "/bin/salome/test/HYDRO"; + QString RefPath = REF_DATA_PATH; BRep_Builder bb; { TopoDS_Shape in, out; diff --git a/src/HYDRO_tests/test_Overview.cxx b/src/HYDRO_tests/test_Overview.cxx index d01de7cf..6da12ce1 100644 --- a/src/HYDRO_tests/test_Overview.cxx +++ b/src/HYDRO_tests/test_Overview.cxx @@ -112,6 +112,7 @@ void test_Overview::showShape() BRep_Builder B; TopoDS_Shape shape; std::string fname = (REF_DATA_PATH + "/test_zone.brep").toStdString(); + std::cout << "Loading shape: " << fname << std::endl; BRepTools::Read( shape, fname.c_str(), B ); TestViewer::show( shape, AIS_Shaded, true, 0x03399FF ); -- 2.39.2