2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-22 01:46:15 +01:00

Rework "qt5 demo: add example of unit testing using QtTest"

This commit is contained in:
Thomas Nagy 2019-06-06 16:37:19 +02:00
parent 31da55afb9
commit 82afd0a0e4
No known key found for this signature in database
GPG Key ID: 49B4C67C05277AAA
2 changed files with 4 additions and 2 deletions

View File

@ -3,6 +3,7 @@
#include "foo.h"
#include <QtTest/QtTest>
#include <qtest_widgets.h>
class TestQt5Test: public QObject {
Q_OBJECT
@ -16,7 +17,7 @@ class TestQt5Test: public QObject {
// Test of the UI by simulating a button click and button label reading
void TestQt5Test::testGui() {
QCOMPARE(myFoo.m_button->text(), QString("Foo Button"));
QTest::mouseClick(myFoo.m_button,Qt::LeftButton,Qt::NoModifier,QPoint(5,5),0);
QTest::mouseClick(myFoo.m_button, Qt::LeftButton,Qt::NoModifier, QPoint(5,5), 0);
QCOMPARE(myFoo.m_button->text(), QString("Button Foo"));
}

View File

@ -36,7 +36,8 @@ def build(bld):
# Example of integration of Qt5 Unit tests using Qt5Test using waf_unit_test
bld(
features = 'qt5 cxx cxxprogram test',
use = 'QT5CORE QT5WIDGETS QT5TEST',
use = 'QT5CORE QT5GUI QT5WIDGETS QT5TEST',
defines = 'QT_WIDGETS_LIB',
source = 'foo.cpp testqt5.cpp',
moc = 'foo.h',
target = 'footest',