1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
#include "persalys/FieldMonteCarloAnalysis.hxx"
#include "persalys/FieldMonteCarloWizard.hxx"
#include "persalys/SymbolicFieldModel.hxx"
#include "persalys/GridMeshModel.hxx"
#include <openturns/OTtypes.hxx>
#include <openturns/Normal.hxx>
#include <openturns/Uniform.hxx>
#include <QtTest/QtTest>
namespace PERSALYS
{
class TestFieldMonteCarloWizard : public QObject
{
Q_OBJECT
public:
TestFieldMonteCarloWizard()
{
GridMeshModel meshModel(OT::Interval(0., 12.), OT::Indices(1, 5));
Input z0("z0", 100, OT::Uniform(100, 150));
Input v0("v0", 55, OT::Normal(55, 10));
Input m("m", 80, OT::Normal(80, 8));
Input c("c", 15, OT::Uniform(0, 30));
Output z("z");
InputCollection inputCollection(4);
inputCollection[0] = z0;
inputCollection[1] = v0;
inputCollection[2] = m;
inputCollection[2] = c;
OutputCollection outputCollection(1, z);
OT::Description formula(1, "max(0, z0 + (m * 9.81 / c) * t + (m / c) * (v0 - (m * 9.81 / c)) * (1 - exp(-t * c / m)))");
model = SymbolicFieldModel("model", meshModel, inputCollection, outputCollection, formula);
}
private:
SymbolicFieldModel model;
private slots:
void TestOutputsSelection()
{
// create the analysis
FieldMonteCarloAnalysis analysis("analysis", model);
// create the wizard
FieldMonteCarloWizard wizard(analysis);
wizard.show();
// checks
// - first page
OutputsSelectionGroupBox * outputsSelectionGroupBox = wizard.findChild<OutputsSelectionGroupBox*>();
TemporaryLabel * errorMessageLabel = wizard.findChild<TemporaryLabel*>();
TitledComboBox * comboBox = outputsSelectionGroupBox->findChild<TitledComboBox*>();
ListWidgetWithCheckBox * listWidget = outputsSelectionGroupBox->findChild<ListWidgetWithCheckBox*>();
QVERIFY2(wizard.validateCurrentPage(), "Page must be valid");
QVERIFY2(errorMessageLabel->text().isEmpty(), "Label must be empty");
QTest::mouseClick(comboBox, Qt::LeftButton); // open listwidget
QTest::mouseClick(listWidget->viewport(), Qt::LeftButton); // deselect all
QVERIFY2(!wizard.validateCurrentPage(), "Page must be not valid");
QVERIFY2(!errorMessageLabel->text().isEmpty(), "Label must be not empty");
wizard.next();
QVERIFY2(wizard.currentId() == 0, "Current page ID must be 0"); // can not go to next page
QTest::mouseClick(listWidget->viewport(), Qt::LeftButton); // select all
QVERIFY2(wizard.validateCurrentPage(), "Page must be valid");
QVERIFY2(errorMessageLabel->text().isEmpty(), "Label must be empty");
}
void TestAnalysis()
{
// create the analysis
FieldMonteCarloAnalysis analysis("analysis", model);
// create the wizard
FieldMonteCarloWizard wizard(analysis);
wizard.show();
// checks
QVERIFY2(wizard.nextId() == -1, "Next page ID must be -1");
bool analysisEquality = wizard.getAnalysis().getParameters() == analysis.getParameters();
QVERIFY2(analysisEquality, "The two FieldMonteCarloAnalysis must be equal");
}
};
}
QTEST_MAIN(PERSALYS::TestFieldMonteCarloWizard)
#include "t_FieldMonteCarloWizard_std.moc"
|