Skip to content
Permalink
Browse files

Fix and add tests

  • Loading branch information
nirvn committed May 15, 2020
1 parent d10b2e8 commit 4a7852337dbc85806b8f3b6be5946815567b081c
Showing with 37 additions and 1 deletion.
  1. +37 −1 tests/src/core/testqgstemporalnavigationobject.cpp
@@ -41,6 +41,7 @@ class TestQgsTemporalNavigationObject : public QObject
void animationState();
void temporalExtents();
void frameSettings();
void navigationMode();
void expressionContext();

private:
@@ -65,6 +66,7 @@ void TestQgsTemporalNavigationObject::init()
//create a temporal object that will be used in all tests...

navigationObject = new QgsTemporalNavigationObject();
navigationObject->setNavigationMode( QgsTemporalNavigationObject::Animated );
}

void TestQgsTemporalNavigationObject::cleanup()
@@ -138,6 +140,41 @@ void TestQgsTemporalNavigationObject::temporalExtents()
QCOMPARE( navigationObject->temporalExtents(), QgsDateTimeRange() );
}

void TestQgsTemporalNavigationObject::navigationMode()
{
QgsDateTimeRange range = QgsDateTimeRange(
QDateTime( QDate( 2010, 1, 1 ) ),
QDateTime( QDate( 2020, 1, 1 ) ) );

QgsDateTimeRange range2 = QgsDateTimeRange(
QDateTime( QDate( 2015, 1, 1 ) ),
QDateTime( QDate( 2020, 1, 1 ) ) );

QgsDateTimeRange check;
auto checkUpdateTemporalRange = [&check]( const QgsDateTimeRange range )
{
QCOMPARE( range, check );
};
QObject *context = new QObject( this );
connect( navigationObject, &QgsTemporalNavigationObject::updateTemporalRange, context, checkUpdateTemporalRange );

// Changing navigation mode emits an updateTemporalRange, in this case it should be an empty range
navigationObject->setNavigationMode( QgsTemporalNavigationObject::NavigationOff );
// Setting temporal extents also triggers an updateTemporalRange with an empty range
navigationObject->setTemporalExtents( range );

// Changing navigation mode emits an updateTemporalRange, in this case it should be the last range
// we used in setTemporalExtents.
check = range;
navigationObject->setNavigationMode( QgsTemporalNavigationObject::FixedRange );
check = range2;
navigationObject->setTemporalExtents( range2 );

// Delete context to disconnect the signal to the lambda function
delete context;
navigationObject->setNavigationMode( QgsTemporalNavigationObject::Animated );
}

void TestQgsTemporalNavigationObject::frameSettings()
{
qRegisterMetaType<QgsDateTimeRange>( "QgsDateTimeRange" );
@@ -175,7 +212,6 @@ void TestQgsTemporalNavigationObject::frameSettings()

navigationObject->setTemporalRangeCumulative( true );
QCOMPARE( navigationObject->dateTimeRangeForFrameNumber( 4 ), range );

}

void TestQgsTemporalNavigationObject::expressionContext()

0 comments on commit 4a78523

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