diff options
author | Frederik Gladhorn <frederik.gladhorn@nokia.com> | 2012-03-07 16:21:38 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-12 15:34:06 +0100 |
commit | ca737f566b1016712a0d90e8b5e55e49ce8748d2 (patch) | |
tree | ed0f85dbf5541ffb083ed24270a29ff8bdb172a0 /src | |
parent | 431eb30e9ec21c15d26d6f1b03d3bbd4cd36c30c (diff) |
Use QAccessibleEvent in test.
Change-Id: I4f9c0f503543caa5704a29c8ccd7c4134b455625
Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/testlib/qtestaccessible.h | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/src/testlib/qtestaccessible.h b/src/testlib/qtestaccessible.h index d402cc8cf8..f9b1b97ac6 100644 --- a/src/testlib/qtestaccessible.h +++ b/src/testlib/qtestaccessible.h @@ -49,8 +49,8 @@ #ifndef QT_NO_ACCESSIBILITY -#define QVERIFY_EVENT(object, child, event) \ - QVERIFY(QTestAccessibility::verifyEvent(object, child, (int)event)) +#define QVERIFY_EVENT(event) \ + QVERIFY(QTestAccessibility::verifyEvent(event)) #include <QtCore/qlist.h> #include <QtGui/qaccessible.h> @@ -63,22 +63,21 @@ QT_BEGIN_NAMESPACE class QObject; -struct QTestAccessibilityEvent -{ - QTestAccessibilityEvent(QObject* o = 0, int c = 0, int e = 0) - : object(o), child(c), event(e) {} +typedef QList<QAccessibleEvent> EventList; - bool operator==(const QTestAccessibilityEvent &o) const - { - return o.object == object && o.child == child && o.event == event; +bool operator==(const QAccessibleEvent &l, const QAccessibleEvent &r) +{ + if (l.type() != r.type() || + l.object() != r.object() || + l.child() != r.child()) + return false; + + if (l.type() == QAccessible::StateChanged) { + return static_cast<const QAccessibleStateChangeEvent*>(&l)->changedStates() + == static_cast<const QAccessibleStateChangeEvent*>(&r)->changedStates(); } - - QObject* object; - int child; - int event; -}; - -typedef QList<QTestAccessibilityEvent> EventList; + return true; +} class QTestAccessibility { @@ -90,6 +89,7 @@ public: qAddPostRoutine(cleanup); } } + static void cleanup() { delete instance(); @@ -97,18 +97,13 @@ public: } static void clearEvents() { eventList().clear(); } static EventList events() { return eventList(); } - static bool verifyEvent(const QTestAccessibilityEvent& ev) + static bool verifyEvent(const QAccessibleEvent& ev) { if (eventList().isEmpty()) return FALSE; return eventList().takeFirst() == ev; } - static bool verifyEvent(QObject *o, int c, int e) - { - return verifyEvent(QTestAccessibilityEvent(o, c, e)); - } - private: QTestAccessibility() { @@ -136,8 +131,15 @@ private: static void updateHandler(const QAccessibleEvent &event) { - // qDebug("updateHandler called: %p %d %d", o, c, (int)e); - eventList().append(QTestAccessibilityEvent(event.object(), event.child(), (int)event.type())); + eventList().append(copyEvent(event)); + } + + static QAccessibleEvent copyEvent(const QAccessibleEvent &event) + { + if (event.type() == QAccessible::StateChanged) + return QAccessibleStateChangeEvent(static_cast<const QAccessibleStateChangeEvent*>(&event)->changedStates(), + event.object(), event.child()); + return QAccessibleEvent(event.type(), event.object(), event.child()); } static EventList &eventList() |