diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-10-25 20:13:09 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-11-03 10:36:58 +0000 |
commit | 043e3d24f9306c18af97156ec613bb64a9dc0d91 (patch) | |
tree | 897d6e5a8851bc07c2997cf02549f6e575ac4f41 /tests/auto/controls/data/tst_checkbox.qml | |
parent | a44d4b5f22799d26414ba8e635cd5ccd88ca1e7d (diff) |
Expose QQuickCheckBox::nextCheckState() to QML
[ChangeLog][Controls][CheckBox] Made it possible to implement
nextCheckState() in QML.
Task-number: QTBUG-63238
Change-Id: I9ca27409efcaf546f557b974563ba598658fe694
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/controls/data/tst_checkbox.qml')
-rw-r--r-- | tests/auto/controls/data/tst_checkbox.qml | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_checkbox.qml b/tests/auto/controls/data/tst_checkbox.qml index cfce1b40..3fb7d15e 100644 --- a/tests/auto/controls/data/tst_checkbox.qml +++ b/tests/auto/controls/data/tst_checkbox.qml @@ -494,4 +494,51 @@ TestCase { verify(control) compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset) } + + Component { + id: nextCheckStateBox + CheckBox { + 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(nextCheckStateBox, 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) + } } |