diff options
author | J-P Nurmi <jpnurmi@digia.com> | 2014-05-30 22:18:38 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-06-02 20:19:15 +0200 |
commit | be1df188f22757d30e474265082d12119dd46844 (patch) | |
tree | c17eba5ee91c32d3d0ffc15dbae69dfa41b08fd8 /tests/auto/controls/data/tst_switch.qml | |
parent | 35c11e02e01d19e1184a97be7e7aba9b1b936b79 (diff) | |
download | qtquickcontrols-be1df188f22757d30e474265082d12119dd46844.tar.gz |
Switch: add pressed-property and clicked() signal
Align with the basic functionality offered by CheckBox, and also
required by certain styles.
Change-Id: I53f2868f19a26e9abc0ed9c94d327edbe940429b
Reviewed-by: Caroline Chao <caroline.chao@digia.com>
Diffstat (limited to 'tests/auto/controls/data/tst_switch.qml')
-rw-r--r-- | tests/auto/controls/data/tst_switch.qml | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_switch.qml b/tests/auto/controls/data/tst_switch.qml index dad39301..2cfd1008 100644 --- a/tests/auto/controls/data/tst_switch.qml +++ b/tests/auto/controls/data/tst_switch.qml @@ -102,6 +102,36 @@ Item { compare(aSwitch.checked, true); } + function test_pressed() { + signalSpy.signalName = "pressedChanged" + signalSpy.target = aSwitch; + compare(signalSpy.count, 0); + compare(aSwitch.pressed, false); + + mousePress(aSwitch, aSwitch.x + 1, aSwitch.y + 1, Qt.LeftButton); + compare(aSwitch.pressed, true); + compare(signalSpy.count, 1); + + mouseRelease(aSwitch, aSwitch.x + 1, aSwitch.y + 1, Qt.LeftButton); + compare(aSwitch.pressed, false); + compare(signalSpy.count, 2); + } + + function test_clicked() { + signalSpy.signalName = "clicked" + signalSpy.target = aSwitch; + compare(signalSpy.count, 0); + + mouseClick(aSwitch, aSwitch.x + 1, aSwitch.y + 1, Qt.LeftButton); + compare(signalSpy.count, 1); + + // release outside -> no clicked() + mousePress(aSwitch, aSwitch.x + 1, aSwitch.y + 1, Qt.LeftButton); + mouseMove(aSwitch, aSwitch.x - 1, aSwitch.y - 1, Qt.LeftButton); + mouseRelease(aSwitch, aSwitch.x - 1, aSwitch.y - 1, Qt.LeftButton); + compare(signalSpy.count, 1); + } + function test_keyPressed() { aSwitch.forceActiveFocus(); signalSpy.signalName = "checkedChanged"; |