diff options
author | Robin Burchell <robin.burchell@jollamobile.com> | 2013-12-03 11:23:17 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-03 12:46:21 +0100 |
commit | c8f86040f6163710aff986446766acb69d1cb92a (patch) | |
tree | 5d5d45249a7cf2b10619dfd0c6da1a708f2e7b4d /tests | |
parent | f93c49b9a7d1e6e48a4ebe3cb0a5ee2c6aec1727 (diff) |
Fix DocumentGallery returning encoded urls.
Tracker stores url properties in encoded form, these need to be
decoded before they are returned and encoded when used in queries.
Cherry pick of c4a36f94bd50d0236aaa7bddbe72bc7e0fbdac4f from
qt-mobility.
Change-Id: I8075490d6079311b94fe1234857a69af88218dc6
Reviewed-by: Marko Mattila <marko.mattila@jollamobile.com>
Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgallerytrackerschema_tracker/tst_qgallerytrackerschema.cpp | 95 |
1 files changed, 86 insertions, 9 deletions
diff --git a/tests/auto/qgallerytrackerschema_tracker/tst_qgallerytrackerschema.cpp b/tests/auto/qgallerytrackerschema_tracker/tst_qgallerytrackerschema.cpp index 1c937ee..7d9c14e 100644 --- a/tests/auto/qgallerytrackerschema_tracker/tst_qgallerytrackerschema.cpp +++ b/tests/auto/qgallerytrackerschema_tracker/tst_qgallerytrackerschema.cpp @@ -101,6 +101,8 @@ private Q_SLOTS: void queryResponseRootItem(); void queryResponseFilter_data(); void queryResponseFilter(); + void queryResponseItemUrl_data(); + void queryResponseItemUrl(); void queryResponseValueColumnToVariant_data(); void queryResponseValueColumnToVariant(); void queryResponseValueColumnToString_data(); @@ -495,7 +497,7 @@ void tst_QGalleryTrackerSchema::prepareValidItemResponse_data() << QStringList() << (QVector<QVariant>() << QLatin1String("uuid:ff172362-d959-99e0-a792-0ddafdd2c559") - << QLatin1String("file:///path/to/file.ext") + << QUrl(QLatin1String("file:///path/to/file.ext")) << 0) << QVariant(QUrl(QLatin1String("file:///path/to/file.ext"))) << QVariant(QLatin1String("File")) @@ -620,7 +622,7 @@ void tst_QGalleryTrackerSchema::queryResponseRootType_data() << 1 << (QVector<QVariant>() << QLatin1String("uuid:ff172362-d959-99e0-a792-0ddafdd2c559") - << QLatin1String("file:///path/to/file.ext") + << QUrl(QLatin1String("file:///path/to/file.ext")) << 0) << "file::uuid:ff172362-d959-99e0-a792-0ddafdd2c559" << QVariant(QUrl(QLatin1String("file:///path/to/file.ext"))) @@ -635,7 +637,7 @@ void tst_QGalleryTrackerSchema::queryResponseRootType_data() << 1 << (QVector<QVariant>() << QLatin1String("uuid:ff172362-d959-99e0-a792-0ddafdd2c559") - << QLatin1String("file:///path/to/image.png") + << QUrl(QLatin1String("file:///path/to/image.png")) << 4) << "image::uuid:ff172362-d959-99e0-a792-0ddafdd2c559" << QVariant(QUrl(QLatin1String("file:///path/to/image.png"))) @@ -650,7 +652,7 @@ void tst_QGalleryTrackerSchema::queryResponseRootType_data() << 1 << (QVector<QVariant>() << QLatin1String("uuid:ff172362-d959-99e0-a792-0ddafdd2c559") - << QLatin1String("file:///path/to/text.txt") + << QUrl(QLatin1String("file:///path/to/text.txt")) << 7) << "text::uuid:ff172362-d959-99e0-a792-0ddafdd2c559" << QVariant(QUrl(QLatin1String("file:///path/to/text.txt"))) @@ -1729,6 +1731,21 @@ void tst_QGalleryTrackerSchema::queryResponseFilter_data() "} " "GROUP BY ?x"; } { + QGalleryFilter filter + = QDocumentGallery::url == QUrl::fromLocalFile(QString::fromUtf8("/path/to/K\xc3\xa4rp\xc3\xa4ssieni.jpg")); + + QTest::newRow("File.url == file:///path/to/K\xc3\xa4rp\xc3\xa4ssieni.jpg") + << "File" + << QString() + << QGalleryQueryRequest::AllDescendants + << filter + << "SELECT ?x nie:url(?x) rdf:type(?x) " + "WHERE {" + "{?x rdf:type nfo:FileDataObject}" + "FILTER((nie:url(?x)='file:///path/to/K%C3%A4rp%C3%A4ssieni.jpg'))" + "} " + "GROUP BY ?x"; + } { QGalleryFilter filter = QDocumentGallery::filePath == QLatin1String("/path/to/file.ext"); QTest::newRow("File.filePath == /path/to/file.ext") @@ -1743,6 +1760,21 @@ void tst_QGalleryTrackerSchema::queryResponseFilter_data() "} " "GROUP BY ?x"; } { + QGalleryFilter filter + = QDocumentGallery::filePath == QString::fromUtf8("/path/to/K\xc3\xa4rp\xc3\xa4ssieni.jpg"); + + QTest::newRow("File.filePath == /path/to/K\xc3\xa4rp\xc3\xa4ssieni.jpg") + << "File" + << QString() + << QGalleryQueryRequest::AllDescendants + << filter + << "SELECT ?x nie:url(?x) rdf:type(?x) " + "WHERE {" + "{?x rdf:type nfo:FileDataObject}" + "FILTER((nie:url(?x)='file:///path/to/K%C3%A4rp%C3%A4ssieni.jpg'))" + "} " + "GROUP BY ?x"; + } { QGalleryFilter filter = QDocumentGallery::filePath > QLatin1String("/path/to/file.ext"); QTest::newRow("File.filePath > /path/to/file.ext") @@ -2290,6 +2322,51 @@ void tst_QGalleryTrackerSchema::queryResponseFilter() QCOMPARE(arguments.sparql, sparql); } + +void tst_QGalleryTrackerSchema::queryResponseItemUrl_data() +{ + QTest::addColumn<QString>("rootType"); + QTest::addColumn<QByteArray>("encodedUrl"); + QTest::addColumn<QUrl>("url"); + + QTest::newRow("File ascii") + << "File" + << QByteArray("file://path/to/file.ext") + << QUrl(QLatin1String("file://path/to/file.ext")); + + QTest::newRow("Image encoded") + << "Image" + << QByteArray("file://path/to/K%C3%A4rp%C3%A4ssieni.jpg") + << QUrl(QString::fromUtf8("file://path/to/K\xc3\xa4rp\xc3\xa4ssieni.jpg")); +} + +void tst_QGalleryTrackerSchema::queryResponseItemUrl() +{ + QFETCH(QString, rootType); + QFETCH(QByteArray, encodedUrl); + QFETCH(QUrl, url); + + QGalleryTrackerResultSetArguments arguments; + + QGalleryTrackerSchema schema(rootType); + + QCOMPARE( + schema.prepareQueryResponse( + &arguments, + this, + QGalleryQueryRequest::AllDescendants, + QString(), + QGalleryFilter(), + QStringList(), + QStringList(), + 0, + 0), + QDocumentGallery::NoError); + + QCOMPARE(arguments.valueColumns.count(), 3); + QCOMPARE(arguments.valueColumns.at(1)->toVariant(encodedUrl).toUrl(), url); +} + void tst_QGalleryTrackerSchema::queryResponseValueColumnToVariant_data() { QTest::addColumn<QString>("rootType"); @@ -2566,7 +2643,7 @@ void tst_QGalleryTrackerSchema::queryResponseCompositeColumn_data() << QString::fromLatin1("filePath") << (QVector<QVariant>() << QLatin1String("uuid:ff172362-d959-99e0-a792-0ddafdd2c559") - << QLatin1String("file:///path/to/file.ext") + << QUrl(QLatin1String("file:///path/to/file.ext")) << QLatin1String("Files")) << QVariant(QLatin1String("/path/to/file.ext")); @@ -2575,7 +2652,7 @@ void tst_QGalleryTrackerSchema::queryResponseCompositeColumn_data() << QString::fromLatin1("path") << (QVector<QVariant>() << QLatin1String("uuid:ff172362-d959-99e0-a792-0ddafdd2c559") - << QLatin1String("file:///path/to/file.ext") + << QUrl(QLatin1String("file:///path/to/file.ext")) << QLatin1String("Files")) << QVariant(QLatin1String("/path/to")); @@ -2584,7 +2661,7 @@ void tst_QGalleryTrackerSchema::queryResponseCompositeColumn_data() << QString::fromLatin1("path") << (QVector<QVariant>() << QLatin1String("uuid:ff172362-d959-99e0-a792-0ddafdd2c559") - << QLatin1String("file:///path/to/") + << QUrl(QLatin1String("file:///path/to/")) << QLatin1String("Files")) << QVariant(QLatin1String("/path/to")); @@ -2593,7 +2670,7 @@ void tst_QGalleryTrackerSchema::queryResponseCompositeColumn_data() << QString::fromLatin1("fileExtension") << (QVector<QVariant>() << QLatin1String("uuid:ff172362-d959-99e0-a792-0ddafdd2c559") - << QLatin1String("file:///path/to/file.ext") + << QUrl(QLatin1String("file:///path/to/file.ext")) << QLatin1String("Files")) << QVariant(QLatin1String("ext")); @@ -2603,7 +2680,7 @@ void tst_QGalleryTrackerSchema::queryResponseCompositeColumn_data() << QString::fromLatin1("fileExtension") << (QVector<QVariant>() << QLatin1String("uuid:ff172362-d959-99e0-a792-0ddafdd2c559") - << QLatin1String("file:///path/to") + << QUrl(QLatin1String("file:///path/to")) << QLatin1String("Files")) << QVariant(); } |