Relax the reqirement in which order events are delivered.

When the pushbutton is shown, it will generate both a ShowEvent and
a StateChange with active=1 (because it is a top level window).

This patch relaxes the reqirement in which order events are delivered.

Ideally the order should also relied on, but I'm not sure if that
is feasible due to differences among window managers across all
platforms.

This got provoked by codereview.qt-project.org/#change,26014

Change-Id: I96159fbb1b64f0ca8d13833d8a4c6799c655afc2
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
This commit is contained in:
Jan-Arve Saether 2012-07-13 09:45:37 +02:00 committed by Qt by Nokia
parent 02faddca53
commit d45bc23cd5

View File

@ -386,7 +386,8 @@ void tst_QAccessibility::eventTest()
button->show();
QAccessibleEvent showEvent(button, QAccessible::ObjectShow);
QVERIFY_EVENT(&showEvent);
// some platforms might send other events first, (such as state change event active=1)
QVERIFY(QTestAccessibility::containsEvent(&showEvent));
button->setFocus(Qt::MouseFocusReason);
QTestAccessibility::clearEvents();
QTest::mouseClick(button, Qt::LeftButton, 0);
@ -400,7 +401,8 @@ void tst_QAccessibility::eventTest()
button->hide();
QAccessibleEvent hideEvent(button, QAccessible::ObjectHide);
QVERIFY_EVENT(&hideEvent);
// some platforms might send other events first, (such as state change event active=1)
QVERIFY(QTestAccessibility::containsEvent(&hideEvent));
delete button;
}
@ -800,18 +802,20 @@ void tst_QAccessibility::mainWindowTest()
QLatin1String name = QLatin1String("I am the main window");
mw->setWindowTitle(name);
QTest::qWaitForWindowShown(mw);
// The order of events is not really that important.
QAccessibleEvent show(mw, QAccessible::ObjectShow);
QVERIFY_EVENT(&show);
QVERIFY(QTestAccessibility::containsEvent(&show));
QAccessible::State activeState;
activeState.active = true;
QAccessibleStateChangeEvent active(mw, activeState);
QVERIFY(QTestAccessibility::containsEvent(&active));
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(mw);
QCOMPARE(iface->text(QAccessible::Name), name);
QCOMPARE(iface->role(), QAccessible::Window);
QVERIFY(iface->state().active);
QAccessible::State activeState;
activeState.active = true;
QAccessibleStateChangeEvent active(mw, activeState);
QVERIFY_EVENT(&active);
delete iface;
delete mw;