Merge lp:~elopio/ubuntu-ui-toolkit/device_emulation_scenarios into lp:ubuntu-ui-toolkit

Proposed by Leo Arias
Status: Superseded
Proposed branch: lp:~elopio/ubuntu-ui-toolkit/device_emulation_scenarios
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 1862 lines (+1146/-187)
34 files modified
components.api (+48/-0)
debian/ubuntu-ui-toolkit-autopilot.install (+1/-1)
documentation/overview.qdoc (+7/-0)
documentation/ubuntu-ui-toolkit-common.qdocconf (+2/-0)
examples/ubuntu-ui-toolkit-gallery/Styles.qml (+48/-0)
examples/ubuntu-ui-toolkit-gallery/Toolbar.qml (+49/-0)
examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml (+10/-0)
modules/Ubuntu/Components/Icon.qml (+2/-2)
modules/Ubuntu/Components/Label.qml (+0/-2)
modules/Ubuntu/Components/OrientationHelper.qml (+55/-21)
modules/Ubuntu/Components/plugin/uctheme.cpp (+10/-0)
modules/Ubuntu/Test/UbuntuTestCase.qml (+7/-6)
modules/Ubuntu/Test/plugin/plugin.pro (+5/-1)
modules/Ubuntu/Test/plugin/testplugin.cpp (+32/-0)
modules/Ubuntu/Test/plugin/testplugin.h (+31/-0)
modules/Ubuntu/Test/plugin/uctestcase.cpp (+0/-26)
modules/Ubuntu/Test/plugin/uctestcase.h (+0/-67)
modules/Ubuntu/Test/plugin/uctestextras.cpp (+203/-0)
modules/Ubuntu/Test/plugin/uctestextras.h (+46/-0)
modules/Ubuntu/Test/qmldir (+1/-0)
tests/autopilot/ubuntuuitoolkit/fixture_setup.py (+36/-2)
tests/autopilot/ubuntuuitoolkit/scenarios.py (+45/-0)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py (+5/-1)
tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py (+23/-1)
tests/autopilot/ubuntuuitoolkit/tests/test_scenarios.py (+50/-0)
tests/launcher/MouseTouchAdaptor.cpp (+159/-0)
tests/launcher/MouseTouchAdaptor.h (+50/-0)
tests/launcher/launcher.cpp (+51/-46)
tests/launcher/launcher.pro (+6/-4)
tests/qmlapicheck.sh (+1/-1)
tests/unit/tst_components/tst_label.qml (+5/-0)
tests/unit_x11/tst_components/tst_textarea.qml (+1/-0)
tests/unit_x11/tst_inversemousearea/tst_inversemouseareatest.cpp (+3/-3)
tests/unit_x11/tst_test/tst_ubuntutestcase.qml (+154/-3)
To merge this branch: bzr merge lp:~elopio/ubuntu-ui-toolkit/device_emulation_scenarios
Reviewer Review Type Date Requested Status
Ubuntu SDK team Pending
Review via email: mp+208146@code.launchpad.net

This proposal has been superseded by a proposal from 2014-06-25.

To post a comment you must log in.
950. By Leo Arias

Merged with staging.

951. By Leo Arias

Merged with trunk.

952. By Leo Arias

Fixed the merge.

953. By Leo Arias

Added test scenarios for the gallery.

954. By Leo Arias

Reverted the size change.

955. By Leo Arias

Added a test for the device case.

956. By Leo Arias

Made explicit the use of scenarios.

957. By Leo Arias

Added python-gi as a dependency.

958. By Leo Arias

Fixed skip message.

959. By Leo Arias

Merged with staging.

960. By Leo Arias

Merged with staging.

961. By Leo Arias

Start the gallery tests with the toolbar closed.

962. By Leo Arias

Scroll the thumb from its bottom.

963. By Leo Arias

Fix pep8.

964. By Leo Arias

Close the toolbar only when needed.

965. By Leo Arias

Move to the thumb first.

966. By Leo Arias

