]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #1332: first automatic test on profiles dialog size BR_1332
authorasl <asl@opencascade.com>
Thu, 28 Sep 2017 06:20:00 +0000 (09:20 +0300)
committerasl <asl@opencascade.com>
Thu, 28 Sep 2017 06:20:00 +0000 (09:20 +0300)
src/HYDROGUI/HYDROGUI_ProfileDlg.cxx
src/HYDROGUI/HYDROGUI_ViewerDlg.cxx
src/HYDRO_tests/CMakeLists.txt
src/HYDRO_tests/ExternalFiles.cmake
src/HYDRO_tests/TestViewer.cxx
src/HYDRO_tests/TestViewer.h
src/HYDRO_tests/reference_data/CMakeLists.txt
src/HYDRO_tests/reference_data/profiles_dlg_presentation.png [new file with mode: 0644]
src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.cxx [new file with mode: 0644]
src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.h [new file with mode: 0644]

index 5b724bbd67771da977d87f7a79f3a66606ba22c9..81cb8239a789499bef51160ccd7a48a1ea4c7fa0 100644 (file)
@@ -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()
index 4465443d7e021a3eccc50add81e3ec92ac94b575..f82ae06ef5f00b4471e6992379e494a218bdc9f5 100644 (file)
@@ -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,
index b6ec22e247d5f0a0a524dd5e668520eb5c071adc..dcd654ff359ee1f5c7857e11efaeb3adb32d4288 100644 (file)
@@ -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 )
index b093912a32801617eaeab5369f1d54c79160ac56..5a5af45f68ade8a9e58b521c3417616c8a0b740f 100644 (file)
@@ -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} )
index 34763265665cdaee38bf4541853555016aa561cb..f7876baab344234da7344dfd2c97f0f43b4c6e57 100644 (file)
@@ -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();
index 90aac8407416c022026ab94f02608623e11edf2b..7bfe1a84864cb282c099328e3c2c0d09b0a8cdbf 100644 (file)
@@ -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();
index dd4f5c16697c3cf195d89fdd38cb882e67c275f0..41dd3c0e6ef2fdbc24632d96991385d2b47ee2be 100644 (file)
@@ -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 (file)
index 0000000..f5483cf
Binary files /dev/null and b/src/HYDRO_tests/reference_data/profiles_dlg_presentation.png differ
diff --git a/src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.cxx b/src/HYDRO_tests/test_HYDROGUI_ProfilesDlg.cxx
new file mode 100644 (file)
index 0000000..fb2cc84
--- /dev/null
@@ -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 <test_HYDROGUI_ProfilesDlg.h>
+#include <HYDROGUI_ProfileDlg.h>
+#include <TestViewer.h>
+#include <QApplication>
+#include <QTest>
+
+#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 (file)
index 0000000..0c40ecf
--- /dev/null
@@ -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 <cppunit/extensions/HelperMacros.h>
+
+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");