From 158b3949f0d12e3a4b36c6f37b270e0f7f037262 Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 14 Oct 2015 11:44:15 +0300 Subject: [PATCH] #650: land cover addition test uses now the images comparison --- src/HYDRO_tests/TestViewer.cxx | 39 +++++++++++++++--- src/HYDRO_tests/TestViewer.h | 2 +- .../LandCoverMap_Add_2_Objects.png | Bin 0 -> 7985 bytes .../test_HYDROData_LandCoverMap.cxx | 1 + src/HYDRO_tests/test_HYDROData_Main.cxx | 2 +- 5 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 src/HYDRO_tests/reference_data/LandCoverMap_Add_2_Objects.png diff --git a/src/HYDRO_tests/TestViewer.cxx b/src/HYDRO_tests/TestViewer.cxx index e0a532c4..96eaec90 100644 --- a/src/HYDRO_tests/TestViewer.cxx +++ b/src/HYDRO_tests/TestViewer.cxx @@ -7,6 +7,7 @@ #include #include #include +#include OCCViewer_ViewManager* TestViewer::myViewManager = 0; OCCViewer_ViewWindow* TestViewer::myViewWindow = 0; @@ -82,11 +83,39 @@ void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll viewWindow()->onFitAll(); } -void TestViewer::dump( const TopoDS_Shape& theShape, int theMode, const QString& theName ) +bool AreImagesEqual( const QImage& theImage1, const QImage& theImage2, double theTolerance = 0.0 ) { - show( theShape, theMode, true ); - QImage anImage = viewWindow()->dumpView(); + if( theImage1.isNull() || theImage2.isNull() ) + return theImage1.isNull() == theImage2.isNull(); - QString aPath = QDir::tempPath() + "/" + theName + ".png"; - anImage.save( aPath ); + if( theImage1.size() != theImage2.size() ) + return false; + + int aBytesCount = theImage1.byteCount(); + const uchar *aBytes1 = theImage1.constBits(); + const uchar *aBytes2 = theImage2.constBits(); + for( int i=0; idumpView(); + + QString anExpectedRefFilePath = qgetenv( "HYDRO_REFERENCE_DATA" ); + anExpectedRefFilePath += "/" + theUseCaseName + ".png"; + QImage anExpectedRefImage; + anExpectedRefImage.load( anExpectedRefFilePath ); + + if( AreImagesEqual( anActualImage, anExpectedRefImage ) ) + return true; + + QString aPath = QDir::tempPath() + "/" + theUseCaseName + ".png"; + anActualImage.save( aPath ); + std::string aMessage = "The viewer contents does not correspond to the reference image: " + theUseCaseName.toStdString(); + CPPUNIT_FAIL( aMessage.c_str() ); + return false; } diff --git a/src/HYDRO_tests/TestViewer.h b/src/HYDRO_tests/TestViewer.h index 8b843ad1..e825208b 100644 --- a/src/HYDRO_tests/TestViewer.h +++ b/src/HYDRO_tests/TestViewer.h @@ -17,7 +17,7 @@ public: static void show( const TopoDS_Shape& theShape, const QColor& theColor, int theMode ); static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll = true ); - static void dump( const TopoDS_Shape& theShape, int theMode, const QString& theName ); + static bool AssertEqual( const QString& theUseCaseName ); private: static OCCViewer_ViewManager* myViewManager; diff --git a/src/HYDRO_tests/reference_data/LandCoverMap_Add_2_Objects.png b/src/HYDRO_tests/reference_data/LandCoverMap_Add_2_Objects.png new file mode 100644 index 0000000000000000000000000000000000000000..86bdba3513aeb125bb2f3aa9920b3df1abd2f9c9 GIT binary patch literal 7985 zcmbVRi#t?X*k60kX7*5K&k!n^J>y;~97?6Jjd34wN=2v3B$aMbq>G`AQ6prEkZyBI zDyIvT?gRLAd|6vKDpa>jZGCW2BpIPyNQ3(K;sP%uyt}!Mf0kD1; zB=(8eu=mr8)r!SSQ);wJ?f0A*KSE(ye=dB&E)mDQ-oz|;!IP4SPJca}Ib&j0>_qOo zn{_Hdl~Nh(Ts3T7dT^G~SuJK5Kb=SP`YEep7a94sMt$_YJZGhyp_P-!?A532JL;#q z`@5ef?;kwC#&!<>xXYxp(G8lPrB2d{bk~cJe zJ((~DG`$qC635pk`WAqind1~x(b}=cxB}37Ho#01C!Y4C)(C12}I>FZY7m4Co6A2j)N2NK8%tF z(Xx*YVsLby@o-H}^Q%R9IHFoIE}Amk^q-K&S}j`s_oDxVva-#?t6KgOG9MR7RjF@O ziE-c&Ux}963YS1-1xFH7GCt^dBf`wWWH}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y*{<)uJ`kP``#PY$shM8cU^p2Y3beFUZ2hL-uSuW$k(6!HoU%@-2**ay?@*Xff%4qPQZy!AO{QtipLg-aAUYkwQ-D0?+A^X)w^UfrREue3LKgPQ)9Z`A?O zgUR3U3^{W zE!_O`M{Ai5iane!$>Lrp>;#*XtI)Nre|PowGh4MUd53ko*;9Kp|0E?PRj+%yZ+-RK zN5^KckLY&S#HY*Wv)C$!MhEhmXCJjeDDNphb@hEo{->gAKVF~tmE&7~%sao;<>D3c zVBFhmK3kKe2+{oh%s*U!Th?fM5!o*C?UuuVIOb5O^{@sIP znkhyn+K!td_ttVn>~I@>&AD7bK(70xRk59H^YJk zX{k@myOj8DGt8}o1O3lOtxoyy$Kb~-hy9-4VJNMV~k@7>?&N#moxq zcTsR1Lps4BP!*Ccx0Ew$qNf#r@uqe|>^#Aigm$dhM;Wht2_g@eI@N%KrQ_2XQrWcQ zULocalPartition( aLC2, "test2" ) ); TestViewer::show( aMap->GetShape(), AIS_Shaded, true ); + TestViewer::AssertEqual( "LandCoverMap_Add_2_Objects" ); aDoc->Close(); } diff --git a/src/HYDRO_tests/test_HYDROData_Main.cxx b/src/HYDRO_tests/test_HYDROData_Main.cxx index 157fee69..5b1367cb 100644 --- a/src/HYDRO_tests/test_HYDROData_Main.cxx +++ b/src/HYDRO_tests/test_HYDROData_Main.cxx @@ -78,6 +78,6 @@ int main( int argc, char* argv[] ) return 0; } - anApp.exec(); + //anApp.exec(); return result.wasSuccessful() ? 0 : 1; } -- 2.39.2