Make sure that all scenarios tests will also run on the phone.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'components.api'
--- components.api 2014-05-28 18:08:33 +0000
+++ components.api 2014-06-25 19:24:49 +0000
@@ -901,3 +901,51 @@
901 prototype: "QQuickItem"901 prototype: "QQuickItem"
902 exports: ["TextureFromImage 0.1", "TextureFromImage 1.0"]902 exports: ["TextureFromImage 0.1", "TextureFromImage 1.0"]
903 Property { name: "image"; type: "QImage" }903 Property { name: "image"; type: "QImage" }
904 name: "UCTestExtras"
905 prototype: "QObject"
906 exports: ["TestExtras 1.0"]
907 Property { name: "touchPresent"; type: "bool"; isReadonly: true }
908 Method { name: "registerTouchDevice" }
909 Method {
910 name: "touchPress"
911 Parameter { name: "touchId"; type: "int" }
912 Parameter { name: "item"; type: "QQuickItem"; isPointer: true }
913 Parameter { name: "point"; type: "QPoint" }
914 Method {
915 name: "touchRelease"
916 Parameter { name: "touchId"; type: "int" }
917 Parameter { name: "item"; type: "QQuickItem"; isPointer: true }
918 Parameter { name: "point"; type: "QPoint" }
919 Method {
920 name: "touchClick"
921 Parameter { name: "touchId"; type: "int" }
922 Parameter { name: "item"; type: "QQuickItem"; isPointer: true }
923 Parameter { name: "point"; type: "QPoint" }
924 Method {
925 name: "touchLongPress"
926 Parameter { name: "touchId"; type: "int" }
927 Parameter { name: "item"; type: "QQuickItem"; isPointer: true }
928 Parameter { name: "point"; type: "QPoint" }
929 Method {
930 name: "touchDoubleClick"
931 Parameter { name: "touchId"; type: "int" }
932 Parameter { name: "item"; type: "QQuickItem"; isPointer: true }
933 Parameter { name: "point"; type: "QPoint" }
934 Method {
935 name: "touchMove"
936 Parameter { name: "touchId"; type: "int" }
937 Parameter { name: "item"; type: "QQuickItem"; isPointer: true }
938 Parameter { name: "point"; type: "QPoint" }
939 Method {
940 name: "touchDrag"
941 Parameter { name: "touchId"; type: "int" }
942 Parameter { name: "item"; type: "QQuickItem"; isPointer: true }
943 Parameter { name: "from"; type: "QPoint" }
944 Parameter { name: "delta"; type: "QPoint" }
945 Parameter { name: "steps"; type: "int" }
946 Method {
947 name: "touchDrag"
948 Parameter { name: "touchId"; type: "int" }
949 Parameter { name: "item"; type: "QQuickItem"; isPointer: true }
950 Parameter { name: "from"; type: "QPoint" }
951 Parameter { name: "delta"; type: "QPoint" }
904952
=== modified file 'debian/ubuntu-ui-toolkit-autopilot.install'
--- debian/ubuntu-ui-toolkit-autopilot.install 2014-05-14 11:00:20 +0000
+++ debian/ubuntu-ui-toolkit-autopilot.install 2014-06-25 19:24:49 +0000
@@ -1,3 +1,3 @@
1usr/lib/python31usr/lib/python3
2usr/lib/ubuntu-ui-toolkit/launcher2usr/lib/*/ubuntu-ui-toolkit/launcher
3usr/lib/python2.73usr/lib/python2.7
44
=== modified file 'documentation/overview.qdoc'
--- documentation/overview.qdoc 2014-04-29 05:39:04 +0000
+++ documentation/overview.qdoc 2014-06-25 19:24:49 +0000
@@ -106,4 +106,11 @@
106 import Ubuntu.PerformanceMetrics 1.0106 import Ubuntu.PerformanceMetrics 1.0
107 \endcode107 \endcode
108 \annotatedlist ubuntu-performance-metrics108 \annotatedlist ubuntu-performance-metrics
109
110 \part Test extensions
111 Available through:
112 \code
113 import Ubuntu Test 1.0
114 \endcode
115 \annotatedlist ubuntu-test
109 */116 */
110117
=== modified file 'documentation/ubuntu-ui-toolkit-common.qdocconf'
--- documentation/ubuntu-ui-toolkit-common.qdocconf 2014-04-29 05:39:04 +0000
+++ documentation/ubuntu-ui-toolkit-common.qdocconf 2014-06-25 19:24:49 +0000
@@ -8,6 +8,8 @@
8headerdirs += ../modules/Ubuntu/Layouts/plugin8headerdirs += ../modules/Ubuntu/Layouts/plugin
9sourcedirs += ../modules/Ubuntu/PerformanceMetrics9sourcedirs += ../modules/Ubuntu/PerformanceMetrics
10headerdirs += ../modules/Ubuntu/PerformanceMetrics/plugin10headerdirs += ../modules/Ubuntu/PerformanceMetrics/plugin
11sourcedirs += ../modules/Ubuntu/Test
12headerdirs += ../modules/Ubuntu/Test/plugin
11exampledirs += snippets13exampledirs += snippets
12excludedirs = ../modules/Ubuntu/Components/Themes14excludedirs = ../modules/Ubuntu/Components/Themes
13imagedirs = images15imagedirs = images
1416
=== added file 'examples/ubuntu-ui-toolkit-gallery/Styles.qml'
--- examples/ubuntu-ui-toolkit-gallery/Styles.qml 1970-01-01 00:00:00 +0000
+++ examples/ubuntu-ui-toolkit-gallery/Styles.qml 2014-06-25 19:24:49 +0000
@@ -0,0 +1,48 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 1.1
19
20Template {
21 objectName: "stylesTemplate"
22
23 Label {
24 anchors.left: parent.left
25 anchors.right: parent.right
26
27 text: i18n.tr("Switch between old and new style header")
28 }
29
30 OptionSelector {
31 model: [ i18n.tr('Header with Toolbar'), i18n.tr('New Style Header') ]
32 expanded: true
33 onSelectedIndexChanged: gallery.useDeprecatedToolbar = (selectedIndex == 0)
34 }
35
36 Label {
37 anchors.left: parent.left
38 anchors.right: parent.right
39
40 text: i18n.tr("Switch between themes")
41 }
42
43 OptionSelector {
44 model: [ 'Ambiance', 'SuruDark' ]
45 expanded: true
46 onSelectedIndexChanged: Theme.name = 'Ubuntu.Components.Themes.%1'.arg(model[selectedIndex])
47 }
48}
049
=== added file 'examples/ubuntu-ui-toolkit-gallery/Toolbar.qml'
--- examples/ubuntu-ui-toolkit-gallery/Toolbar.qml 1970-01-01 00:00:00 +0000
+++ examples/ubuntu-ui-toolkit-gallery/Toolbar.qml 2014-06-25 19:24:49 +0000
@@ -0,0 +1,49 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import Ubuntu.Components.Popups 0.1
20
21Template {
22 objectName: "popoversTemplate"
23
24 tools: ToolbarItems {
25 ToolbarButton {
26 text: "Call"
27 iconName: "call-start"
28 }
29 ToolbarButton {
30 text: i18n.tr("Share")
31 iconName: "share"
32 }
33 ToolbarButton {
34 iconName: "settings"
35 }
36 ToolbarButton {
37 iconName: "speaker"
38 }
39 }
40
41 TemplateSection {
42 className: "Toolbar"
43 documentation: "qml-ubuntu-components-toolbar0-%1.html".arg(className.toLowerCase())
44
45 TemplateRow {
46 title: i18n.tr("See below")
47 }
48 }
49}
050
=== modified file 'examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml'
--- examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml 2014-04-30 10:26:35 +0000
+++ examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml 2014-06-25 19:24:49 +0000
@@ -23,6 +23,11 @@
23 label: "Navigation"23 label: "Navigation"
24 source: "Navigation.qml"24 source: "Navigation.qml"
25 }25 }
26 ListElement {
27 objectName: "stylesElement"
28 label: "Styles"
29 source: "Styles.qml"
30 }
2631
27 ListElement {32 ListElement {
28 objectName: "togglesElement"33 objectName: "togglesElement"
@@ -30,6 +35,11 @@
30 source: "Toggles.qml"35 source: "Toggles.qml"
31 }36 }
32 ListElement {37 ListElement {
38 objectName: "toolbarElement"
39 label: "Toolbar"
40 source: "Toolbar.qml"
41 }
42 ListElement {
33 objectName: "buttonsElement"43 objectName: "buttonsElement"
34 label: "Buttons"44 label: "Buttons"
35 source: "Buttons.qml"45 source: "Buttons.qml"
3646
=== modified file 'modules/Ubuntu/Components/Icon.qml'
--- modules/Ubuntu/Components/Icon.qml 2014-04-23 08:50:20 +0000
+++ modules/Ubuntu/Components/Icon.qml 2014-06-25 19:24:49 +0000
@@ -103,12 +103,12 @@
103 id: colorizedImage103 id: colorizedImage
104104
105 anchors.fill: parent105 anchors.fill: parent
106 visible: active && image.status == Image.Ready106 visible: active
107107
108 // Whether or not a color has been set.108 // Whether or not a color has been set.
109 property bool active: keyColorOut != Qt.rgba(0.0, 0.0, 0.0, 0.0)109 property bool active: keyColorOut != Qt.rgba(0.0, 0.0, 0.0, 0.0)
110110
111 property Image source: visible ? image : null111 property Image source: active && image.status == Image.Ready ? image : null
112 property color keyColorOut: Qt.rgba(0.0, 0.0, 0.0, 0.0)112 property color keyColorOut: Qt.rgba(0.0, 0.0, 0.0, 0.0)
113 property color keyColorIn: "#808080"113 property color keyColorIn: "#808080"
114 property real threshold: 0.1114 property real threshold: 0.1
115115
=== modified file 'modules/Ubuntu/Components/Label.qml'
--- modules/Ubuntu/Components/Label.qml 2014-05-22 09:44:01 +0000
+++ modules/Ubuntu/Components/Label.qml 2014-06-25 19:24:49 +0000
@@ -55,8 +55,6 @@
55 property string fontSize: "medium"55 property string fontSize: "medium"
5656
57 font.pixelSize: FontUtils.sizeToPixels(fontSize)57 font.pixelSize: FontUtils.sizeToPixels(fontSize)
58 font.family: "Ubuntu"
59 font.weight: Font.Light
60 color: Theme.palette.selected.backgroundText58 color: Theme.palette.selected.backgroundText
6159
62 /* FIXME: workaround for QTBUG 35095 where Text's alignment is incorrect60 /* FIXME: workaround for QTBUG 35095 where Text's alignment is incorrect
6361
=== modified file 'modules/Ubuntu/Components/OrientationHelper.qml'
--- modules/Ubuntu/Components/OrientationHelper.qml 2014-06-09 09:07:40 +0000
+++ modules/Ubuntu/Components/OrientationHelper.qml 2014-06-25 19:24:49 +0000
@@ -14,7 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */15 */
1616
17import QtQuick 2.017import QtQuick 2.2
18import QtQuick.Window 2.018import QtQuick.Window 2.0
19import Ubuntu.Components 1.019import Ubuntu.Components 1.0
2020
@@ -136,6 +136,17 @@
136 target: orientationHelper136 target: orientationHelper
137 rotation: 0137 rotation: 0
138 }138 }
139 StateChangeScript {
140 name: "anchorsScript"
141 script: {
142 orientationHelper.anchors.fill = null;
143 orientationHelper.anchors.leftMargin = 0;
144 orientationHelper.anchors.rightMargin = 0;
145 orientationHelper.anchors.topMargin = 0;
146 orientationHelper.anchors.bottomMargin = 0;
147 orientationHelper.anchors.fill = orientationHelper.parent;
148 }
149 }
139 },150 },
140 State {151 State {
141 name: "180"152 name: "180"
@@ -143,17 +154,33 @@
143 target: orientationHelper154 target: orientationHelper
144 rotation: 180155 rotation: 180
145 }156 }
157 StateChangeScript {
158 name: "anchorsScript"
159 script: {
160 orientationHelper.anchors.fill = null;
161 orientationHelper.anchors.leftMargin = 0;
162 orientationHelper.anchors.rightMargin = 0;
163 orientationHelper.anchors.topMargin = 0;
164 orientationHelper.anchors.bottomMargin = 0;
165 orientationHelper.anchors.fill = orientationHelper.parent;
166 }
167 }
146 },168 },
147 State {169 State {
148 name: "270"170 name: "270"
149 PropertyChanges {171 PropertyChanges {
150 target: orientationHelper172 target: orientationHelper
151 rotation: 270173 rotation: 270
152 anchors {174 }
153 leftMargin: (parent.width - parent.height) / 2175 StateChangeScript {
154 rightMargin: anchors.leftMargin176 name: "anchorsScript"
155 topMargin: -anchors.leftMargin177 script: {
156 bottomMargin: anchors.topMargin178 orientationHelper.anchors.fill = null;
179 orientationHelper.anchors.topMargin = Qt.binding(function() {return -(parent.width - parent.height) / 2});
180 orientationHelper.anchors.bottomMargin = Qt.binding(function() {return -(parent.width - parent.height) / 2});
181 orientationHelper.anchors.leftMargin = Qt.binding(function() {return (parent.width - parent.height) / 2});
182 orientationHelper.anchors.rightMargin = Qt.binding(function() {return (parent.width - parent.height) / 2});
183 orientationHelper.anchors.fill = orientationHelper.parent;
157 }184 }
158 }185 }
159 },186 },
@@ -162,11 +189,16 @@
162 PropertyChanges {189 PropertyChanges {
163 target: orientationHelper190 target: orientationHelper
164 rotation: 90191 rotation: 90
165 anchors {192 }
166 leftMargin: (parent.width - parent.height) / 2193 StateChangeScript {
167 rightMargin: anchors.leftMargin194 name: "anchorsScript"
168 topMargin: -anchors.leftMargin195 script: {
169 bottomMargin: anchors.topMargin196 orientationHelper.anchors.fill = null;
197 orientationHelper.anchors.topMargin = Qt.binding(function() {return -(parent.width - parent.height) / 2});
198 orientationHelper.anchors.bottomMargin = Qt.binding(function() {return -(parent.width - parent.height) / 2});
199 orientationHelper.anchors.leftMargin = Qt.binding(function() {return (parent.width - parent.height) / 2});
200 orientationHelper.anchors.rightMargin = Qt.binding(function() {return (parent.width - parent.height) / 2});
201 orientationHelper.anchors.fill = orientationHelper.parent;
170 }202 }
171 }203 }
172 }204 }
@@ -176,18 +208,20 @@
176 Transition {208 Transition {
177 id: orientationTransition209 id: orientationTransition
178 ParallelAnimation {210 ParallelAnimation {
179 SequentialAnimation {211 /* FIXME: this is a workaround for 2 issues that trigger too many changes
180 PauseAnimation {212 to the width and height of orientationHelper which creates intermediary
181 duration: 25213 states of the UI with unexpected sizes:
182 }214 1) upon state change fast-forwarding is used which means that the final values are computed and applied
183 PropertyAction {215 then immediately reverted before the actual transition is applied
184 target: orientationHelper216 2) when margins are applied, width and height are updated separately
185 properties: "anchors.topMargin,anchors.bottomMargin,anchors.rightMargin,anchors.leftMargin"217
186 }218 Without these issues, regular PropertyChanges could be used to set the margins.
219 */
220 ScriptAction {
221 scriptName: "anchorsScript"
187 }222 }
188 RotationAnimation {223 RotationAnimator {
189 target: orientationHelper224 target: orientationHelper
190 properties: "rotation"
191 duration: UbuntuAnimation.FastDuration225 duration: UbuntuAnimation.FastDuration
192 easing: UbuntuAnimation.StandardEasing226 easing: UbuntuAnimation.StandardEasing
193 direction: RotationAnimation.Shortest227 direction: RotationAnimation.Shortest
194228
=== modified file 'modules/Ubuntu/Components/plugin/uctheme.cpp'
--- modules/Ubuntu/Components/plugin/uctheme.cpp 2014-06-09 08:43:30 +0000
+++ modules/Ubuntu/Components/plugin/uctheme.cpp 2014-06-25 19:24:49 +0000
@@ -21,6 +21,7 @@
21#include "listener.h"21#include "listener.h"
22#include "quickutils.h"22#include "quickutils.h"
23#include "i18n.h"23#include "i18n.h"
24#include "ucfontutils.h"
2425
25#include <QtQml/qqml.h>26#include <QtQml/qqml.h>
26#include <QtQml/qqmlinfo.h>27#include <QtQml/qqmlinfo.h>
@@ -32,6 +33,8 @@
32#include <QtCore/QTextStream>33#include <QtCore/QTextStream>
33#include <QtCore/QLibraryInfo>34#include <QtCore/QLibraryInfo>
34#include <QtCore/QStandardPaths>35#include <QtCore/QStandardPaths>
36#include <QtGui/QGuiApplication>
37#include <QtGui/QFont>
3538
36/*!39/*!
37 \qmltype Theme40 \qmltype Theme
@@ -114,6 +117,13 @@
114117
115 QObject::connect(this, SIGNAL(nameChanged()),118 QObject::connect(this, SIGNAL(nameChanged()),
116 this, SLOT(loadPalette()), Qt::UniqueConnection);119 this, SLOT(loadPalette()), Qt::UniqueConnection);
120
121 // set the default font
122 QFont defaultFont;
123 defaultFont.setFamily("Ubuntu");
124 defaultFont.setPixelSize(UCFontUtils::instance().sizeToPixels("medium"));
125 defaultFont.setWeight(QFont::Light);
126 QGuiApplication::setFont(defaultFont);
117}127}
118128
119void UCTheme::updateEnginePaths()129void UCTheme::updateEnginePaths()
120130
=== modified file 'modules/Ubuntu/Test/UbuntuTestCase.qml'
--- modules/Ubuntu/Test/UbuntuTestCase.qml 2014-05-02 07:22:52 +0000
+++ modules/Ubuntu/Test/UbuntuTestCase.qml 2014-06-25 19:24:49 +0000
@@ -19,9 +19,9 @@
19import Ubuntu.Components 1.119import Ubuntu.Components 1.1
2020
21/*!21/*!
22 \qmlabstract UbuntuTestCase22 \qmltype UbuntuTestCase
23 \inqmlmodule Ubuntu.Test 0.123 \inqmlmodule Ubuntu.Test 1.0
24 \ingroup ubuntu24 \ingroup ubuntu-test
25 \brief The UbuntuTestCase class expands the default TestCase class.25 \brief The UbuntuTestCase class expands the default TestCase class.
2626
27 \b{This component is under heavy development.}27 \b{This component is under heavy development.}
@@ -51,6 +51,9 @@
51 return null;51 return null;
52 }52 }
5353
54 /*!
55 Find a non-visual child such as QtObject based on objectName.
56 */
54 function findInvisibleChild(obj,objectName) {57 function findInvisibleChild(obj,objectName) {
55 var childs = new Array(0);58 var childs = new Array(0);
56 childs.push(obj)59 childs.push(obj)
@@ -113,7 +116,7 @@
113 \qmlmethod UbuntuTestCase::flick(item, x, y, dx, dy, pressTimeout = -1, steps = -1, button = Qt.LeftButton, modifiers = Qt.NoModifiers, delay = -1)116 \qmlmethod UbuntuTestCase::flick(item, x, y, dx, dy, pressTimeout = -1, steps = -1, button = Qt.LeftButton, modifiers = Qt.NoModifiers, delay = -1)
114117
115 The function produces a flick event when executed on Flickables. When used118 The function produces a flick event when executed on Flickables. When used
116 on other components it provides the same functionality as \l mouseDrag()119 on other components it provides the same functionality as \c mouseDrag()
117 function. The optional \a pressTimeout parameter can be used to introduce120 function. The optional \a pressTimeout parameter can be used to introduce
118 a small delay between the mouse press and the first mouse move. Setting a121 a small delay between the mouse press and the first mouse move. Setting a
119 negative or zero value will disable the timeout.122 negative or zero value will disable the timeout.
@@ -169,8 +172,6 @@
169 system of \a item into window co-ordinates and then delivered.172 system of \a item into window co-ordinates and then delivered.
170 If \a item is obscured by another item, or a child of \a item occupies173 If \a item is obscured by another item, or a child of \a item occupies
171 that position, then the event will be delivered to the other item instead.174 that position, then the event will be delivered to the other item instead.
172
173 \sa mouseRelease(), mouseClick(), mouseDoubleClick(), mouseMove(), mouseDrag(), mouseWheel()
174 */175 */
175 function mouseLongPress(item, x, y, button, modifiers, delay) {176 function mouseLongPress(item, x, y, button, modifiers, delay) {
176 mousePress(item, x, y, button, modifiers, delay);177 mousePress(item, x, y, button, modifiers, delay);
177178
=== modified file 'modules/Ubuntu/Test/plugin/plugin.pro'
--- modules/Ubuntu/Test/plugin/plugin.pro 2014-06-10 09:28:21 +0000
+++ modules/Ubuntu/Test/plugin/plugin.pro 2014-06-25 19:24:49 +0000
@@ -1,6 +1,6 @@
1TEMPLATE = lib1TEMPLATE = lib
2TARGET = ../UbuntuTest2TARGET = ../UbuntuTest
3QT += core-private qml qml-private quick quick-private gui-private3QT += core-private qml qml-private quick quick-private gui-private testlib
44
5equals(QT_MAJOR_VERSION, 5):lessThan(QT_MINOR_VERSION, 2) {5equals(QT_MAJOR_VERSION, 5):lessThan(QT_MINOR_VERSION, 2) {
6 QT += v8-private6 QT += v8-private
@@ -15,9 +15,13 @@
1515
16HEADERS += \16HEADERS += \
17 uctestcase.h \17 uctestcase.h \
18 testplugin.h \
19 uctestextras.h
1820
19SOURCES += \21SOURCES += \
20 uctestcase.cpp \22 uctestcase.cpp \
23 testplugin.cpp \
24 uctestextras.cpp
2125
22# deployment rules for the plugin26# deployment rules for the plugin
23installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /)27installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /)
2428
=== added file 'modules/Ubuntu/Test/plugin/testplugin.cpp'
--- modules/Ubuntu/Test/plugin/testplugin.cpp 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Test/plugin/testplugin.cpp 2014-06-25 19:24:49 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "testplugin.h"
18#include <QtQml>
19#include "uctestextras.h"
20
21static QObject *registerExtras(QQmlEngine *engine, QJSEngine *scriptEngine)
22{
23 Q_UNUSED(engine)
24 Q_UNUSED(scriptEngine)
25
26 return new UCTestExtras;
27}
28
29void TestPlugin::registerTypes(const char *uri)
30{
31 qmlRegisterSingletonType<UCTestExtras>(uri, 1, 0, "TestExtras", registerExtras);
32}
033
=== added file 'modules/Ubuntu/Test/plugin/testplugin.h'
--- modules/Ubuntu/Test/plugin/testplugin.h 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Test/plugin/testplugin.h 2014-06-25 19:24:49 +0000
@@ -0,0 +1,31 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef TESTPLUGIN_H
18#define TESTPLUGIN_H
19
20#include <QQmlExtensionPlugin>
21
22class TestPlugin : public QQmlExtensionPlugin
23{
24 Q_OBJECT
25 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26
27public:
28 void registerTypes(const char *uri);
29};
30
31#endif // TESTPLUGIN_H
032
=== modified file 'modules/Ubuntu/Test/plugin/uctestcase.cpp'
--- modules/Ubuntu/Test/plugin/uctestcase.cpp 2014-06-10 11:45:11 +0000
+++ modules/Ubuntu/Test/plugin/uctestcase.cpp 2014-06-25 19:24:49 +0000
@@ -26,11 +26,8 @@
26#include <QtTest/QtTest>26#include <QtTest/QtTest>
27#include <QtQuick/QQuickItem>27#include <QtQuick/QQuickItem>
2828
29#include <qpa/qwindowsysteminterface.h>
30
31Q_DECLARE_METATYPE(QList<QQmlError>)29Q_DECLARE_METATYPE(QList<QQmlError>)
3230
33QTouchDevice *UbuntuTestCase::m_touchDevice = 0;
34/*!31/*!
35 * \ingroup ubuntu32 * \ingroup ubuntu
36 * \brief UbuntuTestCase is the C++ pendant to the QML UbuntuTestCase.33 * \brief UbuntuTestCase is the C++ pendant to the QML UbuntuTestCase.
@@ -63,26 +60,3 @@
63 return m_spy->count();60 return m_spy->count();
64}61}
6562
66/*!
67 * Registers a touch device if there's none registered.
68 */
69void UbuntuTestCase::registerTouchDevice()
70{
71 // check if there is any touch device registered in the system
72 if (!m_touchDevice) {
73 QList<const QTouchDevice*> touchDevices = QTouchDevice::devices();
74 Q_FOREACH(const QTouchDevice *device, touchDevices) {
75 if (device->type() == QTouchDevice::TouchScreen) {
76 m_touchDevice = const_cast<QTouchDevice*>(device);
77 break;
78 }
79 }
80 }
81 // if none, register one
82 if (!m_touchDevice) {
83 m_touchDevice = new QTouchDevice;
84 m_touchDevice->setType(QTouchDevice::TouchScreen);
85 QWindowSystemInterface::registerTouchDevice(m_touchDevice);
86 }
87}
88
8963
=== modified file 'modules/Ubuntu/Test/plugin/uctestcase.h'
--- modules/Ubuntu/Test/plugin/uctestcase.h 2014-06-10 11:45:11 +0000
+++ modules/Ubuntu/Test/plugin/uctestcase.h 2014-06-25 19:24:49 +0000
@@ -24,8 +24,6 @@
24#include <QtQuick/QQuickView>24#include <QtQuick/QQuickView>
25#include <QtTest/QSignalSpy>25#include <QtTest/QSignalSpy>
2626
27#define CHECK_TOUCH_DEVICE() if (!checkTouchDevice(__FUNCTION__)) return
28
29class UbuntuTestCase : public QQuickView27class UbuntuTestCase : public QQuickView
30{28{
31 Q_OBJECT29 Q_OBJECT
@@ -44,73 +42,8 @@
44 qFatal("No item '%s' found", qPrintable(objectName));42 qFatal("No item '%s' found", qPrintable(objectName));
45 }43 }
4644
47 static void registerTouchDevice();
48
49 inline static void touchPress(int touchId, QWindow *window, const QPoint &point)
50 {
51 CHECK_TOUCH_DEVICE();
52 QTest::touchEvent(window, m_touchDevice).press(touchId, point, window);
53 }
54 inline static void touchRelease(int touchId, QWindow *window, const QPoint &point)
55 {
56 CHECK_TOUCH_DEVICE();
57 QTest::touchEvent(window, m_touchDevice).release(touchId, point, window);
58 }
59 inline static void touchClick(int touchId, QWindow *window, const QPoint &point)
60 {
61 CHECK_TOUCH_DEVICE();
62 touchPress(touchId, window, point);
63 QTest::qWait(10);
64 touchRelease(touchId, window, point);
65 }
66 inline static void touchLongPress(int touchId, QWindow *window, const QPoint &point)
67 {
68 CHECK_TOUCH_DEVICE();
69 touchPress(touchId, window, point);
70 QTest::qWait(800);
71 }
72 inline static void touchDoubleClick(int touchId, QWindow *window, const QPoint &point)
73 {
74 CHECK_TOUCH_DEVICE();
75 touchClick(touchId, window, point);
76 QTest::qWait(10);
77 touchClick(touchId, window, point);
78 }
79 inline static void touchMove(int touchId, QWindow *window, const QPoint &point)
80 {
81 CHECK_TOUCH_DEVICE();
82 QTest::touchEvent(window, m_touchDevice).move(touchId, point, window);
83 }
84 inline static void touchDrag(int touchId, QWindow *window, const QPoint &from, const QPoint &delta, int steps = 5)
85 {
86 touchPress(touchId, window, from);
87 QTest::qWait(10);
88 QTest::touchEvent(window, m_touchDevice).move(touchId, from, window);
89 qreal stepDx = delta.x() / steps;
90 qreal stepDy = delta.y() / steps;
91 if (!delta.isNull()) {
92 for (int i = 0; i < steps; i++) {
93 QTest::qWait(10);
94 QTest::touchEvent(window, m_touchDevice).move(touchId, from + QPoint(i * stepDx, i * stepDy), window);
95 }
96 }
97 QTest::qWait(10);
98 touchRelease(touchId, window, from + QPoint(stepDx, stepDy));
99 }
100
101
102private:45private:
103 QSignalSpy* m_spy;46 QSignalSpy* m_spy;
104 static QTouchDevice *m_touchDevice;
105
106 static inline bool checkTouchDevice(const char *func)
107 {
108 if (!m_touchDevice) {
109 qWarning() << QString("No touch device registered. Register one using registerTouchDevice() before using %1").arg(func);
110 return false;
111 }
112 return true;
113 }
114};47};
11548
116#endif // UBUNTU_TEST_UBUNTUTESTCASE_H49#endif // UBUNTU_TEST_UBUNTUTESTCASE_H
11750
=== added file 'modules/Ubuntu/Test/plugin/uctestextras.cpp'
--- modules/Ubuntu/Test/plugin/uctestextras.cpp 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Test/plugin/uctestextras.cpp 2014-06-25 19:24:49 +0000
@@ -0,0 +1,203 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "uctestextras.h"
18#include "uctestcase.h"
19
20#include <qpa/qwindowsysteminterface.h>
21
22const char *DEVICE_MISSING_MSG = "No touch device registered. Register one using registerTouchDevice() before using %1";
23
24#define CHECK_TOUCH_DEVICE(touchId, item) \
25 if (!touchDevicePresent()) { \
26 qWarning() << QString(DEVICE_MISSING_MSG).arg(__FUNCTION__); \
27 return; \
28 } \
29 if (touchId < 0) { \
30 qWarning() << "Invalid touchId specified."; \
31 return; \
32 } \
33 if (!item) { \
34 qWarning() << "Invalid item specified."; \
35 return; \
36 }
37
38QTouchDevice *UCTestExtras::m_touchDevice = 0;
39
40/*!
41 * \qmltype TestExtras
42 * \instantiates UCTestExtras
43 * \inqmlmodule Ubuntu.Test 1.0
44 * \ingroup ubuntu-test
45 * \brief Singleton type providing additional test functions.
46 *
47 * The component provides additional test functions like touch handling, registering
48 * touch device on non-touch screen enabled environment.
49 */
50
51UCTestExtras::UCTestExtras(QObject *parent) :
52 QObject(parent)
53{
54}
55
56/*!
57 * \qmlmethod TestExtras::touchDevicePresent()
58 * Returns true if the system has a touch device registered.
59 */
60bool UCTestExtras::touchDevicePresent()
61{
62 QList<const QTouchDevice*> touchDevices = QTouchDevice::devices();
63 Q_FOREACH(const QTouchDevice *device, touchDevices) {
64 if (device->type() == QTouchDevice::TouchScreen) {
65 return true;
66 }
67 }
68 return false;
69}
70
71/*!
72 * \qmlmethod TestExtras::registerTouchDevice()
73 * Registers a touch device if there's none registered. Calling the function in
74 * touch enabled environment has no effect. The function must be called in initTestCase()
75 * in order to perform touch related tests.
76 */
77void UCTestExtras::registerTouchDevice()
78{
79 // check if there is any touch device registered in the system
80 if (!m_touchDevice) {
81 QList<const QTouchDevice*> touchDevices = QTouchDevice::devices();
82 Q_FOREACH(const QTouchDevice *device, touchDevices) {
83 if (device->type() == QTouchDevice::TouchScreen) {
84 m_touchDevice = const_cast<QTouchDevice*>(device);
85 break;
86 }
87 }
88 }
89 // if none, register one
90 if (!m_touchDevice) {
91 m_touchDevice = new QTouchDevice;
92 m_touchDevice->setType(QTouchDevice::TouchScreen);
93 QWindowSystemInterface::registerTouchDevice(m_touchDevice);
94 }
95}
96
97/*!
98 * \qmlmethod TestExtras::touchPress(touchId, item, point)
99 * The function triggers a touch press event for a given \a touchId on a specific
100 * \a item. The \a point contains the (x,y) coordinates of the event in \a item
101 * coordinates.
102 */
103void UCTestExtras::touchPress(int touchId, QQuickItem *item, const QPoint &point)
104{
105 CHECK_TOUCH_DEVICE(touchId, item);
106 QTest::touchEvent(item->window(), m_touchDevice).press(touchId, item->mapToScene(point).toPoint(), item->window());
107}
108/*!
109 * \qmlmethod TestExtras::touchRelease(touchId, item, point)
110 * The function produces a touch release event on a given \a touchId performed on
111 * \a item at a \a point.
112 */
113void UCTestExtras::touchRelease(int touchId, QQuickItem *item, const QPoint &point)
114{
115 CHECK_TOUCH_DEVICE(touchId, item);
116 QTest::touchEvent(item->window(), m_touchDevice).release(touchId, item->mapToScene(point).toPoint(), item->window());
117}
118/*!
119 * \qmlmethod TestExtras::touchClick(touchId, item, point)
120 * The function performs a pair of \l touchPress and \l touchRelease calls on the same
121 * point resulting in a click like event.
122 */
123void UCTestExtras::touchClick(int touchId, QQuickItem *item, const QPoint &point)
124{
125 CHECK_TOUCH_DEVICE(touchId, item);
126 touchPress(touchId, item, point);
127 QTest::qWait(100);
128 touchRelease(touchId, item, point);
129}
130/*!
131 * \qmlmethod TestExtras::touchLongPress(touchId, item, point)
132 * The function produces a \l touchPress event with a timeout equivalent to the
133 * mouse \c pressAndHold timeout, after which the function returns.
134 */
135void UCTestExtras::touchLongPress(int touchId, QQuickItem *item, const QPoint &point)
136{
137 CHECK_TOUCH_DEVICE(touchId, item);
138 touchPress(touchId, item, point);
139 // 800 miliseconds + 200 to let events processed
140 QTest::qWait(1000);
141}
142/*!
143 * \qmlmethod TestExtras::touchDoubleClick(touchId, item, point)
144 * The function performs two consecutive \l touchClick events with a slight delay
145 * in between each click event.
146 */
147void UCTestExtras::touchDoubleClick(int touchId, QQuickItem *item, const QPoint &point)
148{
149 CHECK_TOUCH_DEVICE(touchId, item);
150 touchClick(touchId, item, point);
151 QTest::qWait(100);
152 touchClick(touchId, item, point);
153}
154/*!
155 * \qmlmethod TestExtras::touchMove(touchId, item, point)
156 * The function moves the touch point identified by the \a touchId to the destination
157 * \a point. The point is in \a item coordinates. The touch point identified by the
158 * \a touchId must be pressed before calling this function in order to produce the
159 * desired functionality. The event can be captured in a \c MultiPointTouchArea through
160 * \c updated() signal.
161 */
162void UCTestExtras::touchMove(int touchId, QQuickItem *item, const QPoint &point)
163{
164 CHECK_TOUCH_DEVICE(touchId, item);
165 QTest::touchEvent(item->window(), m_touchDevice).move(touchId, item->mapToScene(point).toPoint(), item->window());
166}
167/*!
168 * \qmlmethod TestExtras::touchDrag(touchId, item, from, delta, steps = 5)
169 * The function performs a drag gesture on a touch point identified by \a touchId
170 * over an \a item from the starting point \a from with a \a delta. The gesture
171 * is realized with a touch press, \a step moves and a release event.
172 *
173 * By default the function uses 5 steps to produce the gesture. This value can be any
174 * positive number, driving the gesture appliance to be faster (less than 5 moves) or
175 * slower (more than 5 moves). If a negative or 0 value is given, the function will
176 * use the default 5 steps to produce the gesture.
177 */
178void UCTestExtras::touchDrag(int touchId, QQuickItem *item, const QPoint &from, const QPoint &delta, int steps)
179{
180 CHECK_TOUCH_DEVICE(touchId, item);
181 if (delta.isNull()) {
182 qWarning() << "delta point is invalid";
183 return;
184 }
185 if (steps <= 0) {
186 steps = 5;
187 }
188 touchPress(touchId, item, from);
189 QTest::qWait(10);
190 touchMove(touchId, item, from);
191 QPoint movePoint(from);
192 qreal stepDx = delta.x() / steps;
193 qreal stepDy = delta.y() / steps;
194 if (!delta.isNull()) {
195 for (int i = 0; i < steps - 1; i++) {
196 QTest::qWait(10);
197 movePoint += QPoint(stepDx, stepDy);
198 touchMove(touchId, item, movePoint);
199 }
200 }
201 QTest::qWait(10);
202 touchRelease(touchId, item, from + delta);
203}
0204
=== added file 'modules/Ubuntu/Test/plugin/uctestextras.h'
--- modules/Ubuntu/Test/plugin/uctestextras.h 1970-01-01 00:00:00 +0000
+++ modules/Ubuntu/Test/plugin/uctestextras.h 2014-06-25 19:24:49 +0000
@@ -0,0 +1,46 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef TESTEXTRAS_H
18#define TESTEXTRAS_H
19
20#include <QtCore/QObject>
21
22class QQuickItem;
23class QTouchDevice;
24class UCTestExtras : public QObject
25{
26 Q_OBJECT
27 Q_PROPERTY(bool touchPresent READ touchDevicePresent)
28public:
29 explicit UCTestExtras(QObject *parent = 0);
30
31 static bool touchDevicePresent();
32public Q_SLOTS:
33 static void registerTouchDevice();
34 static void touchPress(int touchId, QQuickItem *item, const QPoint &point);
35 static void touchRelease(int touchId, QQuickItem *item, const QPoint &point);
36 static void touchClick(int touchId, QQuickItem *item, const QPoint &point);
37 static void touchLongPress(int touchId, QQuickItem *item, const QPoint &point);
38 static void touchDoubleClick(int touchId, QQuickItem *item, const QPoint &point);
39 static void touchMove(int touchId, QQuickItem *item, const QPoint &point);
40 static void touchDrag(int touchId, QQuickItem *item, const QPoint &from, const QPoint &delta, int steps = 5);
41
42private:
43 static QTouchDevice *m_touchDevice;
44};
45
46#endif // TESTEXTRAS_H
047
=== modified file 'modules/Ubuntu/Test/qmldir'
--- modules/Ubuntu/Test/qmldir 2014-04-20 19:25:12 +0000
+++ modules/Ubuntu/Test/qmldir 2014-06-25 19:24:49 +0000
@@ -1,4 +1,5 @@
1module Ubuntu.Test1module Ubuntu.Test
2plugin UbuntuTest
2UbuntuTestCase 0.1 UbuntuTestCase.qml3UbuntuTestCase 0.1 UbuntuTestCase.qml
34
4#version 1.05#version 1.0
56
=== modified file 'tests/autopilot/ubuntuuitoolkit/fixture_setup.py'
--- tests/autopilot/ubuntuuitoolkit/fixture_setup.py 2014-05-26 06:40:24 +0000
+++ tests/autopilot/ubuntuuitoolkit/fixture_setup.py 2014-06-25 19:24:49 +0000
@@ -20,6 +20,7 @@
20import tempfile20import tempfile
2121
22import fixtures22import fixtures
23from autopilot import display
2324
24from ubuntuuitoolkit import base, environment25from ubuntuuitoolkit import base, environment
2526
@@ -29,7 +30,7 @@
29import Ubuntu.Components 1.130import Ubuntu.Components 1.1
3031
31MainView {32MainView {
32 width: units.gu(48)33 width: units.gu(80)
33 height: units.gu(60)34 height: units.gu(60)
3435
35 Label {36 Label {
@@ -105,7 +106,6 @@
105 super(InitctlEnvironmentVariable, self).__init__()106 super(InitctlEnvironmentVariable, self).__init__()
106 self.variables = kwargs107 self.variables = kwargs
107108
108 def setUp(self):
109 super(InitctlEnvironmentVariable, self).setUp()109 super(InitctlEnvironmentVariable, self).setUp()
110 for variable, value in self.variables.items():110 for variable, value in self.variables.items():
111 self._add_variable_cleanup(variable)111 self._add_variable_cleanup(variable)
@@ -163,3 +163,37 @@
163 shutil.copyfile(163 shutil.copyfile(
164 xauthority_file_path,164 xauthority_file_path,
165 os.path.join(directory, '.Xauthority'))165 os.path.join(directory, '.Xauthority'))
166
167
168class SimulateDevice(fixtures.Fixture):
169
170 def __init__(self, app_width, app_height, grid_unit_px):
171 super(SimulateDevice, self).__init__()
172 self.app_width = app_width
173 self.app_height = app_height
174 self.grid_unit_px = grid_unit_px
175
176 def setUp(self):
177 super(SimulateDevice, self).setUp()
178 if self._is_geometry_larger_than_display(
179 self.app_width, self.app_height):
180 scale_divisor = self._get_scale_divisor()
181 grid_unit_px = self.grid_unit_px // scale_divisor
182 grid_unit_px = self.grid_unit_px
183 self.useFixture(
184 fixtures.EnvironmentVariable(
185 'GRID_UNIT_PX', str(grid_unit_px)))
186
187 def _is_geometry_larger_than_display(self, width, height):
188 screen = display.Display.create()
189 screen_width = screen.get_screen_width()
190 screen_height = screen.get_screen_height()
191 return (width > screen_width) or (height > screen_height)
192
193 def _get_scale_divisor(self):
194 scale_divisor = 2
195 while self._is_geometry_larger_than_display(
196 self.app_width // scale_divisor,
197 self.app_height // scale_divisor):
198 scale_divisor = scale_divisor * 2
199 return scale_divisor
166200
=== added file 'tests/autopilot/ubuntuuitoolkit/scenarios.py'
--- tests/autopilot/ubuntuuitoolkit/scenarios.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/ubuntuuitoolkit/scenarios.py 2014-06-25 19:24:49 +0000
@@ -0,0 +1,45 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2014 Canonical Ltd.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as published by
7# the Free Software Foundation; version 3.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
18NEXUS4_DEVICE = 'Nexus4'
19NEXUS10_DEVICE = 'Nexus10'
20DEFAULT_DEVICES = (NEXUS4_DEVICE, NEXUS10_DEVICE)
21
22
23def get_device_simulation_scenarios(devices=DEFAULT_DEVICES):
24 """Return a list of devices to be simulated on tests.
25
26 :param devices: The device or devices to simulate. Default value is all the
27 officially supported devices.
28 :type devices: string or sequence of strings.
29 :return: A list of scenarios to be used with the testscenarios python
30 module, with the values of app_width, app_height and grid_unit
31 corresponding to the selected device.
32
33 """
34 scenarios = []
35 if NEXUS4_DEVICE in devices:
36 scenarios.append(
37 ('Simulating Nexus 4 in desktop',
38 dict(app_width=768, app_height=1280, grid_unit_px=18))
39 )
40 if NEXUS10_DEVICE in devices:
41 scenarios.append(
42 ('Simulating Nexus 10 in desktop',
43 dict(app_width=2560, app_height=1600, grid_unit_px=20))
44 )
45 return scenarios
046
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py'
--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py 2014-05-30 08:21:45 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py 2014-06-25 19:24:49 +0000
@@ -15,6 +15,7 @@
15# along with this program. If not, see <http://www.gnu.org/licenses/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
17import os17import os
18import subprocess
1819
19import testtools20import testtools
20import ubuntuuitoolkit21import ubuntuuitoolkit
@@ -206,8 +207,11 @@
206 if os.path.exists(path_to_local_launcher):207 if os.path.exists(path_to_local_launcher):
207 return path_to_local_launcher208 return path_to_local_launcher
208 else:209 else:
210 arch = subprocess.check_output(
211 ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"],
212 universal_newlines=True).strip()
209 path_to_installed_launcher = os.path.join(213 path_to_installed_launcher = os.path.join(
210 '/', 'usr', 'lib', 'ubuntu-ui-toolkit', 'launcher')214 '/', 'usr', 'lib', arch, 'ubuntu-ui-toolkit', 'launcher')
211 return path_to_installed_launcher215 return path_to_installed_launcher
212216
213 def test_get_unity_top_container(self):217 def test_get_unity_top_container(self):
214218
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py'
--- tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py 2014-06-03 20:10:53 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py 2014-06-25 19:24:49 +0000
@@ -27,7 +27,7 @@
27from autopilot import testcase as autopilot_testcase27from autopilot import testcase as autopilot_testcase
28from testtools.matchers import Contains, FileExists, Not28from testtools.matchers import Contains, FileExists, Not
2929
30from ubuntuuitoolkit import base, environment, fixture_setup30from ubuntuuitoolkit import base, environment, fixture_setup, scenarios
3131
3232
33class FakeApplicationTestCase(testtools.TestCase):33class FakeApplicationTestCase(testtools.TestCase):
@@ -304,3 +304,25 @@
304 self.assertTrue(304 self.assertTrue(
305 os.path.exists(305 os.path.exists(
306 os.path.join(os.environ.get('HOME'), '.Xauthority')))306 os.path.join(os.environ.get('HOME'), '.Xauthority')))
307
308
309class SimulateDeviceTestCase(autopilot_testcase.AutopilotTestCase):
310
311 scenarios = scenarios.get_device_simulation_scenarios()
312
313 def test(self):
314 self.useFixture(fixture_setup.SimulateDevice(
315 self.app_width, self.app_height, self.grid_unit_px))
316
317 fake_application = fixture_setup.FakeApplication()
318 self.useFixture(fake_application)
319
320 self.application = self.launch_test_application(
321 base.get_qmlscene_launch_command(),
322 fake_application.qml_file_path,
323 '--desktop_file_hint={0}'.format(
324 fake_application.desktop_file_path),
325 app_type='qt')
326
327 # We can select a component from the application.
328 self.application.select_single('Label', objectName='testLabel')
307329
=== added file 'tests/autopilot/ubuntuuitoolkit/tests/test_scenarios.py'
--- tests/autopilot/ubuntuuitoolkit/tests/test_scenarios.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/test_scenarios.py 2014-06-25 19:24:49 +0000
@@ -0,0 +1,50 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2014 Canonical Ltd.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as published by
7# the Free Software Foundation; version 3.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17import testtools
18
19from ubuntuuitoolkit import scenarios
20
21
22class ScenariosTestCase(testtools.TestCase):
23
24 def test_get_nexus_4_scenario(self):
25 expected_scenarios = [
26 ('Simulating Nexus 4 in desktop',
27 dict(app_width=768, app_height=1280, grid_unit_px=18)),
28 ]
29 test_scenarios = scenarios.get_device_simulation_scenarios(
30 devices=scenarios.NEXUS4_DEVICE)
31 self.assertEqual(expected_scenarios, test_scenarios)
32
33 def test_get_nexus_10_scenario(self):
34 expected_scenarios = [
35 ('Simulating Nexus 10 in desktop',
36 dict(app_width=2560, app_height=1600, grid_unit_px=20))
37 ]
38 test_scenarios = scenarios.get_device_simulation_scenarios(
39 devices=scenarios.NEXUS10_DEVICE)
40 self.assertEqual(expected_scenarios, test_scenarios)
41
42 def test_get_default_scenarios_must_return_supported_devices(self):
43 expected_scenarios = [
44 ('Simulating Nexus 4 in desktop',
45 dict(app_width=768, app_height=1280, grid_unit_px=18)),
46 ('Simulating Nexus 10 in desktop',
47 dict(app_width=2560, app_height=1600, grid_unit_px=20))
48 ]
49 test_scenarios = scenarios.get_device_simulation_scenarios()
50 self.assertEqual(expected_scenarios, test_scenarios)
051
=== added file 'tests/launcher/MouseTouchAdaptor.cpp'
--- tests/launcher/MouseTouchAdaptor.cpp 1970-01-01 00:00:00 +0000
+++ tests/launcher/MouseTouchAdaptor.cpp 2014-06-25 19:24:49 +0000
@@ -0,0 +1,159 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
17 *
18 */
19
20#include "MouseTouchAdaptor.h"
21
22#include <qpa/qwindowsysteminterface.h>
23
24#include <QtGui/QMouseEvent>
25#include <QtTest/QTest>
26
27using QTest::QTouchEventSequence;
28
29namespace {
30Qt::MouseButton translateMouseButton(xcb_button_t detail)
31{
32 switch (detail) {
33 case 1: return Qt::LeftButton;
34 case 2: return Qt::MidButton;
35 case 3: return Qt::RightButton;
36 // Button values 4-7 are Wheel events
37 default: return Qt::NoButton;
38 }
39}
40} // end of anonymous namespace
41
42MouseTouchAdaptor::MouseTouchAdaptor()
43 : m_leftButtonIsPressed(false)
44{
45 m_touchDevice = new QTouchDevice;
46 m_touchDevice->setType(QTouchDevice::TouchScreen);
47 QWindowSystemInterface::registerTouchDevice(m_touchDevice);
48}
49
50bool MouseTouchAdaptor::nativeEventFilter(const QByteArray & eventType,
51 void * message, long * /*result*/)
52{
53 if (eventType != "xcb_generic_event_t") {
54 // wrong backend.
55 qWarning("MouseTouchAdaptor: XCB backend not in use. Adaptor inoperative!");
56 return false;
57 }
58
59 xcb_generic_event_t *xcbEvent = static_cast<xcb_generic_event_t *>(message);
60
61 switch (xcbEvent->response_type & ~0x80) {
62 case XCB_BUTTON_PRESS:
63 return handleButtonPress(reinterpret_cast<xcb_button_press_event_t *>(xcbEvent));
64 break;
65 case XCB_BUTTON_RELEASE:
66 return handleButtonRelease(reinterpret_cast<xcb_button_release_event_t *>(xcbEvent));
67 break;
68 case XCB_MOTION_NOTIFY:
69 return handleMotionNotify(reinterpret_cast<xcb_motion_notify_event_t *>(xcbEvent));
70 break;
71 default:
72 return false;
73 break;
74 };
75}
76
77bool MouseTouchAdaptor::handleButtonPress(xcb_button_press_event_t *pressEvent)
78{
79 Qt::MouseButton button = translateMouseButton(pressEvent->detail);
80
81 // Skip the event if it wasn't a left mouse press
82 if (button != Qt::LeftButton) {
83 return false;
84 }
85
86 QPoint windowPos(pressEvent->event_x, pressEvent->event_y);
87
88 QWindow *targetWindow = findQWindowWithXWindowID(static_cast<WId>(pressEvent->event));
89
90 // no autoCommit
91 QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice, false);
92 touchEvent.press(0, windowPos);
93 // do not process events when committed, let the events be processed with next event loop
94 touchEvent.commit(false);
95
96 m_leftButtonIsPressed = true;
97 return true;
98}
99
100bool MouseTouchAdaptor::handleButtonRelease(xcb_button_release_event_t *releaseEvent)
101{
102 Qt::MouseButton button = translateMouseButton(releaseEvent->detail);
103
104 // Skip the event if it wasn't a left mouse release
105 if (button != Qt::LeftButton) {
106 return false;
107 }
108
109 QPoint windowPos(releaseEvent->event_x, releaseEvent->event_y);
110
111 QWindow *targetWindow = findQWindowWithXWindowID(static_cast<WId>(releaseEvent->event));
112
113 // no autoCommit
114 QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice, false);
115 touchEvent.release(0, windowPos);
116 // do not process events when committed, let the events be processed with next event loop
117 touchEvent.commit(false);
118
119 m_leftButtonIsPressed = false;
120 return true;
121}
122
123bool MouseTouchAdaptor::handleMotionNotify(xcb_motion_notify_event_t *event)
124{
125 if (!m_leftButtonIsPressed) {
126 return false;
127 }
128
129 QPoint windowPos(event->event_x, event->event_y);
130
131 QWindow *targetWindow = findQWindowWithXWindowID(static_cast<WId>(event->event));
132
133 // no autoCommit
134 QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice, false);
135 touchEvent.move(0, windowPos);
136 // do not process events when committed, let the events be processed with next event loop
137 touchEvent.commit(false);
138
139 return true;
140}
141
142QWindow *MouseTouchAdaptor::findQWindowWithXWindowID(WId windowId)
143{
144 QWindowList windowList = QGuiApplication::topLevelWindows();
145 QWindow *foundWindow = 0;
146
147 int i = 0;
148 while (!foundWindow && i < windowList.count()) {
149 QWindow *window = windowList[i];
150 if (window->winId() == windowId) {
151 foundWindow = window;
152 } else {
153 ++i;
154 }
155 }
156
157 Q_ASSERT(foundWindow);
158 return foundWindow;
159}
0160
=== added file 'tests/launcher/MouseTouchAdaptor.h'
--- tests/launcher/MouseTouchAdaptor.h 1970-01-01 00:00:00 +0000
+++ tests/launcher/MouseTouchAdaptor.h 2014-06-25 19:24:49 +0000
@@ -0,0 +1,50 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
17 *
18 */
19
20#ifndef MOUSE_TOUCH_ADAPTOR_H
21#define MOUSE_TOUCH_ADAPTOR_H
22
23#include <QtCore/QAbstractNativeEventFilter>
24#include <QWindow>
25#include <xcb/xcb.h>
26
27class QMouseEvent;
28class QTouchDevice;
29
30// Transforms QMouseEvents into single-finger QTouchEvents.
31class MouseTouchAdaptor : public QAbstractNativeEventFilter {
32
33public:
34 MouseTouchAdaptor();
35
36 // Filters mouse events and posts the equivalent QTouchEvents.
37 virtual bool nativeEventFilter(const QByteArray & eventType, void *message, long *result);
38
39private:
40
41 bool handleButtonPress(xcb_button_press_event_t *pressEvent);
42 bool handleButtonRelease(xcb_button_release_event_t *releaseEvent);
43 bool handleMotionNotify(xcb_motion_notify_event_t *event);
44 QWindow *findQWindowWithXWindowID(WId windowId);
45
46 QTouchDevice *m_touchDevice;
47 bool m_leftButtonIsPressed;
48};
49
50#endif // MOUSE_TOUCH_ADAPTOR_H
051
=== modified file 'tests/launcher/launcher.cpp'
--- tests/launcher/launcher.cpp 2014-06-09 08:26:24 +0000
+++ tests/launcher/launcher.cpp 2014-06-25 19:24:49 +0000
@@ -30,16 +30,18 @@
30#include <QOpenGLContext>30#include <QOpenGLContext>
31#include <QtGui/private/qopenglcontext_p.h>31#include <QtGui/private/qopenglcontext_p.h>
32#include <QtQuick/private/qsgcontext_p.h>32#include <QtQuick/private/qsgcontext_p.h>
33#include <QtCore/QCommandLineParser>
34#include <QtCore/QCommandLineOption>
35#include "MouseTouchAdaptor.h"
36#include <QtGui/QTouchDevice>
3337
34int usage()38bool touchDevicePresent()
35{39{
36 QString self(QGuiApplication::instance()->arguments().at(0));40 Q_FOREACH(const QTouchDevice *device, QTouchDevice::devices()) {
37 std::cout << "Usage\n "41 if (device->type() == QTouchDevice::TouchScreen)
38 << qPrintable(self)42 return true;
39 << " -testability -frameless -engine"43 }
40 << " --desktop_file_path=DESKTOP_FILE"44 return false;
41 << " -I MODULE_PATH FILENAME\n";
42 return 1;
43}45}
4446
45int main(int argc, const char *argv[])47int main(int argc, const char *argv[])
@@ -58,25 +60,40 @@
58#endif60#endif
59 QGuiApplication::setApplicationName("UITK Launcher");61 QGuiApplication::setApplicationName("UITK Launcher");
60 QGuiApplication application(argc, (char**)argv);62 QGuiApplication application(argc, (char**)argv);
61 QStringList args (application.arguments());63
6264 QCommandLineParser args;
63 int _testability(args.indexOf("-testability"));65 QCommandLineOption _import("I", "Add <path> to the list of import paths", "path");
64 args.removeAt(_testability);66 QCommandLineOption _enableTouch("touch", "Enables mouse to touch conversion on desktop");
65 int _frameless(args.indexOf("-frameless"));67 QCommandLineOption _testability("testability", "Loads the testability driver");
66 args.removeAt(_frameless);68 QCommandLineOption _frameless("frameless", "Run without borders");
67 int _engine(args.indexOf("-engine"));69 QCommandLineOption _engine("engine", "Use quick engine from quick view");
68 args.removeAt(_engine);70 QCommandLineOption _desktop_file_hint("desktop_file_hint", "Desktop file - ignored", "desktop_file");
6971
70 Q_FOREACH(QString arg, args) {72 args.addOption(_import);
71 if (arg.startsWith("--desktop_file_hint")) {73 args.addOption(_enableTouch);
72 // This will not be used - it only needs to be ignored74 args.addOption(_testability);
73 int _desktop_file_hint(args.indexOf(arg));75 args.addOption(_frameless);
74 args.removeAt(_desktop_file_hint);76 args.addOption(_engine);
75 }77 args.addOption(_desktop_file_hint);
78 args.addPositionalArgument("filename", "Document to be viewed");
79 args.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
80 args.addHelpOption();
81 if (!args.parse(application.arguments())) {
82 qWarning() << args.errorText();
83 args.showHelp(1);
84 }
85
86 QString filename;
87 if (args.positionalArguments().count() > 0) {
88 filename = args.positionalArguments()[0];
89 }
90 if (filename.isEmpty()) {
91 // show usage and exit
92 args.showHelp(1);
76 }93 }
7794
78 // Testability is only supported out of the box by QApplication not QGuiApplication95 // Testability is only supported out of the box by QApplication not QGuiApplication
79 if (_testability > -1 || getenv("QT_LOAD_TESTABILITY")) {96 if (args.isSet(_testability) || getenv("QT_LOAD_TESTABILITY")) {
80 QLibrary testLib(QLatin1String("qttestability"));97 QLibrary testLib(QLatin1String("qttestability"));
81 if (testLib.load()) {98 if (testLib.load()) {
82 typedef void (*TasInitialize)(void);99 typedef void (*TasInitialize)(void);
@@ -96,7 +113,7 @@
96 QQmlEngine* engine;113 QQmlEngine* engine;
97 // The default constructor affects the components tree (autopilot vis)114 // The default constructor affects the components tree (autopilot vis)
98 QQuickView* view;115 QQuickView* view;
99 if (_engine > -1) {116 if (args.isSet(_engine)) {
100 view = new QQuickView();117 view = new QQuickView();
101 engine = view->engine();118 engine = view->engine();
102 } else {119 } else {
@@ -104,43 +121,31 @@
104 view = new QQuickView(engine, NULL);121 view = new QQuickView(engine, NULL);
105 }122 }
106123
107 int _import(args.indexOf("-I"));124 if (args.isSet(_import)) {
108 args.removeAt(_import);125 QStringList paths = args.values(_import);
109 if (_import > -1) {126 Q_FOREACH(const QString &path, paths) {
110 if (args.count() > _import) {127 engine->addImportPath(path);
111 QString importPath(args.at(_import));
112 args.removeAt(_import);
113 engine->addImportPath(importPath);
114 }128 }
115 }129 }
116130
117 view->setResizeMode(QQuickView::SizeRootObjectToView);131 view->setResizeMode(QQuickView::SizeRootObjectToView);
118 view->setTitle("UI Toolkit QQuickView");132 view->setTitle("UI Toolkit QQuickView");
119 if (_frameless > -1) {133 if (args.isSet(_frameless)) {
120 view->setFlags(Qt::FramelessWindowHint);134 view->setFlags(Qt::FramelessWindowHint);
121 }135 }
122136
123 // The remaining unnamed argument must be a filename137 if (args.isSet(_enableTouch) && !touchDevicePresent()) {
124 if (args.count() == 1) {138 // has no effect if we have touch screen
125 qCritical() << "Missing filename";139 application.installNativeEventFilter(new MouseTouchAdaptor);
126 return usage();
127 }140 }
128 QString filename(args.at(1));
129 // The first argument is the launcher itself
130 args.removeAt(0);
131141
132 QUrl source(QUrl::fromLocalFile(filename));142 QUrl source(QUrl::fromLocalFile(filename));
133 view->setSource(source);143 view->setSource(source);
134 if (view->errors().count() > 0) {144 if (view->errors().count() > 0) {
135 return usage();145 args.showHelp(3);
136 }146 }
137 view->show();147 view->show();
138148
139 if (args.count() > 1) {
140 qCritical() << "Invalid arguments passed" << args;
141 return usage();
142 }
143
144 return application.exec();149 return application.exec();
145}150}
146151
147152
=== modified file 'tests/launcher/launcher.pro'
--- tests/launcher/launcher.pro 2014-05-14 11:00:20 +0000
+++ tests/launcher/launcher.pro 2014-06-25 19:24:49 +0000
@@ -1,11 +1,13 @@
1TEMPLATE = app1TEMPLATE = app
2QT += qml quick2QT += qml quick
3# For setSharedOpenGLContext3# For setSharedOpenGLContext
4QT += core-private gui-private quick-private4QT += core-private gui-private testlib quick-private
5CONFIG += no_keywords5CONFIG += no_keywords
6SOURCES += \6HEADERS += MouseTouchAdaptor.h
7 launcher.cpp7SOURCES += launcher.cpp \
8launcher.path = /usr/lib/ubuntu-ui-toolkit8 MouseTouchAdaptor.cpp
9installPath = $$[QT_INSTALL_LIBS]/ubuntu-ui-toolkit
10launcher.path = $$installPath
9launcher.files = launcher11launcher.files = launcher
10INSTALLS += launcher12INSTALLS += launcher
1113
1214
=== modified file 'tests/qmlapicheck.sh'
--- tests/qmlapicheck.sh 2014-04-23 13:45:41 +0000
+++ tests/qmlapicheck.sh 2014-06-25 19:24:49 +0000
@@ -16,7 +16,7 @@
16#16#
17################################################################################17################################################################################
18QML="modules/Ubuntu/*/qmldir modules/Ubuntu/Components/Colors/UbuntuColors.qml modules/Ubuntu/Components/*/qmldir modules/Ubuntu/Components/Pickers/PickerPanel.qml"18QML="modules/Ubuntu/*/qmldir modules/Ubuntu/Components/Colors/UbuntuColors.qml modules/Ubuntu/Components/*/qmldir modules/Ubuntu/Components/Pickers/PickerPanel.qml"
19CPP="Ubuntu.Components Ubuntu.Layouts Ubuntu.PerformanceMetrics"19CPP="Ubuntu.Components Ubuntu.Layouts Ubuntu.PerformanceMetrics Ubuntu.Test"
2020
21echo Dumping QML API of C++ components21echo Dumping QML API of C++ components
22echo '' > plugins.qmltypes22echo '' > plugins.qmltypes
2323
=== modified file 'tests/unit/tst_components/tst_label.qml'
--- tests/unit/tst_components/tst_label.qml 2014-05-26 10:13:41 +0000
+++ tests/unit/tst_components/tst_label.qml 2014-06-25 19:24:49 +0000
@@ -21,6 +21,11 @@
21TestCase {21TestCase {
22 name: "LabelAPI"22 name: "LabelAPI"
2323
24 function test_0_defaults() {
25 compare(textCustom.font.family, "Ubuntu", "Default font family");
26 compare(textCustom.font.weight, Font.Light, "Default font weight");
27 }
28
24 function test_fontSize() {29 function test_fontSize() {
25 compare(textCustom.fontSize,"medium","fontSize is 'medium' by default")30 compare(textCustom.fontSize,"medium","fontSize is 'medium' by default")
2631
2732
=== modified file 'tests/unit_x11/tst_components/tst_textarea.qml'
--- tests/unit_x11/tst_components/tst_textarea.qml 2014-06-10 14:22:42 +0000
+++ tests/unit_x11/tst_components/tst_textarea.qml 2014-06-25 19:24:49 +0000
@@ -705,6 +705,7 @@
705 }705 }
706706
707 function test_clear_selection_by_click_beside_selection() {707 function test_clear_selection_by_click_beside_selection() {
708 skip("The test fails and will be overruled by future UX.");
708 longText.focus = true;709 longText.focus = true;
709 var handler = findChild(longText, "input_handler");710 var handler = findChild(longText, "input_handler");
710 var y = longText.height / 2;711 var y = longText.height / 2;
711712
=== modified file 'tests/unit_x11/tst_inversemousearea/tst_inversemouseareatest.cpp'
--- tests/unit_x11/tst_inversemousearea/tst_inversemouseareatest.cpp 2014-06-11 11:24:39 +0000
+++ tests/unit_x11/tst_inversemousearea/tst_inversemouseareatest.cpp 2014-06-25 19:24:49 +0000
@@ -22,7 +22,7 @@
22#include <QtQuick/QQuickItem>22#include <QtQuick/QQuickItem>
23#include <QtCore/QEvent>23#include <QtCore/QEvent>
2424
25#include "uctestcase.h"25#include "uctestextras.h"
26#include "inversemouseareatype.h"26#include "inversemouseareatype.h"
27#include "ucunits.h"27#include "ucunits.h"
28#include <private/qquickevents_p_p.h>28#include <private/qquickevents_p_p.h>
@@ -89,7 +89,7 @@
89 void initTestCase()89 void initTestCase()
90 {90 {
91 // make sure we have a touch device installed91 // make sure we have a touch device installed
92 UbuntuTestCase::registerTouchDevice();92 UCTestExtras::registerTouchDevice();
93 QString modules("../../../modules");93 QString modules("../../../modules");
94 QVERIFY(QDir(modules).exists());94 QVERIFY(QDir(modules).exists());
9595
@@ -513,7 +513,7 @@
513 QCOMPARE(imaSpy.count(), 1);513 QCOMPARE(imaSpy.count(), 1);
514514
515 imaSpy.clear();515 imaSpy.clear();
516 UbuntuTestCase::touchClick(0, quickView, guPoint(20, 5));516 UCTestExtras::touchClick(0, quickView->rootObject(), guPoint(20, 5));
517 QCOMPARE(imaSpy.count(), 1);517 QCOMPARE(imaSpy.count(), 1);
518 }518 }
519519
520520
=== modified file 'tests/unit_x11/tst_test/tst_ubuntutestcase.qml'
--- tests/unit_x11/tst_test/tst_ubuntutestcase.qml 2014-04-20 19:25:12 +0000
+++ tests/unit_x11/tst_test/tst_ubuntutestcase.qml 2014-06-25 19:24:49 +0000
@@ -25,11 +25,19 @@
2525
26 Column {26 Column {
27 anchors.fill: parent27 anchors.fill: parent
28 MultiPointTouchArea {
29 id: topTouchArea
30 width: parent.width
31 height: 100
32 touchPoints: TouchPoint {
33// id: point
34 }
35 }
28 MouseArea {36 MouseArea {
29 id: mouseArea37 id: mouseArea
30 objectName: "myMouseArea"38 objectName: "myMouseArea"
31 width: parent.width39 width: parent.width
32 height: 30040 height: 200
33 hoverEnabled: true41 hoverEnabled: true
34 acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton42 acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
35 property int testX : 043 property int testX : 0
@@ -42,6 +50,15 @@
42 steps++;50 steps++;
43 }51 }
44 }52 }
53 MultiPointTouchArea {
54 id: touchArea
55 width: parent.width
56 height: 100
57 touchPoints: TouchPoint {
58 id: point
59 }
60 }
61
45 Flickable {62 Flickable {
46 id: flicker63 id: flicker
47 width: parent.width64 width: parent.width
@@ -62,18 +79,28 @@
62 name: "TestTheUbuntuTestCase"79 name: "TestTheUbuntuTestCase"
63 when: windowShown80 when: windowShown
6481
82 function initTestCase() {
83 TestExtras.registerTouchDevice();
84 }
85
65 function init() {86 function init() {
66 mouseArea.steps = 0;87 mouseArea.steps = 0;
67 }88 }
68 function cleanup() {89 function cleanup() {
69 movementSpy.clear();90 movementSpy.clear();
70 longPressSpy.clear();91 longPressSpy.clear();
92 touchPressSpy.clear();
93 touchReleaseSpy.clear();
94 touchUpdateSpy.clear();
95 touchPressSpy.target = null;
96 touchReleaseSpy.target = null;
97 touchUpdateSpy.target = null;
71 }98 }
7299
73 function test_mouseMoveSlowly() {100 function test_mouseMoveSlowly() {
74 mouseMoveSlowly(root,0,0,800,300,10,100);101 mouseMoveSlowly(mouseArea,0,0,800,200,10,100);
75 compare(mouseArea.testX,800);102 compare(mouseArea.testX,800);
76 compare(mouseArea.testY,300);103 compare(mouseArea.testY,200);
77 compare(mouseArea.steps,10);104 compare(mouseArea.steps,10);
78 }105 }
79106
@@ -146,5 +173,129 @@
146 flick(flicker, flicker.width, flicker.height, -flicker.width, -flicker.height, 400, 100);173 flick(flicker, flicker.width, flicker.height, -flicker.width, -flicker.height, 400, 100);
147 movementSpy.wait();174 movementSpy.wait();
148 }175 }
176
177 SignalSpy {
178 id: touchPressSpy
179 signalName: "onPressed"
180 target: touchArea
181 }
182 SignalSpy {
183 id: touchReleaseSpy
184 signalName: "onReleased"
185 target: touchArea
186 }
187 SignalSpy {
188 id: touchUpdateSpy
189 signalName: "onUpdated"
190 target: touchArea
191 }
192
193 function test_has_property() {
194 verify(TestExtras.hasOwnProperty("touchPresent"), "touchPresent property missing");
195 }
196
197 function test_touchPress_data() {
198 return [
199 {touch: touchArea},
200 {touch: topTouchArea}
201 ];
202 }
203 function test_touchPress(data) {
204 touchPressSpy.target = data.touch;
205 TestExtras.touchPress(0, data.touch, Qt.point(10, 10));
206 touchPressSpy.wait();
207 // cleanup
208 TestExtras.touchRelease(0, data.touch, Qt.point(10, 10));
209 }
210
211 function test_touchRelease_data() {
212 return [
213 {touch: touchArea},
214 {touch: topTouchArea}
215 ];
216 }
217 function test_touchRelease(data) {
218 // prerequisite: do a press so we get a release
219 TestExtras.touchPress(0, data.touch, Qt.point(10, 10));
220
221 touchReleaseSpy.target = data.touch;
222 TestExtras.touchRelease(0, data.touch, Qt.point(10, 10));
223 touchReleaseSpy.wait();
224 }
225
226 function test_touchClick_data() {
227 return [
228 {touch: touchArea},
229 {touch: topTouchArea}
230 ];
231 }
232 function test_touchClick(data) {
233 touchPressSpy.target = data.touch;
234 touchReleaseSpy.target = data.touch;
235 TestExtras.touchClick(0, data.touch, Qt.point(10, 10));
236 touchReleaseSpy.wait();
237 compare(touchPressSpy.count, 1, "Not pressed?");
238 compare(touchReleaseSpy.count, 1, "Not released?");
239 }
240
241 function test_touchDoubleClick_data() {
242 return [
243 {touch: touchArea},
244 {touch: topTouchArea}
245 ];
246 }
247 function test_touchDoubleClick(data) {
248 touchPressSpy.target = data.touch;
249 touchReleaseSpy.target = data.touch;
250 TestExtras.touchDoubleClick(0, data.touch, Qt.point(10, 10));
251 compare(touchPressSpy.count, 2, "Not pressed twice?");
252 compare(touchReleaseSpy.count, 2, "Not released twice?");
253 }
254
255 function test_touchMove_data() {
256 return [
257 {touch: touchArea},
258 {touch: topTouchArea}
259 ];
260 }
261 function test_touchMove(data) {
262 touchUpdateSpy.target = data.touch;
263 TestExtras.touchPress(0, data.touch, Qt.point(0, 0));
264 TestExtras.touchMove(0, data.touch, Qt.point(10, 10));
265 touchUpdateSpy.wait();
266 TestExtras.touchRelease(0, data.touch, Qt.point(10, 10));
267 }
268
269 function test_touchDrag_default_steps_data() {
270 return [
271 {touch: touchArea},
272 {touch: topTouchArea}
273 ];
274 }
275 function test_touchDrag_default_steps(data) {
276 touchPressSpy.target = data.touch;
277 touchReleaseSpy.target = data.touch;
278 touchUpdateSpy.target = data.touch;
279 TestExtras.touchDrag(0, data.touch, Qt.point(0, 0), Qt.point(10, 10));
280 compare(touchPressSpy.count, 1, "Not pressed?");
281 compare(touchReleaseSpy.count, 1, "Not released?");
282 compare(touchUpdateSpy.count, 5, "Not moved?");
283 }
284
285 function test_touchDrag_10_steps_data() {
286 return [
287 {touch: touchArea},
288 {touch: topTouchArea}
289 ];
290 }
291 function test_touchDrag_10_steps(data) {
292 touchPressSpy.target = data.touch;
293 touchReleaseSpy.target = data.touch;
294 touchUpdateSpy.target = data.touch;
295 TestExtras.touchDrag(0, data.touch, Qt.point(0, 0), Qt.point(100, 100), 10);
296 compare(touchPressSpy.count, 1, "Not pressed?");
297 compare(touchReleaseSpy.count, 1, "Not released?");
298 compare(touchUpdateSpy.count, 10, "Not moved?");
299 }
149 }300 }
150}301}

Subscribers

People subscribed via source and target branches

to status/vote changes: