From d54ababd5f67bb621c1b3a911d0853c23df817a1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 28 Mar 2006 18:58:58 +0000 Subject: * test/qt/*: Sync with KDE Subversion revision 523647. Update the testcases to the new API. Remove testcases for classes that are no longer public or have been removed. --- test/qt/tst_qdbusobject.cpp | 207 -------------------------------------------- 1 file changed, 207 deletions(-) delete mode 100644 test/qt/tst_qdbusobject.cpp (limited to 'test/qt/tst_qdbusobject.cpp') diff --git a/test/qt/tst_qdbusobject.cpp b/test/qt/tst_qdbusobject.cpp deleted file mode 100644 index 904e98b5..00000000 --- a/test/qt/tst_qdbusobject.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* -*- C++ -*- - * - * Copyright (C) 2006 Trolltech AS. All rights reserved. - * Author: Thiago Macieira - * - * Licensed under the Academic Free License version 2.1 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ -#define DBUS_API_SUBJECT_TO_CHANGE 1 -#include -#include -#include - -#include - -const char introspectionData[] = - "\n" - "" - - "" - "" - "" - "" - "" - - "" - "" - "" - "" - "" - "" - "" - ""; - -class IntrospectionAdaptor: public QDBusAbstractAdaptor -{ - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.freedesktop.DBus.Introspectable") -public: - IntrospectionAdaptor(QObject *parent) - : QDBusAbstractAdaptor(parent) - { } - -public slots: - - void Introspect(const QDBusMessage &msg) - { - QDBusMessage reply = QDBusMessage::methodReply(msg); - reply << ::introspectionData; - if (!msg.connection().send(reply)) - exit(1); - } -}; - -class MyObject: public QObject -{ - Q_OBJECT -public: - MyObject() - { - new IntrospectionAdaptor(this); - } - -public slots: - - void ping(const QDBusMessage &msg) - { - QDBusMessage reply = QDBusMessage::methodReply(msg); - reply << static_cast >(msg); - if (!msg.connection().send(reply)) - exit(1); - } -}; - -class tst_QDBusObject: public QObject -{ - Q_OBJECT - MyObject obj; - -private slots: - void initTestCase(); // connect to D-Bus - - void construction_data(); - void construction(); - - void introspection_data(); - void introspection(); -}; - -void tst_QDBusObject::initTestCase() -{ - QDBusConnection &con = QDBus::sessionBus(); - QVERIFY(con.isConnected()); - QVERIFY(con.requestName("com.trolltech.tst_qdbusobject")); - - con.registerObject("/", &obj, QDBusConnection::ExportAdaptors | QDBusConnection::ExportSlots); -} - -void tst_QDBusObject::construction_data() -{ - QTest::addColumn("service"); - QTest::addColumn("path"); - QTest::addColumn("isValid"); - QTest::addColumn("exists"); - - QTest::newRow("null") << QString() << QString() << false << false; - - QTest::newRow("invalid1") << "foo.foo1" << "" << false << false; - QTest::newRow("invalid2") << "foo.foo1" << "foo.bar" << false << false; - QTest::newRow("invalid3") << "foo.foo1" << "/foo.bar" << false << false; - QTest::newRow("invalid4") << "" << "/" << false << false; - QTest::newRow("invalid5") << "foo" << "/" << false << false; - QTest::newRow("invalid6") << ".foo" << "/" << false << false; - - QTest::newRow("invalid7") << "org.freedesktop.DBus" << "" << false << false; - QTest::newRow("invalid8") << "org.freedesktop.DBus" << "foo.bar" << false << false; - QTest::newRow("invalid9") << "org.freedesktop.DBus" << "/foo.bar" << false << false; - - QTest::newRow("existing") << "org.freedesktop.DBus" << "/" << true << true; - QTest::newRow("non-existing") << "org.freedesktop.DBus" << "/foo" << true << false; -} - -void tst_QDBusObject::construction() -{ - QDBusConnection &con = QDBus::sessionBus(); - - QFETCH(QString, service); - QFETCH(QString, path); - QFETCH(bool, isValid); - //QFETCH(bool, exists); - - QDBusObject o = con.findObject(service, path); - QCOMPARE(o.isValid(), isValid); - - if (isValid) { - QCOMPARE(o.service(), service); - QCOMPARE(o.path(), path); - } - else { - QVERIFY(o.service().isNull()); - QVERIFY(o.path().isNull()); - } - - //QCOMPARE(o.exists(), exists); -} - -void tst_QDBusObject::introspection_data() -{ - QTest::addColumn("service"); - QTest::addColumn("path"); - QTest::addColumn("interfaces"); - - QStringList interfaces; - QTest::newRow("nowhere") << QString() << QString() << interfaces; - - // IMPORTANT! - // Keep the interface list sorted! - interfaces << "org.freedesktop.DBus" << DBUS_INTERFACE_INTROSPECTABLE; - QTest::newRow("server") << "org.freedesktop.DBus" << "/" << interfaces; - - QDBusConnection &con = QDBus::sessionBus(); - interfaces.clear(); - interfaces << "com.trolltech.tst_qdbusobject.MyObject" << DBUS_INTERFACE_INTROSPECTABLE; - - QTest::newRow("self1") << con.baseService() << "/" << interfaces; - QTest::newRow("self2") << "com.trolltech.tst_qdbusobject" << "/" << interfaces; -} - -void tst_QDBusObject::introspection() -{ - QDBusConnection &con = QDBus::sessionBus(); - - QFETCH(QString, service); - QFETCH(QString, path); - - QDBusObject o = con.findObject(service, path); - - if (!o.isValid()) - QVERIFY(o.introspect().isEmpty()); - else { - QFETCH(QStringList, interfaces); - QStringList parsed = o.interfaces(); - parsed.sort(); - QCOMPARE(parsed.count(), interfaces.count()); - QCOMPARE(parsed, interfaces); - } -} - -QTEST_MAIN(tst_QDBusObject) - -#include "tst_qdbusobject.moc" - -- cgit