diff options
Diffstat (limited to 'tests/auto/dbus')
-rw-r--r-- | tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp | 2 | ||||
-rw-r--r-- | tests/auto/dbus/qdbusxmlparser/tst_qdbusxmlparser.cpp | 138 |
2 files changed, 35 insertions, 105 deletions
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 <QtTest/QtTest> #include <QtCore/qvariant.h> #include <QtDBus/QtDBus> - +#include <qdebug.h> #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<QString>("xmlData"); QTest::addColumn<int>("interfaceCount"); QTest::addColumn<int>("objectCount"); + QTest::addColumn<int>("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") << "<junk/>" << 0 << 0; + QTest::newRow("junk") << "<junk/>" << 0 << 0 << 0; QTest::newRow("interface-inside-junk") << "<junk><interface name=\"iface.iface1\" /></junk>" - << 0 << 0; + << 0 << 0 << 0; QTest::newRow("object-inside-junk") << "<junk><node name=\"obj1\" /></junk>" - << 0 << 0; + << 0 << 0 << 0; - QTest::newRow("zero-interfaces") << "<node/>" << 0 << 0; - QTest::newRow("one-interface") << "<node><interface name=\"iface.iface1\" /></node>" << 1 << 0; + QTest::newRow("zero-interfaces") << "<node/>" << 0 << 0 << 0; + QTest::newRow("one-interface") << "<node><interface name=\"iface.iface1\" /></node>" << 1 << 0 << 0; QTest::newRow("two-interfaces") << "<node><interface name=\"iface.iface1\" />" - "<interface name=\"iface.iface2\"></node>" - << 2 << 0; + "<interface name=\"iface.iface2\" /></node>" + << 2 << 0 << 0; - QTest::newRow("one-object") << "<node><node name=\"obj1\"/></node>" << 0 << 1; - QTest::newRow("two-objects") << "<node><node name=\"obj1\"/><node name=\"obj2\"></node>" << 0 << 2; + QTest::newRow("one-object") << "<node><node name=\"obj1\"/></node>" << 0 << 1 << 0; + QTest::newRow("two-objects") << "<node><node name=\"obj1\"/><node name=\"obj2\"/></node>" << 0 << 2 << 0; - QTest::newRow("i1o1") << "<node><interface name=\"iface.iface1\"><node name=\"obj1\"></node>" << 1 << 1; + QTest::newRow("i1o1") << "<node><interface name=\"iface.iface1\"/><node name=\"obj1\"/></node>" << 1 << 1 << 0; + QTest::newRow("one-interface-annotated") << "<node><interface name=\"iface.iface1\">" + "<annotation name=\"foo.testing\" value=\"nothing to see here\" />" + "</interface></node>" << 1 << 0 << 1; + QTest::newRow("one-interface-docnamespace") << "<?xml version=\"1.0\" xmlns:doc=\"foo\" ?><node>" + "<interface name=\"iface.iface1\"><doc:something />" + "</interface></node>" << 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<QString>("xmlData"); - QTest::addColumn<QString>("probedObject"); - QTest::addColumn<int>("interfaceCount"); - QTest::addColumn<int>("objectCount"); - - QTest::newRow("zero") << "<node><node name=\"obj\"/></node>" << "obj" << 0 << 0; - - QString xmlData = "<node><node name=\"obj\">" - "<interface name=\"iface.iface1\" />" - "</node></node>"; - QTest::newRow("one-interface") << xmlData << "obj" << 1 << 0; - QTest::newRow("one-interface2") << xmlData << "obj2" << 0 << 0; - - xmlData = "<node><node name=\"obj\">" - "<interface name=\"iface.iface1\" />" - "<interface name=\"iface.iface2\" />" - "</node></node>"; - QTest::newRow("two-interfaces") << xmlData << "obj" << 2 << 0; - QTest::newRow("two-interfaces2") << xmlData << "obj2" << 0 << 0; - - xmlData = "<node><node name=\"obj\">" - "<interface name=\"iface.iface1\" />" - "<interface name=\"iface.iface2\" />" - "</node><node name=\"obj2\">" - "<interface name=\"iface.iface1\" />" - "</node></node>"; - QTest::newRow("two-nodes-two-interfaces") << xmlData << "obj" << 2 << 0; - QTest::newRow("two-nodes-one-interface") << xmlData << "obj2" << 1 << 0; - - xmlData = "<node><node name=\"obj\">" - "<node name=\"obj1\" />" - "</node></node>"; - QTest::newRow("one-object") << xmlData << "obj" << 0 << 1; - QTest::newRow("one-object2") << xmlData << "obj2" << 0 << 0; - - xmlData = "<node><node name=\"obj\">" - "<node name=\"obj1\" />" - "<node name=\"obj2\" />" - "</node></node>"; - QTest::newRow("two-objects") << xmlData << "obj" << 0 << 2; - QTest::newRow("two-objects2") << xmlData << "obj2" << 0 << 0; - - xmlData = "<node><node name=\"obj\">" - "<node name=\"obj1\" />" - "<node name=\"obj2\" />" - "</node><node name=\"obj2\">" - "<node name=\"obj1\" />" - "</node></node>"; - 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<QDBusIntrospection::ObjectTree>& 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("<?xml"))) { + int split = xmlData.indexOf(QLatin1Char('>')) + 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") << "<method name=\"Foo\"/>" "<method name=\"Bar\"/>" - "<method name=\"Baz\"><annotation name=\"foo.testing\" value=\"nothing to see here\"></method>" + "<method name=\"Baz\"><annotation name=\"foo.testing\" value=\"nothing to see here\" /></method>" << map; // arguments @@ -428,7 +356,7 @@ void tst_QDBusXmlParser::signals__data() QTest::newRow("signal-with-annotation") << "<signal name=\"Foo\"/>" "<signal name=\"Bar\"/>" - "<signal name=\"Baz\"><annotation name=\"foo.testing\" value=\"nothing to see here\"></signal>" + "<signal name=\"Baz\"><annotation name=\"foo.testing\" value=\"nothing to see here\" /></signal>" << map; // one out argument @@ -563,6 +491,7 @@ void tst_QDBusXmlParser::properties_data() "<property name=\"baz\" type=\"as\" access=\"write\">" "<annotation name=\"foo.annotation\" value=\"Hello, World\" />" "<annotation name=\"foo.annotation2\" value=\"Goodbye, World\" />" + "</property>" "<property name=\"foo\" type=\"s\" access=\"readwrite\"/>" << map; // and now change the order @@ -570,6 +499,7 @@ void tst_QDBusXmlParser::properties_data() "<property name=\"baz\" type=\"as\" access=\"write\">" "<annotation name=\"foo.annotation2\" value=\"Goodbye, World\" />" "<annotation name=\"foo.annotation\" value=\"Hello, World\" />" + "</property>" "<property name=\"bar\" type=\"i\" access=\"read\"/>" "<property name=\"foo\" type=\"s\" access=\"readwrite\"/>" << map; } |