Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Jan 25, 2022
1 parent b0cce8b commit 7d6b3f1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/src/gui/testqgsrasterlayersaveasdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class TestQgsRasterLayerSaveAsDialog : public QObject
void init(); // will be called before each testfunction is executed.
void cleanup(); // will be called after every testfunction.
void outputLayerExists();
void filenameWhenNoExtension();

private:

Expand Down Expand Up @@ -146,6 +147,24 @@ QString TestQgsRasterLayerSaveAsDialog::prepareDb()
return tmpFile.fileName( );
}

void TestQgsRasterLayerSaveAsDialog::filenameWhenNoExtension()
{
// Try to add a raster layer to the DB
const QString dataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt
const QString rasterPath { dataDir + "/landsat.tif" };

QgsRasterLayer rl( rasterPath, QStringLiteral( "my_raster" ) );
QVERIFY( rl.isValid() );

QgsRasterLayerSaveAsDialog d( &rl, rl.dataProvider(), rl.extent(), rl.crs(), rl.crs() );
d.mFormatComboBox->setCurrentIndex( d.mFormatComboBox->findData( QStringLiteral( "ENVI" ) ) );
QCOMPARE( d.mFormatComboBox->currentData().toString(), QString( "ENVI" ) );

const QString filename = "filename_without_extension";
d.mFilename->setFilePath( filename );
QCOMPARE( d.outputFileName(), filename );
}

QGSTEST_MAIN( TestQgsRasterLayerSaveAsDialog )

#include "testqgsrasterlayersaveasdialog.moc"

0 comments on commit 7d6b3f1

Please sign in to comment.