diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2016-11-10 17:10:20 +0100 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2016-11-11 13:39:59 +0000 |
commit | e83c722db43351329e451e84420a6b69591bc076 (patch) | |
tree | 1bac6d506b8e87fdf269a548c19a2bbbed608c26 /tests/auto | |
parent | c27374541e289962df6947967b97178bfa63e9f7 (diff) |
Make view source working with qrc URLs
Task-number: QTBUG-56353
Change-Id: I9c5dc3a6ba4e6b08ecbb4e44d38a53d24010807b
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 166c5a499..99905a712 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -4992,6 +4992,8 @@ void tst_QWebEnginePage::viewSource() QCOMPARE(page.createdWindows.size(), 1); QTRY_COMPARE(page.createdWindows[0]->url().toString(), QStringLiteral("view-source:%1").arg(url.toString())); + // The requested URL should not be about:blank if the qrc scheme is supported + QTRY_COMPARE(page.createdWindows[0]->requestedUrl(), url); QTRY_COMPARE(page.createdWindows[0]->title(), QStringLiteral("view-source:%1").arg(url.toString())); QVERIFY(!page.createdWindows[0]->action(QWebEnginePage::ViewSource)->isEnabled()); } @@ -5001,21 +5003,24 @@ void tst_QWebEnginePage::viewSourceURL_data() QTest::addColumn<QUrl>("userInputUrl"); QTest::addColumn<bool>("loadSucceed"); QTest::addColumn<QUrl>("url"); + QTest::addColumn<QUrl>("requestedUrl"); QTest::addColumn<QString>("title"); - QTest::newRow("view-source:") << QUrl("view-source:") << true << QUrl("view-source:") << QString("view-source:"); - QTest::newRow("view-source:about:blank") << QUrl("view-source:about:blank") << true << QUrl("view-source:about:blank") << QString("view-source:about:blank"); + QTest::newRow("view-source:") << QUrl("view-source:") << true << QUrl("view-source:") << QUrl("about:blank") << QString("view-source:"); + QTest::newRow("view-source:about:blank") << QUrl("view-source:about:blank") << true << QUrl("view-source:about:blank") << QUrl("about:blank") << QString("view-source:about:blank"); - QUrl testLocalUrl = QUrl(QString("view-source:%1").arg(QUrl::fromLocalFile(TESTS_SOURCE_DIR + QLatin1String("qwebenginepage/resources/test1.html")).toString())); - QUrl testLocalUrlWithoutScheme = QUrl(QString("view-source:%1").arg(TESTS_SOURCE_DIR + QLatin1String("qwebenginepage/resources/test1.html"))); - QTest::newRow(testLocalUrl.toString().toStdString().c_str()) << testLocalUrl << true << testLocalUrl << QString("test1.html"); - QTest::newRow(testLocalUrlWithoutScheme.toString().toStdString().c_str()) << testLocalUrlWithoutScheme << true << testLocalUrl << QString("test1.html"); + QString localFilePath = QString("%1qwebenginepage/resources/test1.html").arg(TESTS_SOURCE_DIR); + QUrl testLocalUrl = QUrl(QString("view-source:%1").arg(QUrl::fromLocalFile(localFilePath).toString())); + QUrl testLocalUrlWithoutScheme = QUrl(QString("view-source:%1").arg(localFilePath)); + QTest::newRow(testLocalUrl.toString().toStdString().c_str()) << testLocalUrl << true << testLocalUrl << QUrl::fromLocalFile(localFilePath) << QString("test1.html"); + QTest::newRow(testLocalUrlWithoutScheme.toString().toStdString().c_str()) << testLocalUrlWithoutScheme << true << testLocalUrl << QUrl::fromLocalFile(localFilePath) << QString("test1.html"); - QUrl testResourceUrl = QUrl("view-source:qrc:/resources/test1.html"); - QTest::newRow(testResourceUrl.toString().toStdString().c_str()) << testResourceUrl << true << testResourceUrl << testResourceUrl.toString(); + QString resourcePath = QLatin1String("qrc:/resources/test1.html"); + QUrl testResourceUrl = QUrl(QString("view-source:%1").arg(resourcePath)); + QTest::newRow(testResourceUrl.toString().toStdString().c_str()) << testResourceUrl << true << testResourceUrl << QUrl(resourcePath) << testResourceUrl.toString(); - QTest::newRow("view-source:http://non.existent") << QUrl("view-source:non.existent") << false << QUrl("view-source:http://non.existent/") << QString("http://non.existent/ is not available"); - QTest::newRow("view-source:non.existent") << QUrl("view-source:non.existent") << false << QUrl("view-source:http://non.existent/") << QString("http://non.existent/ is not available"); + QTest::newRow("view-source:http://non.existent") << QUrl("view-source:non.existent") << false << QUrl("view-source:http://non.existent/") << QUrl("http://non.existent/") << QString("http://non.existent/ is not available"); + QTest::newRow("view-source:non.existent") << QUrl("view-source:non.existent") << false << QUrl("view-source:http://non.existent/") << QUrl("http://non.existent/") << QString("http://non.existent/ is not available"); } void tst_QWebEnginePage::viewSourceURL() @@ -5026,6 +5031,7 @@ void tst_QWebEnginePage::viewSourceURL() QFETCH(QUrl, userInputUrl); QFETCH(bool, loadSucceed); QFETCH(QUrl, url); + QFETCH(QUrl, requestedUrl); QFETCH(QString, title); QWebEnginePage *page = new QWebEnginePage; @@ -5037,6 +5043,7 @@ void tst_QWebEnginePage::viewSourceURL() QCOMPARE(arguments.at(0).toBool(), loadSucceed); QCOMPARE(page->url(), url); + QCOMPARE(page->requestedUrl(), requestedUrl); QCOMPARE(page->title(), title); QVERIFY(!page->action(QWebEnginePage::ViewSource)->isEnabled()); |