From da501590824399b7daa0ecd6a3acd87aaeee1993 Mon Sep 17 00:00:00 2001 From: asl Date: Mon, 20 Nov 2017 11:30:55 +0300 Subject: [PATCH] debug of automatic tests --- src/HYDRO_tests/TestViewer.cxx | 20 +++++-------------- src/HYDRO_tests/test_HYDROData_Bathymetry.cxx | 5 +++-- .../test_HYDROData_LandCoverMap.cxx | 7 ++++--- src/HYDRO_tests/test_HYDROData_Main.cxx | 5 +++++ src/HYDRO_tests/test_HYDROData_Profile.cxx | 7 ++++--- .../test_HYDROData_StricklerTable.cxx | 9 +++------ 6 files changed, 24 insertions(+), 29 deletions(-) diff --git a/src/HYDRO_tests/TestViewer.cxx b/src/HYDRO_tests/TestViewer.cxx index 51b61ce9..7210c108 100644 --- a/src/HYDRO_tests/TestViewer.cxx +++ b/src/HYDRO_tests/TestViewer.cxx @@ -61,6 +61,7 @@ OCCViewer_ViewFrame* TestViewer::myViewWindow = 0; QString TestViewer::myKey = ""; extern QString REF_DATA_PATH; +extern QString TMP_DIR; OCCViewer_ViewManager* TestViewer::viewManager() { @@ -326,14 +327,7 @@ bool TestViewer::AssertImages( QString& theMessage, const QImage* theImage, cons return true; } - QString temp = QDir::tempPath(); -#ifndef WIN32 - temp += "/hydro"; - if( !QDir().exists( temp ) ) - QDir().mkpath( temp ); -#endif - - QString aPath = temp + "/" + myKey + ".png"; + QString aPath = TMP_DIR + "/" + myKey + ".png"; anActualImage.save( aPath ); //std::cout << "Actual image: " << aPath.toStdString() << std::endl; @@ -342,11 +336,11 @@ bool TestViewer::AssertImages( QString& theMessage, const QImage* theImage, cons QImage aDiff = diff( anExpectedRefImage, anActualImage ); - QString aDiffFilePath = temp + "/" + myKey + "_diff.png"; + QString aDiffFilePath = TMP_DIR + "/" + myKey + "_diff.png"; aDiff.save( aDiffFilePath ); //std::cout << "Diff image: " << aDiffFilePath.toStdString() << std::endl; - QString anExpected = temp + "/" + myKey + "_1.png"; + QString anExpected = TMP_DIR + "/" + myKey + "_1.png"; //std::cout << "Expected image: " << anExpected.toStdString() << std::endl; anExpectedRefImage.save( anExpected ); @@ -430,11 +424,7 @@ bool TestViewer::areScriptsEqual( const QString& theBaseName, QString anExpectedRefFilePath = REF_DATA_PATH; anExpectedRefFilePath += "/" + theBaseName; -#ifdef WIN32 - QString anActualFilePath = QDir::tempPath() + "/" + theBaseName; -#else - QString anActualFilePath = QDir::tempPath() + "/hydro/" + theBaseName; -#endif + QString anActualFilePath = TMP_DIR + "/" + theBaseName; QFile anExpected( anExpectedRefFilePath ); QFile anActual( anActualFilePath ); diff --git a/src/HYDRO_tests/test_HYDROData_Bathymetry.cxx b/src/HYDRO_tests/test_HYDROData_Bathymetry.cxx index 1c0fc6ed..5de3256b 100644 --- a/src/HYDRO_tests/test_HYDROData_Bathymetry.cxx +++ b/src/HYDRO_tests/test_HYDROData_Bathymetry.cxx @@ -32,6 +32,7 @@ #include const double EPS = 1E-4; +extern QString TMP_DIR; void generateOne( QTextStream& theStream, double theFirstX, double theFirstY, @@ -121,7 +122,7 @@ void test_HYDROData_Bathymetry::testFileImport() Handle(HYDROData_Bathymetry) aBathymetry = Handle(HYDROData_Bathymetry)::DownCast( aDoc->CreateObject( KIND_BATHYMETRY ) ); - QString aFileName = QDir::tempPath() + QDir::separator() + "test.xyz"; + QString aFileName = TMP_DIR + QDir::separator() + "test.xyz"; if ( !createTestFile( aFileName ) ) return; // No file has been created @@ -165,7 +166,7 @@ void test_HYDROData_Bathymetry::testCopy() Handle(HYDROData_Bathymetry) aBathymetry1 = Handle(HYDROData_Bathymetry)::DownCast( aDoc->CreateObject( KIND_BATHYMETRY ) ); - QString aFileName = QDir::tempPath() + QDir::separator() + "test.xyz"; + QString aFileName = TMP_DIR + QDir::separator() + "test.xyz"; bool anIsFileCreated = createTestFile( aFileName ); diff --git a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx index a958adb0..2355a21a 100644 --- a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx @@ -50,6 +50,7 @@ extern QString REF_DATA_PATH; const QString DEF_STR_PATH = qgetenv( "HYDRO_ROOT_DIR" ) + "/share/salome/resources/hydro/def_strickler_table_06.txt"; +extern QString TMP_DIR; void test_HYDROData_LandCoverMap::test_add_2_objects() { @@ -672,7 +673,7 @@ void test_HYDROData_LandCoverMap::test_dump_python() QString aBaseName = "lc_dump.py"; QString aBaseShp = "lc_dump.shp"; QString aBaseDbf = "lc_dump.dbf"; - QString aTmpPath = QDir::tempPath() + "/" + aBaseName; + QString aTmpPath = TMP_DIR + "/" + aBaseName; CPPUNIT_ASSERT_EQUAL( true, aDoc->DumpToPython( aTmpPath, false ) ); //TODO: CPPUNIT_ASSERT_SCRIPTS_EQUAL( aBaseName, true, false, 20 ); @@ -1109,9 +1110,9 @@ void test_HYDROData_LandCoverMap::test_export_telemac() QString aTmpFileName = "test.telemac"; #ifdef WIN32 - QString aTmpPath = QDir::tempPath() + "/" + aTmpFileName; + QString aTmpPath = TMP_DIR + "/" + aTmpFileName; #else - QString aTmpPath = QDir::tempPath() + "/hydro/" + aTmpFileName; + QString aTmpPath = TMP_DIR + "/hydro/" + aTmpFileName; #endif QString messStat; CPPUNIT_ASSERT_EQUAL( true, aMap->ExportTelemac( aTmpPath, 1E-4, aTable, messStat ) ); diff --git a/src/HYDRO_tests/test_HYDROData_Main.cxx b/src/HYDRO_tests/test_HYDROData_Main.cxx index 3c41a032..9e5bab52 100644 --- a/src/HYDRO_tests/test_HYDROData_Main.cxx +++ b/src/HYDRO_tests/test_HYDROData_Main.cxx @@ -35,10 +35,13 @@ #ifdef WIN32 QString REF_DATA_PATH = qgetenv( "HYDRO_ROOT_DIR" ) + "/bin/salome/test/HYDRO"; +QString TMP_DIR = QDir::tempPath(); #else QString REF_DATA_PATH = qgetenv( "HYDRO_ROOT_DIR" ) + "/bin/salome/test/HYDRO/HYDRO"; +QString TMP_DIR = QDir::tempPath() + "/hydro"; #endif + int MAIN_W = 800, MAIN_H = 600; int main( int argc, char* argv[] ) @@ -47,6 +50,8 @@ int main( int argc, char* argv[] ) SUIT_Session aSession; aSession.startApplication("std"); + QDir().mkdir( TMP_DIR ); + OCCViewer_ViewFrame* aWindow = TestViewer::viewWindow(); aWindow->setGeometry( 400, 100, MAIN_W, MAIN_H ); diff --git a/src/HYDRO_tests/test_HYDROData_Profile.cxx b/src/HYDRO_tests/test_HYDROData_Profile.cxx index ee40097f..d649b6dc 100644 --- a/src/HYDRO_tests/test_HYDROData_Profile.cxx +++ b/src/HYDRO_tests/test_HYDROData_Profile.cxx @@ -35,6 +35,7 @@ const double EPS = 1E-2; extern QString REF_DATA_PATH; +extern QString TMP_DIR; bool test_HYDROData_Profile::createTestFile( const QString& theFileName, const bool theIsParametric ) @@ -81,8 +82,8 @@ void test_HYDROData_Profile::testFileImport() { Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 ); - QString aParamFileName = QDir::tempPath() + QDir::separator() + "parametric.pa"; - QString aGeorefFileName = QDir::tempPath() + QDir::separator() + "georef.pa"; + QString aParamFileName = TMP_DIR + QDir::separator() + "parametric.pa"; + QString aGeorefFileName = TMP_DIR + QDir::separator() + "georef.pa"; if ( !createTestFile( aParamFileName, true ) || !createTestFile( aGeorefFileName, false ) ) return; // No file has been created @@ -143,7 +144,7 @@ void test_HYDROData_Profile::testCopy() Handle(HYDROData_Profile) aProfile1 = Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); - QString aFileName = QDir::tempPath() + QDir::separator() + "georef.pa"; + QString aFileName = TMP_DIR + QDir::separator() + "georef.pa"; bool anIsFileCreated = createTestFile( aFileName, false ); diff --git a/src/HYDRO_tests/test_HYDROData_StricklerTable.cxx b/src/HYDRO_tests/test_HYDROData_StricklerTable.cxx index 46f04314..bfc54037 100644 --- a/src/HYDRO_tests/test_HYDROData_StricklerTable.cxx +++ b/src/HYDRO_tests/test_HYDROData_StricklerTable.cxx @@ -29,6 +29,7 @@ #include const QString DEF_STR_PATH = qgetenv( "HYDRO_ROOT_DIR" ) + "/share/salome/resources/hydro/def_strickler_table_06.txt"; +extern QString TMP_DIR; void test_HYDROData_StricklerTable::test_import() { @@ -64,7 +65,7 @@ void test_HYDROData_StricklerTable::test_import_export_equivalence() Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) ); CPPUNIT_ASSERT_EQUAL( true, aTable->Import( DEF_STR_PATH ) ); - QString aTmpPath = QDir::tempPath() + "/stricker.txt"; + QString aTmpPath = TMP_DIR + "/stricker.txt"; CPPUNIT_ASSERT_EQUAL( true, aTable->Export( aTmpPath ) ); QFile aRefFile( DEF_STR_PATH ), aTmpFile( aTmpPath ); @@ -210,11 +211,7 @@ void test_HYDROData_StricklerTable::test_dump_python() aTable->SetName( "ST" ); CPPUNIT_ASSERT_EQUAL( true, aTable->Import( DEF_STR_PATH ) ); -#ifdef WIN32 - QString aTmpPath = QDir::tempPath() + "/st_dump.py"; -#else - QString aTmpPath = QDir::tempPath() + "/hydro/st_dump.py"; -#endif + QString aTmpPath = TMP_DIR + "/st_dump.py"; CPPUNIT_ASSERT_EQUAL( true, aDoc->DumpToPython( aTmpPath, false ) ); -- 2.39.2