From 5ee99b059fc03388b419fc8020f58212fcd9a47c Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 28 Sep 2017 09:20:00 +0300 Subject: [PATCH] refs #1332: first automatic test on profiles dialog size --- src/HYDROGUI/HYDROGUI_ProfileDlg.cxx | 4 ++ src/HYDROGUI/HYDROGUI_ViewerDlg.cxx | 4 +- src/HYDRO_tests/CMakeLists.txt | 3 +- src/HYDRO_tests/ExternalFiles.cmake | 5 ++ src/HYDRO_tests/TestViewer.cxx | 5 +- src/HYDRO_tests/TestViewer.h | 2 +- src/HYDRO_tests/reference_data/CMakeLists.txt | 1 + .../profiles_dlg_presentation.png | Bin 0 -> 7109 bytes src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.cxx | 52 ++++++++++++++++++ src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.h | 32 +++++++++++ 10 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 src/HYDRO_tests/reference_data/profiles_dlg_presentation.png create mode 100644 src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.cxx create mode 100644 src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.h diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx index 5b724bbd..81cb8239 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx @@ -90,14 +90,18 @@ HYDROGUI_ProfileDlg::HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QStr sizes.append( 25 ); splitter()->setSizes( sizes ); +#ifndef TEST_MODE QSettings settings; splitter()->restoreState( settings.value( splitter_key ).toByteArray() ); +#endif } HYDROGUI_ProfileDlg::~HYDROGUI_ProfileDlg() { +#ifndef TEST_MODE QSettings settings; settings.setValue( splitter_key, splitter()->saveState() ); +#endif } void HYDROGUI_ProfileDlg::reset() diff --git a/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx b/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx index 4465443d..f82ae06e 100644 --- a/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx @@ -47,7 +47,9 @@ HYDROGUI_ViewerDlg::HYDROGUI_ViewerDlg( HYDROGUI_Module* theModule, const QStrin : HYDROGUI_InputPanel( theModule, theTitle, true, isSplitter ) { SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - myViewManager = new OCCViewer_ViewManager( theModule->getApp()->activeStudy(), 0 ); + SUIT_Study* aStudy = theModule ? theModule->getApp()->activeStudy() : 0; + + myViewManager = new OCCViewer_ViewManager( aStudy, 0 ); OCCViewer_Viewer* aViewer = new OCCViewer_Viewer( true ); aViewer->setBackground( OCCViewer_ViewFrame::TOP_LEFT, diff --git a/src/HYDRO_tests/CMakeLists.txt b/src/HYDRO_tests/CMakeLists.txt index b6ec22e2..dcd654ff 100644 --- a/src/HYDRO_tests/CMakeLists.txt +++ b/src/HYDRO_tests/CMakeLists.txt @@ -56,6 +56,7 @@ set(PROJECT_SOURCES test_Dependencies.cxx test_HYDROData_Tool.cxx test_GraphicsView.cxx + test_HYDROGUI_ProfilesDlg.cxx TestShape.cxx TestViewer.cxx @@ -63,7 +64,7 @@ set(PROJECT_SOURCES TestLib_Runner.cxx ) -add_definitions( -DLIGHT_MODE -DHYDRODATA_STATIC -DHYDROGUI_STATIC ) +add_definitions( -DLIGHT_MODE -DHYDRODATA_STATIC -DHYDROGUI_STATIC -DTEST_MODE) IF( ${WIN32} ) add_definitions( -DWNT -D__WIN32__ -D__x86__ -D_WIN64 -D_WIN32_WINNT=0x0400 -D__NT__ -D__OSVERSION__=4 ) diff --git a/src/HYDRO_tests/ExternalFiles.cmake b/src/HYDRO_tests/ExternalFiles.cmake index b093912a..5a5af45f 100644 --- a/src/HYDRO_tests/ExternalFiles.cmake +++ b/src/HYDRO_tests/ExternalFiles.cmake @@ -77,6 +77,9 @@ set( EXTERNAL_FILES ../HYDROGUI/HYDROGUI_StreamDlg.cxx ../HYDROGUI/HYDROGUI_ListSelector.cxx ../HYDROGUI/HYDROGUI_OrderedListWidget.cxx + ../HYDROGUI/HYDROGUI_ProfileDlg.cxx + ../HYDROGUI/HYDROGUI_ViewerDlg.cxx + ../HYDROGUI/HYDROGUI_AISTrihedron.cxx ) set( MOC_HEADERS @@ -85,6 +88,8 @@ set( MOC_HEADERS ../HYDROGUI/HYDROGUI_StreamDlg.h ../HYDROGUI/HYDROGUI_ListSelector.h ../HYDROGUI/HYDROGUI_OrderedListWidget.h + ../HYDROGUI/HYDROGUI_ProfileDlg.h + ../HYDROGUI/HYDROGUI_ViewerDlg.h ) QT_WRAP_MOC( PROJECT_MOC_HEADERS ${MOC_HEADERS} ) diff --git a/src/HYDRO_tests/TestViewer.cxx b/src/HYDRO_tests/TestViewer.cxx index 34763265..f7876baa 100644 --- a/src/HYDRO_tests/TestViewer.cxx +++ b/src/HYDRO_tests/TestViewer.cxx @@ -266,7 +266,7 @@ bool AreImagesEqual( const QImage& theImage1, const QImage& theImage2, double th return true; } -bool TestViewer::AssertImages( QString& theMessage, const QImage* theImage, const char* theCase ) +bool TestViewer::AssertImages( QString& theMessage, const QImage* theImage, const char* theCase, bool swapRGB ) { QImage anActualImage; if( theImage ) @@ -274,8 +274,7 @@ bool TestViewer::AssertImages( QString& theMessage, const QImage* theImage, cons else anActualImage = viewWindow()->dumpView(); - const bool SWAP_RGB_ORDER = true; - if( SWAP_RGB_ORDER ) + if( swapRGB ) { // A temporary patch for bug in SALOME/OCC dump; the result image contains swapped RGB colors anActualImage = anActualImage.rgbSwapped(); diff --git a/src/HYDRO_tests/TestViewer.h b/src/HYDRO_tests/TestViewer.h index 90aac840..7bfe1a84 100644 --- a/src/HYDRO_tests/TestViewer.h +++ b/src/HYDRO_tests/TestViewer.h @@ -45,7 +45,7 @@ public: int theUIANb = 10, int theVIANb = 10); static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const char* theKey, int theUIANb = 10, int theVIANb = 10); - static bool AssertImages( QString& theMessage, const QImage* = 0, const char* theCase = 0 ); + static bool AssertImages( QString& theMessage, const QImage* = 0, const char* theCase = 0, bool swapRGB = true ); static QColor GetColor(int i); static Handle(AIS_ColorScale) colorScale(); diff --git a/src/HYDRO_tests/reference_data/CMakeLists.txt b/src/HYDRO_tests/reference_data/CMakeLists.txt index dd4f5c16..41dd3c0e 100644 --- a/src/HYDRO_tests/reference_data/CMakeLists.txt +++ b/src/HYDRO_tests/reference_data/CMakeLists.txt @@ -124,6 +124,7 @@ SET(REFERENCE_DATA gv_fitall.png gv_zoomed_1.png gv_zoomed_2.png + profiles_dlg_presentation.png ) # Application tests diff --git a/src/HYDRO_tests/reference_data/profiles_dlg_presentation.png b/src/HYDRO_tests/reference_data/profiles_dlg_presentation.png new file mode 100644 index 0000000000000000000000000000000000000000..f5483cf69db4dfb2b947cad455abc7c1f3f7c811 GIT binary patch literal 7109 zcmeHMc~nzrmdCP`D%tF|L`4NHOA!fB#Uh(YRH{TlKtYXRON(p*A;=m?AX*4?6(y9) zB3mM*VJDFQ30s1QfGj4+z9wv8iv&VK0tqDZw0pXHrhDeh{53u2^gHLBm)!5W_rCl4 z?sxC+z4y}H6vim6Q%fUHbmqHFWOMI4&qRDsMu75^lFs>D#!vJEsnLs51X|=ab;)iMQ($@D4-r ziVmIpCBv^u^$(k!tS!4iw??@kcP#AipgL3UTa~4_d|uLbYEUirr0HoD_`(DKQyW!v zbkWEO#~Syd;7dkN&Qc66fhBDgPXwFz_PGi$evn6~OC@YT8aEqEguj4UX0`5y+a9zEJU8%9Mk zV4oYm?+vq2)VaY#4YUE(!S(ulP_AqZ#n~W5HK6*{g!Hd}{RtN{{h=0tsJYt`QSG}D za8jT0`s;y}Hn%?+{j~ zbY($_Yr@iM2*>Mlo|?V>u)O!eDC8=3{*4%q&#x$Mwbvs&FD&%)Z%bL-v1Yn|N0BVo zXPVjWZkXB06&D&L>?yMF2^HSIpA{Ar5ad7cY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bOpG)|Sv!uKqlhk9Y2?Pw35!Q~ZePAM}?6<^0-+=Fko0i5iVU?FkM-B6PO9c;Fd+e5$+;;2@b2B%gJaLGus~p zI3>2xo&_OwwY5)fKFCC#=dw>)^I`ScCfSRxgOCjK@Tu<96S}&}&~@~!j#v59h|T!4 zo!Z*C*<_lgUk5BFl-t-cS>gb?8VgTI8e454Ez*;&qkQ+w4iB82<2 zFQ-BwaO@8j!Xlegb+EiixiKUxeH(P+6=Ft5Cq~pAes{oDBc0r=tFxZGIjsoh2p+#* z&EeNeS7HtRD25xRh+p5^Jr@sX@-Hzd)W%onHV(&<-z2+4wy9Kk<#7d7P zN-5c~G~a*DvQzYv4b<+rHPjL;1T8!v$j2Jln0ZBzogTN)9&gDNUN6{`W+U5k(3{EQp9CDMg_%Guh*oeFjm4*^7`W{d0FcTIY6!=!OcNls26EJ zim^pvP0DT{V@Z*P8Hcl9E11$Ro%CYEMWZ>shX?iz5NoZTsa1<<%v7*=DCMxVW3I)c zVJYbMGqa_TNjP*>hw(nB%R#;CXQcES>hqF|&R9;d|0U;Qh zU0Ei917()ctKOydi`sNL-H(|IXJDiImkk-Q{uuj+QSm^JEBr>e>)Kct3pq?7Ha0dA zl_P<-t1O6QEDT`YCDOlbVD&%dIL9m&7cz4#dl%bYg{N~nGs!nAraBSw(DDPC!$5cO wsY7B)18PA^YPI@b{QHNg|50a`D7M|xpGF-b@K%BEa!QweaQvQh{trL?8-qnchX4Qo literal 0 HcmV?d00001 diff --git a/src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.cxx b/src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.cxx new file mode 100644 index 00000000..fb2cc843 --- /dev/null +++ b/src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.cxx @@ -0,0 +1,52 @@ +// 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 +// + +#undef HYDROGUI_EXPORTS + +#include +#include +#include +#include +#include + +#define CPPUNIT_ASSERT_WIDGET( theWidget, theCase ) \ + { \ + QPixmap aPixmap = QPixmap::grabWindow( theWidget->winId() ); \ + QImage anImage = aPixmap.toImage(); \ + QString aMessage; \ + if( !TestViewer::AssertImages( aMessage, &anImage, theCase, false ) ) \ + { \ + TestViewer::showColorScale( false ); \ + std::string aMessageStl = aMessage.toStdString(); \ + CPPUNIT_FAIL( aMessageStl.c_str() ); \ + } \ + } \ + + +void test_HYDROGUI_ProfilesDlg::test_default_size() +{ + HYDROGUI_ProfileDlg* dlg = new HYDROGUI_ProfileDlg( 0, "test" ); + dlg->resize( 320, 640 ); + dlg->show(); + QTest::qWaitForWindowExposed( dlg ); + + CPPUNIT_ASSERT_WIDGET( dlg, "profiles_dlg_presentation" ); + + dlg->deleteLater(); + qApp->processEvents(); +} diff --git a/src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.h b/src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.h new file mode 100644 index 00000000..0c40ecfe --- /dev/null +++ b/src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.h @@ -0,0 +1,32 @@ +// 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 + +class test_HYDROGUI_ProfilesDlg : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(test_HYDROGUI_ProfilesDlg); + CPPUNIT_TEST(test_default_size); + CPPUNIT_TEST_SUITE_END(); + +public: + void test_default_size(); +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROGUI_ProfilesDlg); +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(test_HYDROGUI_ProfilesDlg, "HYDROGUI_ProfilesDlg"); -- 2.39.2