aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickaccessible
diff options
context:
space:
mode:
authorJan Arve Sæther <jan-arve.saether@qt.io>2019-05-07 14:58:29 +0200
committerFrederik Gladhorn <frederik.gladhorn@qt.io>2019-05-09 06:56:35 +0000
commitd12cc4f6b58ecb5f44458002fe9b74d0c84f10ae (patch)
tree51fa3c077c26c2aad1571673c8d24365d5336e16 /tests/auto/quick/qquickaccessible
parent4a4842118d2303a8d851d1d8b85fe182d3fe492a (diff)
Don't overwrite states if role is assigned after a state
We therefore need to keep track of which states have been explicitly set or not in order to know which ones should get initialized with their defaults. Change-Id: I49fdae82288f04ea4f50d45735a93434ac02abec Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickaccessible')
-rw-r--r--tests/auto/quick/qquickaccessible/data/text.qml11
-rw-r--r--tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp26
2 files changed, 36 insertions, 1 deletions
diff --git a/tests/auto/quick/qquickaccessible/data/text.qml b/tests/auto/quick/qquickaccessible/data/text.qml
index 88f292a61f..6daeacfd81 100644
--- a/tests/auto/quick/qquickaccessible/data/text.qml
+++ b/tests/auto/quick/qquickaccessible/data/text.qml
@@ -46,4 +46,15 @@ Item {
text: "A multi-line text edit\nTesting Accessibility."
Accessible.role: Accessible.EditableText
}
+
+ Text {
+ x: 100
+ y: 160
+ width: 100
+ height: 40
+ text : "Hello 3"
+ Accessible.name: text
+ Accessible.description: "description"
+ }
+
}
diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
index 243d87f212..c5fdb6c1b9 100644
--- a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
+++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
@@ -312,7 +312,7 @@ void tst_QQuickAccessible::basicPropertiesTest()
QAccessibleInterface *item = iface->child(0);
QVERIFY(item);
- QCOMPARE(item->childCount(), 4);
+ QCOMPARE(item->childCount(), 5);
QCOMPARE(item->rect().size(), QSize(400, 400));
QCOMPARE(item->role(), QAccessible::Client);
QCOMPARE(iface->indexOfChild(item), 0);
@@ -382,6 +382,30 @@ void tst_QQuickAccessible::basicPropertiesTest()
QEXPECT_FAIL("", "multi line is not implemented", Continue);
QCOMPARE(textInput->state().multiLine, 1);
+ // Text "Hello 3"
+ QAccessibleInterface *text3 = item->child(4);
+ QVERIFY(text3);
+ QCOMPARE(text3->childCount(), 0);
+ QCOMPARE(text3->text(QAccessible::Name), QLatin1String("Hello 3"));
+ QCOMPARE(text3->role(), QAccessible::StaticText);
+ QCOMPARE(item->indexOfChild(text3), 4);
+ QCOMPARE(text3->state().editable, 0);
+ QCOMPARE(text3->state().readOnly, 0);
+ // test implicit state values due to role change
+ QQuickAccessibleAttached *attached = QQuickAccessibleAttached::attachedProperties(text3->object());
+ attached->setRole(QAccessible::StaticText);
+ QCOMPARE(text3->role(), QAccessible::StaticText);
+ QCOMPARE(text3->state().readOnly, 1);
+
+ // see if implicit changes back
+ attached->setRole(QAccessible::EditableText);
+ QEXPECT_FAIL("", "EditableText does not implicitly set readOnly to false", Continue);
+ QCOMPARE(text3->state().readOnly, 0);
+ // explicitly set state
+ attached->set_readOnly(false);
+ attached->setRole(QAccessible::StaticText);
+ QCOMPARE(text3->state().readOnly, 0);
+
delete window;
QTestAccessibility::clearEvents();
}