summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2020-08-10 09:31:27 +0200
committerMichal Klocek <michal.klocek@qt.io>2020-08-18 23:23:35 +0200
commit75393077108480e1762612331c399a012b5feba7 (patch)
tree38db972a8d47853de4640d15458bfab6e74ea6b0 /tests/auto
parent322742fbdc9a18497946fc736daba9f6bf73ac54 (diff)
Remove obsolete, deprecated api from qwebenginedownloaditem
This patch removes: * path() * type() * DownloadType enum Change-Id: I3e29f9e8ce9e39b015c57cb7005e0290d1496291 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/quick/publicapi/tst_publicapi.cpp7
-rw-r--r--tests/auto/widgets/loadsignals/tst_loadsignals.cpp4
-rw-r--r--tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp152
3 files changed, 3 insertions, 160 deletions
diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp
index 3e24632e0..1ffaa13da 100644
--- a/tests/auto/quick/publicapi/tst_publicapi.cpp
+++ b/tests/auto/quick/publicapi/tst_publicapi.cpp
@@ -199,9 +199,7 @@ static const QStringList expectedAPI = QStringList()
<< "QWebEngineContextMenuRequest.selectedText --> QString"
<< "QWebEngineContextMenuRequest.spellCheckerSuggestions --> QStringList"
<< "QWebEngineContextMenuRequest.position --> QPoint"
- << "QWebEngineDownloadItem.Attachment --> DownloadType"
<< "QWebEngineDownloadItem.CompleteHtmlSaveFormat --> SavePageFormat"
- << "QWebEngineDownloadItem.DownloadAttribute --> DownloadType"
<< "QWebEngineDownloadItem.DownloadCancelled --> DownloadState"
<< "QWebEngineDownloadItem.DownloadCompleted --> DownloadState"
<< "QWebEngineDownloadItem.DownloadInProgress --> DownloadState"
@@ -225,7 +223,6 @@ static const QStringList expectedAPI = QStringList()
<< "QWebEngineDownloadItem.NetworkServerDown --> DownloadInterruptReason"
<< "QWebEngineDownloadItem.NetworkTimeout --> DownloadInterruptReason"
<< "QWebEngineDownloadItem.NoReason --> DownloadInterruptReason"
- << "QWebEngineDownloadItem.SavePage --> DownloadType"
<< "QWebEngineDownloadItem.ServerBadContent --> DownloadInterruptReason"
<< "QWebEngineDownloadItem.ServerCertProblem --> DownloadInterruptReason"
<< "QWebEngineDownloadItem.ServerFailed --> DownloadInterruptReason"
@@ -235,7 +232,6 @@ static const QStringList expectedAPI = QStringList()
<< "QWebEngineDownloadItem.SingleHtmlSaveFormat --> SavePageFormat"
<< "QWebEngineDownloadItem.UnknownSaveFormat --> SavePageFormat"
<< "QWebEngineDownloadItem.UserCanceled --> DownloadInterruptReason"
- << "QWebEngineDownloadItem.UserRequested --> DownloadType"
<< "QWebEngineDownloadItem.accept() --> void"
<< "QWebEngineDownloadItem.cancel() --> void"
<< "QWebEngineDownloadItem.id --> uint"
@@ -248,8 +244,6 @@ static const QStringList expectedAPI = QStringList()
<< "QWebEngineDownloadItem.isPausedChanged() --> void"
<< "QWebEngineDownloadItem.isSavePageDownload --> bool"
<< "QWebEngineDownloadItem.mimeType --> QString"
- << "QWebEngineDownloadItem.path --> QString"
- << "QWebEngineDownloadItem.pathChanged() --> void"
<< "QWebEngineDownloadItem.pause() --> void"
<< "QWebEngineDownloadItem.receivedBytes --> qlonglong"
<< "QWebEngineDownloadItem.receivedBytesChanged() --> void"
@@ -260,7 +254,6 @@ static const QStringList expectedAPI = QStringList()
<< "QWebEngineDownloadItem.stateChanged(QWebEngineDownloadItem::DownloadState) --> void"
<< "QWebEngineDownloadItem.totalBytes --> qlonglong"
<< "QWebEngineDownloadItem.totalBytesChanged() --> void"
- << "QWebEngineDownloadItem.type --> DownloadType"
// FIXME << "QWebEngineDownloadItem.view --> QQuickWebEngineView*"
<< "QWebEngineDownloadItem.url --> QUrl"
<< "QWebEngineDownloadItem.suggestedFileName --> QString"
diff --git a/tests/auto/widgets/loadsignals/tst_loadsignals.cpp b/tests/auto/widgets/loadsignals/tst_loadsignals.cpp
index 20e5fbf0d..31874c5e7 100644
--- a/tests/auto/widgets/loadsignals/tst_loadsignals.cpp
+++ b/tests/auto/widgets/loadsignals/tst_loadsignals.cpp
@@ -238,8 +238,8 @@ void tst_LoadSignals::fileDownloadDoesNotTriggerLoadSignals_qtbug66661()
connect(item, &QWebEngineDownloadItem::stateChanged, [&downloadState](QWebEngineDownloadItem::DownloadState newState){
downloadState = newState;
});
- item->setDownloadDirectory(tempDir.filePath(QFileInfo(item->path()).path()));
- item->setDownloadFileName(QFileInfo(item->path()).fileName());
+ item->setDownloadDirectory(tempDir.path());
+ item->setDownloadFileName(item->suggestedFileName());
item->accept();
});
diff --git a/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp b/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp
index 46de44d08..3d2ad4332 100644
--- a/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp
+++ b/tests/auto/widgets/qwebenginedownloaditem/tst_qwebenginedownloaditem.cpp
@@ -77,9 +77,6 @@ private Q_SLOTS:
void downloadToDefaultLocation();
void downloadToNonExistentDir();
void downloadToReadOnlyDir();
-#if QT_DEPRECATED_SINCE(5, 14)
- void downloadPathValidation();
-#endif
void downloadToDirectoryWithFileName_data();
void downloadToDirectoryWithFileName();
@@ -88,10 +85,6 @@ private:
void clickLink(QPoint linkPos);
void simulateUserAction(QPoint linkPos, UserAction action);
- QWebEngineDownloadItem::DownloadType expectedDownloadType(
- UserAction userAction,
- const QByteArray &contentDisposition = QByteArray());
-
HttpServer *m_server;
QWebEngineProfile *m_profile;
QWebEnginePage *m_page;
@@ -192,16 +185,6 @@ void tst_QWebEngineDownloadItem::simulateUserAction(QPoint linkPos, UserAction a
}
}
-QWebEngineDownloadItem::DownloadType tst_QWebEngineDownloadItem::expectedDownloadType(
- UserAction userAction, const QByteArray &contentDisposition)
-{
- if (userAction == SaveLink)
- return QWebEngineDownloadItem::UserRequested;
- if (contentDisposition == QByteArrayLiteral("attachment"))
- return QWebEngineDownloadItem::Attachment;
- return QWebEngineDownloadItem::DownloadAttribute;
-}
-
void tst_QWebEngineDownloadItem::downloadLink_data()
{
QTest::addColumn<UserAction>("userAction");
@@ -213,7 +196,6 @@ void tst_QWebEngineDownloadItem::downloadLink_data()
QTest::addColumn<QByteArray>("fileDisposition");
QTest::addColumn<bool>("fileHasReferer");
QTest::addColumn<FileAction>("fileAction");
- QTest::addColumn<QWebEngineDownloadItem::DownloadType>("downloadType");
// SaveLink should always trigger a download, even for empty files.
QTest::newRow("save link to empty file")
@@ -463,7 +445,6 @@ void tst_QWebEngineDownloadItem::downloadLink()
QCOMPARE(item->totalBytes(), -1);
QCOMPARE(item->receivedBytes(), 0);
QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), expectedDownloadType(userAction, fileDisposition));
QCOMPARE(item->isSavePageDownload(), false);
QCOMPARE(item->mimeType(), QString(fileMimeTypeDetected));
QCOMPARE(QDir(item->downloadDirectory()).filePath(item->downloadFileName()), suggestedPath);
@@ -477,7 +458,6 @@ void tst_QWebEngineDownloadItem::downloadLink()
QCOMPARE(item->totalBytes(), fileContents.size());
QCOMPARE(item->receivedBytes(), fileContents.size());
QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), expectedDownloadType(userAction, fileDisposition));
QCOMPARE(item->isSavePageDownload(), false);
QCOMPARE(item->mimeType(), QString(fileMimeTypeDetected));
QCOMPARE(QDir(item->downloadDirectory()).filePath(item->downloadFileName()), downloadPath);
@@ -586,14 +566,8 @@ void tst_QWebEngineDownloadItem::downloadTwoLinks()
QCOMPARE(QDir(item->downloadDirectory()).filePath(item->downloadFileName()), standardDir + filePart);
// type() is broken due to race condition in DownloadManagerDelegateQt
- if (action1 == ClickLink && action2 == ClickLink) {
- if (filePart == QStringLiteral("/file1"))
- QCOMPARE(item->type(), expectedDownloadType(action1));
- else if (filePart == QStringLiteral("/file2"))
- QCOMPARE(item->type(), expectedDownloadType(action2, QByteArrayLiteral("attachment")));
- else
+ if (action1 == ClickLink && action2 == ClickLink && filePart != QStringLiteral("/file1") && filePart != QStringLiteral("/file2"))
QFAIL(qPrintable("Unexpected file name: " + filePart));
- }
connect(item, &QWebEngineDownloadItem::isFinishedChanged, [&]() {
finishedCount++;
@@ -663,7 +637,6 @@ void tst_QWebEngineDownloadItem::downloadPage()
QCOMPARE(item->totalBytes(), -1);
QCOMPARE(item->receivedBytes(), 0);
QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), QWebEngineDownloadItem::SavePage);
QCOMPARE(item->isSavePageDownload(), true);
// FIXME(juvaldma): why is mimeType always the same?
QCOMPARE(item->mimeType(), QStringLiteral("application/x-mimearchive"));
@@ -687,7 +660,6 @@ void tst_QWebEngineDownloadItem::downloadPage()
QCOMPARE(item->totalBytes(), item->receivedBytes());
QVERIFY(item->receivedBytes() > 0);
QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), QWebEngineDownloadItem::SavePage);
QCOMPARE(item->isSavePageDownload(), true);
QCOMPARE(item->mimeType(), QStringLiteral("application/x-mimearchive"));
QCOMPARE(QDir(item->downloadDirectory()).filePath(item->downloadFileName()), downloadPath);
@@ -924,7 +896,6 @@ void tst_QWebEngineDownloadItem::downloadUniqueFilename()
QCOMPARE(item->totalBytes(), item->receivedBytes());
QVERIFY(item->receivedBytes() > 0);
QCOMPARE(item->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(item->type(), QWebEngineDownloadItem::Attachment);
QCOMPARE(item->isSavePageDownload(), false);
downloadedFilePath = QDir(item->downloadDirectory()).filePath(item->downloadFileName());
downloadFinished = true;
@@ -1159,126 +1130,6 @@ void tst_QWebEngineDownloadItem::downloadToReadOnlyDir()
QFile(m_profile->downloadPath()).setPermissions(QFileDevice::WriteOwner);
}
-#if QT_DEPRECATED_SINCE(5, 14)
-void tst_QWebEngineDownloadItem::downloadPathValidation()
-{
- const QString fileName = "test.txt";
- QString downloadPath;
- QString originalDownloadPath;
-
- QTemporaryDir tmpDir;
- QVERIFY(tmpDir.isValid());
- m_profile->setDownloadPath(tmpDir.path());
-
- // Set up HTTP server
- ScopedConnection sc1 = connect(m_server, &HttpServer::newRequest, [&](HttpReqRep *rr) {
- auto requestPath = QString::fromUtf8(rr->requestPath());
- if (rr->requestMethod() == "GET" && requestPath == ("/" + fileName)) {
- rr->setResponseHeader(QByteArrayLiteral("content-type"), QByteArrayLiteral("application/octet-stream"));
- rr->setResponseHeader(QByteArrayLiteral("content-disposition"), QByteArrayLiteral("attachment"));
- rr->setResponseBody(QByteArrayLiteral("a"));
- rr->sendResponse();
- } else {
- rr->setResponseStatus(404);
- rr->sendResponse();
- }
- });
-
- // Set up profile and download handler
- QPointer<QWebEngineDownloadItem> downloadItem;
- ScopedConnection sc2 = connect(m_profile, &QWebEngineProfile::downloadRequested, [&](QWebEngineDownloadItem *item) {
- downloadItem = item;
- originalDownloadPath = item->path();
-
- item->setPath(downloadPath);
- item->accept();
-
- connect(item, &QWebEngineDownloadItem::stateChanged, [&, item](QWebEngineDownloadItem::DownloadState downloadState) {
- if (downloadState == QWebEngineDownloadItem::DownloadInterrupted) {
- item->cancel();
- }
- });
-
- connect(item, &QWebEngineDownloadItem::isFinishedChanged, [&, item]() {
- QCOMPARE(item->isFinished(), true);
- QCOMPARE(item->totalBytes(), item->receivedBytes());
- QVERIFY(item->receivedBytes() > 0);
- QCOMPARE(item->page(), m_page);
- });
- });
-
- QString oldPath = QDir::currentPath();
- QDir::setCurrent(tmpDir.path());
-
- // Set only the file name.
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = fileName;
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), fileName);
-
- // Set only the directory path.
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = tmpDir.path();
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), originalDownloadPath);
-
- // Set only the directory path with separator.
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = tmpDir.path() + QDir::separator();
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), originalDownloadPath);
-
- // Set only the directory with the current directory path without ending separator.
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = ".";
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), originalDownloadPath);
-
- // Set only the directory with the current directory path with ending separator.
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = "./";
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), originalDownloadPath);
-
- downloadItem.clear();
- originalDownloadPath = "";
- downloadPath = "...";
- m_page->setUrl(m_server->url("/" + fileName));
- QTRY_VERIFY(downloadItem);
-#if !defined(Q_OS_WIN)
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCancelled);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::FileFailed);
- QCOMPARE(downloadItem->path(), downloadPath);
-#else
- // Windows interprets the "..." path as a valid path. It will be the current path.
- QTRY_COMPARE(downloadItem->state(), QWebEngineDownloadItem::DownloadCompleted);
- QCOMPARE(downloadItem->interruptReason(), QWebEngineDownloadItem::NoReason);
- QCOMPARE(downloadItem->path(), originalDownloadPath);
-#endif // !defined(Q_OS_WIN)
- QDir::setCurrent(oldPath);
-}
-#endif
-
void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName_data()
{
QTest::addColumn<bool>("setDirectoryFirst");
@@ -1335,7 +1186,6 @@ void tst_QWebEngineDownloadItem::downloadToDirectoryWithFileName()
QCOMPARE(item->downloadDirectory(), downloadDirectory);
}
- QCOMPARE(item->path(), QDir(item->downloadDirectory()).filePath(item->downloadFileName()));
item->accept();
connect(item, &QWebEngineDownloadItem::isFinishedChanged, [&, item]() {