From 0696071316b3dacb8d1ca15a269e4f4215642b9d Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Wed, 18 Jan 2012 21:28:31 +0100 Subject: Remove dependency of QtDBus onto QtXml Replace the QDom based code in qdbusxmlparser with code using QXmlStreamReader. Task-number: QTBUG-20856 Change-Id: I294e3ebd6faa813c20806be3ae225ac00befb622 Reviewed-by: Thiago Macieira --- .../dbus/qdbusinterface/tst_qdbusinterface.cpp | 2 +- .../dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp | 138 +++++---------------- 2 files changed, 35 insertions(+), 105 deletions(-) (limited to 'tests') diff --git a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp index dc8363db42..44f1b1cfa7 100644 --- a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp @@ -46,7 +46,7 @@ #include #include #include - +#include #include "../qdbusmarshall/common.h" #include "myobject.h" diff --git a/tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp b/tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp index 42a3fd19cc..dad8c6d577 100644 --- a/tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp +++ b/tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp @@ -61,9 +61,6 @@ private slots: void parsingWithDoctype_data(); void parsingWithDoctype(); - void objectWithContent_data(); - void objectWithContent(); - void methods_data(); void methods(); void signals__data(); @@ -77,40 +74,49 @@ void tst_QDBusXmlParser::parsing_data() QTest::addColumn("xmlData"); QTest::addColumn("interfaceCount"); QTest::addColumn("objectCount"); + QTest::addColumn("annotationCount"); - QTest::newRow("null") << QString() << 0 << 0; - QTest::newRow("empty") << QString("") << 0 << 0; + QTest::newRow("null") << QString() << 0 << 0 << 0; + QTest::newRow("empty") << QString("") << 0 << 0 << 0; - QTest::newRow("junk") << "" << 0 << 0; + QTest::newRow("junk") << "" << 0 << 0 << 0; QTest::newRow("interface-inside-junk") << "" - << 0 << 0; + << 0 << 0 << 0; QTest::newRow("object-inside-junk") << "" - << 0 << 0; + << 0 << 0 << 0; - QTest::newRow("zero-interfaces") << "" << 0 << 0; - QTest::newRow("one-interface") << "" << 1 << 0; + QTest::newRow("zero-interfaces") << "" << 0 << 0 << 0; + QTest::newRow("one-interface") << "" << 1 << 0 << 0; QTest::newRow("two-interfaces") << "" - "" - << 2 << 0; + "" + << 2 << 0 << 0; - QTest::newRow("one-object") << "" << 0 << 1; - QTest::newRow("two-objects") << "" << 0 << 2; + QTest::newRow("one-object") << "" << 0 << 1 << 0; + QTest::newRow("two-objects") << "" << 0 << 2 << 0; - QTest::newRow("i1o1") << "" << 1 << 1; + QTest::newRow("i1o1") << "" << 1 << 1 << 0; + QTest::newRow("one-interface-annotated") << "" + "" + "" << 1 << 0 << 1; + QTest::newRow("one-interface-docnamespace") << "" + "" + "" << 1 << 0 << 0; } void tst_QDBusXmlParser::parsing_common(const QString &xmlData) { - QDBusIntrospection::ObjectTree obj = - QDBusIntrospection::parseObjectTree(xmlData, "local.testing", "/"); + QDBusIntrospection::Object obj = + QDBusIntrospection::parseObject(xmlData, "local.testing", "/"); QFETCH(int, interfaceCount); QFETCH(int, objectCount); + QFETCH(int, annotationCount); QCOMPARE(obj.interfaces.count(), interfaceCount); QCOMPARE(obj.childObjects.count(), objectCount); + QCOMPARE(QDBusIntrospection::parseInterface(xmlData).annotations.count(), annotationCount); // also verify the naming int i = 0; @@ -140,92 +146,14 @@ void tst_QDBusXmlParser::parsingWithDoctype() "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"; QFETCH(QString, xmlData); - parsing_common(docType + xmlData); -} - -void tst_QDBusXmlParser::objectWithContent_data() -{ - QTest::addColumn("xmlData"); - QTest::addColumn("probedObject"); - QTest::addColumn("interfaceCount"); - QTest::addColumn("objectCount"); - - QTest::newRow("zero") << "" << "obj" << 0 << 0; - - QString xmlData = "" - "" - ""; - QTest::newRow("one-interface") << xmlData << "obj" << 1 << 0; - QTest::newRow("one-interface2") << xmlData << "obj2" << 0 << 0; - - xmlData = "" - "" - "" - ""; - QTest::newRow("two-interfaces") << xmlData << "obj" << 2 << 0; - QTest::newRow("two-interfaces2") << xmlData << "obj2" << 0 << 0; - - xmlData = "" - "" - "" - "" - "" - ""; - QTest::newRow("two-nodes-two-interfaces") << xmlData << "obj" << 2 << 0; - QTest::newRow("two-nodes-one-interface") << xmlData << "obj2" << 1 << 0; - - xmlData = "" - "" - ""; - QTest::newRow("one-object") << xmlData << "obj" << 0 << 1; - QTest::newRow("one-object2") << xmlData << "obj2" << 0 << 0; - - xmlData = "" - "" - "" - ""; - QTest::newRow("two-objects") << xmlData << "obj" << 0 << 2; - QTest::newRow("two-objects2") << xmlData << "obj2" << 0 << 0; - - xmlData = "" - "" - "" - "" - "" - ""; - QTest::newRow("two-nodes-two-objects") << xmlData << "obj" << 0 << 2; - QTest::newRow("two-nodes-one-object") << xmlData << "obj2" << 0 << 1; -} - -void tst_QDBusXmlParser::objectWithContent() -{ - QFETCH(QString, xmlData); - QFETCH(QString, probedObject); - - QDBusIntrospection::ObjectTree tree = - QDBusIntrospection::parseObjectTree(xmlData, "local.testing", "/"); - - const ObjectMap &om = tree.childObjectData; - - if (om.contains(probedObject)) { - const QSharedDataPointer& obj = om.value(probedObject); - QVERIFY(obj != 0); - - QFETCH(int, interfaceCount); - QFETCH(int, objectCount); - - QCOMPARE(obj->interfaces.count(), interfaceCount); - QCOMPARE(obj->childObjects.count(), objectCount); - - // verify the object names - int i = 0; - foreach (QString name, obj->interfaces) - QCOMPARE(name, QString("iface.iface%1").arg(++i)); - - i = 0; - foreach (QString name, obj->childObjects) - QCOMPARE(name, QString("obj%1").arg(++i)); + QString toParse; + if (xmlData.startsWith(QLatin1String("')) + 1; + toParse = xmlData.left(split) + docType + xmlData.mid(split); + } else { + toParse = docType + xmlData; } + parsing_common(toParse); } void tst_QDBusXmlParser::methods_data() @@ -261,7 +189,7 @@ void tst_QDBusXmlParser::methods_data() QTest::newRow("method-with-annotation") << "" "" - "" + "" << map; // arguments @@ -428,7 +356,7 @@ void tst_QDBusXmlParser::signals__data() QTest::newRow("signal-with-annotation") << "" "" - "" + "" << map; // one out argument @@ -563,6 +491,7 @@ void tst_QDBusXmlParser::properties_data() "" "" "" + "" "" << map; // and now change the order @@ -570,6 +499,7 @@ void tst_QDBusXmlParser::properties_data() "" "" "" + "" "" "" << map; } -- cgit v1.2.3