diff options
Diffstat (limited to 'tests/auto/other/qaccessibility/tst_qaccessibility.cpp')
-rw-r--r-- | tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 4f891fcda0..62c2c0a916 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -162,16 +162,6 @@ static inline bool verifyChild(QWidget *child, QAccessibleInterface *interface, return true; } -static inline int indexOfChild(QAccessibleInterface *parentInterface, QWidget *childWidget) -{ - if (!parentInterface || !childWidget) - return -1; - QAccessibleInterface *childInterface(QAccessible::queryAccessibleInterface(childWidget)); - if (!childInterface) - return -1; - return parentInterface->indexOfChild(childInterface); -} - #define EXPECT(cond) \ do { \ if (!errorAt && !(cond)) { \ @@ -462,15 +452,15 @@ void tst_QAccessibility::statesStructTest() QVERIFY(s1.modal == 0); QAccessible::State s2; - QVERIFY(s2 == s1); + QCOMPARE(s2, s1); s2.busy = true; QVERIFY(!(s2 == s1)); s1.busy = true; - QVERIFY(s2 == s1); + QCOMPARE(s2, s1); s1 = QAccessible::State(); QVERIFY(!(s2 == s1)); s1 = s2; - QVERIFY(s2 == s1); + QCOMPARE(s2, s1); QVERIFY(s1.busy == 1); } @@ -533,9 +523,9 @@ void tst_QAccessibility::navigateHierarchy() QVERIFY(ifaceW->isValid()); QAccessibleInterface *target = ifaceW->child(14); - QVERIFY(target == 0); + QVERIFY(!target); target = ifaceW->child(-1); - QVERIFY(target == 0); + QVERIFY(!target); target = ifaceW->child(0); QAccessibleInterface *interfaceW1(ifaceW->child(0)); QVERIFY(target); @@ -551,7 +541,7 @@ void tst_QAccessibility::navigateHierarchy() QCOMPARE(target->object(), (QObject*)w3); QAccessibleInterface *child = target->child(1); - QVERIFY(child == 0); + QVERIFY(!child); child = target->child(0); QVERIFY(child != 0); QVERIFY(child->isValid()); @@ -969,7 +959,7 @@ void tst_QAccessibility::mainWindowTest() QWindow window; window.setGeometry(80, 80, 40, 40); window.show(); - QTRY_VERIFY(QGuiApplication::focusWindow() == &window); + QTRY_COMPARE(QGuiApplication::focusWindow(), &window); // We currently don't have an accessible interface for QWindow // the active state is either in the QMainWindow or QQuickView @@ -1313,7 +1303,7 @@ void tst_QAccessibility::tabTest() QCOMPARE(child1->text(QAccessible::Description), QLatin1String("Cool tool tip")); QCOMPARE(child1->text(QAccessible::Help), QLatin1String("I don't know")); - QVERIFY((child1->state().invisible) == false); + QVERIFY(!(child1->state().invisible)); tabBar->hide(); QCoreApplication::processEvents(); @@ -1660,7 +1650,7 @@ void tst_QAccessibility::spinBoxTest() // make sure that the line edit is not there const int numChildren = interface->childCount(); QCOMPARE(numChildren, 0); - QVERIFY(interface->child(0) == Q_NULLPTR); + QVERIFY(!interface->child(0)); QVERIFY(interface->valueInterface()); QCOMPARE(interface->valueInterface()->currentValue().toInt(), 3); @@ -1746,6 +1736,13 @@ static bool fuzzyRectCompare(const QRect &a, const QRect &b) && qAbs(delta.right()) <= MAX_ACCEPTABLE_DELTA && qAbs(delta.bottom()) <= MAX_ACCEPTABLE_DELTA; } +static QByteArray msgRectMismatch(const QRect &a, const QRect &b) +{ + QString result; + QDebug(&result) << a << "!=" << b; + return result.toLocal8Bit(); +} + void tst_QAccessibility::textEditTest() { for (int pass = 0; pass < 2; ++pass) { @@ -1791,16 +1788,24 @@ void tst_QAccessibility::textEditTest() int offset = 10; QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("d")); - QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset))); + const QRect actual10 = textIface->characterRect(offset); + const QRect expected10 = characterRect(edit, offset); + QVERIFY2(fuzzyRectCompare(actual10, expected10), msgRectMismatch(actual10, expected10).constData()); offset = 13; QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("H")); - QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset))); + const QRect actual13 = textIface->characterRect(offset); + const QRect expected13 = characterRect(edit, offset); + QVERIFY2(fuzzyRectCompare(actual13, expected13), msgRectMismatch(actual13, expected13).constData()); offset = 21; QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("y")); - QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset))); + const QRect actual21 = textIface->characterRect(offset); + const QRect expected21 = characterRect(edit, offset); + QVERIFY2(fuzzyRectCompare(actual21, expected21), msgRectMismatch(actual21, expected21).constData()); offset = 32; QCOMPARE(textIface->text(offset, offset + 1), QStringLiteral("I")); - QVERIFY(fuzzyRectCompare(textIface->characterRect(offset), characterRect(edit, offset))); + const QRect actual32 = textIface->characterRect(offset); + const QRect expected32 = characterRect(edit, offset); + QVERIFY2(fuzzyRectCompare(actual32, expected32), msgRectMismatch(actual32, expected32).constData()); QTestAccessibility::clearEvents(); @@ -2481,7 +2486,7 @@ void tst_QAccessibility::groupBoxTest() QCOMPARE(iface->text(QAccessible::Name), QLatin1String("Test QGroupBox")); QCOMPARE(iface->text(QAccessible::Description), QLatin1String("This group box will be used to test accessibility")); QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > relations = rButtonIface->relations(); - QVERIFY(relations.size() == 1); + QCOMPARE(relations.size(), 1); QPair<QAccessibleInterface*, QAccessible::Relation> relation = relations.first(); QCOMPARE(relation.first->object(), groupBox); QCOMPARE(relation.second, QAccessible::Label); @@ -3526,13 +3531,13 @@ void tst_QAccessibility::dockWidgetTest() QPoint buttonPoint = pb2->mapToGlobal(QPoint(pb2->width()/2, pb2->height()/2)); QAccessibleInterface *childAt = accDock2->childAt(buttonPoint.x(), buttonPoint.y()); QVERIFY(childAt); - QVERIFY(childAt->object() == pb2); + QCOMPARE(childAt->object(), pb2); QWidget *close1 = qobject_cast<QWidget*>(dock1Close->object()); QPoint close1ButtonPoint = close1->mapToGlobal(QPoint(close1->width()/2, close1->height()/2)); QAccessibleInterface *childAt2 = accDock1->childAt(close1ButtonPoint.x(), close1ButtonPoint.y()); QVERIFY(childAt2); - QVERIFY(childAt2->object() == close1); + QCOMPARE(childAt2->object(), close1); // custom title bar widget QDockWidget *dock3 = new QDockWidget(mw); |