on xenial help sign in
consolidate the mouse deco test
770ce2bLukáš Tinkl
qml/Stages/WindowDecoration.qml+7−6
@@ -27,6 +27,7 @@ MouseArea {
27 property Item target
27 property Item target
28 property alias title: titleLabel.text
28 property alias title: titleLabel.text
29 property bool active: false
29 property bool active: false
30+ acceptedButtons: Qt.AllButtons // prevent leaking unhandled mouse events
30
31
31 signal closeClicked()
32 signal closeClicked()
32 signal minimizeClicked()
33 signal minimizeClicked()
@@ -34,7 +35,11 @@ MouseArea {
34 signal maximizeHorizontallyClicked()
35 signal maximizeHorizontallyClicked()
35 signal maximizeVerticallyClicked()
36 signal maximizeVerticallyClicked()
36
37
38+ onDoubleClicked: {
39+ if (mouse.button == Qt.LeftButton) {
37− onDoubleClicked: root.maximizeClicked()
40+ root.maximizeClicked();
41+ }
42+ }
38
43
39 QtObject {
44 QtObject {
40 id: priv
45 id: priv
@@ -44,11 +49,7 @@ MouseArea {
44 }
49 }
45
50
46 onPressedChanged: {
51 onPressedChanged: {
47− if (pressedButtons != Qt.LeftButton) {
52+ if (pressed && pressedButtons == Qt.LeftButton) {
48− return;
49− }
50−
51− if (pressed) {
52 var pos = mapToItem(root.target, mouseX, mouseY);
53 var pos = mapToItem(root.target, mouseX, mouseY);
53 priv.distanceX = pos.x;
54 priv.distanceX = pos.x;
54 priv.distanceY = pos.y;
55 priv.distanceY = pos.y;
tests/qmltests/Stages/tst_DesktopStage.qml+12−11
@@ -91,10 +91,8 @@ Item {
91 }
91 }
92
92
93 MouseArea {
93 MouseArea {
94− id: fakeMouseArea
94+ id: clickThroughTester
95 anchors.fill: desktopStageLoader.item
95 anchors.fill: desktopStageLoader.item
96− enabled: desktopStageLoader.status === Loader.Ready && testCase.running
97− visible: enabled
98 acceptedButtons: Qt.AllButtons
96 acceptedButtons: Qt.AllButtons
99 hoverEnabled: true
97 hoverEnabled: true
100 }
98 }
@@ -151,7 +149,7 @@ Item {
151
149
152 SignalSpy {
150 SignalSpy {
153 id: mouseEaterSpy
151 id: mouseEaterSpy
154− target: fakeMouseArea
152+ target: clickThroughTester
155 }
153 }
156
154
157 UnityTestCase {
155 UnityTestCase {
@@ -672,10 +670,11 @@ Item {
672
670
673 function test_eatWindowDecorationMouseEvents_data() {
671 function test_eatWindowDecorationMouseEvents_data() {
674 return [
672 return [
675− {tag: "left mouse press", signalName: "pressed", button: Qt.LeftButton },
673+ {tag: "left mouse click", signalName: "clicked", button: Qt.LeftButton },
676− {tag: "right mouse press", signalName: "pressed", button: Qt.RightButton },
674+ {tag: "right mouse click", signalName: "clicked", button: Qt.RightButton },
677− {tag: "middle mouse press", signalName: "pressed", button: Qt.MiddleButton },
675+ {tag: "middle mouse click", signalName: "clicked", button: Qt.MiddleButton },
678− {tag: "mouse wheel", signalName: "wheel", button: Qt.MiddleButton }
676+ {tag: "mouse wheel", signalName: "wheel", button: Qt.MiddleButton },
677+ {tag: "double click (RMB)", signalName: "doubleClicked", button: Qt.RightButton },
679 ]
678 ]
680 }
679 }
681
680
@@ -685,15 +684,17 @@ Item {
685 var decoration = findChild(dialerAppDelegate, "appWindowDecoration");
684 var decoration = findChild(dialerAppDelegate, "appWindowDecoration");
686 verify(decoration);
685 verify(decoration);
687
686
688− fakeMouseArea.enabled = true;
689 mouseEaterSpy.signalName = data.signalName;
687 mouseEaterSpy.signalName = data.signalName;
690 if (data.signalName === "wheel") {
688 if (data.signalName === "wheel") {
691 mouseWheel(decoration, decoration.width/2, decoration.height/2, 20, 20);
689 mouseWheel(decoration, decoration.width/2, decoration.height/2, 20, 20);
692− } else {
690+ } else if (data.signalName === "clicked") {
693 mouseClick(decoration, decoration.width/2, decoration.height/2, data.button);
691 mouseClick(decoration, decoration.width/2, decoration.height/2, data.button);
692+ } else {
693+ mouseDoubleClick(decoration, decoration.width/2, decoration.height/2, data.button);
694+ tryCompare(dialerAppDelegate, "maximized", false);
694 }
695 }
696+
695 tryCompare(mouseEaterSpy, "count", 0);
697 tryCompare(mouseEaterSpy, "count", 0);
696− fakeMouseArea.enabled = false;
697 }
698 }
698 }
699 }
699}
700}