on xenial help sign in
Make DragHandle tests run again.
f7a8a76Daniel d'Andrada
plugins/Ubuntu/Gestures/DirectionalDragArea.cpp+8−2
@@ -715,8 +715,14 @@ void DirectionalDragArea::itemChange(ItemChange change, const ItemChangeData &va
715 value.window->installEventFilter(TouchRegistry::instance());
715 value.window->installEventFilter(TouchRegistry::instance());
716
716
717 // TODO: Handle window->screen() changes (ie window changing screens)
717 // TODO: Handle window->screen() changes (ie window changing screens)
718+
718− qreal pixelsPerMm = value.window->screen()->physicalDotsPerInch() / 25.4;
719+ qreal pixelsPerInch = value.window->screen()->physicalDotsPerInch();
719− d->setPixelsPerMm(pixelsPerMm);
720+ if (pixelsPerInch < 0) {
721+ // It can return garbage when run in a XVFB server (Virtual Framebuffer 'fake' X server)
722+ pixelsPerInch = 72;
723+ }
724+
725+ d->setPixelsPerMm(pixelsPerInch / 25.4);
720 }
726 }
721 }
727 }
722}
728}
tests/qmltests/Components/CMakeLists.txt+1−1
@@ -15,7 +15,7 @@ qt5_use_modules(DragHandleTestExec Test Core Qml Gui Quick)
15target_link_libraries(DragHandleTestExec UbuntuGesturesQml UbuntuGestures)
15target_link_libraries(DragHandleTestExec UbuntuGesturesQml UbuntuGestures)
16
16
17add_unity8_uitest(DragHandle DragHandleTestExec ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures)
17add_unity8_uitest(DragHandle DragHandleTestExec ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/Ubuntu/Gestures)
18−add_manual_qml_test(. DragHandle IMPORT_PATHS ${UNITY_PLUGINPATH})
18+add_manual_qml_test(. DragHandle IMPORT_PATHS ${UNITY_IMPORT_PATHS})
19
19
20########## tst_EdgeDragEvaluator
20########## tst_EdgeDragEvaluator
21add_executable(EdgeDragEvaluatorTestExec tst_EdgeDragEvaluator.cpp)
21add_executable(EdgeDragEvaluatorTestExec tst_EdgeDragEvaluator.cpp)
tests/qmltests/Components/tst_DragHandle.qml+6−6
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2013,2015 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -51,7 +51,7 @@ Rectangle {
51 objectName: "baseItem"
51 objectName: "baseItem"
52 anchors.fill: parent
52 anchors.fill: parent
53
53
54− Button {
54+ SimpleButton {
55 visible: root.bidirectional && bidirectionalShowable.fullyHidden
55 visible: root.bidirectional && bidirectionalShowable.fullyHidden
56 text: "bidirectionalShowable.show()"
56 text: "bidirectionalShowable.show()"
57 anchors.centerIn: parent
57 anchors.centerIn: parent
@@ -169,12 +169,12 @@ Rectangle {
169 anchors.margins: units.gu(1)
169 anchors.margins: units.gu(1)
170 spacing: units.gu(1)
170 spacing: units.gu(1)
171
171
172− Button {
172+ SimpleButton {
173 text: root.stretch ? "stretch" : "move"
173 text: root.stretch ? "stretch" : "move"
174 onClicked: { root.stretch = !root.stretch; }
174 onClicked: { root.stretch = !root.stretch; }
175 }
175 }
176
176
177− Button {
177+ SimpleButton {
178 text: root.hintDisplacement > 0 ? "hint" : "no hint"
178 text: root.hintDisplacement > 0 ? "hint" : "no hint"
179 onClicked: {
179 onClicked: {
180 if (root.hintDisplacement > 0) {
180 if (root.hintDisplacement > 0) {
@@ -185,7 +185,7 @@ Rectangle {
185 }
185 }
186 }
186 }
187
187
188− Button {
188+ SimpleButton {
189 text: "rotation: " + baseItem.rotation
189 text: "rotation: " + baseItem.rotation
190 onClicked: {
190 onClicked: {
191 if (baseItem.rotation === 0.0) {
191 if (baseItem.rotation === 0.0) {
@@ -196,7 +196,7 @@ Rectangle {
196 }
196 }
197 }
197 }
198
198
199− Button {
199+ SimpleButton {
200 text: root.bidirectional ? "bidirectional" : "directional"
200 text: root.bidirectional ? "bidirectional" : "directional"
201 onClicked: { root.bidirectional = !root.bidirectional; }
201 onClicked: { root.bidirectional = !root.bidirectional; }
202 }
202 }
tests/qmltests/Components/tst_DragHandle/SimpleButton.qmlnew file+36
@@ -0,0 +1,36 @@
1+/*
2+ * Copyright 2015 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.4
18+import Ubuntu.Components 1.3
19+
20+
21+Rectangle {
22+ id: root
23+ property alias text: textItem.text
24+ signal clicked()
25+ width: textItem.width + units.gu(1.5)
26+ height: textItem.height + units.gu(1.5)
27+ Text {
28+ id: textItem
29+ anchors.centerIn: parent
30+ font.pixelSize: units.gu(1.5)
31+ }
32+ MouseArea {
33+ anchors.fill: parent
34+ onClicked: root.clicked()
35+ }
36+}