From 887eec67815083a9d01d2f186898c338b6b5e565 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 4 Oct 2011 16:46:45 +0200 Subject: [PATCH] Clean up accessible spin box test. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: Ic56f5a99ee57a23d43a81d66af82324ecba8964c Reviewed-on: http://codereview.qt-project.org/5994 Reviewed-by: Qt Sanity Bot Reviewed-by: Jan-Arve Sæther --- tests/auto/qaccessibility/tst_qaccessibility.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index e0bcb30..4bb7a97 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -1658,21 +1658,32 @@ void tst_QAccessibility::menuTest() void tst_QAccessibility::spinBoxTest() { QSpinBox * const spinBox = new QSpinBox(); + spinBox->setValue(3); spinBox->show(); QAccessibleInterface * const interface = QAccessible::queryAccessibleInterface(spinBox); QVERIFY(interface); + QCOMPARE(interface->role(), QAccessible::SpinBox); const QRect widgetRect = spinBox->geometry(); - const QRect accessibleRect = interface->rect(0); + const QRect accessibleRect = interface->rect(); QCOMPARE(accessibleRect, widgetRect); + QCOMPARE(interface->text(QAccessible::Value, 0), QLatin1String("3")); - // Test that we get valid rects for all the spinbox child interfaces. + // one child, the line edit const int numChildren = interface->childCount(); - for (int i = 1; i <= numChildren; ++i) { - const QRect childRect = interface->rect(i); - QVERIFY(childRect.isNull() == false); - } + QCOMPARE(numChildren, 1); + QAccessibleInterface *lineEdit = interface->child(0); + + QCOMPARE(lineEdit->role(), QAccessible::EditableText); + QCOMPARE(lineEdit->text(QAccessible::Value, 0), QLatin1String("3")); + delete lineEdit; + + QVERIFY(interface->valueInterface()); + QCOMPARE(interface->valueInterface()->currentValue().toInt(), 3); + interface->valueInterface()->setCurrentValue(23); + QCOMPARE(interface->valueInterface()->currentValue().toInt(), 23); + QCOMPARE(spinBox->value(), 23); spinBox->setFocus(); QTestAccessibility::clearEvents(); -- 2.7.4