mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
LsColXMLParser: More testing 2
This commit is contained in:
parent
2074bdbb19
commit
2866e56c51
@ -363,6 +363,7 @@ bool LsColXMLParser::parse( const QByteArray& xml, QHash<QString, qint64> *sizes
|
||||
bool currentPropsHaveHttp200 = false;
|
||||
bool insidePropstat = false;
|
||||
bool insideProp = false;
|
||||
bool insideMultiStatus = false;
|
||||
|
||||
while (!reader.atEnd()) {
|
||||
QXmlStreamReader::TokenType type = reader.readNext();
|
||||
@ -384,6 +385,9 @@ bool LsColXMLParser::parse( const QByteArray& xml, QHash<QString, qint64> *sizes
|
||||
} else if (name == QLatin1String("prop")) {
|
||||
insideProp = true;
|
||||
continue;
|
||||
} else if (name == QLatin1String("multistatus")) {
|
||||
insideMultiStatus = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -428,7 +432,10 @@ bool LsColXMLParser::parse( const QByteArray& xml, QHash<QString, qint64> *sizes
|
||||
|
||||
if (reader.hasError()) {
|
||||
// XML Parser error? Whatever had been emitted before will come as directoryListingIterated
|
||||
qDebug() << "ERROR" << reader.errorString();
|
||||
qDebug() << "ERROR" << reader.errorString() << xml;
|
||||
return false;
|
||||
} else if (!insideMultiStatus) {
|
||||
qDebug() << "ERROR no WebDAV response?" << xml;
|
||||
return false;
|
||||
} else {
|
||||
emit directoryListingSubfolders(folders);
|
||||
|
||||
@ -197,6 +197,28 @@ private slots:
|
||||
QVERIFY(_subdirs.size() == 0);
|
||||
}
|
||||
|
||||
void testParserEmptyXmlNoDav() {
|
||||
const QByteArray testXml = "<html><body>I am under construction</body></html>";
|
||||
|
||||
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 = "";
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user