tst_QAccessibilityLinux make state checking more convenient
Change-Id: I96274ab0a0f5d942746de0166df47936e2390c65 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
This commit is contained in:
parent
07f79a8029
commit
1c614d07fb
@ -211,6 +211,27 @@ void tst_QAccessibilityLinux::registerDbus()
|
|||||||
mainWindow = getInterface(window, "org.a11y.atspi.Accessible");
|
mainWindow = getInterface(window, "org.a11y.atspi.Accessible");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quint64 getAtspiState(QDBusInterface *interface)
|
||||||
|
{
|
||||||
|
QDBusMessage msg = interface->call(QDBus::Block, "GetState");
|
||||||
|
const QDBusArgument arg = msg.arguments().at(0).value<QDBusArgument>();
|
||||||
|
quint32 state1 = 0;
|
||||||
|
quint64 state2 = 0;
|
||||||
|
arg.beginArray();
|
||||||
|
arg >> state1;
|
||||||
|
arg >> state2;
|
||||||
|
arg.endArray();
|
||||||
|
|
||||||
|
state2 = state2 << 32;
|
||||||
|
return state2 | state1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasState(QDBusInterface *interface, AtspiStateType state)
|
||||||
|
{
|
||||||
|
quint64 intState = quint64(1) << state;
|
||||||
|
return getAtspiState(interface) & intState;
|
||||||
|
}
|
||||||
|
|
||||||
#define ROOTPATH "/org/a11y/atspi/accessible"
|
#define ROOTPATH "/org/a11y/atspi/accessible"
|
||||||
|
|
||||||
void tst_QAccessibilityLinux::testLabel()
|
void tst_QAccessibilityLinux::testLabel()
|
||||||
@ -471,21 +492,6 @@ void tst_QAccessibilityLinux::testSlider()
|
|||||||
m_window->clearChildren();
|
m_window->clearChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 getAtspiState(QDBusInterface *interface)
|
|
||||||
{
|
|
||||||
QDBusMessage msg = interface->call(QDBus::Block, "GetState");
|
|
||||||
const QDBusArgument arg = msg.arguments().at(0).value<QDBusArgument>();
|
|
||||||
quint32 state1 = 0;
|
|
||||||
quint64 state2 = 0;
|
|
||||||
arg.beginArray();
|
|
||||||
arg >> state1;
|
|
||||||
arg >> state2;
|
|
||||||
arg.endArray();
|
|
||||||
|
|
||||||
state2 = state2 << 32;
|
|
||||||
return state2 | state1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QAccessibilityLinux::testFocus()
|
void tst_QAccessibilityLinux::testFocus()
|
||||||
{
|
{
|
||||||
QLineEdit *lineEdit1 = new QLineEdit(m_window);
|
QLineEdit *lineEdit1 = new QLineEdit(m_window);
|
||||||
@ -508,15 +514,14 @@ void tst_QAccessibilityLinux::testFocus()
|
|||||||
QDBusInterface *componentInterfaceLineEdit2 = getInterface(children.at(1), "org.a11y.atspi.Component");
|
QDBusInterface *componentInterfaceLineEdit2 = getInterface(children.at(1), "org.a11y.atspi.Component");
|
||||||
QVERIFY(componentInterfaceLineEdit2->isValid());
|
QVERIFY(componentInterfaceLineEdit2->isValid());
|
||||||
|
|
||||||
quint64 focusedState = quint64(1) << ATSPI_STATE_FOCUSED;
|
QVERIFY(hasState(accessibleInterfaceLineEdit1, ATSPI_STATE_FOCUSED));
|
||||||
QVERIFY(getAtspiState(accessibleInterfaceLineEdit1) & focusedState);
|
QVERIFY(!hasState(accessibleInterfaceLineEdit2, ATSPI_STATE_FOCUSED));
|
||||||
QVERIFY(!(getAtspiState(accessibleInterfaceLineEdit2) & focusedState));
|
|
||||||
|
|
||||||
QDBusMessage focusReply = componentInterfaceLineEdit2->call(QDBus::Block, "GrabFocus");
|
QDBusMessage focusReply = componentInterfaceLineEdit2->call(QDBus::Block, "GrabFocus");
|
||||||
QVERIFY(focusReply.arguments().at(0).toBool());
|
QVERIFY(focusReply.arguments().at(0).toBool());
|
||||||
QVERIFY(lineEdit2->hasFocus());
|
QVERIFY(lineEdit2->hasFocus());
|
||||||
QVERIFY(!(getAtspiState(accessibleInterfaceLineEdit1) & focusedState));
|
QVERIFY(!hasState(accessibleInterfaceLineEdit1, ATSPI_STATE_FOCUSED));
|
||||||
QVERIFY(getAtspiState(accessibleInterfaceLineEdit2) & focusedState);
|
QVERIFY(hasState(accessibleInterfaceLineEdit2, ATSPI_STATE_FOCUSED));
|
||||||
m_window->clearChildren();
|
m_window->clearChildren();
|
||||||
delete accessibleInterfaceLineEdit1;
|
delete accessibleInterfaceLineEdit1;
|
||||||
delete accessibleInterfaceLineEdit2;
|
delete accessibleInterfaceLineEdit2;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user