on xenial help sign in
consolidate the mouse deco test
commit770ce2bd5d910e4e21bcc3b9c0dab47a0de09d7a authorLukáš Tinkl <lukas.tinkl@canonical.com> dateWed 15 Jun 2016, 18:24 (10 years ago) parenta323c57
2 files changed+19−17
qml/Stages/WindowDecoration.qml+7−6 tests/qmltests/Stages/tst_DesktopStage.qml+12−11
qml/Stages/WindowDecoration.qml+7−6
@@ -27,6 +27,7 @@ MouseArea {
2727 property Item target
2828 property alias title: titleLabel.text
2929 property bool active: false
30+ acceptedButtons: Qt.AllButtons // prevent leaking unhandled mouse events
3031
3132 signal closeClicked()
3233 signal minimizeClicked()
@@ -34,7 +35,11 @@ MouseArea {
3435 signal maximizeHorizontallyClicked()
3536 signal maximizeVerticallyClicked()
3637
37− onDoubleClicked: root.maximizeClicked()
38+ onDoubleClicked: {
39+ if (mouse.button == Qt.LeftButton) {
40+ root.maximizeClicked();
41+ }
42+ }
3843
3944 QtObject {
4045 id: priv
@@ -44,11 +49,7 @@ MouseArea {
4449 }
4550
4651 onPressedChanged: {
47− if (pressedButtons != Qt.LeftButton) {
48− return;
49− }
50−
51− if (pressed) {
52+ if (pressed && pressedButtons == Qt.LeftButton) {
5253 var pos = mapToItem(root.target, mouseX, mouseY);
5354 priv.distanceX = pos.x;
5455 priv.distanceY = pos.y;
tests/qmltests/Stages/tst_DesktopStage.qml+12−11
@@ -91,10 +91,8 @@ Item {
9191 }
9292
9393 MouseArea {
94− id: fakeMouseArea
94+ id: clickThroughTester
9595 anchors.fill: desktopStageLoader.item
96− enabled: desktopStageLoader.status === Loader.Ready && testCase.running
97− visible: enabled
9896 acceptedButtons: Qt.AllButtons
9997 hoverEnabled: true
10098 }
@@ -151,7 +149,7 @@ Item {
151149
152150 SignalSpy {
153151 id: mouseEaterSpy
154− target: fakeMouseArea
152+ target: clickThroughTester
155153 }
156154
157155 UnityTestCase {
@@ -672,10 +670,11 @@ Item {
672670
673671 function test_eatWindowDecorationMouseEvents_data() {
674672 return [
675− {tag: "left mouse press", signalName: "pressed", button: Qt.LeftButton },
676− {tag: "right mouse press", signalName: "pressed", button: Qt.RightButton },
677− {tag: "middle mouse press", signalName: "pressed", button: Qt.MiddleButton },
678− {tag: "mouse wheel", signalName: "wheel", button: Qt.MiddleButton }
673+ {tag: "left mouse click", signalName: "clicked", button: Qt.LeftButton },
674+ {tag: "right mouse click", signalName: "clicked", button: Qt.RightButton },
675+ {tag: "middle mouse click", signalName: "clicked", button: Qt.MiddleButton },
676+ {tag: "mouse wheel", signalName: "wheel", button: Qt.MiddleButton },
677+ {tag: "double click (RMB)", signalName: "doubleClicked", button: Qt.RightButton },
679678 ]
680679 }
681680
@@ -685,15 +684,17 @@ Item {
685684 var decoration = findChild(dialerAppDelegate, "appWindowDecoration");
686685 verify(decoration);
687686
688− fakeMouseArea.enabled = true;
689687 mouseEaterSpy.signalName = data.signalName;
690688 if (data.signalName === "wheel") {
691689 mouseWheel(decoration, decoration.width/2, decoration.height/2, 20, 20);
692− } else {
690+ } else if (data.signalName === "clicked") {
693691 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);
694695 }
696+
695697 tryCompare(mouseEaterSpy, "count", 0);
696− fakeMouseArea.enabled = false;
697698 }
698699 }
699700}