on xenial help sign in
Make DragHandle tests run again.

- "make tryDragHandle" was missing import paths - "make testDragHandle" was crashing because of some uitk::Button style issue during initialization. So I decided to move entirely away from this extra complexity. Approved by: Albert Astals Cid

commitf7a8a7634c472e62583192f4be5cad2060a7352d authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateMon 11 Jan 2016, 17:37 (11 years ago) parent93ce5bb75d2e73
4 files changed+51−9
plugins/Ubuntu/Gestures/DirectionalDragArea.cpp+8−2 tests/qmltests/Components/CMakeLists.txt+1−1 tests/qmltests/Components/tst_DragHandle.qml+6−6 tests/qmltests/Components/tst_DragHandle/SimpleButton.qml+36
plugins/Ubuntu/Gestures/DirectionalDragArea.cpp+8−2
@@ -715,8 +715,14 @@ void DirectionalDragArea::itemChange(ItemChange change, const ItemChangeData &va
715715 value.window->installEventFilter(TouchRegistry::instance());
716716
717717 // TODO: Handle window->screen() changes (ie window changing screens)
718− qreal pixelsPerMm = value.window->screen()->physicalDotsPerInch() / 25.4;
719− d->setPixelsPerMm(pixelsPerMm);
718+
719+ qreal pixelsPerInch = value.window->screen()->physicalDotsPerInch();
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);
720726 }
721727 }
722728}
tests/qmltests/Components/CMakeLists.txt+1−1
@@ -15,7 +15,7 @@ qt5_use_modules(DragHandleTestExec Test Core Qml Gui Quick)
1515target_link_libraries(DragHandleTestExec UbuntuGesturesQml UbuntuGestures)
1616
1717add_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})
1919
2020########## tst_EdgeDragEvaluator
2121add_executable(EdgeDragEvaluatorTestExec tst_EdgeDragEvaluator.cpp)
tests/qmltests/Components/tst_DragHandle.qml+6−6
@@ -1,5 +1,5 @@
11/*
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2013,2015 Canonical Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -51,7 +51,7 @@ Rectangle {
5151 objectName: "baseItem"
5252 anchors.fill: parent
5353
54− Button {
54+ SimpleButton {
5555 visible: root.bidirectional && bidirectionalShowable.fullyHidden
5656 text: "bidirectionalShowable.show()"
5757 anchors.centerIn: parent
@@ -169,12 +169,12 @@ Rectangle {
169169 anchors.margins: units.gu(1)
170170 spacing: units.gu(1)
171171
172− Button {
172+ SimpleButton {
173173 text: root.stretch ? "stretch" : "move"
174174 onClicked: { root.stretch = !root.stretch; }
175175 }
176176
177− Button {
177+ SimpleButton {
178178 text: root.hintDisplacement > 0 ? "hint" : "no hint"
179179 onClicked: {
180180 if (root.hintDisplacement > 0) {
@@ -185,7 +185,7 @@ Rectangle {
185185 }
186186 }
187187
188− Button {
188+ SimpleButton {
189189 text: "rotation: " + baseItem.rotation
190190 onClicked: {
191191 if (baseItem.rotation === 0.0) {
@@ -196,7 +196,7 @@ Rectangle {
196196 }
197197 }
198198
199− Button {
199+ SimpleButton {
200200 text: root.bidirectional ? "bidirectional" : "directional"
201201 onClicked: { root.bidirectional = !root.bidirectional; }
202202 }
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+}