diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp | 21 | ||||
-rw-r--r-- | tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 19 |
2 files changed, 36 insertions, 4 deletions
diff --git a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp index 7094c8e4b..83e8d1101 100644 --- a/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp +++ b/tests/auto/widgets/qwebenginedownloads/tst_qwebenginedownloads.cpp @@ -431,6 +431,13 @@ void tst_QWebEngineDownloads::downloadLink() void tst_QWebEngineDownloads::downloadTwoLinks() { HttpServer server; + QSignalSpy requestSpy(&server, &HttpServer::newRequest); + QList<HttpReqRep*> results; + connect(&server, &HttpServer::newRequest, [&](HttpReqRep *rr) { + rr->setParent(nullptr); + results.append(rr); + }); + QWebEngineProfile profile; QWebEnginePage page(&profile); QWebEngineView view; @@ -438,7 +445,8 @@ void tst_QWebEngineDownloads::downloadTwoLinks() view.load(server.url()); view.show(); - auto indexRR = waitForRequest(&server); + QTRY_COMPARE(requestSpy.count(), 1); + std::unique_ptr<HttpReqRep> indexRR(results.takeFirst()); QVERIFY(indexRR); QCOMPARE(indexRR->requestMethod(), QByteArrayLiteral("GET")); QCOMPARE(indexRR->requestPath(), QByteArrayLiteral("/")); @@ -449,19 +457,24 @@ void tst_QWebEngineDownloads::downloadTwoLinks() QVERIFY(waitForSignal(&page, &QWebEnginePage::loadFinished, [&](bool ok){ loadOk = ok; })); QVERIFY(loadOk); - auto favIconRR = waitForFaviconRequest(&server); + QTRY_COMPARE(requestSpy.count(), 2); + std::unique_ptr<HttpReqRep> favIconRR(results.takeFirst()); QVERIFY(favIconRR); + favIconRR->setResponseStatus(404); + favIconRR->sendResponse(); QTRY_VERIFY(view.focusWidget()); QWidget *renderWidget = view.focusWidget(); QTest::mouseClick(renderWidget, Qt::LeftButton, {}, QPoint(10, 10)); QTest::mouseClick(renderWidget, Qt::LeftButton, {}, QPoint(10, 30)); - auto file1RR = waitForRequest(&server); + QTRY_VERIFY(requestSpy.count() >= 3); + std::unique_ptr<HttpReqRep> file1RR(results.takeFirst()); QVERIFY(file1RR); QCOMPARE(file1RR->requestMethod(), QByteArrayLiteral("GET")); QCOMPARE(file1RR->requestPath(), QByteArrayLiteral("/file1")); - auto file2RR = waitForRequest(&server); + QTRY_COMPARE(requestSpy.count(), 4); + std::unique_ptr<HttpReqRep> file2RR(results.takeFirst()); QVERIFY(file2RR); QCOMPARE(file2RR->requestMethod(), QByteArrayLiteral("GET")); QCOMPARE(file2RR->requestPath(), QByteArrayLiteral("/file2")); diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 1c9b668ae..54cf27066 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -29,6 +29,7 @@ #include <QMainWindow> #include <QMenu> #include <QMimeDatabase> +#include <QNetworkProxy> #include <QOpenGLWidget> #include <QPaintEngine> #include <QPushButton> @@ -215,6 +216,7 @@ private Q_SLOTS: void viewSource(); void viewSourceURL_data(); void viewSourceURL(); + void proxyConfigWithUnexpectedHostPortPair(); private: static QPoint elementCenter(QWebEnginePage *page, const QString &id); @@ -4528,6 +4530,23 @@ void tst_QWebEnginePage::viewSourceURL() QVERIFY(!page.action(QWebEnginePage::ViewSource)->isEnabled()); } +Q_DECLARE_METATYPE(QNetworkProxy::ProxyType); + +void tst_QWebEnginePage::proxyConfigWithUnexpectedHostPortPair() +{ + // Chromium expects a proxy of type NoProxy to not have a host or port set. + + QNetworkProxy proxy; + proxy.setType(QNetworkProxy::NoProxy); + proxy.setHostName(QStringLiteral("127.0.0.1")); + proxy.setPort(244); + QNetworkProxy::setApplicationProxy(proxy); + + QSignalSpy loadFinishedSpy(m_page, SIGNAL(loadFinished(bool))); + m_page->load(QStringLiteral("http://127.0.0.1:245/")); + QTRY_COMPARE(loadFinishedSpy.count(), 1); +} + static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")}; W_QTEST_MAIN(tst_QWebEnginePage, params) |