mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +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 m_timer;
|
||||||
|
|
||||||
// delete dbus session
|
// delete dbus session
|
||||||
long id = reinterpret_cast<long>(this);
|
qlonglong id = reinterpret_cast<qlonglong>(this);
|
||||||
QDBusConnection::sessionBus().unregisterObject(QString("/%1").arg(id));
|
QDBusConnection::sessionBus().unregisterObject(QString("/%1").arg(id));
|
||||||
|
|
||||||
// core
|
// core
|
||||||
@ -330,7 +330,7 @@ void AWKeys::calculateValues()
|
|||||||
void AWKeys::createDBusInterface()
|
void AWKeys::createDBusInterface()
|
||||||
{
|
{
|
||||||
// get this object id
|
// get this object id
|
||||||
long id = reinterpret_cast<long>(this);
|
qlonglong id = reinterpret_cast<qlonglong>(this);
|
||||||
|
|
||||||
// create session
|
// create session
|
||||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||||
|
@ -18,10 +18,13 @@
|
|||||||
|
|
||||||
#include "testawkeys.h"
|
#include "testawkeys.h"
|
||||||
|
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusMessage>
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|
||||||
#include "awkeys.h"
|
#include "awkeys.h"
|
||||||
#include "awtestlibrary.h"
|
#include "awtestlibrary.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
void TestAWKeys::initTestCase()
|
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);
|
QTEST_MAIN(TestAWKeys);
|
||||||
|
@ -40,6 +40,7 @@ private slots:
|
|||||||
void test_wrapNewLines();
|
void test_wrapNewLines();
|
||||||
void test_infoByKey();
|
void test_infoByKey();
|
||||||
void test_valueByKey();
|
void test_valueByKey();
|
||||||
|
void test_dbus();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AWKeys *plugin = nullptr;
|
AWKeys *plugin = nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user