mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
add test for dbus connection
This commit is contained in:
parent
77a94aa0c1
commit
d520f55afc
@ -79,7 +79,7 @@ AWKeys::~AWKeys()
|
||||
delete m_timer;
|
||||
|
||||
// delete dbus session
|
||||
long id = reinterpret_cast<long>(this);
|
||||
qlonglong id = reinterpret_cast<qlonglong>(this);
|
||||
QDBusConnection::sessionBus().unregisterObject(QString("/%1").arg(id));
|
||||
|
||||
// core
|
||||
@ -330,7 +330,7 @@ void AWKeys::calculateValues()
|
||||
void AWKeys::createDBusInterface()
|
||||
{
|
||||
// get this object id
|
||||
long id = reinterpret_cast<long>(this);
|
||||
qlonglong id = reinterpret_cast<qlonglong>(this);
|
||||
|
||||
// create session
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
|
@ -18,10 +18,13 @@
|
||||
|
||||
#include "testawkeys.h"
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QtTest>
|
||||
|
||||
#include "awkeys.h"
|
||||
#include "awtestlibrary.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
void TestAWKeys::initTestCase()
|
||||
@ -159,4 +162,24 @@ void TestAWKeys::test_valueByKey()
|
||||
}
|
||||
|
||||
|
||||
void TestAWKeys::test_dbus()
|
||||
{
|
||||
// get id
|
||||
qlonglong id = reinterpret_cast<qlonglong>(plugin);
|
||||
|
||||
// create connection and message
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
QDBusMessage request
|
||||
= QDBusMessage::createMethodCall(AWDBUS_SERVICE, QString("/%1").arg(id),
|
||||
AWDBUS_SERVICE, QString("WhoAmI"));
|
||||
// send message to dbus
|
||||
QDBusMessage response = bus.call(request, QDBus::BlockWithGui);
|
||||
|
||||
// parse result
|
||||
QList<QVariant> arguments = response.arguments();
|
||||
QVERIFY(!arguments.isEmpty());
|
||||
QCOMPARE(arguments.at(0).toLongLong(), id);
|
||||
}
|
||||
|
||||
|
||||
QTEST_MAIN(TestAWKeys);
|
||||
|
@ -40,6 +40,7 @@ private slots:
|
||||
void test_wrapNewLines();
|
||||
void test_infoByKey();
|
||||
void test_valueByKey();
|
||||
void test_dbus();
|
||||
|
||||
private:
|
||||
AWKeys *plugin = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user