Skip to content

Commit

Permalink
Unit tests for setting and getting relation reference widget values
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed May 3, 2018
1 parent 561d255 commit 2c415e8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/src/gui/testqgsrelationreferencewidget.cpp
Expand Up @@ -298,14 +298,21 @@ void TestQgsRelationReferenceWidget::testSetGetForeignKey()
w.setRelation( *mRelation, true );
w.init();

QSignalSpy spy( &w, SIGNAL( foreignKeyChanged( QVariant ) ) );

w.setForeignKey( 11 );
QCOMPARE( w.foreignKey(), QVariant( 11 ) );
QCOMPARE( w.mComboBox->currentText(), QStringLiteral( "(11)" ) );
QCOMPARE( spy.count(), 1 );

w.setForeignKey( 12 );
QCOMPARE( w.foreignKey(), QVariant( 12 ) );
QCOMPARE( w.mComboBox->currentText(), QStringLiteral( "(12)" ) );
QCOMPARE( spy.count(), 2 );

w.setForeignKey( QVariant( QVariant::Int ) );
Q_ASSERT( w.foreignKey().isNull() );
QCOMPARE( spy.count(), 3 );
}

QGSTEST_MAIN( TestQgsRelationReferenceWidget )
Expand Down

0 comments on commit 2c415e8

Please sign in to comment.