From: Ivailo Monev Date: Fri, 19 Nov 2021 23:25:54 +0000 (+0200) Subject: workaround lack of focus events when testing via Xvfb in tst_QFocusEvent::checkReason... X-Git-Tag: 4.12.0~1627 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=8dd351c7a91330fe78fe1662dcd21e63ee95395c;p=kde%2FKatie.git workaround lack of focus events when testing via Xvfb in tst_QFocusEvent::checkReason_ActiveWindow() upstream commit: https://github.com/qt/qtbase/commit/c7e7a785c6e3bec422fe5b62361e5417240c0ada Signed-off-by: Ivailo Monev --- diff --git a/README b/README index 1eee08a35..44eb76046 100644 --- a/README +++ b/README @@ -83,7 +83,7 @@ QTBUG-12564, QTBUG-20028, QTBUG-71967, QTBUG-70956, QTBUG-71446, QTBUG-61307, QTBUG-27287, QTBUG-25143, QTBUG-22833, QTBUG-57399, QTBUG-59159, QTBUG-15773, QTBUG-70506, QTBUG-46054, QTBUG-11223, QTBUG-63108, QTBUG-6932, QTBUG-42365, QTBUG-83817, QTBUG-4341, QTBUG-36933, QTBUG-49113, QTBUG-69920, QTBUG-40015, -QTBUG-54942, QTBUG-91261, QTBUG-73445, QTBUG-21098 +QTBUG-54942, QTBUG-91261, QTBUG-73445, QTBUG-21098, QTBUG-59966 Unless you use QMake and QDoc porting to Katie or even supporting it along with Qt4 in the same codebase is trivial and requires only minor changes because diff --git a/tests/auto/qfocusevent/CMakeLists.txt b/tests/auto/qfocusevent/CMakeLists.txt index 8e9d42fff..adabdcb0a 100644 --- a/tests/auto/qfocusevent/CMakeLists.txt +++ b/tests/auto/qfocusevent/CMakeLists.txt @@ -1,3 +1,7 @@ +include_directories(${X11_INCLUDE_DIR}) + katie_gui_test(tst_qfocusevent ${CMAKE_CURRENT_SOURCE_DIR}/tst_qfocusevent.cpp ) + +target_link_libraries(tst_qfocusevent ${X11_X11_LIB}) diff --git a/tests/auto/qfocusevent/tst_qfocusevent.cpp b/tests/auto/qfocusevent/tst_qfocusevent.cpp index 628fb6507..075cd02a4 100644 --- a/tests/auto/qfocusevent/tst_qfocusevent.cpp +++ b/tests/auto/qfocusevent/tst_qfocusevent.cpp @@ -29,12 +29,31 @@ #include #include #include +#include "qx11info_x11.h" +#include "qt_x11_p.h" #include "../../shared/util.h" //TESTED_CLASS= //TESTED_FILES=gui/kernel/qevent.h gui/kernel/qevent.cpp + +static bool hasNetWM() +{ + Atom type; + int format; + unsigned long nitems, after; + unsigned char *data = 0; + + int e = XGetWindowProperty(qt_x11Data->display, QX11Info::appRootWindow(), + ATOM(_NET_SUPPORTED), 0, 0, + False, XA_ATOM, &type, &format, &nitems, &after, &data); + if (data) { + XFree(data); + } + return (e == Success && type == XA_ATOM && format == 32); +} + class FocusLineEdit : public QLineEdit { public: @@ -136,8 +155,7 @@ void tst_QFocusEvent::cleanup() void tst_QFocusEvent::initWidget() { - // On X11 we have to ensure the event was processed before doing any checking, on Windows - // this is processed straight away. + // On X11 we have to ensure the event was processed before doing any checking QApplication::setActiveWindow(childFocusWidgetOne); for (int i = 0; i < 1000; ++i) { @@ -319,6 +337,10 @@ void tst_QFocusEvent::checkReason_focusWidget() void tst_QFocusEvent::checkReason_ActiveWindow() { + if ( !hasNetWM() ) { + QSKIP("No X11 WM, focus is borked", SkipAll); + } + initWidget(); QDialog* d = new QDialog( testFocusWidget ); @@ -336,7 +358,6 @@ void tst_QFocusEvent::checkReason_ActiveWindow() QVERIFY( !childFocusWidgetOne->hasFocus() ); d->hide(); - QTest::qWait(100); QTRY_VERIFY(childFocusWidgetOne->focusInEventRecieved); QVERIFY(childFocusWidgetOne->focusInEventGotFocus);