aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/controls/data/tst_checkdelegate.qml
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-11-08 10:36:00 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-11-08 10:13:55 +0000
commit03155ec2e2fd6cc60b4293af19964d2e1a65b7d9 (patch)
tree9aacfeca5df6f8e65ee3f66d8434bed392733b96 /tests/auto/controls/data/tst_checkdelegate.qml
parentf246314b21604c5fe2a2abe0aec8af89f06eb610 (diff)
Expose QQuickCheckDelegate::nextCheckState() to QML
Same as 043e3d24 for CheckBox. [ChangeLog][Controls][CheckDelegate] Made it possible to implement nextCheckState() in QML. Task-number: QTBUG-63238 Change-Id: Id765191b1e5559393696183ffea9ed9c69eed475 Reviewed-by: Liang Qi <liang.qi@qt.io>
Diffstat (limited to 'tests/auto/controls/data/tst_checkdelegate.qml')
-rw-r--r--tests/auto/controls/data/tst_checkdelegate.qml47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_checkdelegate.qml b/tests/auto/controls/data/tst_checkdelegate.qml
index 9f92b4dc..72b45251 100644
--- a/tests/auto/controls/data/tst_checkdelegate.qml
+++ b/tests/auto/controls/data/tst_checkdelegate.qml
@@ -170,4 +170,51 @@ TestCase {
break;
}
}
+
+ Component {
+ id: nextCheckStateDelegate
+ CheckDelegate {
+ tristate: true
+ nextCheckState: function() {
+ if (checkState === Qt.Checked)
+ return Qt.Unchecked
+ else
+ return Qt.Checked
+ }
+ }
+ }
+
+ function test_nextCheckState_data() {
+ return [
+ { tag: "unchecked", checkState: Qt.Unchecked, expectedState: Qt.Checked },
+ { tag: "partially-checked", checkState: Qt.PartiallyChecked, expectedState: Qt.Checked },
+ { tag: "checked", checkState: Qt.Checked, expectedState: Qt.Unchecked }
+ ]
+ }
+
+ function test_nextCheckState(data) {
+ var control = createTemporaryObject(nextCheckStateDelegate, testCase)
+ verify(control)
+
+ // mouse
+ control.checkState = data.checkState
+ compare(control.checkState, data.checkState)
+ mouseClick(control)
+ compare(control.checkState, data.expectedState)
+
+ // touch
+ control.checkState = data.checkState
+ compare(control.checkState, data.checkState)
+ var touch = touchEvent(control)
+ touch.press(0, control).commit().release(0, control).commit()
+ compare(control.checkState, data.expectedState)
+
+ // keyboard
+ control.forceActiveFocus()
+ tryCompare(control, "activeFocus", true)
+ control.checkState = data.checkState
+ compare(control.checkState, data.checkState)
+ keyClick(Qt.Key_Space)
+ compare(control.checkState, data.expectedState)
+ }
}