@@ -22,6 +22,8 @@ TestCase {
2222 name: "PhysicalKeysMapper"
2323
2424 Loader {
25+ // Using a Loader here to make sure mapper state is coherent
26+ // regardless of unmatched KeyPress and KeyRelease events
2527 id: loader
2628 active: false
2729 sourceComponent: PhysicalKeysMapper { }
@@ -94,15 +96,24 @@ TestCase {
9496 volumeDownSpy.wait(100);
9597 }
9698
97− function test_VolumeDownButton() {
98− loader.item.onKeyPressed({ key: Qt.Key_VolumeDown });
99− loader.item.onKeyReleased({ key: Qt.Key_VolumeDown });
100− volumeDownSpy.wait();
99+ function test_VolumeButton_data() {
100+ return [
101+ { tag: "Down", key: Qt.Key_VolumeDown, spy: volumeDownSpy },
102+ { tag: "Up", key: Qt.Key_VolumeUp, spy: volumeUpSpy },
103+ ];
101104 }
102105
103− function test_VolumeUpButton() {
104− loader.item.onKeyPressed({ key: Qt.Key_VolumeUp });
105− loader.item.onKeyReleased({ key: Qt.Key_VolumeUp });
106− volumeUpSpy.wait();
106+ function test_VolumeButton(data) {
107+ loader.item.onKeyPressed({ key: data.key });
108+ expectFailContinue("", "Signal should not fire on press");
109+ data.spy.wait(100);
110+ data.spy.clear();
111+
112+ loader.item.onKeyReleased({ key: data.key });
113+ data.spy.wait();
114+
115+ loader.item.onKeyPressed({ key: data.key });
116+ loader.item.onKeyPressed({ key: data.key, isAutoRepeat: true });
117+ data.spy.wait();
107118 }
108119}