mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-02-15 02:10:29 +01:00
convert to QTestLib 4.1
This commit is contained in:
parent
52d4364f90
commit
e447b1f2be
1 changed files with 33 additions and 33 deletions
|
|
@ -34,15 +34,15 @@ void tst_QDBusConnection::sendSignal()
|
|||
QDBusConnection con = QDBusConnection::addConnection(
|
||||
QDBusConnection::SessionBus);
|
||||
|
||||
VERIFY(con.isConnected());
|
||||
QVERIFY(con.isConnected());
|
||||
|
||||
QDBusMessage msg = QDBusMessage::signal("/org/kde/selftest", "org.kde.selftest",
|
||||
"Ping");
|
||||
msg << QLatin1String("ping");
|
||||
|
||||
VERIFY(con.send(msg));
|
||||
QVERIFY(con.send(msg));
|
||||
|
||||
QTest::wait(1000);
|
||||
QTest::qWait(1000);
|
||||
}
|
||||
|
||||
void tst_QDBusConnection::send()
|
||||
|
|
@ -50,35 +50,35 @@ void tst_QDBusConnection::send()
|
|||
QDBusConnection con = QDBusConnection::addConnection(
|
||||
QDBusConnection::SessionBus);
|
||||
|
||||
VERIFY(con.isConnected());
|
||||
QVERIFY(con.isConnected());
|
||||
|
||||
QDBusMessage msg = QDBusMessage::methodCall("org.freedesktop.DBus",
|
||||
"/org/freedesktop/DBus", "org.freedesktop.DBus", "ListNames");
|
||||
|
||||
QDBusMessage reply = con.sendWithReply(msg);
|
||||
|
||||
COMPARE(reply.count(), 1);
|
||||
COMPARE(reply.at(0).typeName(), "QStringList");
|
||||
VERIFY(reply.at(0).toStringList().contains(con.baseService()));
|
||||
QCOMPARE(reply.count(), 1);
|
||||
QCOMPARE(reply.at(0).typeName(), "QStringList");
|
||||
QVERIFY(reply.at(0).toStringList().contains(con.baseService()));
|
||||
}
|
||||
|
||||
void tst_QDBusConnection::sendAsync()
|
||||
{
|
||||
QDBusConnection con = QDBusConnection::addConnection(QDBusConnection::SessionBus);
|
||||
VERIFY(con.isConnected());
|
||||
QVERIFY(con.isConnected());
|
||||
|
||||
QDBusSpy spy;
|
||||
|
||||
QDBusMessage msg = QDBusMessage::methodCall("org.freedesktop.DBus",
|
||||
"/org/freedesktop/DBus", "org.freedesktop.DBus", "ListNames");
|
||||
int msgId = con.sendWithReplyAsync(msg, &spy, SLOT(asyncReply(QDBusMessage)));
|
||||
VERIFY(msgId != 0);
|
||||
QVERIFY(msgId != 0);
|
||||
|
||||
QTest::wait(1000);
|
||||
QTest::qWait(1000);
|
||||
|
||||
COMPARE(spy.args.value(0).typeName(), "QStringList");
|
||||
VERIFY(spy.args.at(0).toStringList().contains(con.baseService()));
|
||||
COMPARE(spy.serial, msgId);
|
||||
QCOMPARE(spy.args.value(0).typeName(), "QStringList");
|
||||
QVERIFY(spy.args.at(0).toStringList().contains(con.baseService()));
|
||||
QCOMPARE(spy.serial, msgId);
|
||||
}
|
||||
|
||||
void tst_QDBusConnection::connect()
|
||||
|
|
@ -95,12 +95,12 @@ void tst_QDBusConnection::connect()
|
|||
"ping");
|
||||
msg << QLatin1String("ping");
|
||||
|
||||
VERIFY(con.send(msg));
|
||||
QVERIFY(con.send(msg));
|
||||
|
||||
QTest::wait(1000);
|
||||
QTest::qWait(1000);
|
||||
|
||||
COMPARE(spy.args.count(), 1);
|
||||
COMPARE(spy.args.at(0).toString(), QString("ping"));
|
||||
QCOMPARE(spy.args.count(), 1);
|
||||
QCOMPARE(spy.args.at(0).toString(), QString("ping"));
|
||||
}
|
||||
|
||||
void tst_QDBusConnection::addConnection()
|
||||
|
|
@ -109,51 +109,51 @@ void tst_QDBusConnection::addConnection()
|
|||
QDBusConnection con = QDBusConnection::addConnection(
|
||||
QDBusConnection::SessionBus, "bubu");
|
||||
|
||||
VERIFY(con.isConnected());
|
||||
VERIFY(!con.lastError().isValid());
|
||||
QVERIFY(con.isConnected());
|
||||
QVERIFY(!con.lastError().isValid());
|
||||
|
||||
QDBusConnection con2;
|
||||
VERIFY(!con2.isConnected());
|
||||
VERIFY(!con2.lastError().isValid());
|
||||
QVERIFY(!con2.isConnected());
|
||||
QVERIFY(!con2.lastError().isValid());
|
||||
|
||||
con2 = con;
|
||||
VERIFY(con.isConnected());
|
||||
VERIFY(con2.isConnected());
|
||||
VERIFY(!con.lastError().isValid());
|
||||
VERIFY(!con2.lastError().isValid());
|
||||
QVERIFY(con.isConnected());
|
||||
QVERIFY(con2.isConnected());
|
||||
QVERIFY(!con.lastError().isValid());
|
||||
QVERIFY(!con2.lastError().isValid());
|
||||
}
|
||||
|
||||
{
|
||||
QDBusConnection con("bubu");
|
||||
VERIFY(con.isConnected());
|
||||
VERIFY(!con.lastError().isValid());
|
||||
QVERIFY(con.isConnected());
|
||||
QVERIFY(!con.lastError().isValid());
|
||||
}
|
||||
|
||||
QDBusConnection::closeConnection("bubu");
|
||||
|
||||
{
|
||||
QDBusConnection con("bubu");
|
||||
VERIFY(!con.isConnected());
|
||||
VERIFY(!con.lastError().isValid());
|
||||
QVERIFY(!con.isConnected());
|
||||
QVERIFY(!con.lastError().isValid());
|
||||
}
|
||||
|
||||
{
|
||||
{
|
||||
QDBusConnection con = QDBusConnection::addConnection(
|
||||
QDBusConnection::SessionBus);
|
||||
VERIFY(con.isConnected());
|
||||
QVERIFY(con.isConnected());
|
||||
}
|
||||
|
||||
{
|
||||
QDBusConnection con;
|
||||
VERIFY(con.isConnected());
|
||||
QVERIFY(con.isConnected());
|
||||
QDBusConnection::closeConnection();
|
||||
VERIFY(con.isConnected());
|
||||
QVERIFY(con.isConnected());
|
||||
}
|
||||
|
||||
{
|
||||
QDBusConnection con;
|
||||
VERIFY(!con.isConnected());
|
||||
QVERIFY(!con.isConnected());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue