Adjust ordering of Flow keywords

This commit is contained in:
Alif Be authored and Kristian Bendiksen committed 2026-10-07 10:48:42 +02:00
1 parent 7fa10b3e59
commit 1abff4c0dc
2 files changed
+77 -18

No files matched your search

@@ -117,6 +117,79 @@ TEST_F( RicExportScheduleFeatureTest, ExportWritesScheduleForTimelineEvents )
EXPECT_TRUE( content.contains( "--DAY" ) );
}
TEST_F( RicExportScheduleFeatureTest, ExportKeepsKeywordPriorityOrderRegardlessOfInsertionOrder )
{
FeatureTestModel model = RiaFeatureTestModelBuilder::combinedModel();
ASSERT_TRUE( model.eclipseCase != nullptr );
RimOilField* oilField = RimProject::current()->activeOilField();
ASSERT_TRUE( oilField != nullptr && oilField->wellPathCollection() != nullptr );
RimWellEventTimeline* timeline = oilField->wellPathCollection()->eventTimeline();
ASSERT_TRUE( timeline != nullptr );
// Added out of priority order on purpose: the exporter must still emit them sorted by the
// keyword priority order, with the group keywords (GCONPROD, GCONINJE, GEFAC) placed between
// WRFTPLT and TUNING, and the MSW keywords (WELSEGS, WSEGVALV, WSEGAICD, COMPSEGS) kept in that
// relative order. The MSW/group keywords use schedule-level keyword events with dummy data (not
// real well completions), so only the keyword priority order is exercised here.
const QDateTime date( QDate( 2024, 1, 1 ), QTime( 0, 0, 0 ) );
timeline->addKeywordEvent( date, "RPTRST" )->addIntItem( "BASIC", 2 );
timeline->addKeywordEvent( date, "TUNING" );
timeline->addKeywordEvent( date, "GEFAC" )->addStringItem( "GROUP", "FIELD" );
timeline->addKeywordEvent( date, "GCONINJE" )->addStringItem( "GROUP", "FIELD" );
timeline->addKeywordEvent( date, "GCONPROD" )->addStringItem( "GROUP", "FIELD" );
timeline->addKeywordEvent( date, "WRFTPLT" )->addStringItem( "WELL", "W1" );
timeline->addKeywordEvent( date, "COMPSEGS" )->addStringItem( "WELL", "W1" );
timeline->addKeywordEvent( date, "WSEGAICD" )->addStringItem( "WELL", "W1" );
timeline->addKeywordEvent( date, "WSEGVALV" )->addStringItem( "WELL", "W1" );
timeline->addKeywordEvent( date, "WELSEGS" )->addStringItem( "WELL", "W1" );
caf::SelectionManager::instance()->setSelectedItem( timeline );
QTemporaryDir temporaryDir;
ASSERT_TRUE( temporaryDir.isValid() );
const QString fileName = temporaryDir.filePath( "schedule_order.SCH" );
auto exportedFile = RicExportScheduleFeature::exportScheduleToFile( *timeline, *model.eclipseCase, fileName );
ASSERT_TRUE( exportedFile.has_value() ) << exportedFile.error().toStdString();
QFile file( fileName );
ASSERT_TRUE( file.open( QIODevice::ReadOnly | QIODevice::Text ) );
const QString content = QTextStream( &file ).readAll();
const int wrftpltPos = content.indexOf( "WRFTPLT" );
const int gconprodPos = content.indexOf( "GCONPROD" );
const int gconinjePos = content.indexOf( "GCONINJE" );
const int gefacPos = content.indexOf( "GEFAC" );
const int tuningPos = content.indexOf( "TUNING" );
const int rptrstPos = content.indexOf( "RPTRST" );
const int welsegsPos = content.indexOf( "WELSEGS" );
const int wsegvalvPos = content.indexOf( "WSEGVALV" );
const int wsegaicdPos = content.indexOf( "WSEGAICD" );
const int compsegsPos = content.indexOf( "COMPSEGS" );
ASSERT_NE( wrftpltPos, -1 );
ASSERT_NE( gconprodPos, -1 );
ASSERT_NE( gconinjePos, -1 );
ASSERT_NE( gefacPos, -1 );
ASSERT_NE( tuningPos, -1 );
ASSERT_NE( rptrstPos, -1 );
ASSERT_NE( welsegsPos, -1 );
ASSERT_NE( wsegvalvPos, -1 );
ASSERT_NE( wsegaicdPos, -1 );
ASSERT_NE( compsegsPos, -1 );
EXPECT_LT( wrftpltPos, gconprodPos );
EXPECT_LT( gconprodPos, gconinjePos );
EXPECT_LT( gconinjePos, gefacPos );
EXPECT_LT( gefacPos, tuningPos );
EXPECT_LT( tuningPos, rptrstPos );
EXPECT_LT( welsegsPos, wsegvalvPos );
EXPECT_LT( wsegvalvPos, wsegaicdPos );
EXPECT_LT( wsegaicdPos, compsegsPos );
}
TEST_F( RicExportScheduleFeatureTest, ExportOfEmptyTimelineFails )
{
FeatureTestModel model = RiaFeatureTestModelBuilder::combinedModel();