aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJoni Poikelin <joni.poikelin@qt.io>2017-12-12 14:25:48 +0200
committerJoni Poikelin <joni.poikelin@qt.io>2017-12-13 07:45:33 +0000
commit3688d440ab22c5887dd5f5e85de561f5571ea6ba (patch)
treea68f3d28acc92f853e69663455bc69b5a62bee35 /tests/auto
parent43719398070b799c54e095724691bb5a9339cefa (diff)
Fix double toggling through Action with checked AbstractButton
Action caused checked state of the button to be reset back to its original value if checked status had been change through click or key press. To avoid this, separate private function has been added to that does not change the status. Task-number: QTBUG-65108 Change-Id: I8a5aaa9aab739db3ba10d0202f5fb718cc7195bd Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/controls/data/tst_abstractbutton.qml63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_abstractbutton.qml b/tests/auto/controls/data/tst_abstractbutton.qml
index 90c6567f..ea381a32 100644
--- a/tests/auto/controls/data/tst_abstractbutton.qml
+++ b/tests/auto/controls/data/tst_abstractbutton.qml
@@ -262,6 +262,69 @@ TestCase {
compare(control.action.enabled, true) // does NOT propagate
}
+ Component {
+ id: checkableButton
+ AbstractButton {
+ checkable: true
+ action: Action {}
+ }
+ }
+
+ function test_checkable_button() {
+ var control = createTemporaryObject(checkableButton, testCase)
+ verify(control)
+ control.checked = false
+ control.forceActiveFocus()
+ verify(control.activeFocus)
+ verify(!control.checked)
+ verify(!control.action.checked)
+
+ keyPress(Qt.Key_Space)
+ keyRelease(Qt.Key_Space)
+
+ compare(control.action.checked, true)
+ compare(control.checked, true)
+
+ keyPress(Qt.Key_Space)
+
+ compare(control.action.checked, true)
+ compare(control.checked, true)
+
+ keyRelease(Qt.Key_Space)
+
+ compare(control.action.checked, false)
+ compare(control.checked, false)
+
+ var checkedSpy = signalSpy.createObject(control, {target: control.action, signalName: "checkedChanged"})
+ var toggledSpy = signalSpy.createObject(control, {target: control, signalName: "toggled"})
+ var actionToggledSpy = signalSpy.createObject(control, {target: control.action, signalName: "toggled"})
+
+ verify(checkedSpy.valid)
+ verify(toggledSpy.valid)
+ verify(actionToggledSpy.valid)
+
+ mousePress(control)
+
+ compare(control.action.checked, false)
+ compare(control.checked, false)
+
+ mouseRelease(control)
+
+ checkedSpy.wait()
+ compare(checkedSpy.count, 1)
+ compare(actionToggledSpy.count, 1)
+ compare(toggledSpy.count, 1)
+
+ compare(control.action.checked, true)
+ compare(control.checked, true)
+
+ mousePress(control)
+ mouseRelease(control)
+
+ compare(control.checked, false)
+ compare(control.action.checked, false)
+ }
+
function test_trigger_data() {
return [
{tag: "click", click: true, button: true, action: true, clicked: true, triggered: true},