diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-12-20 04:30:27 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-12-20 04:36:15 (GMT) |
commit | 327169a6a3fb0bac258cb878019734211a707cce (patch) | |
tree | c807253dfcbeedb358b059a63c3170f7e56348a8 /tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp | |
parent | 0aeebdc851682d2afd63494ddeafa4e745ad2b72 (diff) | |
download | Qt-327169a6a3fb0bac258cb878019734211a707cce.zip Qt-327169a6a3fb0bac258cb878019734211a707cce.tar.gz Qt-327169a6a3fb0bac258cb878019734211a707cce.tar.bz2 |
Don't truncate image:// url strings prematurely
Url fragments and queries were being removed from the image ids
passed to QDeclarativeImageProvider.
Task-number: QTBUG-16195
Reviewed-by: Martin Jones
Diffstat (limited to 'tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp')
-rw-r--r-- | tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp index cd12e3a..5b214e6 100644 --- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp +++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp @@ -100,6 +100,8 @@ public: QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) { + lastImageId = id; + if (id == QLatin1String("no-such-file.png")) return QImage(); @@ -114,6 +116,7 @@ public: } bool *deleteWatch; + QString lastImageId; }; Q_DECLARE_METATYPE(TestQImageProvider*); @@ -134,6 +137,8 @@ public: QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize) { + lastImageId = id; + if (id == QLatin1String("no-such-file.png")) return QPixmap(); @@ -148,6 +153,7 @@ public: } bool *deleteWatch; + QString lastImageId; }; Q_DECLARE_METATYPE(TestQPixmapProvider*); @@ -164,22 +170,49 @@ QString tst_qdeclarativeimageprovider::newImageFileName() const void tst_qdeclarativeimageprovider::fillRequestTestsData(const QString &id) { QTest::addColumn<QString>("source"); + QTest::addColumn<QString>("imageId"); QTest::addColumn<QString>("properties"); QTest::addColumn<QSize>("size"); QTest::addColumn<QString>("error"); - QTest::newRow(QTest::toString(id + " exists")) << newImageFileName() << "" << QSize(100,100) << ""; - QTest::newRow(QTest::toString(id + " scaled")) << newImageFileName() << "sourceSize: \"80x30\"" << QSize(80,30) << ""; + QString fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " simple test")) + << "image://test/" + fileName << fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with no id")) + << "image://test/" + fileName << "" + fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with path")) + << "image://test/test/path" + fileName << "test/path" + fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with fragment")) + << "image://test/faq.html?#question13" + fileName << "faq.html?#question13" + fileName << "" << QSize(100,100) << ""; - QTest::newRow(QTest::toString(id + " missing")) << "image://test/no-such-file.png" << "" << QSize() + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with query")) + << "image://test/cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName << "cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName + << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " scaled image")) + << "image://test/" + fileName << fileName << "sourceSize: \"80x30\"" << QSize(80,30) << ""; + + QTest::newRow(QTest::toString(id + " missing")) + << "image://test/no-such-file.png" << "no-such-file.png" << "" << QSize(100,100) << "file::2:1: QML Image: Failed to get image from provider: image://test/no-such-file.png"; - QTest::newRow(QTest::toString(id + " unknown provider")) << "image://bogus/exists.png" << "" << QSize() + + QTest::newRow(QTest::toString(id + " unknown provider")) + << "image://bogus/exists.png" << "" << "" << QSize() << "file::2:1: QML Image: Failed to get image from provider: image://bogus/exists.png"; } void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvider *provider) { QFETCH(QString, source); + QFETCH(QString, imageId); QFETCH(QString, properties); QFETCH(QSize, size); QFETCH(QString, error); @@ -210,6 +243,11 @@ void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvide QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); else QVERIFY(obj->status() == QDeclarativeImage::Ready); + if (QByteArray(QTest::currentDataTag()).startsWith("qimage")) + QCOMPARE(static_cast<TestQImageProvider*>(provider)->lastImageId, imageId); + else + QCOMPARE(static_cast<TestQPixmapProvider*>(provider)->lastImageId, imageId); + QCOMPARE(obj->width(), qreal(size.width())); QCOMPARE(obj->height(), qreal(size.height())); QCOMPARE(obj->pixmap().width(), size.width()); |