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 Pick-to: 6.5 6.4 6.2 Change-Id: Ibcf687c69b3e53a10f21d718d28c8177a02d6be6 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
d8e213a9e6
commit
c9cf4037ca
@ -14,3 +14,10 @@ qt_internal_add_test(tst_qtextimagehandler
|
||||
TESTDATA
|
||||
${test_data}
|
||||
)
|
||||
|
||||
qt_internal_add_resource(tst_qtextimagehandler "qtextimagehandler"
|
||||
PREFIX
|
||||
"/"
|
||||
FILES
|
||||
${test_data}
|
||||
)
|
||||
|
@ -42,6 +42,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()
|
||||
@ -68,6 +71,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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user