tst_QTimer: refactor CMake code
It's used to build different variations of the unittest, linking against QtCore-only/QtGui, with/without GLib, that's four individual tests. Change-Id: Iaf0f37041dbb148134631f86be99feaa881a8ce8 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
2dc0c01449
commit
9cf47946fc
@ -11,22 +11,24 @@ if (NOT QT_FEATURE_thread)
|
|||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
qt_internal_add_test(tst_qtimer
|
function(addTimerTest test)
|
||||||
SOURCES
|
qt_internal_add_test(${test}
|
||||||
tst_qtimer.cpp
|
|
||||||
LIBRARIES
|
|
||||||
Qt::CorePrivate
|
|
||||||
Qt::TestPrivate
|
|
||||||
)
|
|
||||||
|
|
||||||
if(QT_FEATURE_glib AND UNIX)
|
|
||||||
qt_internal_add_test(tst_qtimer_no_glib
|
|
||||||
SOURCES
|
SOURCES
|
||||||
tst_qtimer.cpp
|
tst_qtimer.cpp
|
||||||
DEFINES
|
|
||||||
DISABLE_GLIB
|
|
||||||
LIBRARIES
|
LIBRARIES
|
||||||
Qt::CorePrivate
|
Qt::CorePrivate
|
||||||
Qt::TestPrivate
|
Qt::TestPrivate
|
||||||
)
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
addTimerTest(tst_qtimer)
|
||||||
|
|
||||||
|
if(QT_FEATURE_glib AND UNIX)
|
||||||
|
addTimerTest(tst_qtimer_no_glib)
|
||||||
|
qt_internal_extend_target(tst_qtimer_no_glib
|
||||||
|
DEFINES
|
||||||
|
DISABLE_GLIB
|
||||||
|
tst_QTimer=tst_QTimer_no_glib # Class name in the unittest
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#ifdef QT_GUI_LIB
|
#ifdef QT_GUI_LIB
|
||||||
# include <QtGui/QGuiApplication>
|
# include <QtGui/QGuiApplication>
|
||||||
# define tst_QTimer tst_QGuiTimer
|
|
||||||
#else
|
#else
|
||||||
# include <QtCore/QCoreApplication>
|
# include <QtCore/QCoreApplication>
|
||||||
#endif
|
#endif
|
||||||
@ -24,12 +23,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DISABLE_GLIB
|
#ifdef DISABLE_GLIB
|
||||||
# ifdef tst_QTimer
|
|
||||||
# undef tst_QTimer
|
|
||||||
# define tst_QTimer tst_QGuiTimer_NoGlib
|
|
||||||
# else
|
|
||||||
# define tst_QTimer tst_QTimer_NoGlib
|
|
||||||
# endif
|
|
||||||
static bool glibDisabled = []() {
|
static bool glibDisabled = []() {
|
||||||
qputenv("QT_NO_GLIB", "1");
|
qputenv("QT_NO_GLIB", "1");
|
||||||
return true;
|
return true;
|
||||||
|
@ -11,25 +11,28 @@ if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
|
|||||||
find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
|
find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
qt_internal_add_test(tst_qguitimer
|
function(addGuiTimerTest test)
|
||||||
SOURCES
|
qt_internal_add_test(${test}
|
||||||
../../../corelib/kernel/qtimer/tst_qtimer.cpp
|
|
||||||
LIBRARIES
|
|
||||||
Qt::CorePrivate
|
|
||||||
Qt::Gui
|
|
||||||
Qt::TestPrivate
|
|
||||||
)
|
|
||||||
|
|
||||||
if(QT_FEATURE_glib AND UNIX)
|
|
||||||
# only exists as a different dispatcher for XCB
|
|
||||||
qt_internal_add_test(tst_qguitimer_no_glib
|
|
||||||
SOURCES
|
SOURCES
|
||||||
../../../corelib/kernel/qtimer/tst_qtimer.cpp
|
../../../corelib/kernel/qtimer/tst_qtimer.cpp
|
||||||
DEFINES
|
|
||||||
DISABLE_GLIB
|
|
||||||
LIBRARIES
|
LIBRARIES
|
||||||
Qt::CorePrivate
|
Qt::CorePrivate
|
||||||
Qt::Gui
|
Qt::Gui
|
||||||
Qt::TestPrivate
|
Qt::TestPrivate
|
||||||
)
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
addGuiTimerTest(tst_qguitimer)
|
||||||
|
qt_internal_extend_target(tst_qguitimer
|
||||||
|
DEFINES
|
||||||
|
tst_Qtimer=tst_QGuiTimer
|
||||||
|
)
|
||||||
|
|
||||||
|
if(QT_FEATURE_glib AND UNIX)
|
||||||
|
addGuiTimerTest(tst_qguitimer_no_glib)
|
||||||
|
qt_internal_extend_target(tst_qguitimer_no_glib
|
||||||
|
DEFINES
|
||||||
|
DISABLE_GLIB
|
||||||
|
tst_QTimer=tst_QGuiTimer_no_glib # Class name in the unittest
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user