mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +00:00
initial commit with test modules
This commit is contained in:
parent
2dccc92933
commit
ea7c15d865
@ -80,5 +80,9 @@ if (BUILD_PLASMOIDS)
|
|||||||
add_subdirectory(desktop-panel)
|
add_subdirectory(desktop-panel)
|
||||||
add_subdirectory(translations)
|
add_subdirectory(translations)
|
||||||
endif ()
|
endif ()
|
||||||
|
if (BUILD_TESTING)
|
||||||
|
enable_testing()
|
||||||
|
add_subdirectory(test)
|
||||||
|
endif ()
|
||||||
|
|
||||||
include(packages-recipe.cmake)
|
include(packages-recipe.cmake)
|
||||||
|
@ -2,18 +2,18 @@
|
|||||||
find_package(Gettext REQUIRED)
|
find_package(Gettext REQUIRED)
|
||||||
|
|
||||||
# main qt libraries
|
# main qt libraries
|
||||||
find_package(Qt5 5.6.0 REQUIRED COMPONENTS Core DBus Network Qml Widgets)
|
find_package(Qt5 5.6.0 REQUIRED COMPONENTS Core DBus Network Qml Test Widgets)
|
||||||
add_definitions(
|
add_definitions(
|
||||||
${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Network_DEFINITIONS}
|
${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Network_DEFINITIONS}
|
||||||
${Qt5Qml_DEFINITIONS} ${Qt5Widgets_DEFINITIONS}
|
${Qt5Qml_DEFINITIONS} ${Qt5Test_DEFINITIONS} ${Qt5Widgets_DEFINITIONS}
|
||||||
)
|
)
|
||||||
set(Qt_INCLUDE
|
set(Qt_INCLUDE
|
||||||
${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}
|
${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}
|
||||||
${Qt5Qml_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS}
|
${Qt5Qml_INCLUDE_DIRS} ${Qt5Test_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
set(Qt_LIBRARIES
|
set(Qt_LIBRARIES
|
||||||
${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} ${Qt5Network_LIBRARIES}
|
${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} ${Qt5Network_LIBRARIES}
|
||||||
${Qt5Qml_LIBRARIES} ${Qt5Widgets_LIBRARIES}
|
${Qt5Qml_LIBRARIES} ${Qt5Test_LIBRARIES} ${Qt5Widgets_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
# kf5 libraries
|
# kf5 libraries
|
||||||
|
23
sources/test/CMakeLists.txt
Normal file
23
sources/test/CMakeLists.txt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
set(SUBPROJECT awesomewidgets-test)
|
||||||
|
message(STATUS "Subproject ${SUBPROJECT}")
|
||||||
|
|
||||||
|
# find qt test package
|
||||||
|
include_directories(
|
||||||
|
${CMAKE_SOURCE_DIR}
|
||||||
|
${CMAKE_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/../${PROJECT_LIBRARY}/
|
||||||
|
${PROJECT_TRDPARTY_DIR}
|
||||||
|
${Qt_INCLUDE}
|
||||||
|
${Kf5_INCLUDE}
|
||||||
|
${Qt5Test_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
# extscript
|
||||||
|
set (EXTSCRIPT_HEADERS testextscript.h)
|
||||||
|
set (EXTSCRIPT_SOURCES testextscript.cpp)
|
||||||
|
# qt5_wrap_cpp(EXTSCRIPT_MOC_SOURCES ${EXTSCRIPT_HEADERS})
|
||||||
|
add_executable (${SUBPROJECT}-extscript ${EXTSCRIPT_HEADERS} ${EXTSCRIPT_SOURCES} ${EXTSCRIPT_MOC_SOURCES})
|
||||||
|
target_link_libraries (${SUBPROJECT}-extscript ${PROJECT_LIBRARY} ${Qt_LIBRARIES} ${Qt5Test_LIBRARIES})
|
||||||
|
add_test (NAME "ExtScript" COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT}-extscript
|
||||||
|
"-o" "../Testing/output-extscript.log")
|
||||||
|
|
72
sources/test/testextscript.cpp
Normal file
72
sources/test/testextscript.cpp
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets 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. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "testextscript.h"
|
||||||
|
|
||||||
|
#include <QtTest>
|
||||||
|
|
||||||
|
#include "extscript.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
|
void TestExtScript::initTestCase()
|
||||||
|
{
|
||||||
|
extScript = new ExtScript(nullptr);
|
||||||
|
extScript->setInterval(1);
|
||||||
|
extScript->setExecutable(QString("hello world"));
|
||||||
|
extScript->setRedirect(ExtScript::Redirect::stderr2stdout);
|
||||||
|
extScript->setPrefix(QString("echo"));
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
qDebug() <<extScript->run();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TestExtScript::cleanupTestCase()
|
||||||
|
{
|
||||||
|
delete extScript;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TestExtScript::test_values()
|
||||||
|
{
|
||||||
|
QCOMPARE(extScript->interval(), 1);
|
||||||
|
QCOMPARE(extScript->executable(), QString("hello world"));
|
||||||
|
QCOMPARE(extScript->prefix(), QString("echo"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TestExtScript::test_firstRun()
|
||||||
|
{
|
||||||
|
QVariantHash firstValue = extScript->run();
|
||||||
|
qDebug() << firstValue;
|
||||||
|
QTest::qSleep(20000);
|
||||||
|
QCOMPARE(firstValue[extScript->tag(QString("custom"))].toString(), QString(""));
|
||||||
|
QTest::qSleep(20000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TestExtScript::test_secondRun()
|
||||||
|
{
|
||||||
|
QVariantHash secondValue = extScript->run();
|
||||||
|
qDebug() << secondValue;
|
||||||
|
QCOMPARE(secondValue[extScript->tag(QString("custom"))].toString(), QString("hello world"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QTEST_MAIN(TestExtScript);
|
46
sources/test/testextscript.h
Normal file
46
sources/test/testextscript.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets 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. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets 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 awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef TESTEXTSCRIPT_H
|
||||||
|
#define TESTEXTSCRIPT_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
|
||||||
|
class ExtScript;
|
||||||
|
|
||||||
|
class TestExtScript : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
// initialization
|
||||||
|
void initTestCase();
|
||||||
|
void cleanupTestCase();
|
||||||
|
// test
|
||||||
|
void test_values();
|
||||||
|
void test_firstRun();
|
||||||
|
void test_secondRun();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ExtScript *extScript = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* TESTEXTSCRIPT_H */
|
Loading…
Reference in New Issue
Block a user