mirror of https://gitlab.com/ita1024/waf.git
Add a configuration test for: "qt5 demo: add example of unit testing using QtTest"
This commit is contained in:
parent
9df72c7898
commit
1ade97f5c3
|
@ -16,6 +16,31 @@ def configure(conf):
|
||||||
conf.load('compiler_cxx qt5 waf_unit_test')
|
conf.load('compiler_cxx qt5 waf_unit_test')
|
||||||
#conf.env.append_value('CXXFLAGS', ['-g']) # test
|
#conf.env.append_value('CXXFLAGS', ['-g']) # test
|
||||||
|
|
||||||
|
# These tests would run on Ubuntu but not on other platforms
|
||||||
|
conf.check(
|
||||||
|
define_name = 'XYZ_QT5_TESTS',
|
||||||
|
mandatory = False,
|
||||||
|
execute = True,
|
||||||
|
features = 'qt5 cxx cxxprogram',
|
||||||
|
includes = '.',
|
||||||
|
defines = 'QT_WIDGETS_LIB',
|
||||||
|
use = 'QT5CORE QT5GUI QT5WIDGETS QT5TEST',
|
||||||
|
msg = 'Checking whether Qt5 tests can run',
|
||||||
|
fragment = '''
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
class TestQt5Test: public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
void testGui() {
|
||||||
|
QWidget *widget = NULL;
|
||||||
|
QTest::mouseClick(widget, Qt::LeftButton, Qt::NoModifier, QPoint(5,5), 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
QTEST_MAIN(TestQt5Test)
|
||||||
|
#include "test.moc"
|
||||||
|
''')
|
||||||
|
|
||||||
def build(bld):
|
def build(bld):
|
||||||
# According to the Qt5 documentation:
|
# According to the Qt5 documentation:
|
||||||
# Qt classes in foo.h -> declare foo.h as a header to be processed by moc
|
# Qt classes in foo.h -> declare foo.h as a header to be processed by moc
|
||||||
|
@ -33,19 +58,20 @@ def build(bld):
|
||||||
langname = 'somefile', # include the .qm files from somefile.qrc
|
langname = 'somefile', # include the .qm files from somefile.qrc
|
||||||
)
|
)
|
||||||
|
|
||||||
# Example of integration of Qt5 Unit tests using Qt5Test using waf_unit_test
|
if bld.env.XYZ_QT5_TESTS:
|
||||||
bld(
|
# Example of integration of Qt5 Unit tests using Qt5Test using waf_unit_test
|
||||||
features = 'qt5 cxx cxxprogram test',
|
bld(
|
||||||
use = 'QT5CORE QT5GUI QT5WIDGETS QT5TEST',
|
features = 'qt5 cxx cxxprogram test',
|
||||||
defines = 'QT_WIDGETS_LIB',
|
use = 'QT5CORE QT5GUI QT5WIDGETS QT5TEST',
|
||||||
source = 'foo.cpp testqt5.cpp',
|
defines = 'QT_WIDGETS_LIB',
|
||||||
moc = 'foo.h',
|
source = 'foo.cpp testqt5.cpp',
|
||||||
target = 'footest',
|
moc = 'foo.h',
|
||||||
includes = '.',
|
target = 'footest',
|
||||||
# ut_str = './${SRC} -o test-report.xml,xunitxml', # put output to a xunit xml
|
includes = '.',
|
||||||
)
|
# ut_str = './${SRC} -o test-report.xml,xunitxml', # put output to a xunit xml
|
||||||
|
)
|
||||||
|
|
||||||
bld.add_post_fun(print_test_results) # print output of test runner to user
|
bld.add_post_fun(print_test_results) # print output of test runner to user
|
||||||
|
|
||||||
|
|
||||||
def print_test_results(bld):
|
def print_test_results(bld):
|
||||||
|
|
Loading…
Reference in New Issue