diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-12-21 14:30:36 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-12-22 23:20:27 +0100 |
commit | 1197590299fa9ee4ea23dbd2497e35b1979279b4 (patch) | |
tree | df1650a9790654aacff8e431e0cf808d79fce84e /tests | |
parent | 1a37fd3148fa623b6855992ffe67a4d84671e242 (diff) |
QTextImageHandler: Add test coverage for resources and URLs
If an image source in HTML is specified via local file name or resource
path (i.e. without qrc prefix), then the correct image is loaded.
With file:/ or qrc:/ schema however, the image is either not loaded at
all, or the 2x image is not loaded. The qt_findAtNxFile helper in
qicon.cpp gets a URL path, but expects a file path (that can be tested
with QFile::exists).
Task-number: QTBUG-109212
Change-Id: Ibcf687c69b3e53a10f21d718d28c8177a02d6be6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit c9cf4037cafe22aa20cfea6efe1c6a4c7211d21f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gui/text/qtextimagehandler/CMakeLists.txt | 7 | ||||
-rw-r--r-- | tests/auto/gui/text/qtextimagehandler/tst_qtextimagehandler.cpp | 10 |
2 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qtextimagehandler/CMakeLists.txt b/tests/auto/gui/text/qtextimagehandler/CMakeLists.txt index c9d20fe956..45feab12f1 100644 --- a/tests/auto/gui/text/qtextimagehandler/CMakeLists.txt +++ b/tests/auto/gui/text/qtextimagehandler/CMakeLists.txt @@ -14,3 +14,10 @@ qt_internal_add_test(tst_qtextimagehandler TESTDATA ${test_data} ) + +qt_internal_add_resource(tst_qtextimagehandler "qtextimagehandler" + PREFIX + "/" + FILES + ${test_data} +) diff --git a/tests/auto/gui/text/qtextimagehandler/tst_qtextimagehandler.cpp b/tests/auto/gui/text/qtextimagehandler/tst_qtextimagehandler.cpp index 1863c3eeb7..fc8900f94f 100644 --- a/tests/auto/gui/text/qtextimagehandler/tst_qtextimagehandler.cpp +++ b/tests/auto/gui/text/qtextimagehandler/tst_qtextimagehandler.cpp @@ -67,6 +67,9 @@ void tst_QTextImageHandler::loadAtNImages_data() QTest::addColumn<QString>("imageFile"); QTest::addRow("file") << QFINDTESTDATA("data/image.png"); + QTest::addRow("file_url") << QString("file:/") + QFINDTESTDATA("data/image.png"); + QTest::addRow("resource") << ":/data/image.png"; + QTest::addRow("qrc_url") << "qrc:/data/image.png"; } void tst_QTextImageHandler::loadAtNImages() @@ -93,6 +96,13 @@ void tst_QTextImageHandler::loadAtNImages() p.end(); QVERIFY(!img.isNull()); const auto expectedColor = dpr == 1 ? Qt::red : Qt::green; +#ifdef Q_OS_ANDROID // On Android, file:/ fails completely + QEXPECT_FAIL("file_url", "file:/ schema not handled - QTBUG-109212", Continue); +#else + if (dpr != 1) + QEXPECT_FAIL("file_url", "Nx images not resolved for file:/ schema - QTBUG-109212", Continue); +#endif + QEXPECT_FAIL("qrc_url", "qrc:/ schema not handled - QTBUG-109212", Continue); QCOMPARE(img.pixelColor(0, 0), expectedColor); } } |