mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added dialog for configuration and execution of regression test from
Debug->Regression Test Dialog Generalized read/write of pdm object fields using QSettings
This commit is contained in:
parent
227e3e6353
commit
b0761d0612
@ -123,7 +123,7 @@ RiaApplication::RiaApplication(int& argc, char** argv)
|
||||
//cvf::Trace::enable(false);
|
||||
|
||||
m_preferences = new RiaPreferences;
|
||||
readPreferences();
|
||||
readFieldsFromApplicationStore(m_preferences);
|
||||
applyPreferences();
|
||||
|
||||
if (useShaders())
|
||||
@ -287,7 +287,7 @@ bool RiaApplication::loadProject(const QString& projectFileName)
|
||||
// VL check regarding specific order mentioned in comment above...
|
||||
|
||||
m_preferences->lastUsedProjectFileName = projectFileName;
|
||||
writePreferences();
|
||||
writeFieldsToApplicationStore(m_preferences);
|
||||
|
||||
for (size_t oilFieldIdx = 0; oilFieldIdx < m_project->oilFields().size(); oilFieldIdx++)
|
||||
{
|
||||
@ -472,7 +472,7 @@ bool RiaApplication::saveProjectAs(const QString& fileName)
|
||||
m_project->writeFile();
|
||||
|
||||
m_preferences->lastUsedProjectFileName = fileName;
|
||||
writePreferences();
|
||||
writeFieldsToApplicationStore(m_preferences);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -695,7 +695,7 @@ void RiaApplication::setActiveReservoirView(RimReservoirView* rv)
|
||||
void RiaApplication::setUseShaders(bool enable)
|
||||
{
|
||||
m_preferences->useShaders = enable;
|
||||
writePreferences();
|
||||
writeFieldsToApplicationStore(m_preferences);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -727,7 +727,7 @@ RiaApplication::RINavigationPolicy RiaApplication::navigationPolicy() const
|
||||
void RiaApplication::setShowPerformanceInfo(bool enable)
|
||||
{
|
||||
m_preferences->showHud = enable;
|
||||
writePreferences();
|
||||
writeFieldsToApplicationStore(m_preferences);
|
||||
}
|
||||
|
||||
|
||||
@ -870,15 +870,7 @@ bool RiaApplication::parseArguments()
|
||||
|
||||
if (isRunRegressionTest)
|
||||
{
|
||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||
if (mainWnd)
|
||||
{
|
||||
mainWnd->hideAllDockWindows();
|
||||
|
||||
runRegressionTest(regressionTestPath);
|
||||
|
||||
mainWnd->loadWinGeoAndDockToolBarLayout();
|
||||
}
|
||||
executeRegressionTests(regressionTestPath);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1080,12 +1072,12 @@ bool RiaApplication::launchProcessForMultipleCases(const QString& program, const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Read fields of a Pdm object using QSettings
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::readPreferences()
|
||||
void RiaApplication::readFieldsFromApplicationStore(caf::PdmObject* object)
|
||||
{
|
||||
QSettings settings;
|
||||
std::vector<caf::PdmFieldHandle*> fields;
|
||||
|
||||
m_preferences->fields(fields);
|
||||
object->fields(fields);
|
||||
size_t i;
|
||||
for (i = 0; i < fields.size(); i++)
|
||||
{
|
||||
@ -1102,12 +1094,14 @@ void RiaApplication::readPreferences()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Write fields of a Pdm object using QSettings
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::writePreferences()
|
||||
void RiaApplication::writeFieldsToApplicationStore(const caf::PdmObject* object)
|
||||
{
|
||||
CVF_ASSERT(object);
|
||||
|
||||
QSettings settings;
|
||||
|
||||
std::vector<caf::PdmFieldHandle*> fields;
|
||||
m_preferences->fields(fields);
|
||||
object->fields(fields);
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < fields.size(); i++)
|
||||
@ -1769,3 +1763,20 @@ void RiaApplication::executeCommandObjects()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::executeRegressionTests(const QString& regressionTestPath)
|
||||
{
|
||||
RiuMainWindow* mainWnd = RiuMainWindow::instance();
|
||||
if (mainWnd)
|
||||
{
|
||||
mainWnd->hideAllDockWindows();
|
||||
|
||||
runRegressionTest(regressionTestPath);
|
||||
|
||||
mainWnd->loadWinGeoAndDockToolBarLayout();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -67,6 +67,8 @@ public:
|
||||
|
||||
bool parseArguments();
|
||||
|
||||
void executeRegressionTests(const QString& regressionTestPath);
|
||||
|
||||
void setActiveReservoirView(RimReservoirView*);
|
||||
RimReservoirView* activeReservoirView();
|
||||
const RimReservoirView* activeReservoirView() const;
|
||||
@ -124,8 +126,8 @@ public:
|
||||
void terminateProcess();
|
||||
|
||||
RiaPreferences* preferences();
|
||||
void readPreferences();
|
||||
void writePreferences();
|
||||
void readFieldsFromApplicationStore(caf::PdmObject* object);
|
||||
void writeFieldsToApplicationStore(const caf::PdmObject* object);
|
||||
void applyPreferences();
|
||||
|
||||
cvf::Font* standardFont();
|
||||
|
60
ApplicationCode/Application/RiaRegressionTest.cpp
Normal file
60
ApplicationCode/Application/RiaRegressionTest.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight 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 General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiaRegressionTest.h"
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RiaRegressionTest, "RiaRegressionTest");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaRegressionTest::RiaRegressionTest(void)
|
||||
{
|
||||
CAF_PDM_InitFieldNoDefault(&applicationWorkingFolder, "workingFolder", "Application Working Folder", "", "", "");
|
||||
applicationWorkingFolder.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(®ressionTestFolder, "regressionTestFolder", "Regression Test Folder", "", "", "");
|
||||
regressionTestFolder.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaRegressionTest::~RiaRegressionTest(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaRegressionTest::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
|
||||
{
|
||||
if (field == &applicationWorkingFolder || field == ®ressionTestFolder)
|
||||
{
|
||||
caf::PdmUiFilePathEditorAttribute* myAttr = static_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
|
||||
if (myAttr)
|
||||
{
|
||||
myAttr->m_selectDirectory = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
43
ApplicationCode/Application/RiaRegressionTest.h
Normal file
43
ApplicationCode/Application/RiaRegressionTest.h
Normal file
@ -0,0 +1,43 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight 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 General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
|
||||
class RiaRegressionTest : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RiaRegressionTest(void);
|
||||
virtual ~RiaRegressionTest(void);
|
||||
|
||||
public:
|
||||
caf::PdmField<QString> applicationWorkingFolder;
|
||||
caf::PdmField<QString> regressionTestFolder;
|
||||
|
||||
protected:
|
||||
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
|
||||
|
||||
|
||||
};
|
@ -36,6 +36,7 @@ set( APPLICATION_FILES
|
||||
Application/RiaPreferences.cpp
|
||||
Application/RiaImageFileCompare.cpp
|
||||
Application/RiaImageCompareReporter.cpp
|
||||
Application/RiaRegressionTest.cpp
|
||||
)
|
||||
|
||||
set( USER_INTERFACE_FILES
|
||||
@ -151,6 +152,7 @@ list( REMOVE_ITEM RAW_SOURCES
|
||||
|
||||
Application/RiaImageFileCompare.cpp
|
||||
Application/RiaImageCompareReporter.cpp
|
||||
Application/RiaRegressionTest.cpp
|
||||
|
||||
FileInterface/RifEclipseInputFileTools.cpp
|
||||
FileInterface/RifEclipseOutputFileTools.cpp
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "Rim3dOverlayInfoConfig.h"
|
||||
#include "RiuWellImportWizard.h"
|
||||
#include "RimCalcScript.h"
|
||||
#include "RiaRegressionTest.h"
|
||||
|
||||
|
||||
|
||||
@ -202,6 +203,7 @@ void RiuMainWindow::createActions()
|
||||
m_snapshotAllViewsToFile = new QAction(QIcon(":/SnapShotSaveViews.png"), "Snapshot All Views To File", this);
|
||||
|
||||
m_createCommandObject = new QAction("Create Command Object", this);
|
||||
m_showRegressionTestDialog = new QAction("Regression Test Dialog", this);
|
||||
|
||||
m_saveProjectAction = new QAction(QIcon(":/Save.png"), "&Save Project", this);
|
||||
m_saveProjectAsAction = new QAction(QIcon(":/Save.png"), "Save Project &As", this);
|
||||
@ -227,6 +229,7 @@ void RiuMainWindow::createActions()
|
||||
connect(m_snapshotAllViewsToFile, SIGNAL(triggered()), SLOT(slotSnapshotAllViewsToFile()));
|
||||
|
||||
connect(m_createCommandObject, SIGNAL(triggered()), SLOT(slotCreateCommandObject()));
|
||||
connect(m_showRegressionTestDialog, SIGNAL(triggered()), SLOT(slotShowRegressionTestDialog()));
|
||||
|
||||
connect(m_saveProjectAction, SIGNAL(triggered()), SLOT(slotSaveProject()));
|
||||
connect(m_saveProjectAsAction, SIGNAL(triggered()), SLOT(slotSaveProjectAs()));
|
||||
@ -364,7 +367,8 @@ void RiuMainWindow::createMenus()
|
||||
debugMenu->addAction(m_mockInputModelAction);
|
||||
debugMenu->addSeparator();
|
||||
debugMenu->addAction(m_createCommandObject);
|
||||
|
||||
debugMenu->addSeparator();
|
||||
debugMenu->addAction(m_showRegressionTestDialog);
|
||||
|
||||
connect(debugMenu, SIGNAL(aboutToShow()), SLOT(slotRefreshDebugActions()));
|
||||
|
||||
@ -1197,13 +1201,13 @@ void RiuMainWindow::slotEditPreferences()
|
||||
if (preferencesDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
// Write preferences using QSettings and apply them to the application
|
||||
app->writePreferences();
|
||||
app->writeFieldsToApplicationStore(app->preferences());
|
||||
app->applyPreferences();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read back currently stored values using QSettings
|
||||
app->readPreferences();
|
||||
app->readFieldsFromApplicationStore(app->preferences());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1700,3 +1704,28 @@ void RiuMainWindow::slotCreateCommandObject()
|
||||
app->project()->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindow::slotShowRegressionTestDialog()
|
||||
{
|
||||
RiaRegressionTest regTestConfig;
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
app->readFieldsFromApplicationStore(®TestConfig);
|
||||
|
||||
RiuPreferencesDialog regressionTestDialog(this, ®TestConfig, "Regression Test");
|
||||
if (regressionTestDialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
// Write preferences using QSettings and apply them to the application
|
||||
app->writeFieldsToApplicationStore(®TestConfig);
|
||||
|
||||
QString currentApplicationPath = QDir::currentPath();
|
||||
|
||||
QDir::setCurrent(regTestConfig.applicationWorkingFolder);
|
||||
app->executeRegressionTests(regTestConfig.regressionTestFolder);
|
||||
|
||||
QDir::setCurrent(currentApplicationPath);
|
||||
}
|
||||
}
|
||||
|
@ -155,6 +155,7 @@ private:
|
||||
QAction* m_snapshotAllViewsToFile;
|
||||
|
||||
QAction* m_createCommandObject;
|
||||
QAction* m_showRegressionTestDialog;
|
||||
|
||||
// Help actions
|
||||
QAction* m_aboutAction;
|
||||
@ -225,6 +226,8 @@ private slots:
|
||||
|
||||
void slotCreateCommandObject();
|
||||
|
||||
void slotShowRegressionTestDialog();
|
||||
|
||||
// Mock models
|
||||
void slotMockModel();
|
||||
void slotMockResultsModel();
|
||||
|
Loading…
Reference in New Issue
Block a user