add dbus functions to netctlauto and wpasup

This commit is contained in:
arcan1s 2014-08-17 16:38:28 +04:00
parent 2c2919160b
commit dd05782f80
4 changed files with 44 additions and 0 deletions

View File

@ -18,10 +18,14 @@
#include "testnetctlauto.h" #include "testnetctlauto.h"
#include <QDBusConnection>
#include <QDBusMessage>
#include <QtTest> #include <QtTest>
#include <netctlgui/netctlgui.h> #include <netctlgui/netctlgui.h>
#include "version.h"
Netctl *TestNetctlAuto::createNetctlObj() Netctl *TestNetctlAuto::createNetctlObj()
{ {
@ -73,6 +77,20 @@ void TestNetctlAuto::removeTestProfiles()
} }
QList<QVariant> TestNetctlAuto::sendDBusRequest(const QString path, const QString cmd, const QList<QVariant> args)
{
QDBusConnection bus = QDBusConnection::systemBus();
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_HELPER_SERVICE, path,
DBUS_HELPER_INTERFACE, cmd);
if (!args.isEmpty())
request.setArguments(args);
QDBusMessage response = bus.call(request);
QList<QVariant> arguments = response.arguments();
return arguments;
}
void TestNetctlAuto::initTestCase() void TestNetctlAuto::initTestCase()
{ {
qDebug() << "netctlgui library tests"; qDebug() << "netctlgui library tests";

View File

@ -19,6 +19,7 @@
#define TESTNETCTLAUTO_H #define TESTNETCTLAUTO_H
#include <QObject> #include <QObject>
#include <QVariant>
class Netctl; class Netctl;
@ -39,6 +40,9 @@ private:
NetctlProfile *createNetctlProfileObj(); NetctlProfile *createNetctlProfileObj();
void createTestProfiles(); void createTestProfiles();
void removeTestProfiles(); void removeTestProfiles();
QList<QVariant> sendDBusRequest(const QString path,
const QString cmd,
const QList<QVariant> args = QList<QVariant>());
}; };

View File

@ -18,10 +18,14 @@
#include "testwpasup.h" #include "testwpasup.h"
#include <QDBusConnection>
#include <QDBusMessage>
#include <QtTest> #include <QtTest>
#include <netctlgui/netctlgui.h> #include <netctlgui/netctlgui.h>
#include "version.h"
WpaSup *TestWpaSup::createWpaSupObj() WpaSup *TestWpaSup::createWpaSupObj()
{ {
@ -34,6 +38,20 @@ WpaSup *TestWpaSup::createWpaSupObj()
} }
QList<QVariant> TestWpaSup::sendDBusRequest(const QString path, const QString cmd, const QList<QVariant> args)
{
QDBusConnection bus = QDBusConnection::systemBus();
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_HELPER_SERVICE, path,
DBUS_HELPER_INTERFACE, cmd);
if (!args.isEmpty())
request.setArguments(args);
QDBusMessage response = bus.call(request);
QList<QVariant> arguments = response.arguments();
return arguments;
}
void TestWpaSup::initTestCase() void TestWpaSup::initTestCase()
{ {
qDebug() << "netctlgui library tests"; qDebug() << "netctlgui library tests";

View File

@ -19,6 +19,7 @@
#define TESTWPASUP_H #define TESTWPASUP_H
#include <QObject> #include <QObject>
#include <QVariant>
class WpaSup; class WpaSup;
@ -36,6 +37,9 @@ private slots:
private: private:
WpaSup *createWpaSupObj(); WpaSup *createWpaSupObj();
QList<QVariant> sendDBusRequest(const QString path,
const QString cmd,
const QList<QVariant> args = QList<QVariant>());
}; };