aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@digia.com>2014-09-23 11:24:58 +0200
committerJan Arve Sæther <jan-arve.saether@theqtcompany.com>2014-10-20 17:10:01 +0200
commit09a67ad96508dad0e85137c68d9e45fc3544a138 (patch)
treee605409bea60b5a742ac15604f92035d02b2e8ff /tests/auto/quick
parent7f692693d98522187029e82c746627e3bd51be67 (diff)
Make test more robust against ignored children.
With the upcoming change that changes the semantics of Accessible.ignored, some assumptions in the test does not hold anymore. Change-Id: I9b34f1ecc61fc0d4e8abe5a5505a5bcff44501d4 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/qquickaccessible/data/checkbuttons.qml1
-rw-r--r--tests/auto/quick/qquickaccessible/data/hittest.qml42
-rw-r--r--tests/auto/quick/qquickaccessible/data/statictext.qml2
-rw-r--r--tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp72
4 files changed, 84 insertions, 33 deletions
diff --git a/tests/auto/quick/qquickaccessible/data/checkbuttons.qml b/tests/auto/quick/qquickaccessible/data/checkbuttons.qml
index 8769c04095..8424e3b2d5 100644
--- a/tests/auto/quick/qquickaccessible/data/checkbuttons.qml
+++ b/tests/auto/quick/qquickaccessible/data/checkbuttons.qml
@@ -3,6 +3,7 @@ import QtQuick 2.0
Item {
width: 400
height: 400
+ Accessible.name: "root"
// button, not checkable
Rectangle {
diff --git a/tests/auto/quick/qquickaccessible/data/hittest.qml b/tests/auto/quick/qquickaccessible/data/hittest.qml
index 07e2bbaaf6..97eb6013a1 100644
--- a/tests/auto/quick/qquickaccessible/data/hittest.qml
+++ b/tests/auto/quick/qquickaccessible/data/hittest.qml
@@ -40,6 +40,7 @@ Rectangle {
width: 640
height: 480
color: "white"
+ Accessible.name: "root"
Rectangle {
id: header
color: "#c0c0c0"
@@ -165,4 +166,45 @@ Rectangle {
}
}
+ TextRect {
+ x: 0
+ y: 300
+ text: "rect3"
+ width: 200
+ height: 100
+ color: "#ffa0a0"
+ TextRect {
+ x: 10
+ y: 10
+ text: "rect30"
+ width: 80
+ height: 80
+ color: "#ffa0a0"
+ TextRect {
+ x: 30
+ y: 50
+ text: "rect300"
+ width: 80
+ height: 80
+ color: "#ffa0a0"
+ }
+ }
+ TextRect {
+ x: 100
+ y: 10
+ text: "rect31"
+ width: 80
+ height: 80
+ color: "#ffa0a0"
+ TextRect {
+ x: -50
+ y: 60
+ z: -3
+ text: "rect310"
+ width: 80
+ height: 80
+ color: "#ffa0a0"
+ }
+ }
+ }
}
diff --git a/tests/auto/quick/qquickaccessible/data/statictext.qml b/tests/auto/quick/qquickaccessible/data/statictext.qml
index 7cf1b707a0..1092f33daf 100644
--- a/tests/auto/quick/qquickaccessible/data/statictext.qml
+++ b/tests/auto/quick/qquickaccessible/data/statictext.qml
@@ -3,6 +3,8 @@ import QtQuick 2.0
Item {
width: 400
height: 400
+ Accessible.name: "root"
+ Accessible.role: Accessible.Client
Text {
x: 100
diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
index 2806c41bef..c514f96d24 100644
--- a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
+++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
@@ -332,40 +332,46 @@ void tst_QQuickAccessible::hitTest()
// check the root item from app
QAccessibleInterface *appIface = QAccessible::queryAccessibleInterface(qApp);
QVERIFY(appIface);
- QAccessibleInterface *itemHit(appIface->childAt(rootRect.x() + 200, rootRect.y() + 50));
+ QAccessibleInterface *itemHit = appIface->childAt(rootRect.x() + 200, rootRect.y() + 50);
QVERIFY(itemHit);
- QCOMPARE(rootRect, itemHit->rect());
-
- // hit rect1
- QAccessibleInterface *rect1(rootItem->child(0));
- QRect rect1Rect = rect1->rect();
- QAccessibleInterface *rootItemIface = rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10);
- QVERIFY(rootItemIface);
- QCOMPARE(rect1Rect, rootItemIface->rect());
- QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect1"));
-
- // should also work from top level (app)
- QAccessibleInterface *app(QAccessible::queryAccessibleInterface(qApp));
- QAccessibleInterface *itemHit2(topLevelChildAt(app, rect1Rect.x() + 10, rect1Rect.y() + 10));
- QVERIFY(itemHit2);
- QCOMPARE(itemHit2->rect(), rect1Rect);
- QCOMPARE(itemHit2->text(QAccessible::Name), QLatin1String("rect1"));
-
- // hit rect201
- QAccessibleInterface *rect2(rootItem->child(1));
- QVERIFY(rect2);
- // FIXME: This is seems broken on mac
- // QCOMPARE(rect2->rect().translated(rootItem->rect().x(), rootItem->rect().y()), QRect(0, 50, 100, 100));
- QAccessibleInterface *rect20(rect2->child(0));
- QVERIFY(rect20);
- QAccessibleInterface *rect201(rect20->child(1));
- QVERIFY(rect201);
-
- QRect rect201Rect = rect201->rect();
- rootItemIface = windowIface->childAt(rect201Rect.x() + 20, rect201Rect.y() + 20);
- QVERIFY(rootItemIface);
- QCOMPARE(rootItemIface->rect(), rect201Rect);
- QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect201"));
+ QCOMPARE(itemHit->rect(), rootRect);
+
+ QAccessibleInterface *rootItemIface;
+ for (int c = 0; c < rootItem->childCount(); ++c) {
+ QAccessibleInterface *iface = rootItem->child(c);
+ QString name = iface->text(QAccessible::Name);
+ if (name == QLatin1String("rect1")) {
+ // hit rect1
+ QAccessibleInterface *rect1 = iface;
+ QRect rect1Rect = rect1->rect();
+ QAccessibleInterface *rootItemIface = rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10);
+ QVERIFY(rootItemIface);
+ QCOMPARE(rect1Rect, rootItemIface->rect());
+ QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect1"));
+
+ // should also work from top level (app)
+ QAccessibleInterface *app(QAccessible::queryAccessibleInterface(qApp));
+ QAccessibleInterface *itemHit2(topLevelChildAt(app, rect1Rect.x() + 10, rect1Rect.y() + 10));
+ QVERIFY(itemHit2);
+ QCOMPARE(itemHit2->rect(), rect1Rect);
+ QCOMPARE(itemHit2->text(QAccessible::Name), QLatin1String("rect1"));
+ } else if (name == QLatin1String("rect2")) {
+ QAccessibleInterface *rect2 = iface;
+ // FIXME: This is seems broken on OS X
+ // QCOMPARE(rect2->rect().translated(rootItem->rect().x(), rootItem->rect().y()), QRect(0, 50, 100, 100));
+ QAccessibleInterface *rect20 = rect2->child(0);
+ QVERIFY(rect20);
+ QCOMPARE(rect20->text(QAccessible::Name), QLatin1String("rect20"));
+ QPoint p = rect20->rect().bottomRight() + QPoint(20, 20);
+ QAccessibleInterface *rect201 = rect20->childAt(p.x(), p.y());
+ QVERIFY(rect201);
+ QCOMPARE(rect201->text(QAccessible::Name), QLatin1String("rect201"));
+ rootItemIface = topLevelChildAt(windowIface, p.x(), p.y());
+ QVERIFY(rootItemIface);
+ QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect201"));
+
+ }
+ }
delete window;
QTestAccessibility::clearEvents();