diff --git a/ApplicationLibCode/Application/Tools/RiaRegressionTest.cpp b/ApplicationLibCode/Application/Tools/RiaRegressionTest.cpp index 230786ac79..b5259dccbf 100644 --- a/ApplicationLibCode/Application/Tools/RiaRegressionTest.cpp +++ b/ApplicationLibCode/Application/Tools/RiaRegressionTest.cpp @@ -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" ); diff --git a/ApplicationLibCode/Application/Tools/RiaRegressionTest.h b/ApplicationLibCode/Application/Tools/RiaRegressionTest.h index 4b70fa397a..f16593ef4c 100644 --- a/ApplicationLibCode/Application/Tools/RiaRegressionTest.h +++ b/ApplicationLibCode/Application/Tools/RiaRegressionTest.h @@ -52,6 +52,7 @@ class RiaRegressionTest : public caf::PdmObject caf::PdmField openReportInBrowser; caf::PdmField appendTestsAfterTestFilter; caf::PdmField invalidateExternalFilePaths; + caf::PdmField activateObjectsInPropertyEditor; caf::PdmField exportSnapshots3dViews; caf::PdmField exportSnapshotsPlots; diff --git a/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.cpp b/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.cpp index a90982ae88..13a2581a26 100644 --- a/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.cpp +++ b/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.cpp @@ -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 @@ -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 baseObjects; + + auto oilField = project->activeOilField(); + + std::vector fields = oilField->fields(); + for ( auto f : fields ) + { + std::vector 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( childObject ) != nullptr ) + { + continue; + } + + caf::PdmObject* pdmObjectChild = dynamic_cast( childObject ); + if ( pdmObjectChild ) + { + baseObjects.push_back( pdmObjectChild ); + } + } + } + + baseObjects.push_back( project->mainPlotCollection() ); + + std::vector allObjects; + for ( auto baseObj : baseObjects ) + { + auto objectsForSelection = baseObj->descendantsIncludingThisOfType(); + + 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( obj ) ) continue; + if ( dynamic_cast( obj ) ) continue; + if ( dynamic_cast( 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 ); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.h b/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.h index cf10faa09b..7ae23b2ec7 100644 --- a/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.h +++ b/ApplicationLibCode/Application/Tools/RiaRegressionTestRunner.h @@ -70,6 +70,8 @@ class RiaRegressionTestRunner static QString diff2htmlHeaderText( const QString& testRootPath ); QFileInfoList subDirectoriesForTestExecution( const QDir& directory ); + static void selectObjectsInProject(); + private: QString m_rootPath; QStringList m_testFilter;