Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add test
  • Loading branch information
pblottiere committed Nov 27, 2017
1 parent b1008c7 commit 7ff6470
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/src/gui/testqgsrelationreferencewidget.cpp
Expand Up @@ -20,13 +20,15 @@
#include <qgsapplication.h>
#include "qgseditorwidgetwrapper.h"
#include <editorwidgets/qgsrelationreferencewidget.h>
#include <editorwidgets/qgsrelationreferencewidgetwrapper.h>
#include <qgsproject.h>
#include <qgsattributeform.h>
#include <qgsrelationmanager.h>
#include <attributetable/qgsattributetablefiltermodel.h>
#include "qgsfeaturelistcombobox.h"
#include "qgsfeaturefiltermodel.h"
#include "qgsgui.h"
#include "qgsmapcanvas.h"

class TestQgsRelationReferenceWidget : public QObject
{
Expand All @@ -43,6 +45,7 @@ class TestQgsRelationReferenceWidget : public QObject
void testChainFilter();
void testChainFilterRefreshed();
void testChainFilterDeleteForeignKey();
void testInvalidRelation();

private:
std::unique_ptr<QgsVectorLayer> mLayer1;
Expand Down Expand Up @@ -273,5 +276,16 @@ void TestQgsRelationReferenceWidget::testChainFilterDeleteForeignKey()
QCOMPARE( cbs[2]->isEnabled(), false );
}

void TestQgsRelationReferenceWidget::testInvalidRelation()
{
QgsVectorLayer vl( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=fk:int" ), QStringLiteral( "vl1" ), QStringLiteral( "memory" ) );
QgsMapCanvas canvas;
QgsRelationReferenceWidget editor( new QWidget() );

// initWidget with an invalid relation
QgsRelationReferenceWidgetWrapper ww( &vl, 10, &editor, &canvas, nullptr, nullptr );
ww.initWidget( nullptr );
}

QGSTEST_MAIN( TestQgsRelationReferenceWidget )
#include "testqgsrelationreferencewidget.moc"

0 comments on commit 7ff6470

Please sign in to comment.