diff options
author | Tamas Zakor <ztamas@inf.u-szeged.hu> | 2019-11-29 14:43:24 +0100 |
---|---|---|
committer | Tamas Zakor <ztamas@inf.u-szeged.hu> | 2019-12-18 14:54:13 +0000 |
commit | 17ea5b6534d6221e50cdd37dc773e03b5d34665e (patch) | |
tree | 559ca387ef7928797bdb5e1127ed31a1d668aa2a /tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp | |
parent | 12874d951f917d814efd582742b32d9d2884f9e4 (diff) |
Fix Q(Quick)WebEngineDownloadItem::setDownloadDirectory()
Keep the custom file name if the calling order of setDownloadDirectory()
and setDownloadFileName() changes.
Also do not emit patchChanged signal twice if setDownloadDirectory()
changes the uniquifier of the file name.
Add TempDir for qml auto tests what uses QTemporaryDir() to create
temporary directory for downloads.
See https://cgit.kde.org/messagelib.git/commit/?id=2c113dcb155b11bf2c0af3c85544962485784b26
for details.
Fixes: QTBUG-80566
Change-Id: Ia76f263558eaf55cb297700407948523788c6229
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp')
-rw-r--r-- | tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp b/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp index bbcef2226..55d8ac6e8 100644 --- a/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp +++ b/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp @@ -80,6 +80,7 @@ private Q_SLOTS: #if QT_DEPRECATED_SINCE(5, 14) void downloadPathValidation(); #endif + void downloadToDirectoryWithFileName_data(); void downloadToDirectoryWithFileName(); private: @@ -1271,8 +1272,17 @@ void tst_QWebEngineDownloadItem::downloadPathValidation() } #endif +void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName_data() +{ + QTest::addColumn<bool>("setDirectoryFirst"); + + QTest::newRow("setDirectoryFirst") << true; + QTest::newRow("setFileNameFirst") << false; +} + void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName() { + QFETCH(bool, setDirectoryFirst); QString downloadDirectory; QString downloadFileName; QString downloadedFilePath; @@ -1302,7 +1312,7 @@ void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName() // Set up profile and download handler ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) { - if (!downloadDirectory.isEmpty()) { + if (!downloadDirectory.isEmpty() && setDirectoryFirst) { item->setDownloadDirectory(downloadDirectory); QCOMPARE(item->downloadDirectory(), downloadDirectory); } @@ -1312,6 +1322,11 @@ void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName() QCOMPARE(item->downloadFileName(), downloadFileName); } + if (!downloadDirectory.isEmpty() && !setDirectoryFirst) { + item->setDownloadDirectory(downloadDirectory); + QCOMPARE(item->downloadDirectory(), downloadDirectory); + } + QCOMPARE(item->path(), QDir(item->downloadDirectory()).filePath(item->downloadFileName())); item->accept(); |