mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-22 05:48:13 -06:00
#15008 Test that the added folder matches subCollectionClassKeyword()
The Python generator declares the add_folder() return type from subCollectionClassKeyword(), while the folder is created by createSubCollection(). Nothing tied the two together, so overriding only one of them would give wrong type hints without any failing test. ResInsight-tests: the folder added to a polygon collection, a surface collection and an ensemble surface has the class named by subCollectionClassKeyword(), and a polygon file declares and creates no folder.
This commit is contained in:
1 parent
7aebcdc92e
commit
fc7d5c0594
1 file changed
+41
@@ -20,6 +20,8 @@
|
||||
#include "Polygons/Cloud/RimPolygonCloudAddress.h"
|
||||
#include "Polygons/RimPolygonCollection.h"
|
||||
#include "Polygons/RimPolygonFile.h"
|
||||
#include "RimEnsembleSurface.h"
|
||||
#include "RimSurfaceCollection.h"
|
||||
|
||||
#include "RimcDataContainerString.h"
|
||||
#include "RimcNestedCollectionBase.h"
|
||||
@@ -40,6 +42,17 @@ QString scriptCollectionName( caf::PdmNestedCollectionBase* collection )
|
||||
|
||||
return strings->m_stringValues().front();
|
||||
}
|
||||
|
||||
// The Python generator declares the folder type from subCollectionClassKeyword(), while the folder is
|
||||
// created by createSubCollection(). Both must name the same class.
|
||||
void expectAddedFolderMatchesDeclaredKeyword( caf::PdmNestedCollectionBase& collection, const QString& expectedKeyword )
|
||||
{
|
||||
EXPECT_EQ( expectedKeyword, collection.subCollectionClassKeyword() );
|
||||
|
||||
caf::PdmNestedCollectionBase* added = collection.addNewSubCollection();
|
||||
ASSERT_NE( nullptr, added );
|
||||
EXPECT_EQ( collection.subCollectionClassKeyword(), added->classKeyword() );
|
||||
}
|
||||
} // namespace
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -71,6 +84,34 @@ TEST( RimcNestedCollectionBase, CollectionNameUsesPolygonFileFallback )
|
||||
EXPECT_EQ( polygonFile.name(), scriptCollectionName( &polygonFile ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RimcNestedCollectionBase, AddedFolderMatchesSubCollectionClassKeyword )
|
||||
{
|
||||
RimPolygonCollection polygonCollection;
|
||||
expectAddedFolderMatchesDeclaredKeyword( polygonCollection, RimPolygonCollection::classKeywordStatic() );
|
||||
|
||||
RimSurfaceCollection surfaceCollection;
|
||||
expectAddedFolderMatchesDeclaredKeyword( surfaceCollection, RimSurfaceCollection::classKeywordStatic() );
|
||||
|
||||
// An ensemble surface creates plain surface folders, not ensemble surfaces
|
||||
RimEnsembleSurface ensembleSurface;
|
||||
expectAddedFolderMatchesDeclaredKeyword( ensembleSurface, RimSurfaceCollection::classKeywordStatic() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// A leaf folder declares no folder type and creates none.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RimcNestedCollectionBase, LeafFolderHasNoSubCollectionClassKeyword )
|
||||
{
|
||||
RimPolygonFile polygonFile;
|
||||
EXPECT_FALSE( polygonFile.canAddSubCollection() );
|
||||
EXPECT_TRUE( polygonFile.subCollectionClassKeyword().isEmpty() );
|
||||
EXPECT_EQ( nullptr, polygonFile.addNewSubCollection() );
|
||||
EXPECT_TRUE( polygonFile.subCollections().empty() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user