Regression Test: Find relevant objects and show them in Property Editor

This commit is contained in:
Magne Sjaastad 2024-10-01 14:11:56 +02:00
parent f43ecd5e92
commit e7a082ac29
4 changed files with 89 additions and 0 deletions

View File

@ -82,6 +82,8 @@ RiaRegressionTest::RiaRegressionTest()
CAF_PDM_InitField( &appendTestsAfterTestFilter, "appendTestsAfterTestFilter", false, "Append All Tests After Test Filter" );
CAF_PDM_InitField( &invalidateExternalFilePaths, "invalidateExternalFilePaths", false, "Invalidate External File Paths" );
CAF_PDM_InitField( &activateObjectsInPropertyEditor, "activateObjectsInPropertyEditor", false, "Activate Objects In Property Editor" );
CAF_PDM_InitFieldNoDefault( &overridePlotEngine, "forcePlotEngine", "Force Plot Engine" );
CAF_PDM_InitField( &exportSnapshots3dViews, "exportSnapshots3dViews", true, "Export Snapshots 3D Views" );

View File

@ -52,6 +52,7 @@ public:
caf::PdmField<bool> openReportInBrowser;
caf::PdmField<bool> appendTestsAfterTestFilter;
caf::PdmField<bool> invalidateExternalFilePaths;
caf::PdmField<bool> activateObjectsInPropertyEditor;
caf::PdmField<bool> exportSnapshots3dViews;
caf::PdmField<bool> exportSnapshotsPlots;

View File

@ -32,8 +32,14 @@
#include "Rim3dView.h"
#include "RimCase.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseResultAddress.h"
#include "RimFaultInView.h"
#include "RimMainPlotCollection.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSimWellInView.h"
#include "RimSummaryCaseMainCollection.h"
#include "RiuDockWidgetTools.h"
#include "RiuMainWindow.h"
@ -47,6 +53,7 @@
#include "DockManager.h"
#include "cafMemoryInspector.h"
#include "cafPdmUiTreeView.h"
#include "cafUtils.h"
#include <QDateTime>
@ -255,6 +262,11 @@ void RiaRegressionTestRunner::runRegressionTest()
uint64_t usedMemoryBeforeClose = caf::MemoryInspector::getApplicationPhysicalMemoryUsageMiB();
if ( regressionTestConfig.activateObjectsInPropertyEditor )
{
RiaRegressionTestRunner::selectObjectsInProject();
}
app->closeProject();
QApplication::processEvents();
@ -632,6 +644,78 @@ QFileInfoList RiaRegressionTestRunner::subDirectoriesForTestExecution( const QDi
return foldersMatchingTestFilter;
}
//--------------------------------------------------------------------------------------------------
/// Find relevant object to show in property editor. Loop through all objects in project and select them, this will activate the Property
/// Editor. Avoid RimSummaryCaseMainCollection, as this container contains all the summary addresses, and can potentially contain extremely
/// many objects
//--------------------------------------------------------------------------------------------------
void RiaRegressionTestRunner::selectObjectsInProject()
{
auto project = RimProject::current();
if ( !project ) return;
std::vector<caf::PdmObject*> baseObjects;
auto oilField = project->activeOilField();
std::vector<caf::PdmFieldHandle*> fields = oilField->fields();
for ( auto f : fields )
{
std::vector<caf::PdmObjectHandle*> childObjects = f->children();
for ( auto childObject : childObjects )
{
// Skip RimSummaryCaseMainCollection, as this container contains all the summary addresses, and can potentially contain extemely
// many objects
if ( dynamic_cast<RimSummaryCaseMainCollection*>( childObject ) != nullptr )
{
continue;
}
caf::PdmObject* pdmObjectChild = dynamic_cast<caf::PdmObject*>( childObject );
if ( pdmObjectChild )
{
baseObjects.push_back( pdmObjectChild );
}
}
}
baseObjects.push_back( project->mainPlotCollection() );
std::vector<caf::PdmObject*> allObjects;
for ( auto baseObj : baseObjects )
{
auto objectsForSelection = baseObj->descendantsIncludingThisOfType<caf::PdmObject>();
allObjects.insert( allObjects.end(), objectsForSelection.begin(), objectsForSelection.end() );
}
QApplication::processEvents( QEventLoop::ExcludeUserInputEvents );
auto mainWindow = RiuMainWindow::instance();
auto plotMainWindow = RiuPlotMainWindow::instance();
for ( auto obj : allObjects )
{
if ( dynamic_cast<RimFaultInView*>( obj ) ) continue;
if ( dynamic_cast<RimEclipseResultAddress*>( obj ) ) continue;
if ( dynamic_cast<RimSimWellInView*>( obj ) ) continue;
if ( auto treeView = mainWindow->getTreeViewWithItem( obj ) )
{
treeView->selectItems( { obj } );
QApplication::processEvents( QEventLoop::ExcludeUserInputEvents );
}
if ( auto treeView = plotMainWindow->getTreeViewWithItem( obj ) )
{
treeView->selectItems( { obj } );
QApplication::processEvents( QEventLoop::ExcludeUserInputEvents );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -70,6 +70,8 @@ private:
static QString diff2htmlHeaderText( const QString& testRootPath );
QFileInfoList subDirectoriesForTestExecution( const QDir& directory );
static void selectObjectsInProject();
private:
QString m_rootPath;
QStringList m_testFilter;