Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKlaas Freitag <freitag@owncloud.com>2015-04-14 09:37:06 +0300
committerKlaas Freitag <freitag@owncloud.com>2015-04-14 14:43:05 +0300
commitd2bae21b14f1c8f1ed5c83904038d4d4cb6507e6 (patch)
tree8373dec581cc5e4818797fdf444fb24f70684de8 /test
parent4283ab3b44e8801a9707ff24baf2dd7b1d6e09b8 (diff)
Added unit test for XML Parser class.
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt2
-rw-r--r--test/testxmlparse.h125
2 files changed, 126 insertions, 1 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 62acf37c8..f1d44061b 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -32,5 +32,5 @@ owncloud_add_test(SyncJournalDB "")
owncloud_add_test(SyncFileItem "")
owncloud_add_test(ConcatUrl "")
-
+owncloud_add_test(XmlParse "")
diff --git a/test/testxmlparse.h b/test/testxmlparse.h
new file mode 100644
index 000000000..78f2db0a3
--- /dev/null
+++ b/test/testxmlparse.h
@@ -0,0 +1,125 @@
+/*
+ * This software is in the public domain, furnished "as is", without technical
+ * support, and with no warranty, express or implied, as to its usefulness for
+ * any purpose.
+ * */
+
+#ifndef MIRALL_TESTXMLPARSE_H
+#define MIRALL_TESTXMLPARSE_H
+
+#include <QtTest>
+
+#include "networkjobs.h"
+
+using namespace OCC;
+
+class TestXmlParse : public QObject
+{
+ Q_OBJECT
+
+private:
+ bool _success;
+ QStringList _subdirs;
+ QStringList _items;
+
+private slots:
+ void initTestCase() {
+ _success = false;
+ }
+
+ void cleanupTestCase() {
+ }
+
+ void slotDirectoryListingSubFolders(const QStringList& list)
+ {
+ qDebug() << "subfolders: " << list;
+ _subdirs.append(list);
+ }
+
+ void slotDirectoryListingIterated(const QString& item, const QMap<QString,QString>& )
+ {
+ qDebug() << " item: " << item;
+ _items.append(item);
+ }
+
+ void slotFinishedSuccessfully()
+ {
+ _success = true;
+ }
+
+ 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\">"
+ "<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;
+ parser.parse( testXml, &sizes );
+
+ QVERIFY(_success);
+ QVERIFY(sizes.size() == 0 ); // No quota info in the XML
+
+ QVERIFY(_items.contains("/oc/remote.php/webdav/sharefolder/quitte.pdf"));
+ QVERIFY(_items.contains("/oc/remote.php/webdav/sharefolder"));
+ QVERIFY(_items.size() == 2 );
+
+ QVERIFY(_subdirs.contains("/oc/remote.php/webdav/sharefolder/"));
+ QVERIFY(_subdirs.size() == 1);
+ }
+};
+
+#endif