From 76ddc9bc0c14b01e2e3c760cade5265da4f4a5c1 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 7 Mar 2012 19:09:33 +0100 Subject: Autotest details of QAccessibleEvent. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ieec33c23e7b18cfedf061088d6561203a5e7ac39 Reviewed-by: Jan-Arve Sæther --- src/testlib/qtestaccessible.h | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/qtestaccessible.h b/src/testlib/qtestaccessible.h index f9b1b97ac6..048e048789 100644 --- a/src/testlib/qtestaccessible.h +++ b/src/testlib/qtestaccessible.h @@ -63,7 +63,8 @@ QT_BEGIN_NAMESPACE class QObject; -typedef QList EventList; +// Use pointers since we subclass QAccessibleEvent +typedef QList EventList; bool operator==(const QAccessibleEvent &l, const QAccessibleEvent &r) { @@ -100,8 +101,18 @@ public: static bool verifyEvent(const QAccessibleEvent& ev) { if (eventList().isEmpty()) - return FALSE; - return eventList().takeFirst() == ev; + return false; + QAccessibleEvent *first = eventList().takeFirst(); + bool res = *first == ev; + delete first; + return res; + } + static bool containsEvent(const QAccessibleEvent &event) { + Q_FOREACH (QAccessibleEvent *ev, eventList()) { + if (*ev == event) + return true; + } + return false; } private: @@ -134,12 +145,12 @@ private: eventList().append(copyEvent(event)); } - static QAccessibleEvent copyEvent(const QAccessibleEvent &event) + static QAccessibleEvent *copyEvent(const QAccessibleEvent &event) { if (event.type() == QAccessible::StateChanged) - return QAccessibleStateChangeEvent(static_cast(&event)->changedStates(), + return new QAccessibleStateChangeEvent(static_cast(&event)->changedStates(), event.object(), event.child()); - return QAccessibleEvent(event.type(), event.object(), event.child()); + return new QAccessibleEvent(event.type(), event.object(), event.child()); } static EventList &eventList() -- cgit v1.2.3 From 268f41ec70fd70d4aa44a5043d1a4e678df4c5b5 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 12 Mar 2012 10:48:08 +0200 Subject: Deliver events in qtestmouse Not waiting until the QPA event queue is processed after handleMouseEvent() is wrong. Unlike the synchronous sendEvent() calls these tests most likely utilized earlier, many of the QWindowSystemInterace functions are asynchronous in the sense that they just queue the event, delivery will happen when the event dispatcher on the main thread gets there. Change-Id: I8197d2dc4805cda684a8279ceb8d4b317f19aba7 Reviewed-by: Michael Brasser Reviewed-by: Jason McDonald --- src/testlib/qtestmouse.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h index 593e164b01..441cfa1f65 100644 --- a/src/testlib/qtestmouse.h +++ b/src/testlib/qtestmouse.h @@ -70,6 +70,15 @@ namespace QTest { enum MouseAction { MousePress, MouseRelease, MouseClick, MouseDClick, MouseMove }; + static void waitForEvents() + { +#ifdef Q_OS_MAC + QTest::qWait(20); +#else + qApp->processEvents(); +#endif + } + static void mouseEvent(MouseAction action, QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1) { @@ -119,15 +128,11 @@ namespace QTest case MouseMove: QWindowSystemInterface::handleMouseEvent(window,pos,window->mapToGlobal(pos),lastButton,stateKey); //QCursor::setPos(window->mapToGlobal(pos)); -#ifdef Q_OS_MAC - QTest::qWait(20); -#else - qApp->processEvents(); -#endif - return; + break; default: QTEST_ASSERT(false); } + waitForEvents(); } inline void mousePress(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0, -- cgit v1.2.3 From a17907829e6b180f2bb4af9a8594996b2a0e531a Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 8 Mar 2012 16:10:10 +0100 Subject: Use pointers for QAccessibleEvent. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At least on mac g++ badly wants to copy the event and cannot use the copy ctor. The sensible solution is thus to use pointers. This is in line with QCoreApplication::sendEvent. Change-Id: Icb58852be351ab04ffa17069989d7a07d4b377da Reviewed-by: Jan-Arve Sæther --- src/testlib/qtestaccessible.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/qtestaccessible.h b/src/testlib/qtestaccessible.h index 048e048789..807cc2f846 100644 --- a/src/testlib/qtestaccessible.h +++ b/src/testlib/qtestaccessible.h @@ -140,17 +140,16 @@ private: } } - static void updateHandler(const QAccessibleEvent &event) + static void updateHandler(QAccessibleEvent *event) { eventList().append(copyEvent(event)); } - - static QAccessibleEvent *copyEvent(const QAccessibleEvent &event) + static QAccessibleEvent *copyEvent(QAccessibleEvent *event) { - if (event.type() == QAccessible::StateChanged) - return new QAccessibleStateChangeEvent(static_cast(&event)->changedStates(), - event.object(), event.child()); - return new QAccessibleEvent(event.type(), event.object(), event.child()); + if (event->type() == QAccessible::StateChanged) + return new QAccessibleStateChangeEvent(static_cast(event)->changedStates(), + event->object(), event->child()); + return new QAccessibleEvent(event->type(), event->object(), event->child()); } static EventList &eventList() -- cgit v1.2.3 From 0b70d8c6afb525d80cf4f1fc788e1a5947f0b152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 14 Mar 2012 12:16:45 +0100 Subject: Improved qWaitForWindowShown(). Made faster by actually waiting for the window to be exposed, using similar waiting logic as qWait(). Should speed up autotests that use it quite a bit. Change-Id: I628c6110a554fdbbf5bed7e91f57c2fe341113ed Reviewed-by: Lars Knoll --- src/testlib/qtestsystem.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/qtestsystem.h b/src/testlib/qtestsystem.h index 1f10967557..ade5f4c8ac 100644 --- a/src/testlib/qtestsystem.h +++ b/src/testlib/qtestsystem.h @@ -53,9 +53,6 @@ QT_BEGIN_NAMESPACE class QWidget; -#ifdef Q_WS_X11 -extern void qt_x11_wait_for_window_manager(QWidget *w); -#endif namespace QTest { @@ -74,22 +71,25 @@ namespace QTest inline static bool qWaitForWindowShown(QWidget *window) { -#if defined(Q_WS_X11) - qt_x11_wait_for_window_manager(window); - QCoreApplication::processEvents(); -#else Q_UNUSED(window); qWait(200); -#endif return true; } + inline static bool qWaitForWindowShown(QWindow *window) { - Q_UNUSED(window); - qWait(200); + QElapsedTimer timer; + timer.start(); + while (!window->isExposed()) { + int remaining = int(timer.elapsed()) - 1000; + if (remaining <= 0) + break; + QCoreApplication::processEvents(QEventLoop::AllEvents, remaining); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QTest::qSleep(10); + } return true; } - } QT_END_NAMESPACE -- cgit v1.2.3