[Pkg-owncloud-commits] [owncloud-client] 106/159: LsColXMLParser: More testing 2
Sandro Knauß
hefee-guest at moszumanska.debian.org
Fri May 1 13:05:31 UTC 2015
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 2866e56c5186c19ff0d373cc624d70fb87651514
Author: Markus Goetz <markus at woboq.com>
Date: Tue Apr 14 14:56:25 2015 +0200
LsColXMLParser: More testing 2
---
src/libsync/networkjobs.cpp | 9 ++++++++-
test/testxmlparse.h | 22 ++++++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp
index 18837ea..7e92d96 100644
--- a/src/libsync/networkjobs.cpp
+++ b/src/libsync/networkjobs.cpp
@@ -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);
diff --git a/test/testxmlparse.h b/test/testxmlparse.h
index 065d5cf..add06cd 100644
--- a/test/testxmlparse.h
+++ b/test/testxmlparse.h
@@ -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 = "";
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list