#5185 Regression Test : Always set regression image size on snapshot commands

This commit is contained in:
Magne Sjaastad 2019-12-05 09:25:44 +01:00
parent ad648eadc1
commit d6bdc53ee5
5 changed files with 31 additions and 12 deletions

View File

@ -201,13 +201,14 @@ void RiaRegressionTestRunner::runRegressionTest()
// Wait until all command objects have completed // Wait until all command objects have completed
app->waitUntilCommandObjectsHasBeenProcessed(); app->waitUntilCommandObjectsHasBeenProcessed();
setDefaultFixedWindowSizeFor3dViews(); setDefaultSnapshotSizeFor3dViews();
QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath( generatedFolderName ); QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath( generatedFolderName );
RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( fullPathGeneratedFolder ); RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( fullPathGeneratedFolder );
QApplication::processEvents(); QApplication::processEvents();
resizePlotWindows(); setDefaultSnapshotSizeForPlotWindows();
RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( fullPathGeneratedFolder ); RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( fullPathGeneratedFolder );
app->closeProject(); app->closeProject();
@ -467,7 +468,7 @@ void RiaRegressionTestRunner::removeDirectoryWithContent( QDir& dirToDelete )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiaRegressionTestRunner::setDefaultFixedWindowSizeFor3dViews() void RiaRegressionTestRunner::setDefaultSnapshotSizeFor3dViews()
{ {
RiuMainWindow* mainWnd = RiuMainWindow::instance(); RiuMainWindow* mainWnd = RiuMainWindow::instance();
if ( !mainWnd ) return; if ( !mainWnd ) return;
@ -480,7 +481,7 @@ void RiaRegressionTestRunner::setDefaultFixedWindowSizeFor3dViews()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiaRegressionTestRunner::resizePlotWindows() void RiaRegressionTestRunner::setDefaultSnapshotSizeForPlotWindows()
{ {
RiuPlotMainWindow* plotMainWindow = RiaGuiApplication::instance()->mainPlotWindow(); RiuPlotMainWindow* plotMainWindow = RiaGuiApplication::instance()->mainPlotWindow();
if ( !plotMainWindow ) return; if ( !plotMainWindow ) return;

View File

@ -42,7 +42,9 @@ public:
bool useOpenMPForGeometryCreation() const; bool useOpenMPForGeometryCreation() const;
static void updateRegressionTest( const QString& testRootPath ); static void updateRegressionTest( const QString& testRootPath );
static void setDefaultFixedWindowSizeFor3dViews();
static void setDefaultSnapshotSizeFor3dViews();
static void setDefaultSnapshotSizeForPlotWindows();
private: private:
RiaRegressionTestRunner(); RiaRegressionTestRunner();
@ -60,7 +62,6 @@ private:
const QDir& testDir ); const QDir& testDir );
static void removeDirectoryWithContent( QDir& dirToDelete ); static void removeDirectoryWithContent( QDir& dirToDelete );
static void resizePlotWindows();
static QSize regressionDefaultImageSize(); static QSize regressionDefaultImageSize();
static QString diff2htmlHeaderText( const QString& testRootPath ); static QString diff2htmlHeaderText( const QString& testRootPath );
QFileInfoList subDirectoriesForTestExecution( const QDir& directory ); QFileInfoList subDirectoriesForTestExecution( const QDir& directory );

View File

@ -25,6 +25,7 @@
#include "RiaGuiApplication.h" #include "RiaGuiApplication.h"
#include "RiaLogging.h" #include "RiaLogging.h"
#include "RiaRegressionTestRunner.h"
#include "RiuMainWindow.h" #include "RiuMainWindow.h"
@ -87,6 +88,13 @@ RicfCommandResponse RicfExportSnapshots::execute()
} }
if ( m_type == RicfExportSnapshots::VIEWS || m_type == RicfExportSnapshots::ALL ) if ( m_type == RicfExportSnapshots::VIEWS || m_type == RicfExportSnapshots::ALL )
{ {
if ( RiaRegressionTestRunner::instance()->isRunningRegressionTests() )
{
RiaRegressionTestRunner::setDefaultSnapshotSizeFor3dViews();
QApplication::processEvents();
}
RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( absolutePathToSnapshotDir, RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( absolutePathToSnapshotDir,
m_prefix, m_prefix,
m_caseId(), m_caseId(),
@ -94,6 +102,13 @@ RicfCommandResponse RicfExportSnapshots::execute()
} }
if ( m_type == RicfExportSnapshots::PLOTS || m_type == RicfExportSnapshots::ALL ) if ( m_type == RicfExportSnapshots::PLOTS || m_type == RicfExportSnapshots::ALL )
{ {
if ( RiaRegressionTestRunner::instance()->isRunningRegressionTests() )
{
RiaRegressionTestRunner::setDefaultSnapshotSizeForPlotWindows();
QApplication::processEvents();
}
RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( absolutePathToSnapshotDir, RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( absolutePathToSnapshotDir,
m_prefix, m_prefix,
m_viewId() ); m_viewId() );

View File

@ -22,7 +22,6 @@
#include "RiaApplication.h" #include "RiaApplication.h"
#include "RiaLogging.h" #include "RiaLogging.h"
#include "RiaRegressionTestRunner.h"
#include <QDir> #include <QDir>
#include <QFileInfo> #include <QFileInfo>
@ -57,11 +56,6 @@ RicfCommandResponse RicfOpenProject::execute()
return RicfCommandResponse( RicfCommandResponse::COMMAND_ERROR, errMsg ); return RicfCommandResponse( RicfCommandResponse::COMMAND_ERROR, errMsg );
} }
if ( RiaRegressionTestRunner::instance()->isRunningRegressionTests() )
{
RiaRegressionTestRunner::setDefaultFixedWindowSizeFor3dViews();
}
RicfCommandFileExecutor::instance()->setLastProjectPath( projectPath ); RicfCommandFileExecutor::instance()->setLastProjectPath( projectPath );
return RicfCommandResponse(); return RicfCommandResponse();

View File

@ -108,7 +108,15 @@ void RiuMainWindowTools::setWindowSizeOnWidgetsInMdiWindows( RiuMainWindowBase*
if ( !w ) continue; if ( !w ) continue;
w->showNormal(); 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() ); auto viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget( w->widget() );
if ( viewWindow && viewWindow->viewWidget() ) if ( viewWindow && viewWindow->viewWidget() )