Skip to content
Permalink
Browse files

fix test (was broken before)

  • Loading branch information
3nids committed Apr 30, 2020
1 parent 3fd45ec commit d7edbcb323b1411631a765bfed5e42fe31e55307
Showing with 17 additions and 20 deletions.
  1. +5 −5 src/core/qgsfeaturefiltermodel.cpp
  2. +12 −15 tests/src/gui/testqgsfeaturelistcombobox.cpp
@@ -110,7 +110,10 @@ bool QgsFeatureFilterModel::identifierIsNull( const QVariant &identifier ) const

QVariant QgsFeatureFilterModel::nullIentifier() const
{
return QVariantList();
QVariantList nullValues;
for ( int i = 0; i < mIdentifierFields.count(); i++ )
nullValues << QVariant( QVariant::Int );
return nullValues;
}

QStringList QgsFeatureFilterModel::identifierFields() const
@@ -140,10 +143,7 @@ QVariantList QgsFeatureFilterModel::extraIdentifierValues() const
QVariantList values = mExtraIdentifierValue.toList();
if ( values.count() != mIdentifierFields.count() )
{
QVariantList nullValues;
for ( int i = 0; i < mIdentifierFields.count(); i++ )
nullValues << QVariant( QVariant::Int );
return nullValues;
return nullIentifier().toList();
}
return values;
}
@@ -26,6 +26,7 @@
#include <memory>

#include <QLineEdit>
#include <QSignalSpy>

class QgsFilterLineEdit;

@@ -121,27 +122,23 @@ void TestQgsFeatureListComboBox::testSetGetLayer()

void TestQgsFeatureListComboBox::testSetGetForeignKey()
{
std::unique_ptr<QgsFeatureListComboBox> cb( new QgsFeatureListComboBox() );

QgsFeatureFilterModel *model = qobject_cast<QgsFeatureFilterModel *>( cb->model() );
QEventLoop loop;
connect( model, &QgsFeatureFilterModel::filterJobCompleted, &loop, &QEventLoop::quit );
QgsFeatureListComboBox cb;

Q_NOWARN_DEPRECATED_PUSH
QVERIFY( cb->identifierValue().isNull() );
QVERIFY( cb.identifierValue().isNull() );

cb->setSourceLayer( mLayer.get() );
cb->setDisplayExpression( "\"material\"" );
cb->lineEdit()->setText( "ro" );
emit cb->lineEdit()->textChanged( "ro" );
QVERIFY( cb->identifierValue().isNull() );
cb.setSourceLayer( mLayer.get() );
cb.setDisplayExpression( "\"material\"" );
cb.setIdentifierField( "material" );

loop.exec();
QSignalSpy spy( &cb, &QgsFeatureListComboBox::identifierValueChanged );
QTest::keyClicks( cb.lineEdit(), "ro" );
QTest::keyClick( cb.lineEdit(), Qt::Key_Enter );

spy.wait();

QVERIFY( cb->identifierValue().isNull() );
QCOMPARE( cb.identifierValue().toString(), QStringLiteral( "iron" ) );

cb->setIdentifierValue( 20 );
QCOMPARE( cb->identifierValue(), QVariant( 20 ) );
Q_NOWARN_DEPRECATED_POP
}

0 comments on commit d7edbcb

Please sign in to comment.
You can’t perform that action at this time.