From 47bc742c484ce4439a77b35de099d7296079a026 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Wed, 2 Aug 2023 03:28:29 +0300 Subject: [PATCH] QEventDispatcher: test with glib disabled too Change-Id: I05f09e720170c77a567ffea31dfe06a658f1df2b Reviewed-by: Thiago Macieira --- .../kernel/qeventdispatcher/CMakeLists.txt | 24 +++++++++++--- .../qeventdispatcher/tst_qeventdispatcher.cpp | 8 ++++- .../kernel/qguieventdispatcher/CMakeLists.txt | 31 ++++++++++++++++--- 3 files changed, 53 insertions(+), 10 deletions(-) diff --git a/tests/auto/corelib/kernel/qeventdispatcher/CMakeLists.txt b/tests/auto/corelib/kernel/qeventdispatcher/CMakeLists.txt index fed7f447d0..1f9cfb9449 100644 --- a/tests/auto/corelib/kernel/qeventdispatcher/CMakeLists.txt +++ b/tests/auto/corelib/kernel/qeventdispatcher/CMakeLists.txt @@ -11,7 +11,23 @@ if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) endif() -qt_internal_add_test(tst_qeventdispatcher - SOURCES - tst_qeventdispatcher.cpp -) +set(test_names "tst_qeventdispatcher") +if(QT_FEATURE_glib AND UNIX) + list(APPEND test_names "tst_qeventdispatcher_no_glib") +endif() + +foreach(test ${test_names}) + qt_internal_add_test(${test} + NO_BATCH + SOURCES + tst_qeventdispatcher.cpp + ) +endforeach() + +if (TARGET tst_qeventdispatcher_no_glib) + qt_internal_extend_target(tst_qeventdispatcher_no_glib + DEFINES + DISABLE_GLIB + tst_QEventDispatcher=tst_QEventDispatcher_no_glib + ) +endif() diff --git a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp index fe78d0002f..a14cd7141d 100644 --- a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp +++ b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp @@ -3,7 +3,6 @@ #ifdef QT_GUI_LIB # include -# define tst_QEventDispatcher tst_QGuiEventDispatcher #else # include #endif @@ -12,6 +11,13 @@ #include #include +#ifdef DISABLE_GLIB +static bool glibDisabled = []() { + qputenv("QT_NO_GLIB", "1"); + return true; +}(); +#endif + enum { PreciseTimerInterval = 10, CoarseTimerInterval = 200, diff --git a/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt b/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt index 51fbb5e0e3..62299f77df 100644 --- a/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt +++ b/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt @@ -11,9 +11,30 @@ if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) endif() -qt_internal_add_test(tst_qguieventdispatcher - SOURCES - ../../../corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp - LIBRARIES - Qt::Gui +set(test_names "tst_qguieventdispatcher") +if(QT_FEATURE_glib AND UNIX) + list(APPEND test_names "tst_qguieventdispatcher_no_glib") +endif() + +foreach(test ${test_names}) + qt_internal_add_test(${test} + NO_BATCH + SOURCES + ../../../corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp + LIBRARIES + Qt::Gui + ) +endforeach() + +qt_internal_extend_target(tst_qguieventdispatcher + DEFINES + tst_QEventDispatcher=tst_qguieventdispatcher ) + +if (TARGET tst_qeventdispatcher_no_glib) + qt_internal_extend_target(tst_qguieventdispatcher_no_glib + DEFINES + DISABLE_GLIB + tst_QEventDispatcher=tst_qguieventdispatcher_no_glib + ) +endif()