mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-07-07 11:05:45 +00:00
end work on tests
This commit is contained in:
@ -66,7 +66,6 @@ TODO (wish list)
|
|||||||
|
|
||||||
* add helper polkit-qt integration ?
|
* add helper polkit-qt integration ?
|
||||||
* test several profiles support
|
* test several profiles support
|
||||||
* autotests (QCOMPARE(gui, lib));
|
|
||||||
|
|
||||||
Links
|
Links
|
||||||
-----
|
-----
|
||||||
|
@ -99,6 +99,11 @@ void TestNetctlAuto::initTestCase()
|
|||||||
qDebug() << "with the working profile isn't tested here (including netctl-auto)";
|
qDebug() << "with the working profile isn't tested here (including netctl-auto)";
|
||||||
QWARN("Some functions requires root privileges");
|
QWARN("Some functions requires root privileges");
|
||||||
createTestProfiles();
|
createTestProfiles();
|
||||||
|
if (sendDBusRequest(QString("/ctrl"), QString("Active")).isEmpty()) {
|
||||||
|
helper = false;
|
||||||
|
QWARN("Helper isn't active. DBus tests will be ignored");
|
||||||
|
} else
|
||||||
|
helper = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ private slots:
|
|||||||
// netctl-auto
|
// netctl-auto
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool helper;
|
||||||
Netctl *createNetctlObj();
|
Netctl *createNetctlObj();
|
||||||
NetctlProfile *createNetctlProfileObj();
|
NetctlProfile *createNetctlProfileObj();
|
||||||
void createTestProfiles();
|
void createTestProfiles();
|
||||||
|
@ -18,10 +18,14 @@
|
|||||||
|
|
||||||
#include "testnetctlprofile.h"
|
#include "testnetctlprofile.h"
|
||||||
|
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusMessage>
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|
||||||
#include <netctlgui/netctlgui.h>
|
#include <netctlgui/netctlgui.h>
|
||||||
|
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
NetctlProfile *TestNetctlProfile::createNetctlProfileObj()
|
NetctlProfile *TestNetctlProfile::createNetctlProfileObj()
|
||||||
{
|
{
|
||||||
@ -59,6 +63,20 @@ bool TestNetctlProfile::removeTestProfile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<QVariant> TestNetctlProfile::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 TestNetctlProfile::initTestCase()
|
void TestNetctlProfile::initTestCase()
|
||||||
{
|
{
|
||||||
qDebug() << "netctlgui library tests";
|
qDebug() << "netctlgui library tests";
|
||||||
@ -68,6 +86,11 @@ void TestNetctlProfile::initTestCase()
|
|||||||
QWARN("Some functions requires root privileges");
|
QWARN("Some functions requires root privileges");
|
||||||
// arent needed
|
// arent needed
|
||||||
// createTestProfile();
|
// createTestProfile();
|
||||||
|
if (sendDBusRequest(QString("/ctrl"), QString("Active")).isEmpty()) {
|
||||||
|
helper = false;
|
||||||
|
QWARN("Helper isn't active. DBus tests will be ignored");
|
||||||
|
} else
|
||||||
|
helper = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -98,6 +121,18 @@ void TestNetctlProfile::test_copyProfile()
|
|||||||
{
|
{
|
||||||
NetctlProfile *netctl = createNetctlProfileObj();
|
NetctlProfile *netctl = createNetctlProfileObj();
|
||||||
QVERIFY(createTestProfile());
|
QVERIFY(createTestProfile());
|
||||||
|
if (helper) {
|
||||||
|
QList<QVariant> args;
|
||||||
|
args.append(QString("netctlgui-test-dummy"));
|
||||||
|
QStringList profileSettings;
|
||||||
|
profileSettings.append(QString("Connection==dummy"));
|
||||||
|
profileSettings.append(QString("Description==\"Simple test profile\""));
|
||||||
|
profileSettings.append(QString("IP==no"));
|
||||||
|
profileSettings.append(QString("IP6==no"));
|
||||||
|
profileSettings.append(QString("Interface==ngtest"));
|
||||||
|
args.append(profileSettings);
|
||||||
|
QVERIFY(sendDBusRequest(QString("/ctrl"), QString("Create"), args)[0].toBool());
|
||||||
|
}
|
||||||
delete netctl;
|
delete netctl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +147,7 @@ void TestNetctlProfile::test_getValueFromProfile()
|
|||||||
original.append(QString("no"));
|
original.append(QString("no"));
|
||||||
original.append(QString("no"));
|
original.append(QString("no"));
|
||||||
original.append(QString("ngtest"));
|
original.append(QString("ngtest"));
|
||||||
QStringList result;
|
QStringList result, dbus;
|
||||||
result.append(netctl->getValueFromProfile(QString("netctlgui-test-dummy"),
|
result.append(netctl->getValueFromProfile(QString("netctlgui-test-dummy"),
|
||||||
QString("Connection")));
|
QString("Connection")));
|
||||||
result.append(netctl->getValueFromProfile(QString("netctlgui-test-dummy"),
|
result.append(netctl->getValueFromProfile(QString("netctlgui-test-dummy"),
|
||||||
@ -123,6 +158,29 @@ void TestNetctlProfile::test_getValueFromProfile()
|
|||||||
QString("IP6")));
|
QString("IP6")));
|
||||||
result.append(netctl->getValueFromProfile(QString("netctlgui-test-dummy"),
|
result.append(netctl->getValueFromProfile(QString("netctlgui-test-dummy"),
|
||||||
QString("Interface")));
|
QString("Interface")));
|
||||||
|
if (helper) {
|
||||||
|
QList<QVariant> args;
|
||||||
|
args.append(QString("netctlgui-test-dummy"));
|
||||||
|
args.append(QString("Connection"));
|
||||||
|
dbus.append(sendDBusRequest(QString("/netctl"), QString("ProfileValue"), args)[0].toString());
|
||||||
|
args.clear();
|
||||||
|
args.append(QString("netctlgui-test-dummy"));
|
||||||
|
args.append(QString("Description"));
|
||||||
|
dbus.append(sendDBusRequest(QString("/netctl"), QString("ProfileValue"), args)[0].toString());
|
||||||
|
args.clear();
|
||||||
|
args.append(QString("netctlgui-test-dummy"));
|
||||||
|
args.append(QString("IP"));
|
||||||
|
dbus.append(sendDBusRequest(QString("/netctl"), QString("ProfileValue"), args)[0].toString());
|
||||||
|
args.clear();
|
||||||
|
args.append(QString("netctlgui-test-dummy"));
|
||||||
|
args.append(QString("IP6"));
|
||||||
|
dbus.append(sendDBusRequest(QString("/netctl"), QString("ProfileValue"), args)[0].toString());
|
||||||
|
args.clear();
|
||||||
|
args.append(QString("netctlgui-test-dummy"));
|
||||||
|
args.append(QString("Interface"));
|
||||||
|
dbus.append(sendDBusRequest(QString("/netctl"), QString("ProfileValue"), args)[0].toString());
|
||||||
|
QCOMPARE(dbus, result);
|
||||||
|
}
|
||||||
delete netctl;
|
delete netctl;
|
||||||
|
|
||||||
QCOMPARE(result, original);
|
QCOMPARE(result, original);
|
||||||
@ -174,6 +232,15 @@ void TestNetctlProfile::test_createProfile()
|
|||||||
'phase2=\"auth=PAP\"'\n\
|
'phase2=\"auth=PAP\"'\n\
|
||||||
");
|
");
|
||||||
QVERIFY(netctl->copyProfile(netctl->createProfile(QString("netctlgui-test-full"), profileSettings)));
|
QVERIFY(netctl->copyProfile(netctl->createProfile(QString("netctlgui-test-full"), profileSettings)));
|
||||||
|
if (helper) {
|
||||||
|
QList<QVariant> args;
|
||||||
|
args.append(QString("netctlgui-test-full"));
|
||||||
|
QStringList profileSettingsList;
|
||||||
|
for (int i=0; i<profileSettings.keys().count(); i++)
|
||||||
|
profileSettingsList.append(profileSettings.keys()[i] + QString("==") + profileSettings[profileSettings.keys()[i]]);
|
||||||
|
args.append(profileSettingsList);
|
||||||
|
QVERIFY(sendDBusRequest(QString("/ctrl"), QString("Create"), args)[0].toBool());
|
||||||
|
}
|
||||||
delete netctl;
|
delete netctl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +292,12 @@ password=\"mypassword\"\n\
|
|||||||
priority=1\n\
|
priority=1\n\
|
||||||
phase2=\"auth=PAP\"\
|
phase2=\"auth=PAP\"\
|
||||||
");
|
");
|
||||||
QStringList result;
|
QStringList result, dbus;
|
||||||
|
if (helper) {
|
||||||
|
QList<QVariant> args;
|
||||||
|
args.append(QString("netctlgui-test-full"));
|
||||||
|
dbus = sendDBusRequest(QString("/netctl"), QString("Profile"), args)[0].toStringList();
|
||||||
|
}
|
||||||
QMap<QString, QString> resultMap = netctl->getSettingsFromProfile(QString("netctlgui-test-full"));
|
QMap<QString, QString> resultMap = netctl->getSettingsFromProfile(QString("netctlgui-test-full"));
|
||||||
for (int i=0; i<resultMap.keys().count(); i++)
|
for (int i=0; i<resultMap.keys().count(); i++)
|
||||||
result.append(resultMap.keys()[i] + QString("==") + resultMap[resultMap.keys()[i]]);
|
result.append(resultMap.keys()[i] + QString("==") + resultMap[resultMap.keys()[i]]);
|
||||||
@ -233,6 +305,7 @@ phase2=\"auth=PAP\"\
|
|||||||
delete netctl;
|
delete netctl;
|
||||||
|
|
||||||
QCOMPARE(result, original);
|
QCOMPARE(result, original);
|
||||||
|
if (helper) QCOMPARE(dbus, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#define TESTNETCTLPROFILE_H
|
#define TESTNETCTLPROFILE_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
|
||||||
class NetctlProfile;
|
class NetctlProfile;
|
||||||
@ -40,9 +41,13 @@ private slots:
|
|||||||
void test_removeProfile();
|
void test_removeProfile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool helper;
|
||||||
NetctlProfile *createNetctlProfileObj();
|
NetctlProfile *createNetctlProfileObj();
|
||||||
bool createTestProfile();
|
bool createTestProfile();
|
||||||
bool removeTestProfile();
|
bool removeTestProfile();
|
||||||
|
QList<QVariant> sendDBusRequest(const QString path,
|
||||||
|
const QString cmd,
|
||||||
|
const QList<QVariant> args = QList<QVariant>());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,6 +59,11 @@ void TestWpaSup::initTestCase()
|
|||||||
qDebug() << "TODO: unfortunately, some functions which is required to work";
|
qDebug() << "TODO: unfortunately, some functions which is required to work";
|
||||||
qDebug() << "with the working profile isn't tested here (including netctl-auto)";
|
qDebug() << "with the working profile isn't tested here (including netctl-auto)";
|
||||||
QWARN("Some functions requires root privileges");
|
QWARN("Some functions requires root privileges");
|
||||||
|
if (sendDBusRequest(QString("/ctrl"), QString("Active")).isEmpty()) {
|
||||||
|
helper = false;
|
||||||
|
QWARN("Helper isn't active. DBus tests will be ignored");
|
||||||
|
} else
|
||||||
|
helper = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ private slots:
|
|||||||
void test_getRecommendedConfiguration();
|
void test_getRecommendedConfiguration();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool helper;
|
||||||
WpaSup *createWpaSupObj();
|
WpaSup *createWpaSupObj();
|
||||||
QList<QVariant> sendDBusRequest(const QString path,
|
QList<QVariant> sendDBusRequest(const QString path,
|
||||||
const QString cmd,
|
const QString cmd,
|
||||||
|
Reference in New Issue
Block a user