Skip to content

Commit

Permalink
Add a test case for unwriteable folders in file downloader
Browse files Browse the repository at this point in the history
Attempt to verify bug 17410 Identify tool->download in a not authorised folder block qgis

The test passes, so let's push it in, I'll continue
to investigate if there is an issue in the GUI logic.
  • Loading branch information
elpaso committed Nov 8, 2017
1 parent e781ad2 commit f06ea87
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/src/gui/testqgsfiledownloader.cpp
Expand Up @@ -17,6 +17,7 @@
#include "qgstest.h"
#include <QObject>
#include <QTemporaryFile>
#include <QTemporaryDir>
#include <QUrl>
#include <QEventLoop>
#include <QTimer>
Expand Down Expand Up @@ -73,6 +74,7 @@ class TestQgsFileDownloader: public QObject
void testCanceledDownload();
void testInvalidUrl();
void testBlankUrl();
void testLacksWritePermissionsError();
#ifndef QT_NO_SSL
void testSslError_data();
void testSslError();
Expand Down Expand Up @@ -236,6 +238,22 @@ void TestQgsFileDownloader::testSslError()
QVERIFY( !mCanceled );
}

void TestQgsFileDownloader::testLacksWritePermissionsError()
{
QTemporaryDir dir;
QFile tmpDir( dir.path( ) );
tmpDir.setPermissions( tmpDir.permissions() & !( QFile::Permission::WriteGroup | QFile::Permission::WriteUser | QFile::Permission::WriteOther | QFile::Permission::WriteOwner ) );
QVERIFY( ! tmpDir.isWritable() );
QString fileName( dir.path() + '/' + QStringLiteral( "tmp.bin" ) );
makeCall( QUrl( QStringLiteral( "http://www.qgis.org" ) ), fileName );
QVERIFY( mExited );
QVERIFY( !mCompleted );
QVERIFY( mError );
QVERIFY( !mCanceled );
QVERIFY( ! QFileInfo( fileName ).exists( ) );
}


#endif


Expand Down

0 comments on commit f06ea87

Please sign in to comment.