mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 14:40:26 -05:00
Add the ResInsight-featuretests executable: a headless GUI test harness (RiaFeatureTestModelBuilder, RiaFeatureTestTreeView), a runner that triggers Ric*Feature commands through their QAction (RicFeatureExecutionRunner), a generic execution sweep over every registered feature (RicFeatureSweep-Test, RicFeatureExecutionSweep-Test, RicFeatureSubprocessSweep-Test, RicFeatureSweepDenylist), and supporting CMake wiring. Adds RiaRegressionTestRunner::setRunningRegressionTests() so tests can suppress modal dialogs, and shares RimMockSummaryCase as a common test model under TestModels.
86 lines
3.1 KiB
C++
86 lines
3.1 KiB
C++
#pragma once
|
|
|
|
#include "RifSummaryReaderInterface.h"
|
|
#include "RigCaseRealizationParameters.h"
|
|
#include "RimSummaryCase.h"
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
class RimMockSummaryCase : public RimSummaryCase, public RifSummaryReaderInterface
|
|
{
|
|
public:
|
|
void setName( const QString& name ) { m_name = name; }
|
|
|
|
void addVector( const RifEclipseSummaryAddress& address,
|
|
const std::vector<time_t>& timeSteps,
|
|
const std::vector<double>& values,
|
|
const std::string& unit = "" )
|
|
{
|
|
m_data[address] = { timeSteps, values, unit };
|
|
m_allResultAddresses.insert( address );
|
|
}
|
|
|
|
// RimSummaryCase overrides
|
|
void createSummaryReaderInterface() override {}
|
|
RifSummaryReaderInterface* summaryReader() override { return this; }
|
|
QString caseName() const override { return m_name; }
|
|
|
|
// RifSummaryReaderInterface overrides
|
|
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override
|
|
{
|
|
auto it = m_data.find( resultAddress );
|
|
if ( it != m_data.end() ) return it->second.timeSteps;
|
|
return {};
|
|
}
|
|
|
|
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override
|
|
{
|
|
auto it = m_data.find( resultAddress );
|
|
if ( it != m_data.end() ) return { true, it->second.values };
|
|
return { false, {} };
|
|
}
|
|
|
|
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override
|
|
{
|
|
auto it = m_data.find( resultAddress );
|
|
if ( it != m_data.end() ) return it->second.unit;
|
|
return {};
|
|
}
|
|
|
|
RiaDefines::EclipseUnitSystem unitSystem() const override { return RiaDefines::EclipseUnitSystem::UNITS_METRIC; }
|
|
|
|
size_t keywordCount() const override { return m_allResultAddresses.size(); }
|
|
|
|
void refreshCalculatedAddresses() override { m_refreshCalculatedAddressesCount++; }
|
|
int refreshCalculatedAddressesCount() const { return m_refreshCalculatedAddressesCount; }
|
|
|
|
private:
|
|
struct VectorData
|
|
{
|
|
std::vector<time_t> timeSteps;
|
|
std::vector<double> values;
|
|
std::string unit;
|
|
};
|
|
|
|
QString m_name = "MockCase";
|
|
std::map<RifEclipseSummaryAddress, VectorData> m_data;
|
|
int m_refreshCalculatedAddressesCount = 0;
|
|
};
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
/// A mock case carrying the realization number a delta ensemble matches its source cases on.
|
|
//--------------------------------------------------------------------------------------------------
|
|
inline RimSummaryCase* createMockCase( int realizationNumber )
|
|
{
|
|
auto* summaryCase = new RimMockSummaryCase();
|
|
|
|
auto parameters = std::make_shared<RigCaseRealizationParameters>();
|
|
parameters->setRealizationNumber( realizationNumber );
|
|
summaryCase->setCaseRealizationParameters( parameters );
|
|
|
|
return summaryCase;
|
|
}
|