mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
Add some tests
This commit is contained in:
parent
f18293fb39
commit
fc876fe547
@ -40,6 +40,7 @@ class TestQgsRelationReferenceWidget : public QObject
|
||||
|
||||
void testChainFilter();
|
||||
void testChainFilterRefreshed();
|
||||
void testChainFilterDeleteForeignKey();
|
||||
|
||||
private:
|
||||
std::unique_ptr<QgsVectorLayer> mLayer1;
|
||||
@ -222,5 +223,48 @@ void TestQgsRelationReferenceWidget::testChainFilterRefreshed()
|
||||
QCOMPARE( cbs[2]->currentText(), QString( "sleeve" ) );
|
||||
}
|
||||
|
||||
void TestQgsRelationReferenceWidget::testChainFilterDeleteForeignKey()
|
||||
{
|
||||
// init a relation reference widget
|
||||
QStringList filterFields = { "material", "diameter", "raccord" };
|
||||
|
||||
QgsRelationReferenceWidget w( new QWidget() );
|
||||
w.setChainFilters( true );
|
||||
w.setFilterFields( filterFields );
|
||||
w.setRelation( *mRelation, true );
|
||||
w.init();
|
||||
|
||||
// check the default status of filter comboboxes
|
||||
QList<QComboBox *> cbs = w.mFilterComboBoxes;
|
||||
|
||||
QCOMPARE( cbs[0]->currentText(), QString( "material" ) );
|
||||
QCOMPARE( cbs[0]->isEnabled(), true );
|
||||
|
||||
QCOMPARE( cbs[1]->currentText(), QString( "diameter" ) );
|
||||
QCOMPARE( cbs[1]->isEnabled(), false );
|
||||
|
||||
QCOMPARE( cbs[2]->currentText(), QString( "raccord" ) );
|
||||
QCOMPARE( cbs[2]->isEnabled(), false );
|
||||
|
||||
// set a foreign key
|
||||
w.setForeignKey( QVariant( 11 ) );
|
||||
|
||||
QCOMPARE( cbs[0]->currentText(), QString( "iron" ) );
|
||||
QCOMPARE( cbs[1]->currentText(), QString( "120" ) );
|
||||
QCOMPARE( cbs[2]->currentText(), QString( "sleeve" ) );
|
||||
|
||||
// delete the foreign key
|
||||
w.deleteForeignKey();
|
||||
|
||||
QCOMPARE( cbs[0]->currentText(), QString( "material" ) );
|
||||
QCOMPARE( cbs[0]->isEnabled(), true );
|
||||
|
||||
QCOMPARE( cbs[1]->currentText(), QString( "diameter" ) );
|
||||
QCOMPARE( cbs[1]->isEnabled(), false );
|
||||
|
||||
QCOMPARE( cbs[2]->currentText(), QString( "raccord" ) );
|
||||
QCOMPARE( cbs[2]->isEnabled(), false );
|
||||
}
|
||||
|
||||
QGSTEST_MAIN( TestQgsRelationReferenceWidget )
|
||||
#include "testqgsrelationreferencewidget.moc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user