mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
more pretty tests
This commit is contained in:
parent
a7911d48d1
commit
4cc9d0ec11
@ -71,6 +71,7 @@ if (BUILD_HELPER)
|
|||||||
add_subdirectory (helper)
|
add_subdirectory (helper)
|
||||||
endif ()
|
endif ()
|
||||||
if (BUILD_TEST)
|
if (BUILD_TEST)
|
||||||
|
enable_testing ()
|
||||||
add_subdirectory (test)
|
add_subdirectory (test)
|
||||||
endif ()
|
endif ()
|
||||||
if (BUILD_GUI)
|
if (BUILD_GUI)
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
enable_testing ()
|
|
||||||
|
|
||||||
# set project name
|
# set project name
|
||||||
set (SUBPROJECT netctlgui-test)
|
set (SUBPROJECT netctlgui-test)
|
||||||
message (STATUS "Subproject ${SUBPROJECT}")
|
message (STATUS "Subproject ${SUBPROJECT}")
|
||||||
@ -9,11 +7,14 @@ set (SUBPROJECT_BINARY_DIR bin)
|
|||||||
|
|
||||||
# additional targets
|
# additional targets
|
||||||
set (TARGETS "")
|
set (TARGETS "")
|
||||||
set (HEADERS "")
|
|
||||||
|
|
||||||
# set files
|
# set files
|
||||||
file (GLOB SOURCES *.cpp)
|
# netctl
|
||||||
file (GLOB HEADERS *.h)
|
set (NETCTL_HEADERS testnetctl.h)
|
||||||
|
set (NETCTL_SOURCES testnetctl.cpp)
|
||||||
|
# netctl-auto
|
||||||
|
set (NETCTLAUTO_HEADERS testnetctlauto.h)
|
||||||
|
set (NETCTLAUTO_SOURCES testnetctlauto.cpp)
|
||||||
|
|
||||||
# include_path
|
# include_path
|
||||||
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../${PROJECT_LIBRARY}/include/
|
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../${PROJECT_LIBRARY}/include/
|
||||||
@ -30,16 +31,25 @@ if (USE_QT5)
|
|||||||
add_definitions(${Qt5Test_DEFINITIONS})
|
add_definitions(${Qt5Test_DEFINITIONS})
|
||||||
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5Test_INCLUDE_DIRS})
|
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5Test_INCLUDE_DIRS})
|
||||||
set (QT_NEEDED_LIBS ${Qt5Core_LIBRARIES} ${Qt5Test_LIBRARIES})
|
set (QT_NEEDED_LIBS ${Qt5Core_LIBRARIES} ${Qt5Test_LIBRARIES})
|
||||||
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
|
qt5_wrap_cpp (NETCTL_MOC_SOURCES ${NETCTL_HEADERS})
|
||||||
|
qt5_wrap_cpp (NETCTLAUTO_MOC_SOURCES ${NETCTLAUTO_HEADERS})
|
||||||
else ()
|
else ()
|
||||||
find_package (Qt4 COMPONENTS QtCore QtTest REQUIRED)
|
find_package (Qt4 COMPONENTS QtCore QtTest REQUIRED)
|
||||||
include (${QT_USE_FILE})
|
include (${QT_USE_FILE})
|
||||||
set (QT_NEEDED_LIBS ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY})
|
set (QT_NEEDED_LIBS ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY})
|
||||||
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
|
qt4_wrap_cpp (NETCTL_MOC_SOURCES ${NETCTL_HEADERS})
|
||||||
|
qt4_wrap_cpp (NETCTLAUTO_MOC_SOURCES ${NETCTLAUTO_HEADERS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable (${SUBPROJECT} ${HEADERS} ${SOURCES} ${MOC_SOURCES})
|
# netctl
|
||||||
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
|
add_executable (${SUBPROJECT}-netctl ${NETCTL_HEADERS} ${NETCTL_SOURCES} ${NETCTL_MOC_SOURCES})
|
||||||
|
target_link_libraries (${SUBPROJECT}-netctl ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
|
||||||
|
# netctl-auto
|
||||||
|
add_executable (${SUBPROJECT}-netctlauto ${NETCTLAUTO_HEADERS} ${NETCTLAUTO_SOURCES} ${NETCTLAUTO_MOC_SOURCES})
|
||||||
|
target_link_libraries (${SUBPROJECT}-netctlauto ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
|
||||||
# install properties
|
# install properties
|
||||||
add_test (BaseTest ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT})
|
add_test (NAME Netctl COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT}-netctl
|
||||||
|
"-o" "../Testing/output-netctl.log")
|
||||||
|
add_test (NAME NetctlAuto COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT}-netctlauto
|
||||||
|
"-o" "../Testing/output-netctlauto.log")
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ Netctl *TestNetctl::createNetctlObj()
|
|||||||
{
|
{
|
||||||
QMap<QString, QString> settings = Netctl::getRecommendedConfiguration();
|
QMap<QString, QString> settings = Netctl::getRecommendedConfiguration();
|
||||||
settings[QString("FORCE_SUDO")] = QString("true");
|
settings[QString("FORCE_SUDO")] = QString("true");
|
||||||
|
// to test netctl-auto with dummy profiles
|
||||||
|
settings[QString("PREFERED_IFACE")] = QString("ngtest");
|
||||||
Netctl *netctl = new Netctl(false, settings);
|
Netctl *netctl = new Netctl(false, settings);
|
||||||
|
|
||||||
return netctl;
|
return netctl;
|
||||||
@ -53,12 +55,6 @@ void TestNetctl::createTestProfile()
|
|||||||
profileSettings["IP6"] = QString("no");
|
profileSettings["IP6"] = QString("no");
|
||||||
profileSettings["Interface"] = QString("ngtest");
|
profileSettings["Interface"] = QString("ngtest");
|
||||||
netctl->copyProfile(netctl->createProfile(QString("netctlgui-test-dummy"), profileSettings));
|
netctl->copyProfile(netctl->createProfile(QString("netctlgui-test-dummy"), profileSettings));
|
||||||
profileSettings["Connection"] = QString("dummy");
|
|
||||||
profileSettings["Description"] = QString("\"Second simple test profile\"");
|
|
||||||
profileSettings["IP"] = QString("no");
|
|
||||||
profileSettings["IP6"] = QString("no");
|
|
||||||
profileSettings["Interface"] = QString("ngtest");
|
|
||||||
netctl->copyProfile(netctl->createProfile(QString("netctlgui-test-dummy-snd"), profileSettings));
|
|
||||||
delete netctl;
|
delete netctl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,11 +63,19 @@ void TestNetctl::removeTestProfile()
|
|||||||
{
|
{
|
||||||
NetctlProfile *netctl = createNetctlProfileObj();
|
NetctlProfile *netctl = createNetctlProfileObj();
|
||||||
netctl->removeProfile(QString("netctlgui-test-dummy"));
|
netctl->removeProfile(QString("netctlgui-test-dummy"));
|
||||||
netctl->removeProfile(QString("netctlgui-test-dummy-snd"));
|
|
||||||
delete netctl;
|
delete netctl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TestNetctl::initTestCase()
|
||||||
|
{
|
||||||
|
qDebug() << "netctlgui library tests";
|
||||||
|
qDebug() << "TODO: unfortunately, some functions which is required to work";
|
||||||
|
qDebug() << "with the working profile isn't tested here (including netctl-auto)";
|
||||||
|
QWARN("Some functions requires root privileges");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TestNetctl::test_getRecommendedConfiguration()
|
void TestNetctl::test_getRecommendedConfiguration()
|
||||||
{
|
{
|
||||||
QStringList original;
|
QStringList original;
|
||||||
@ -214,6 +218,4 @@ void TestNetctl::test_restartProfile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: unfortunately, some functions which is required to work
|
|
||||||
// with the working profile isn't tested here
|
|
||||||
QTEST_MAIN(TestNetctl);
|
QTEST_MAIN(TestNetctl);
|
||||||
|
@ -29,6 +29,9 @@ class TestNetctl : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
// initialization
|
||||||
|
void initTestCase();
|
||||||
|
// netctl
|
||||||
void test_getRecommendedConfiguration();
|
void test_getRecommendedConfiguration();
|
||||||
void test_getActiveProfile();
|
void test_getActiveProfile();
|
||||||
void test_getProfileDescription();
|
void test_getProfileDescription();
|
||||||
|
86
sources/test/testnetctlauto.cpp
Normal file
86
sources/test/testnetctlauto.cpp
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of netctl-gui *
|
||||||
|
* *
|
||||||
|
* netctl-gui is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* netctl-gui is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "testnetctlauto.h"
|
||||||
|
|
||||||
|
#include <QtTest>
|
||||||
|
|
||||||
|
#include <netctlgui/netctlgui.h>
|
||||||
|
|
||||||
|
|
||||||
|
Netctl *TestNetctlAuto::createNetctlObj()
|
||||||
|
{
|
||||||
|
QMap<QString, QString> settings = Netctl::getRecommendedConfiguration();
|
||||||
|
settings[QString("FORCE_SUDO")] = QString("true");
|
||||||
|
// to test netctl-auto with dummy profiles
|
||||||
|
settings[QString("PREFERED_IFACE")] = QString("ngtest");
|
||||||
|
Netctl *netctl = new Netctl(false, settings);
|
||||||
|
|
||||||
|
return netctl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NetctlProfile *TestNetctlAuto::createNetctlProfileObj()
|
||||||
|
{
|
||||||
|
QMap<QString, QString> settings = NetctlProfile::getRecommendedConfiguration();
|
||||||
|
settings[QString("FORCE_SUDO")] = QString("true");
|
||||||
|
NetctlProfile *netctl = new NetctlProfile(false, settings);
|
||||||
|
|
||||||
|
return netctl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TestNetctlAuto::createTestProfiles()
|
||||||
|
{
|
||||||
|
NetctlProfile *netctl = createNetctlProfileObj();
|
||||||
|
QMap<QString, QString> profileSettings;
|
||||||
|
profileSettings["Connection"] = QString("dummy");
|
||||||
|
profileSettings["Description"] = QString("\"Simple test profile\"");
|
||||||
|
profileSettings["IP"] = QString("no");
|
||||||
|
profileSettings["IP6"] = QString("no");
|
||||||
|
profileSettings["Interface"] = QString("ngtest");
|
||||||
|
netctl->copyProfile(netctl->createProfile(QString("netctlgui-test-dummy"), profileSettings));
|
||||||
|
profileSettings["Connection"] = QString("dummy");
|
||||||
|
profileSettings["Description"] = QString("\"Second simple test profile\"");
|
||||||
|
profileSettings["IP"] = QString("no");
|
||||||
|
profileSettings["IP6"] = QString("no");
|
||||||
|
profileSettings["Interface"] = QString("ngtest");
|
||||||
|
netctl->copyProfile(netctl->createProfile(QString("netctlgui-test-dummy-snd"), profileSettings));
|
||||||
|
delete netctl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TestNetctlAuto::removeTestProfiles()
|
||||||
|
{
|
||||||
|
NetctlProfile *netctl = createNetctlProfileObj();
|
||||||
|
netctl->removeProfile(QString("netctlgui-test-dummy"));
|
||||||
|
netctl->removeProfile(QString("netctlgui-test-dummy-snd"));
|
||||||
|
delete netctl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TestNetctlAuto::initTestCase()
|
||||||
|
{
|
||||||
|
qDebug() << "netctlgui library tests";
|
||||||
|
qDebug() << "TODO: unfortunately, some functions which is required to work";
|
||||||
|
qDebug() << "with the working profile isn't tested here (including netctl-auto)";
|
||||||
|
QWARN("Some functions requires root privileges");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QTEST_MAIN(TestNetctlAuto);
|
44
sources/test/testnetctlauto.h
Normal file
44
sources/test/testnetctlauto.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of netctl-gui *
|
||||||
|
* *
|
||||||
|
* netctl-gui is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* netctl-gui is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef TESTNETCTLAUTO_H
|
||||||
|
#define TESTNETCTLAUTO_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
|
||||||
|
class Netctl;
|
||||||
|
class NetctlProfile;
|
||||||
|
|
||||||
|
class TestNetctlAuto : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
// initialization
|
||||||
|
void initTestCase();
|
||||||
|
// netctl-auto
|
||||||
|
|
||||||
|
private:
|
||||||
|
Netctl *createNetctlObj();
|
||||||
|
NetctlProfile *createNetctlProfileObj();
|
||||||
|
void createTestProfiles();
|
||||||
|
void removeTestProfiles();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* TESTNETCTLAUTO_H */
|
Loading…
Reference in New Issue
Block a user