workaround lack of focus events when testing via Xvfb in tst_QFocusEvent::checkReason_ActiveWindow()

upstream commit:
c7e7a785c6

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-11-20 01:25:54 +02:00
parent e514490135
commit 8dd351c7a9
3 changed files with 29 additions and 4 deletions

2
README
View file

@ -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

View file

@ -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})

View file

@ -29,12 +29,31 @@
#include <qevent.h>
#include <qlineedit.h>
#include <QBoxLayout>
#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);