mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 13:05:51 +03:00
LsColXMLParser: More testing
This commit is contained in:
parent
d212ac7d16
commit
2074bdbb19
1 changed files with 116 additions and 18 deletions
|
@ -22,14 +22,7 @@ private:
|
|||
QStringList _subdirs;
|
||||
QStringList _items;
|
||||
|
||||
private slots:
|
||||
void initTestCase() {
|
||||
_success = false;
|
||||
}
|
||||
|
||||
void cleanupTestCase() {
|
||||
}
|
||||
|
||||
public slots:
|
||||
void slotDirectoryListingSubFolders(const QStringList& list)
|
||||
{
|
||||
qDebug() << "subfolders: " << list;
|
||||
|
@ -47,6 +40,18 @@ private slots:
|
|||
_success = true;
|
||||
}
|
||||
|
||||
private slots:
|
||||
void init() {
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
_success = false;
|
||||
_subdirs.clear();
|
||||
_items.clear();
|
||||
}
|
||||
|
||||
void cleanup() {
|
||||
}
|
||||
|
||||
|
||||
void testParser1() {
|
||||
const QByteArray testXml = "<?xml version='1.0' encoding='utf-8'?>"
|
||||
"<d:multistatus xmlns:d=\"DAV:\" xmlns:s=\"http://sabredav.org/ns\" xmlns:oc=\"http://owncloud.org/ns\">"
|
||||
|
@ -120,6 +125,99 @@ private slots:
|
|||
QVERIFY(_subdirs.contains("/oc/remote.php/webdav/sharefolder/"));
|
||||
QVERIFY(_subdirs.size() == 1);
|
||||
}
|
||||
|
||||
void testParserBrokenXml() {
|
||||
const QByteArray testXml = "X<?xml version='1.0' encoding='utf-8'?>"
|
||||
"<d:multistatus xmlns:d=\"DAV:\" xmlns:s=\"http://sabredav.org/ns\" xmlns:oc=\"http://owncloud.org/ns\">"
|
||||
"<d:response>"
|
||||
"<d:href>/oc/remote.php/webdav/sharefolder/</d:href>"
|
||||
"<d:propstat>"
|
||||
"<d:prop>"
|
||||
"<oc:id>00004213ocobzus5kn6s</oc:id>"
|
||||
"<oc:permissions>RDNVCK</oc:permissions>"
|
||||
"<oc:size>121780</oc:size>"
|
||||
"<d:getetag>\"5527beb0400b0\"</d:getetag>"
|
||||
"<d:resourcetype>"
|
||||
"<d:collection/>"
|
||||
"</d:resourcetype>"
|
||||
"<d:getlastmodified>Fri, 06 Feb 2015 13:49:55 GMT</d:getlastmodified>"
|
||||
"</d:prop>"
|
||||
"<d:status>HTTP/1.1 200 OK</d:status>"
|
||||
"</d:propstat>"
|
||||
"<d:propstat>"
|
||||
"<d:prop>"
|
||||
"<d:getcontentlength/>"
|
||||
"<oc:downloadURL/>"
|
||||
"<oc:dDC/>"
|
||||
"</d:prop>"
|
||||
"<d:status>HTTP/1.1 404 Not Found</d:status>"
|
||||
"</d:propstat>"
|
||||
"</d:response>"
|
||||
"<d:response>"
|
||||
"<d:href>/oc/remote.php/webdav/sharefolder/quitte.pdf</d:href>"
|
||||
"<d:propstat>"
|
||||
"<d:prop>"
|
||||
"<oc:id>00004215ocobzus5kn6s</oc:id>"
|
||||
"<oc:permissions>RDNVW</oc:permissions>"
|
||||
"<d:getetag>\"2fa2f0d9ed49ea0c3e409d49e652dea0\"</d:getetag>"
|
||||
"<d:resourcetype/>"
|
||||
"<d:getlastmodified>Fri, 06 Feb 2015 13:49:55 GMT</d:getlastmodified>"
|
||||
"<d:getcontentlength>121780</d:getcontentlength>"
|
||||
"</d:prop>"
|
||||
"<d:status>HTTP/1.1 200 OK</d:status>"
|
||||
"</d:propstat>"
|
||||
"<d:propstat>"
|
||||
"<d:prop>"
|
||||
"<oc:downloadURL/>"
|
||||
"<oc:dDC/>"
|
||||
"</d:prop>"
|
||||
"<d:status>HTTP/1.1 404 Not Found</d:status>"
|
||||
"</d:propstat>"
|
||||
"</d:response>"
|
||||
"</d:multistatus>";
|
||||
|
||||
|
||||
LsColXMLParser parser;
|
||||
|
||||
connect( &parser, SIGNAL(directoryListingSubfolders(const QStringList&)),
|
||||
this, SLOT(slotDirectoryListingSubFolders(const QStringList&)) );
|
||||
connect( &parser, SIGNAL(directoryListingIterated(const QString&, const QMap<QString,QString>&)),
|
||||
this, SLOT(slotDirectoryListingIterated(const QString&, const QMap<QString,QString>&)) );
|
||||
connect( &parser, SIGNAL(finishedWithoutError()),
|
||||
this, SLOT(slotFinishedSuccessfully()) );
|
||||
|
||||
QHash <QString, qint64> sizes;
|
||||
QVERIFY(false == parser.parse( testXml, &sizes )); // verify false
|
||||
|
||||
QVERIFY(!_success);
|
||||
QVERIFY(sizes.size() == 0 ); // No quota info in the XML
|
||||
|
||||
QVERIFY(_items.size() == 0 ); // FIXME: We should change the parser to not emit during parsing but at the end
|
||||
|
||||
QVERIFY(_subdirs.size() == 0);
|
||||
}
|
||||
|
||||
void testParserEmptyXml() {
|
||||
const QByteArray testXml = "";
|
||||
|
||||
LsColXMLParser parser;
|
||||
|
||||
connect( &parser, SIGNAL(directoryListingSubfolders(const QStringList&)),
|
||||
this, SLOT(slotDirectoryListingSubFolders(const QStringList&)) );
|
||||
connect( &parser, SIGNAL(directoryListingIterated(const QString&, const QMap<QString,QString>&)),
|
||||
this, SLOT(slotDirectoryListingIterated(const QString&, const QMap<QString,QString>&)) );
|
||||
connect( &parser, SIGNAL(finishedWithoutError()),
|
||||
this, SLOT(slotFinishedSuccessfully()) );
|
||||
|
||||
QHash <QString, qint64> sizes;
|
||||
QVERIFY(false == parser.parse( testXml, &sizes )); // verify false
|
||||
|
||||
QVERIFY(!_success);
|
||||
QVERIFY(sizes.size() == 0 ); // No quota info in the XML
|
||||
|
||||
QVERIFY(_items.size() == 0 ); // FIXME: We should change the parser to not emit during parsing but at the end
|
||||
QVERIFY(_subdirs.size() == 0);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue