From d6bdc53ee505b318758627bc99df3efda81fec86 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 5 Dec 2019 09:25:44 +0100 Subject: [PATCH] #5185 Regression Test : Always set regression image size on snapshot commands --- .../Application/Tools/RiaRegressionTestRunner.cpp | 9 +++++---- .../Application/Tools/RiaRegressionTestRunner.h | 5 +++-- .../CommandFileInterface/RicfExportSnapshots.cpp | 15 +++++++++++++++ .../CommandFileInterface/RicfOpenProject.cpp | 6 ------ .../UserInterface/RiuMainWindowTools.cpp | 8 ++++++++ 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp index 53cf4e2621..01f37727eb 100644 --- a/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp +++ b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp @@ -201,13 +201,14 @@ void RiaRegressionTestRunner::runRegressionTest() // Wait until all command objects have completed app->waitUntilCommandObjectsHasBeenProcessed(); - setDefaultFixedWindowSizeFor3dViews(); + setDefaultSnapshotSizeFor3dViews(); QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath( generatedFolderName ); RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( fullPathGeneratedFolder ); QApplication::processEvents(); - resizePlotWindows(); + setDefaultSnapshotSizeForPlotWindows(); + RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( fullPathGeneratedFolder ); app->closeProject(); @@ -467,7 +468,7 @@ void RiaRegressionTestRunner::removeDirectoryWithContent( QDir& dirToDelete ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaRegressionTestRunner::setDefaultFixedWindowSizeFor3dViews() +void RiaRegressionTestRunner::setDefaultSnapshotSizeFor3dViews() { RiuMainWindow* mainWnd = RiuMainWindow::instance(); if ( !mainWnd ) return; @@ -480,7 +481,7 @@ void RiaRegressionTestRunner::setDefaultFixedWindowSizeFor3dViews() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaRegressionTestRunner::resizePlotWindows() +void RiaRegressionTestRunner::setDefaultSnapshotSizeForPlotWindows() { RiuPlotMainWindow* plotMainWindow = RiaGuiApplication::instance()->mainPlotWindow(); if ( !plotMainWindow ) return; diff --git a/ApplicationCode/Application/Tools/RiaRegressionTestRunner.h b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.h index 0e7e0af445..0ee6005a8b 100644 --- a/ApplicationCode/Application/Tools/RiaRegressionTestRunner.h +++ b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.h @@ -42,7 +42,9 @@ public: bool useOpenMPForGeometryCreation() const; static void updateRegressionTest( const QString& testRootPath ); - static void setDefaultFixedWindowSizeFor3dViews(); + + static void setDefaultSnapshotSizeFor3dViews(); + static void setDefaultSnapshotSizeForPlotWindows(); private: RiaRegressionTestRunner(); @@ -60,7 +62,6 @@ private: const QDir& testDir ); static void removeDirectoryWithContent( QDir& dirToDelete ); - static void resizePlotWindows(); static QSize regressionDefaultImageSize(); static QString diff2htmlHeaderText( const QString& testRootPath ); QFileInfoList subDirectoriesForTestExecution( const QDir& directory ); diff --git a/ApplicationCode/CommandFileInterface/RicfExportSnapshots.cpp b/ApplicationCode/CommandFileInterface/RicfExportSnapshots.cpp index b827e379b6..323e5cc574 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSnapshots.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportSnapshots.cpp @@ -25,6 +25,7 @@ #include "RiaGuiApplication.h" #include "RiaLogging.h" +#include "RiaRegressionTestRunner.h" #include "RiuMainWindow.h" @@ -87,6 +88,13 @@ RicfCommandResponse RicfExportSnapshots::execute() } if ( m_type == RicfExportSnapshots::VIEWS || m_type == RicfExportSnapshots::ALL ) { + if ( RiaRegressionTestRunner::instance()->isRunningRegressionTests() ) + { + RiaRegressionTestRunner::setDefaultSnapshotSizeFor3dViews(); + + QApplication::processEvents(); + } + RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( absolutePathToSnapshotDir, m_prefix, m_caseId(), @@ -94,6 +102,13 @@ RicfCommandResponse RicfExportSnapshots::execute() } if ( m_type == RicfExportSnapshots::PLOTS || m_type == RicfExportSnapshots::ALL ) { + if ( RiaRegressionTestRunner::instance()->isRunningRegressionTests() ) + { + RiaRegressionTestRunner::setDefaultSnapshotSizeForPlotWindows(); + + QApplication::processEvents(); + } + RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( absolutePathToSnapshotDir, m_prefix, m_viewId() ); diff --git a/ApplicationCode/CommandFileInterface/RicfOpenProject.cpp b/ApplicationCode/CommandFileInterface/RicfOpenProject.cpp index d93d653031..c333e86343 100644 --- a/ApplicationCode/CommandFileInterface/RicfOpenProject.cpp +++ b/ApplicationCode/CommandFileInterface/RicfOpenProject.cpp @@ -22,7 +22,6 @@ #include "RiaApplication.h" #include "RiaLogging.h" -#include "RiaRegressionTestRunner.h" #include #include @@ -57,11 +56,6 @@ RicfCommandResponse RicfOpenProject::execute() return RicfCommandResponse( RicfCommandResponse::COMMAND_ERROR, errMsg ); } - if ( RiaRegressionTestRunner::instance()->isRunningRegressionTests() ) - { - RiaRegressionTestRunner::setDefaultFixedWindowSizeFor3dViews(); - } - RicfCommandFileExecutor::instance()->setLastProjectPath( projectPath ); return RicfCommandResponse(); diff --git a/ApplicationCode/UserInterface/RiuMainWindowTools.cpp b/ApplicationCode/UserInterface/RiuMainWindowTools.cpp index 07267b546d..1c049f9959 100644 --- a/ApplicationCode/UserInterface/RiuMainWindowTools.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindowTools.cpp @@ -108,7 +108,15 @@ void RiuMainWindowTools::setWindowSizeOnWidgetsInMdiWindows( RiuMainWindowBase* if ( !w ) continue; w->showNormal(); + } + // Process events before resize to make sure the widget is ready for resize + // If not, a maximized window with not get the prescribed window size + QApplication::processEvents(); + + for ( auto w : widgets ) + { + if ( !w ) continue; auto viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget( w->widget() ); if ( viewWindow && viewWindow->viewWidget() )