mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Setter and getter tests for relation reference widget
This commit is contained in:
parent
19261f0986
commit
da93520c1f
@ -46,6 +46,7 @@ class TestQgsRelationReferenceWidget : public QObject
|
||||
void testChainFilterRefreshed();
|
||||
void testChainFilterDeleteForeignKey();
|
||||
void testInvalidRelation();
|
||||
void testSetGetForeignKey();
|
||||
|
||||
private:
|
||||
std::unique_ptr<QgsVectorLayer> mLayer1;
|
||||
@ -129,6 +130,8 @@ void TestQgsRelationReferenceWidget::init()
|
||||
|
||||
void TestQgsRelationReferenceWidget::cleanup()
|
||||
{
|
||||
QgsProject::instance()->removeMapLayer( mLayer1.get() );
|
||||
QgsProject::instance()->removeMapLayer( mLayer2.get() );
|
||||
}
|
||||
|
||||
void TestQgsRelationReferenceWidget::testChainFilter()
|
||||
@ -136,7 +139,8 @@ void TestQgsRelationReferenceWidget::testChainFilter()
|
||||
// init a relation reference widget
|
||||
QStringList filterFields = { "material", "diameter", "raccord" };
|
||||
|
||||
QgsRelationReferenceWidget w( new QWidget() );
|
||||
QWidget parentWidget;
|
||||
QgsRelationReferenceWidget w( &parentWidget );
|
||||
w.setChainFilters( true );
|
||||
w.setFilterFields( filterFields );
|
||||
w.setRelation( *mRelation, true );
|
||||
@ -287,5 +291,22 @@ void TestQgsRelationReferenceWidget::testInvalidRelation()
|
||||
ww.initWidget( nullptr );
|
||||
}
|
||||
|
||||
void TestQgsRelationReferenceWidget::testSetGetForeignKey()
|
||||
{
|
||||
QWidget parentWidget;
|
||||
QgsRelationReferenceWidget w( &parentWidget );
|
||||
w.setRelation( *mRelation, true );
|
||||
w.init();
|
||||
|
||||
w.setForeignKey( 11 );
|
||||
QCOMPARE( w.foreignKey(), QVariant( 11 ) );
|
||||
|
||||
w.setForeignKey( 12 );
|
||||
QCOMPARE( w.foreignKey(), QVariant( 12 ) );
|
||||
|
||||
w.setForeignKey( QVariant( QVariant::Int ) );
|
||||
Q_ASSERT( w.foreignKey().isNull() );
|
||||
}
|
||||
|
||||
QGSTEST_MAIN( TestQgsRelationReferenceWidget )
|
||||
#include "testqgsrelationreferencewidget.moc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user