Merge lp:~elopio/ubuntu-ui-toolkit/device_emulation_scenarios into lp:ubuntu-ui-toolkit
- device_emulation_scenarios
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu SDK team | Pending | ||
Review via email:
|
This proposal has been superseded by a proposal from 2014-06-25.
Commit message
Description of the change
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
1 | === modified file 'components.api' | |||
2 | --- components.api 2014-05-28 18:08:33 +0000 | |||
3 | +++ components.api 2014-06-25 19:24:49 +0000 | |||
4 | @@ -901,3 +901,51 @@ | |||
5 | 901 | prototype: "QQuickItem" | 901 | prototype: "QQuickItem" |
6 | 902 | exports: ["TextureFromImage 0.1", "TextureFromImage 1.0"] | 902 | exports: ["TextureFromImage 0.1", "TextureFromImage 1.0"] |
7 | 903 | Property { name: "image"; type: "QImage" } | 903 | Property { name: "image"; type: "QImage" } |
8 | 904 | name: "UCTestExtras" | ||
9 | 905 | prototype: "QObject" | ||
10 | 906 | exports: ["TestExtras 1.0"] | ||
11 | 907 | Property { name: "touchPresent"; type: "bool"; isReadonly: true } | ||
12 | 908 | Method { name: "registerTouchDevice" } | ||
13 | 909 | Method { | ||
14 | 910 | name: "touchPress" | ||
15 | 911 | Parameter { name: "touchId"; type: "int" } | ||
16 | 912 | Parameter { name: "item"; type: "QQuickItem"; isPointer: true } | ||
17 | 913 | Parameter { name: "point"; type: "QPoint" } | ||
18 | 914 | Method { | ||
19 | 915 | name: "touchRelease" | ||
20 | 916 | Parameter { name: "touchId"; type: "int" } | ||
21 | 917 | Parameter { name: "item"; type: "QQuickItem"; isPointer: true } | ||
22 | 918 | Parameter { name: "point"; type: "QPoint" } | ||
23 | 919 | Method { | ||
24 | 920 | name: "touchClick" | ||
25 | 921 | Parameter { name: "touchId"; type: "int" } | ||
26 | 922 | Parameter { name: "item"; type: "QQuickItem"; isPointer: true } | ||
27 | 923 | Parameter { name: "point"; type: "QPoint" } | ||
28 | 924 | Method { | ||
29 | 925 | name: "touchLongPress" | ||
30 | 926 | Parameter { name: "touchId"; type: "int" } | ||
31 | 927 | Parameter { name: "item"; type: "QQuickItem"; isPointer: true } | ||
32 | 928 | Parameter { name: "point"; type: "QPoint" } | ||
33 | 929 | Method { | ||
34 | 930 | name: "touchDoubleClick" | ||
35 | 931 | Parameter { name: "touchId"; type: "int" } | ||
36 | 932 | Parameter { name: "item"; type: "QQuickItem"; isPointer: true } | ||
37 | 933 | Parameter { name: "point"; type: "QPoint" } | ||
38 | 934 | Method { | ||
39 | 935 | name: "touchMove" | ||
40 | 936 | Parameter { name: "touchId"; type: "int" } | ||
41 | 937 | Parameter { name: "item"; type: "QQuickItem"; isPointer: true } | ||
42 | 938 | Parameter { name: "point"; type: "QPoint" } | ||
43 | 939 | Method { | ||
44 | 940 | name: "touchDrag" | ||
45 | 941 | Parameter { name: "touchId"; type: "int" } | ||
46 | 942 | Parameter { name: "item"; type: "QQuickItem"; isPointer: true } | ||
47 | 943 | Parameter { name: "from"; type: "QPoint" } | ||
48 | 944 | Parameter { name: "delta"; type: "QPoint" } | ||
49 | 945 | Parameter { name: "steps"; type: "int" } | ||
50 | 946 | Method { | ||
51 | 947 | name: "touchDrag" | ||
52 | 948 | Parameter { name: "touchId"; type: "int" } | ||
53 | 949 | Parameter { name: "item"; type: "QQuickItem"; isPointer: true } | ||
54 | 950 | Parameter { name: "from"; type: "QPoint" } | ||
55 | 951 | Parameter { name: "delta"; type: "QPoint" } | ||
56 | 904 | 952 | ||
57 | === modified file 'debian/ubuntu-ui-toolkit-autopilot.install' | |||
58 | --- debian/ubuntu-ui-toolkit-autopilot.install 2014-05-14 11:00:20 +0000 | |||
59 | +++ debian/ubuntu-ui-toolkit-autopilot.install 2014-06-25 19:24:49 +0000 | |||
60 | @@ -1,3 +1,3 @@ | |||
61 | 1 | usr/lib/python3 | 1 | usr/lib/python3 |
63 | 2 | usr/lib/ubuntu-ui-toolkit/launcher | 2 | usr/lib/*/ubuntu-ui-toolkit/launcher |
64 | 3 | usr/lib/python2.7 | 3 | usr/lib/python2.7 |
65 | 4 | 4 | ||
66 | === modified file 'documentation/overview.qdoc' | |||
67 | --- documentation/overview.qdoc 2014-04-29 05:39:04 +0000 | |||
68 | +++ documentation/overview.qdoc 2014-06-25 19:24:49 +0000 | |||
69 | @@ -106,4 +106,11 @@ | |||
70 | 106 | import Ubuntu.PerformanceMetrics 1.0 | 106 | import Ubuntu.PerformanceMetrics 1.0 |
71 | 107 | \endcode | 107 | \endcode |
72 | 108 | \annotatedlist ubuntu-performance-metrics | 108 | \annotatedlist ubuntu-performance-metrics |
73 | 109 | |||
74 | 110 | \part Test extensions | ||
75 | 111 | Available through: | ||
76 | 112 | \code | ||
77 | 113 | import Ubuntu Test 1.0 | ||
78 | 114 | \endcode | ||
79 | 115 | \annotatedlist ubuntu-test | ||
80 | 109 | */ | 116 | */ |
81 | 110 | 117 | ||
82 | === modified file 'documentation/ubuntu-ui-toolkit-common.qdocconf' | |||
83 | --- documentation/ubuntu-ui-toolkit-common.qdocconf 2014-04-29 05:39:04 +0000 | |||
84 | +++ documentation/ubuntu-ui-toolkit-common.qdocconf 2014-06-25 19:24:49 +0000 | |||
85 | @@ -8,6 +8,8 @@ | |||
86 | 8 | headerdirs += ../modules/Ubuntu/Layouts/plugin | 8 | headerdirs += ../modules/Ubuntu/Layouts/plugin |
87 | 9 | sourcedirs += ../modules/Ubuntu/PerformanceMetrics | 9 | sourcedirs += ../modules/Ubuntu/PerformanceMetrics |
88 | 10 | headerdirs += ../modules/Ubuntu/PerformanceMetrics/plugin | 10 | headerdirs += ../modules/Ubuntu/PerformanceMetrics/plugin |
89 | 11 | sourcedirs += ../modules/Ubuntu/Test | ||
90 | 12 | headerdirs += ../modules/Ubuntu/Test/plugin | ||
91 | 11 | exampledirs += snippets | 13 | exampledirs += snippets |
92 | 12 | excludedirs = ../modules/Ubuntu/Components/Themes | 14 | excludedirs = ../modules/Ubuntu/Components/Themes |
93 | 13 | imagedirs = images | 15 | imagedirs = images |
94 | 14 | 16 | ||
95 | === added file 'examples/ubuntu-ui-toolkit-gallery/Styles.qml' | |||
96 | --- examples/ubuntu-ui-toolkit-gallery/Styles.qml 1970-01-01 00:00:00 +0000 | |||
97 | +++ examples/ubuntu-ui-toolkit-gallery/Styles.qml 2014-06-25 19:24:49 +0000 | |||
98 | @@ -0,0 +1,48 @@ | |||
99 | 1 | /* | ||
100 | 2 | * Copyright 2014 Canonical Ltd. | ||
101 | 3 | * | ||
102 | 4 | * This program is free software; you can redistribute it and/or modify | ||
103 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
104 | 6 | * the Free Software Foundation; version 3. | ||
105 | 7 | * | ||
106 | 8 | * This program is distributed in the hope that it will be useful, | ||
107 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
108 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
109 | 11 | * GNU Lesser General Public License for more details. | ||
110 | 12 | * | ||
111 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
112 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
113 | 15 | */ | ||
114 | 16 | |||
115 | 17 | import QtQuick 2.0 | ||
116 | 18 | import Ubuntu.Components 1.1 | ||
117 | 19 | |||
118 | 20 | Template { | ||
119 | 21 | objectName: "stylesTemplate" | ||
120 | 22 | |||
121 | 23 | Label { | ||
122 | 24 | anchors.left: parent.left | ||
123 | 25 | anchors.right: parent.right | ||
124 | 26 | |||
125 | 27 | text: i18n.tr("Switch between old and new style header") | ||
126 | 28 | } | ||
127 | 29 | |||
128 | 30 | OptionSelector { | ||
129 | 31 | model: [ i18n.tr('Header with Toolbar'), i18n.tr('New Style Header') ] | ||
130 | 32 | expanded: true | ||
131 | 33 | onSelectedIndexChanged: gallery.useDeprecatedToolbar = (selectedIndex == 0) | ||
132 | 34 | } | ||
133 | 35 | |||
134 | 36 | Label { | ||
135 | 37 | anchors.left: parent.left | ||
136 | 38 | anchors.right: parent.right | ||
137 | 39 | |||
138 | 40 | text: i18n.tr("Switch between themes") | ||
139 | 41 | } | ||
140 | 42 | |||
141 | 43 | OptionSelector { | ||
142 | 44 | model: [ 'Ambiance', 'SuruDark' ] | ||
143 | 45 | expanded: true | ||
144 | 46 | onSelectedIndexChanged: Theme.name = 'Ubuntu.Components.Themes.%1'.arg(model[selectedIndex]) | ||
145 | 47 | } | ||
146 | 48 | } | ||
147 | 0 | 49 | ||
148 | === added file 'examples/ubuntu-ui-toolkit-gallery/Toolbar.qml' | |||
149 | --- examples/ubuntu-ui-toolkit-gallery/Toolbar.qml 1970-01-01 00:00:00 +0000 | |||
150 | +++ examples/ubuntu-ui-toolkit-gallery/Toolbar.qml 2014-06-25 19:24:49 +0000 | |||
151 | @@ -0,0 +1,49 @@ | |||
152 | 1 | /* | ||
153 | 2 | * Copyright 2014 Canonical Ltd. | ||
154 | 3 | * | ||
155 | 4 | * This program is free software; you can redistribute it and/or modify | ||
156 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
157 | 6 | * the Free Software Foundation; version 3. | ||
158 | 7 | * | ||
159 | 8 | * This program is distributed in the hope that it will be useful, | ||
160 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
161 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
162 | 11 | * GNU Lesser General Public License for more details. | ||
163 | 12 | * | ||
164 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
165 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
166 | 15 | */ | ||
167 | 16 | |||
168 | 17 | import QtQuick 2.0 | ||
169 | 18 | import Ubuntu.Components 0.1 | ||
170 | 19 | import Ubuntu.Components.Popups 0.1 | ||
171 | 20 | |||
172 | 21 | Template { | ||
173 | 22 | objectName: "popoversTemplate" | ||
174 | 23 | |||
175 | 24 | tools: ToolbarItems { | ||
176 | 25 | ToolbarButton { | ||
177 | 26 | text: "Call" | ||
178 | 27 | iconName: "call-start" | ||
179 | 28 | } | ||
180 | 29 | ToolbarButton { | ||
181 | 30 | text: i18n.tr("Share") | ||
182 | 31 | iconName: "share" | ||
183 | 32 | } | ||
184 | 33 | ToolbarButton { | ||
185 | 34 | iconName: "settings" | ||
186 | 35 | } | ||
187 | 36 | ToolbarButton { | ||
188 | 37 | iconName: "speaker" | ||
189 | 38 | } | ||
190 | 39 | } | ||
191 | 40 | |||
192 | 41 | TemplateSection { | ||
193 | 42 | className: "Toolbar" | ||
194 | 43 | documentation: "qml-ubuntu-components-toolbar0-%1.html".arg(className.toLowerCase()) | ||
195 | 44 | |||
196 | 45 | TemplateRow { | ||
197 | 46 | title: i18n.tr("See below") | ||
198 | 47 | } | ||
199 | 48 | } | ||
200 | 49 | } | ||
201 | 0 | 50 | ||
202 | === modified file 'examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml' | |||
203 | --- examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml 2014-04-30 10:26:35 +0000 | |||
204 | +++ examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml 2014-06-25 19:24:49 +0000 | |||
205 | @@ -23,6 +23,11 @@ | |||
206 | 23 | label: "Navigation" | 23 | label: "Navigation" |
207 | 24 | source: "Navigation.qml" | 24 | source: "Navigation.qml" |
208 | 25 | } | 25 | } |
209 | 26 | ListElement { | ||
210 | 27 | objectName: "stylesElement" | ||
211 | 28 | label: "Styles" | ||
212 | 29 | source: "Styles.qml" | ||
213 | 30 | } | ||
214 | 26 | 31 | ||
215 | 27 | ListElement { | 32 | ListElement { |
216 | 28 | objectName: "togglesElement" | 33 | objectName: "togglesElement" |
217 | @@ -30,6 +35,11 @@ | |||
218 | 30 | source: "Toggles.qml" | 35 | source: "Toggles.qml" |
219 | 31 | } | 36 | } |
220 | 32 | ListElement { | 37 | ListElement { |
221 | 38 | objectName: "toolbarElement" | ||
222 | 39 | label: "Toolbar" | ||
223 | 40 | source: "Toolbar.qml" | ||
224 | 41 | } | ||
225 | 42 | ListElement { | ||
226 | 33 | objectName: "buttonsElement" | 43 | objectName: "buttonsElement" |
227 | 34 | label: "Buttons" | 44 | label: "Buttons" |
228 | 35 | source: "Buttons.qml" | 45 | source: "Buttons.qml" |
229 | 36 | 46 | ||
230 | === modified file 'modules/Ubuntu/Components/Icon.qml' | |||
231 | --- modules/Ubuntu/Components/Icon.qml 2014-04-23 08:50:20 +0000 | |||
232 | +++ modules/Ubuntu/Components/Icon.qml 2014-06-25 19:24:49 +0000 | |||
233 | @@ -103,12 +103,12 @@ | |||
234 | 103 | id: colorizedImage | 103 | id: colorizedImage |
235 | 104 | 104 | ||
236 | 105 | anchors.fill: parent | 105 | anchors.fill: parent |
238 | 106 | visible: active && image.status == Image.Ready | 106 | visible: active |
239 | 107 | 107 | ||
240 | 108 | // Whether or not a color has been set. | 108 | // Whether or not a color has been set. |
241 | 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) |
242 | 110 | 110 | ||
244 | 111 | property Image source: visible ? image : null | 111 | property Image source: active && image.status == Image.Ready ? image : null |
245 | 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) |
246 | 113 | property color keyColorIn: "#808080" | 113 | property color keyColorIn: "#808080" |
247 | 114 | property real threshold: 0.1 | 114 | property real threshold: 0.1 |
248 | 115 | 115 | ||
249 | === modified file 'modules/Ubuntu/Components/Label.qml' | |||
250 | --- modules/Ubuntu/Components/Label.qml 2014-05-22 09:44:01 +0000 | |||
251 | +++ modules/Ubuntu/Components/Label.qml 2014-06-25 19:24:49 +0000 | |||
252 | @@ -55,8 +55,6 @@ | |||
253 | 55 | property string fontSize: "medium" | 55 | property string fontSize: "medium" |
254 | 56 | 56 | ||
255 | 57 | font.pixelSize: FontUtils.sizeToPixels(fontSize) | 57 | font.pixelSize: FontUtils.sizeToPixels(fontSize) |
256 | 58 | font.family: "Ubuntu" | ||
257 | 59 | font.weight: Font.Light | ||
258 | 60 | color: Theme.palette.selected.backgroundText | 58 | color: Theme.palette.selected.backgroundText |
259 | 61 | 59 | ||
260 | 62 | /* FIXME: workaround for QTBUG 35095 where Text's alignment is incorrect | 60 | /* FIXME: workaround for QTBUG 35095 where Text's alignment is incorrect |
261 | 63 | 61 | ||
262 | === modified file 'modules/Ubuntu/Components/OrientationHelper.qml' | |||
263 | --- modules/Ubuntu/Components/OrientationHelper.qml 2014-06-09 09:07:40 +0000 | |||
264 | +++ modules/Ubuntu/Components/OrientationHelper.qml 2014-06-25 19:24:49 +0000 | |||
265 | @@ -14,7 +14,7 @@ | |||
266 | 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/>. |
267 | 15 | */ | 15 | */ |
268 | 16 | 16 | ||
270 | 17 | import QtQuick 2.0 | 17 | import QtQuick 2.2 |
271 | 18 | import QtQuick.Window 2.0 | 18 | import QtQuick.Window 2.0 |
272 | 19 | import Ubuntu.Components 1.0 | 19 | import Ubuntu.Components 1.0 |
273 | 20 | 20 | ||
274 | @@ -136,6 +136,17 @@ | |||
275 | 136 | target: orientationHelper | 136 | target: orientationHelper |
276 | 137 | rotation: 0 | 137 | rotation: 0 |
277 | 138 | } | 138 | } |
278 | 139 | StateChangeScript { | ||
279 | 140 | name: "anchorsScript" | ||
280 | 141 | script: { | ||
281 | 142 | orientationHelper.anchors.fill = null; | ||
282 | 143 | orientationHelper.anchors.leftMargin = 0; | ||
283 | 144 | orientationHelper.anchors.rightMargin = 0; | ||
284 | 145 | orientationHelper.anchors.topMargin = 0; | ||
285 | 146 | orientationHelper.anchors.bottomMargin = 0; | ||
286 | 147 | orientationHelper.anchors.fill = orientationHelper.parent; | ||
287 | 148 | } | ||
288 | 149 | } | ||
289 | 139 | }, | 150 | }, |
290 | 140 | State { | 151 | State { |
291 | 141 | name: "180" | 152 | name: "180" |
292 | @@ -143,17 +154,33 @@ | |||
293 | 143 | target: orientationHelper | 154 | target: orientationHelper |
294 | 144 | rotation: 180 | 155 | rotation: 180 |
295 | 145 | } | 156 | } |
296 | 157 | StateChangeScript { | ||
297 | 158 | name: "anchorsScript" | ||
298 | 159 | script: { | ||
299 | 160 | orientationHelper.anchors.fill = null; | ||
300 | 161 | orientationHelper.anchors.leftMargin = 0; | ||
301 | 162 | orientationHelper.anchors.rightMargin = 0; | ||
302 | 163 | orientationHelper.anchors.topMargin = 0; | ||
303 | 164 | orientationHelper.anchors.bottomMargin = 0; | ||
304 | 165 | orientationHelper.anchors.fill = orientationHelper.parent; | ||
305 | 166 | } | ||
306 | 167 | } | ||
307 | 146 | }, | 168 | }, |
308 | 147 | State { | 169 | State { |
309 | 148 | name: "270" | 170 | name: "270" |
310 | 149 | PropertyChanges { | 171 | PropertyChanges { |
311 | 150 | target: orientationHelper | 172 | target: orientationHelper |
312 | 151 | rotation: 270 | 173 | rotation: 270 |
318 | 152 | anchors { | 174 | } |
319 | 153 | leftMargin: (parent.width - parent.height) / 2 | 175 | StateChangeScript { |
320 | 154 | rightMargin: anchors.leftMargin | 176 | name: "anchorsScript" |
321 | 155 | topMargin: -anchors.leftMargin | 177 | script: { |
322 | 156 | bottomMargin: anchors.topMargin | 178 | orientationHelper.anchors.fill = null; |
323 | 179 | orientationHelper.anchors.topMargin = Qt.binding(function() {return -(parent.width - parent.height) / 2}); | ||
324 | 180 | orientationHelper.anchors.bottomMargin = Qt.binding(function() {return -(parent.width - parent.height) / 2}); | ||
325 | 181 | orientationHelper.anchors.leftMargin = Qt.binding(function() {return (parent.width - parent.height) / 2}); | ||
326 | 182 | orientationHelper.anchors.rightMargin = Qt.binding(function() {return (parent.width - parent.height) / 2}); | ||
327 | 183 | orientationHelper.anchors.fill = orientationHelper.parent; | ||
328 | 157 | } | 184 | } |
329 | 158 | } | 185 | } |
330 | 159 | }, | 186 | }, |
331 | @@ -162,11 +189,16 @@ | |||
332 | 162 | PropertyChanges { | 189 | PropertyChanges { |
333 | 163 | target: orientationHelper | 190 | target: orientationHelper |
334 | 164 | rotation: 90 | 191 | rotation: 90 |
340 | 165 | anchors { | 192 | } |
341 | 166 | leftMargin: (parent.width - parent.height) / 2 | 193 | StateChangeScript { |
342 | 167 | rightMargin: anchors.leftMargin | 194 | name: "anchorsScript" |
343 | 168 | topMargin: -anchors.leftMargin | 195 | script: { |
344 | 169 | bottomMargin: anchors.topMargin | 196 | orientationHelper.anchors.fill = null; |
345 | 197 | orientationHelper.anchors.topMargin = Qt.binding(function() {return -(parent.width - parent.height) / 2}); | ||
346 | 198 | orientationHelper.anchors.bottomMargin = Qt.binding(function() {return -(parent.width - parent.height) / 2}); | ||
347 | 199 | orientationHelper.anchors.leftMargin = Qt.binding(function() {return (parent.width - parent.height) / 2}); | ||
348 | 200 | orientationHelper.anchors.rightMargin = Qt.binding(function() {return (parent.width - parent.height) / 2}); | ||
349 | 201 | orientationHelper.anchors.fill = orientationHelper.parent; | ||
350 | 170 | } | 202 | } |
351 | 171 | } | 203 | } |
352 | 172 | } | 204 | } |
353 | @@ -176,18 +208,20 @@ | |||
354 | 176 | Transition { | 208 | Transition { |
355 | 177 | id: orientationTransition | 209 | id: orientationTransition |
356 | 178 | ParallelAnimation { | 210 | ParallelAnimation { |
365 | 179 | SequentialAnimation { | 211 | /* FIXME: this is a workaround for 2 issues that trigger too many changes |
366 | 180 | PauseAnimation { | 212 | to the width and height of orientationHelper which creates intermediary |
367 | 181 | duration: 25 | 213 | states of the UI with unexpected sizes: |
368 | 182 | } | 214 | 1) upon state change fast-forwarding is used which means that the final values are computed and applied |
369 | 183 | PropertyAction { | 215 | then immediately reverted before the actual transition is applied |
370 | 184 | target: orientationHelper | 216 | 2) when margins are applied, width and height are updated separately |
371 | 185 | properties: "anchors.topMargin,anchors.bottomMargin,anchors.rightMargin,anchors.leftMargin" | 217 | |
372 | 186 | } | 218 | Without these issues, regular PropertyChanges could be used to set the margins. |
373 | 219 | */ | ||
374 | 220 | ScriptAction { | ||
375 | 221 | scriptName: "anchorsScript" | ||
376 | 187 | } | 222 | } |
378 | 188 | RotationAnimation { | 223 | RotationAnimator { |
379 | 189 | target: orientationHelper | 224 | target: orientationHelper |
380 | 190 | properties: "rotation" | ||
381 | 191 | duration: UbuntuAnimation.FastDuration | 225 | duration: UbuntuAnimation.FastDuration |
382 | 192 | easing: UbuntuAnimation.StandardEasing | 226 | easing: UbuntuAnimation.StandardEasing |
383 | 193 | direction: RotationAnimation.Shortest | 227 | direction: RotationAnimation.Shortest |
384 | 194 | 228 | ||
385 | === modified file 'modules/Ubuntu/Components/plugin/uctheme.cpp' | |||
386 | --- modules/Ubuntu/Components/plugin/uctheme.cpp 2014-06-09 08:43:30 +0000 | |||
387 | +++ modules/Ubuntu/Components/plugin/uctheme.cpp 2014-06-25 19:24:49 +0000 | |||
388 | @@ -21,6 +21,7 @@ | |||
389 | 21 | #include "listener.h" | 21 | #include "listener.h" |
390 | 22 | #include "quickutils.h" | 22 | #include "quickutils.h" |
391 | 23 | #include "i18n.h" | 23 | #include "i18n.h" |
392 | 24 | #include "ucfontutils.h" | ||
393 | 24 | 25 | ||
394 | 25 | #include <QtQml/qqml.h> | 26 | #include <QtQml/qqml.h> |
395 | 26 | #include <QtQml/qqmlinfo.h> | 27 | #include <QtQml/qqmlinfo.h> |
396 | @@ -32,6 +33,8 @@ | |||
397 | 32 | #include <QtCore/QTextStream> | 33 | #include <QtCore/QTextStream> |
398 | 33 | #include <QtCore/QLibraryInfo> | 34 | #include <QtCore/QLibraryInfo> |
399 | 34 | #include <QtCore/QStandardPaths> | 35 | #include <QtCore/QStandardPaths> |
400 | 36 | #include <QtGui/QGuiApplication> | ||
401 | 37 | #include <QtGui/QFont> | ||
402 | 35 | 38 | ||
403 | 36 | /*! | 39 | /*! |
404 | 37 | \qmltype Theme | 40 | \qmltype Theme |
405 | @@ -114,6 +117,13 @@ | |||
406 | 114 | 117 | ||
407 | 115 | QObject::connect(this, SIGNAL(nameChanged()), | 118 | QObject::connect(this, SIGNAL(nameChanged()), |
408 | 116 | this, SLOT(loadPalette()), Qt::UniqueConnection); | 119 | this, SLOT(loadPalette()), Qt::UniqueConnection); |
409 | 120 | |||
410 | 121 | // set the default font | ||
411 | 122 | QFont defaultFont; | ||
412 | 123 | defaultFont.setFamily("Ubuntu"); | ||
413 | 124 | defaultFont.setPixelSize(UCFontUtils::instance().sizeToPixels("medium")); | ||
414 | 125 | defaultFont.setWeight(QFont::Light); | ||
415 | 126 | QGuiApplication::setFont(defaultFont); | ||
416 | 117 | } | 127 | } |
417 | 118 | 128 | ||
418 | 119 | void UCTheme::updateEnginePaths() | 129 | void UCTheme::updateEnginePaths() |
419 | 120 | 130 | ||
420 | === modified file 'modules/Ubuntu/Test/UbuntuTestCase.qml' | |||
421 | --- modules/Ubuntu/Test/UbuntuTestCase.qml 2014-05-02 07:22:52 +0000 | |||
422 | +++ modules/Ubuntu/Test/UbuntuTestCase.qml 2014-06-25 19:24:49 +0000 | |||
423 | @@ -19,9 +19,9 @@ | |||
424 | 19 | import Ubuntu.Components 1.1 | 19 | import Ubuntu.Components 1.1 |
425 | 20 | 20 | ||
426 | 21 | /*! | 21 | /*! |
430 | 22 | \qmlabstract UbuntuTestCase | 22 | \qmltype UbuntuTestCase |
431 | 23 | \inqmlmodule Ubuntu.Test 0.1 | 23 | \inqmlmodule Ubuntu.Test 1.0 |
432 | 24 | \ingroup ubuntu | 24 | \ingroup ubuntu-test |
433 | 25 | \brief The UbuntuTestCase class expands the default TestCase class. | 25 | \brief The UbuntuTestCase class expands the default TestCase class. |
434 | 26 | 26 | ||
435 | 27 | \b{This component is under heavy development.} | 27 | \b{This component is under heavy development.} |
436 | @@ -51,6 +51,9 @@ | |||
437 | 51 | return null; | 51 | return null; |
438 | 52 | } | 52 | } |
439 | 53 | 53 | ||
440 | 54 | /*! | ||
441 | 55 | Find a non-visual child such as QtObject based on objectName. | ||
442 | 56 | */ | ||
443 | 54 | function findInvisibleChild(obj,objectName) { | 57 | function findInvisibleChild(obj,objectName) { |
444 | 55 | var childs = new Array(0); | 58 | var childs = new Array(0); |
445 | 56 | childs.push(obj) | 59 | childs.push(obj) |
446 | @@ -113,7 +116,7 @@ | |||
447 | 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) |
448 | 114 | 117 | ||
449 | 115 | The function produces a flick event when executed on Flickables. When used | 118 | The function produces a flick event when executed on Flickables. When used |
451 | 116 | on other components it provides the same functionality as \l mouseDrag() | 119 | on other components it provides the same functionality as \c mouseDrag() |
452 | 117 | function. The optional \a pressTimeout parameter can be used to introduce | 120 | function. The optional \a pressTimeout parameter can be used to introduce |
453 | 118 | a small delay between the mouse press and the first mouse move. Setting a | 121 | a small delay between the mouse press and the first mouse move. Setting a |
454 | 119 | negative or zero value will disable the timeout. | 122 | negative or zero value will disable the timeout. |
455 | @@ -169,8 +172,6 @@ | |||
456 | 169 | system of \a item into window co-ordinates and then delivered. | 172 | system of \a item into window co-ordinates and then delivered. |
457 | 170 | If \a item is obscured by another item, or a child of \a item occupies | 173 | If \a item is obscured by another item, or a child of \a item occupies |
458 | 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. |
459 | 172 | |||
460 | 173 | \sa mouseRelease(), mouseClick(), mouseDoubleClick(), mouseMove(), mouseDrag(), mouseWheel() | ||
461 | 174 | */ | 175 | */ |
462 | 175 | function mouseLongPress(item, x, y, button, modifiers, delay) { | 176 | function mouseLongPress(item, x, y, button, modifiers, delay) { |
463 | 176 | mousePress(item, x, y, button, modifiers, delay); | 177 | mousePress(item, x, y, button, modifiers, delay); |
464 | 177 | 178 | ||
465 | === modified file 'modules/Ubuntu/Test/plugin/plugin.pro' | |||
466 | --- modules/Ubuntu/Test/plugin/plugin.pro 2014-06-10 09:28:21 +0000 | |||
467 | +++ modules/Ubuntu/Test/plugin/plugin.pro 2014-06-25 19:24:49 +0000 | |||
468 | @@ -1,6 +1,6 @@ | |||
469 | 1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
470 | 2 | TARGET = ../UbuntuTest | 2 | TARGET = ../UbuntuTest |
472 | 3 | QT += core-private qml qml-private quick quick-private gui-private | 3 | QT += core-private qml qml-private quick quick-private gui-private testlib |
473 | 4 | 4 | ||
474 | 5 | equals(QT_MAJOR_VERSION, 5):lessThan(QT_MINOR_VERSION, 2) { | 5 | equals(QT_MAJOR_VERSION, 5):lessThan(QT_MINOR_VERSION, 2) { |
475 | 6 | QT += v8-private | 6 | QT += v8-private |
476 | @@ -15,9 +15,13 @@ | |||
477 | 15 | 15 | ||
478 | 16 | HEADERS += \ | 16 | HEADERS += \ |
479 | 17 | uctestcase.h \ | 17 | uctestcase.h \ |
480 | 18 | testplugin.h \ | ||
481 | 19 | uctestextras.h | ||
482 | 18 | 20 | ||
483 | 19 | SOURCES += \ | 21 | SOURCES += \ |
484 | 20 | uctestcase.cpp \ | 22 | uctestcase.cpp \ |
485 | 23 | testplugin.cpp \ | ||
486 | 24 | uctestextras.cpp | ||
487 | 21 | 25 | ||
488 | 22 | # deployment rules for the plugin | 26 | # deployment rules for the plugin |
489 | 23 | installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) | 27 | installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) |
490 | 24 | 28 | ||
491 | === added file 'modules/Ubuntu/Test/plugin/testplugin.cpp' | |||
492 | --- modules/Ubuntu/Test/plugin/testplugin.cpp 1970-01-01 00:00:00 +0000 | |||
493 | +++ modules/Ubuntu/Test/plugin/testplugin.cpp 2014-06-25 19:24:49 +0000 | |||
494 | @@ -0,0 +1,32 @@ | |||
495 | 1 | /* | ||
496 | 2 | * Copyright 2014 Canonical Ltd. | ||
497 | 3 | * | ||
498 | 4 | * This program is free software; you can redistribute it and/or modify | ||
499 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
500 | 6 | * the Free Software Foundation; version 3. | ||
501 | 7 | * | ||
502 | 8 | * This program is distributed in the hope that it will be useful, | ||
503 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
504 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
505 | 11 | * GNU Lesser General Public License for more details. | ||
506 | 12 | * | ||
507 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
508 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
509 | 15 | */ | ||
510 | 16 | |||
511 | 17 | #include "testplugin.h" | ||
512 | 18 | #include <QtQml> | ||
513 | 19 | #include "uctestextras.h" | ||
514 | 20 | |||
515 | 21 | static QObject *registerExtras(QQmlEngine *engine, QJSEngine *scriptEngine) | ||
516 | 22 | { | ||
517 | 23 | Q_UNUSED(engine) | ||
518 | 24 | Q_UNUSED(scriptEngine) | ||
519 | 25 | |||
520 | 26 | return new UCTestExtras; | ||
521 | 27 | } | ||
522 | 28 | |||
523 | 29 | void TestPlugin::registerTypes(const char *uri) | ||
524 | 30 | { | ||
525 | 31 | qmlRegisterSingletonType<UCTestExtras>(uri, 1, 0, "TestExtras", registerExtras); | ||
526 | 32 | } | ||
527 | 0 | 33 | ||
528 | === added file 'modules/Ubuntu/Test/plugin/testplugin.h' | |||
529 | --- modules/Ubuntu/Test/plugin/testplugin.h 1970-01-01 00:00:00 +0000 | |||
530 | +++ modules/Ubuntu/Test/plugin/testplugin.h 2014-06-25 19:24:49 +0000 | |||
531 | @@ -0,0 +1,31 @@ | |||
532 | 1 | /* | ||
533 | 2 | * Copyright 2014 Canonical Ltd. | ||
534 | 3 | * | ||
535 | 4 | * This program is free software; you can redistribute it and/or modify | ||
536 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
537 | 6 | * the Free Software Foundation; version 3. | ||
538 | 7 | * | ||
539 | 8 | * This program is distributed in the hope that it will be useful, | ||
540 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
541 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
542 | 11 | * GNU Lesser General Public License for more details. | ||
543 | 12 | * | ||
544 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
545 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
546 | 15 | */ | ||
547 | 16 | |||
548 | 17 | #ifndef TESTPLUGIN_H | ||
549 | 18 | #define TESTPLUGIN_H | ||
550 | 19 | |||
551 | 20 | #include <QQmlExtensionPlugin> | ||
552 | 21 | |||
553 | 22 | class TestPlugin : public QQmlExtensionPlugin | ||
554 | 23 | { | ||
555 | 24 | Q_OBJECT | ||
556 | 25 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") | ||
557 | 26 | |||
558 | 27 | public: | ||
559 | 28 | void registerTypes(const char *uri); | ||
560 | 29 | }; | ||
561 | 30 | |||
562 | 31 | #endif // TESTPLUGIN_H | ||
563 | 0 | 32 | ||
564 | === modified file 'modules/Ubuntu/Test/plugin/uctestcase.cpp' | |||
565 | --- modules/Ubuntu/Test/plugin/uctestcase.cpp 2014-06-10 11:45:11 +0000 | |||
566 | +++ modules/Ubuntu/Test/plugin/uctestcase.cpp 2014-06-25 19:24:49 +0000 | |||
567 | @@ -26,11 +26,8 @@ | |||
568 | 26 | #include <QtTest/QtTest> | 26 | #include <QtTest/QtTest> |
569 | 27 | #include <QtQuick/QQuickItem> | 27 | #include <QtQuick/QQuickItem> |
570 | 28 | 28 | ||
571 | 29 | #include <qpa/qwindowsysteminterface.h> | ||
572 | 30 | |||
573 | 31 | Q_DECLARE_METATYPE(QList<QQmlError>) | 29 | Q_DECLARE_METATYPE(QList<QQmlError>) |
574 | 32 | 30 | ||
575 | 33 | QTouchDevice *UbuntuTestCase::m_touchDevice = 0; | ||
576 | 34 | /*! | 31 | /*! |
577 | 35 | * \ingroup ubuntu | 32 | * \ingroup ubuntu |
578 | 36 | * \brief UbuntuTestCase is the C++ pendant to the QML UbuntuTestCase. | 33 | * \brief UbuntuTestCase is the C++ pendant to the QML UbuntuTestCase. |
579 | @@ -63,26 +60,3 @@ | |||
580 | 63 | return m_spy->count(); | 60 | return m_spy->count(); |
581 | 64 | } | 61 | } |
582 | 65 | 62 | ||
583 | 66 | /*! | ||
584 | 67 | * Registers a touch device if there's none registered. | ||
585 | 68 | */ | ||
586 | 69 | void UbuntuTestCase::registerTouchDevice() | ||
587 | 70 | { | ||
588 | 71 | // check if there is any touch device registered in the system | ||
589 | 72 | if (!m_touchDevice) { | ||
590 | 73 | QList<const QTouchDevice*> touchDevices = QTouchDevice::devices(); | ||
591 | 74 | Q_FOREACH(const QTouchDevice *device, touchDevices) { | ||
592 | 75 | if (device->type() == QTouchDevice::TouchScreen) { | ||
593 | 76 | m_touchDevice = const_cast<QTouchDevice*>(device); | ||
594 | 77 | break; | ||
595 | 78 | } | ||
596 | 79 | } | ||
597 | 80 | } | ||
598 | 81 | // if none, register one | ||
599 | 82 | if (!m_touchDevice) { | ||
600 | 83 | m_touchDevice = new QTouchDevice; | ||
601 | 84 | m_touchDevice->setType(QTouchDevice::TouchScreen); | ||
602 | 85 | QWindowSystemInterface::registerTouchDevice(m_touchDevice); | ||
603 | 86 | } | ||
604 | 87 | } | ||
605 | 88 | |||
606 | 89 | 63 | ||
607 | === modified file 'modules/Ubuntu/Test/plugin/uctestcase.h' | |||
608 | --- modules/Ubuntu/Test/plugin/uctestcase.h 2014-06-10 11:45:11 +0000 | |||
609 | +++ modules/Ubuntu/Test/plugin/uctestcase.h 2014-06-25 19:24:49 +0000 | |||
610 | @@ -24,8 +24,6 @@ | |||
611 | 24 | #include <QtQuick/QQuickView> | 24 | #include <QtQuick/QQuickView> |
612 | 25 | #include <QtTest/QSignalSpy> | 25 | #include <QtTest/QSignalSpy> |
613 | 26 | 26 | ||
614 | 27 | #define CHECK_TOUCH_DEVICE() if (!checkTouchDevice(__FUNCTION__)) return | ||
615 | 28 | |||
616 | 29 | class UbuntuTestCase : public QQuickView | 27 | class UbuntuTestCase : public QQuickView |
617 | 30 | { | 28 | { |
618 | 31 | Q_OBJECT | 29 | Q_OBJECT |
619 | @@ -44,73 +42,8 @@ | |||
620 | 44 | qFatal("No item '%s' found", qPrintable(objectName)); | 42 | qFatal("No item '%s' found", qPrintable(objectName)); |
621 | 45 | } | 43 | } |
622 | 46 | 44 | ||
623 | 47 | static void registerTouchDevice(); | ||
624 | 48 | |||
625 | 49 | inline static void touchPress(int touchId, QWindow *window, const QPoint &point) | ||
626 | 50 | { | ||
627 | 51 | CHECK_TOUCH_DEVICE(); | ||
628 | 52 | QTest::touchEvent(window, m_touchDevice).press(touchId, point, window); | ||
629 | 53 | } | ||
630 | 54 | inline static void touchRelease(int touchId, QWindow *window, const QPoint &point) | ||
631 | 55 | { | ||
632 | 56 | CHECK_TOUCH_DEVICE(); | ||
633 | 57 | QTest::touchEvent(window, m_touchDevice).release(touchId, point, window); | ||
634 | 58 | } | ||
635 | 59 | inline static void touchClick(int touchId, QWindow *window, const QPoint &point) | ||
636 | 60 | { | ||
637 | 61 | CHECK_TOUCH_DEVICE(); | ||
638 | 62 | touchPress(touchId, window, point); | ||
639 | 63 | QTest::qWait(10); | ||
640 | 64 | touchRelease(touchId, window, point); | ||
641 | 65 | } | ||
642 | 66 | inline static void touchLongPress(int touchId, QWindow *window, const QPoint &point) | ||
643 | 67 | { | ||
644 | 68 | CHECK_TOUCH_DEVICE(); | ||
645 | 69 | touchPress(touchId, window, point); | ||
646 | 70 | QTest::qWait(800); | ||
647 | 71 | } | ||
648 | 72 | inline static void touchDoubleClick(int touchId, QWindow *window, const QPoint &point) | ||
649 | 73 | { | ||
650 | 74 | CHECK_TOUCH_DEVICE(); | ||
651 | 75 | touchClick(touchId, window, point); | ||
652 | 76 | QTest::qWait(10); | ||
653 | 77 | touchClick(touchId, window, point); | ||
654 | 78 | } | ||
655 | 79 | inline static void touchMove(int touchId, QWindow *window, const QPoint &point) | ||
656 | 80 | { | ||
657 | 81 | CHECK_TOUCH_DEVICE(); | ||
658 | 82 | QTest::touchEvent(window, m_touchDevice).move(touchId, point, window); | ||
659 | 83 | } | ||
660 | 84 | inline static void touchDrag(int touchId, QWindow *window, const QPoint &from, const QPoint &delta, int steps = 5) | ||
661 | 85 | { | ||
662 | 86 | touchPress(touchId, window, from); | ||
663 | 87 | QTest::qWait(10); | ||
664 | 88 | QTest::touchEvent(window, m_touchDevice).move(touchId, from, window); | ||
665 | 89 | qreal stepDx = delta.x() / steps; | ||
666 | 90 | qreal stepDy = delta.y() / steps; | ||
667 | 91 | if (!delta.isNull()) { | ||
668 | 92 | for (int i = 0; i < steps; i++) { | ||
669 | 93 | QTest::qWait(10); | ||
670 | 94 | QTest::touchEvent(window, m_touchDevice).move(touchId, from + QPoint(i * stepDx, i * stepDy), window); | ||
671 | 95 | } | ||
672 | 96 | } | ||
673 | 97 | QTest::qWait(10); | ||
674 | 98 | touchRelease(touchId, window, from + QPoint(stepDx, stepDy)); | ||
675 | 99 | } | ||
676 | 100 | |||
677 | 101 | |||
678 | 102 | private: | 45 | private: |
679 | 103 | QSignalSpy* m_spy; | 46 | QSignalSpy* m_spy; |
680 | 104 | static QTouchDevice *m_touchDevice; | ||
681 | 105 | |||
682 | 106 | static inline bool checkTouchDevice(const char *func) | ||
683 | 107 | { | ||
684 | 108 | if (!m_touchDevice) { | ||
685 | 109 | qWarning() << QString("No touch device registered. Register one using registerTouchDevice() before using %1").arg(func); | ||
686 | 110 | return false; | ||
687 | 111 | } | ||
688 | 112 | return true; | ||
689 | 113 | } | ||
690 | 114 | }; | 47 | }; |
691 | 115 | 48 | ||
692 | 116 | #endif // UBUNTU_TEST_UBUNTUTESTCASE_H | 49 | #endif // UBUNTU_TEST_UBUNTUTESTCASE_H |
693 | 117 | 50 | ||
694 | === added file 'modules/Ubuntu/Test/plugin/uctestextras.cpp' | |||
695 | --- modules/Ubuntu/Test/plugin/uctestextras.cpp 1970-01-01 00:00:00 +0000 | |||
696 | +++ modules/Ubuntu/Test/plugin/uctestextras.cpp 2014-06-25 19:24:49 +0000 | |||
697 | @@ -0,0 +1,203 @@ | |||
698 | 1 | /* | ||
699 | 2 | * Copyright 2014 Canonical Ltd. | ||
700 | 3 | * | ||
701 | 4 | * This program is free software; you can redistribute it and/or modify | ||
702 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
703 | 6 | * the Free Software Foundation; version 3. | ||
704 | 7 | * | ||
705 | 8 | * This program is distributed in the hope that it will be useful, | ||
706 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
707 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
708 | 11 | * GNU Lesser General Public License for more details. | ||
709 | 12 | * | ||
710 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
711 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
712 | 15 | */ | ||
713 | 16 | |||
714 | 17 | #include "uctestextras.h" | ||
715 | 18 | #include "uctestcase.h" | ||
716 | 19 | |||
717 | 20 | #include <qpa/qwindowsysteminterface.h> | ||
718 | 21 | |||
719 | 22 | const char *DEVICE_MISSING_MSG = "No touch device registered. Register one using registerTouchDevice() before using %1"; | ||
720 | 23 | |||
721 | 24 | #define CHECK_TOUCH_DEVICE(touchId, item) \ | ||
722 | 25 | if (!touchDevicePresent()) { \ | ||
723 | 26 | qWarning() << QString(DEVICE_MISSING_MSG).arg(__FUNCTION__); \ | ||
724 | 27 | return; \ | ||
725 | 28 | } \ | ||
726 | 29 | if (touchId < 0) { \ | ||
727 | 30 | qWarning() << "Invalid touchId specified."; \ | ||
728 | 31 | return; \ | ||
729 | 32 | } \ | ||
730 | 33 | if (!item) { \ | ||
731 | 34 | qWarning() << "Invalid item specified."; \ | ||
732 | 35 | return; \ | ||
733 | 36 | } | ||
734 | 37 | |||
735 | 38 | QTouchDevice *UCTestExtras::m_touchDevice = 0; | ||
736 | 39 | |||
737 | 40 | /*! | ||
738 | 41 | * \qmltype TestExtras | ||
739 | 42 | * \instantiates UCTestExtras | ||
740 | 43 | * \inqmlmodule Ubuntu.Test 1.0 | ||
741 | 44 | * \ingroup ubuntu-test | ||
742 | 45 | * \brief Singleton type providing additional test functions. | ||
743 | 46 | * | ||
744 | 47 | * The component provides additional test functions like touch handling, registering | ||
745 | 48 | * touch device on non-touch screen enabled environment. | ||
746 | 49 | */ | ||
747 | 50 | |||
748 | 51 | UCTestExtras::UCTestExtras(QObject *parent) : | ||
749 | 52 | QObject(parent) | ||
750 | 53 | { | ||
751 | 54 | } | ||
752 | 55 | |||
753 | 56 | /*! | ||
754 | 57 | * \qmlmethod TestExtras::touchDevicePresent() | ||
755 | 58 | * Returns true if the system has a touch device registered. | ||
756 | 59 | */ | ||
757 | 60 | bool UCTestExtras::touchDevicePresent() | ||
758 | 61 | { | ||
759 | 62 | QList<const QTouchDevice*> touchDevices = QTouchDevice::devices(); | ||
760 | 63 | Q_FOREACH(const QTouchDevice *device, touchDevices) { | ||
761 | 64 | if (device->type() == QTouchDevice::TouchScreen) { | ||
762 | 65 | return true; | ||
763 | 66 | } | ||
764 | 67 | } | ||
765 | 68 | return false; | ||
766 | 69 | } | ||
767 | 70 | |||
768 | 71 | /*! | ||
769 | 72 | * \qmlmethod TestExtras::registerTouchDevice() | ||
770 | 73 | * Registers a touch device if there's none registered. Calling the function in | ||
771 | 74 | * touch enabled environment has no effect. The function must be called in initTestCase() | ||
772 | 75 | * in order to perform touch related tests. | ||
773 | 76 | */ | ||
774 | 77 | void UCTestExtras::registerTouchDevice() | ||
775 | 78 | { | ||
776 | 79 | // check if there is any touch device registered in the system | ||
777 | 80 | if (!m_touchDevice) { | ||
778 | 81 | QList<const QTouchDevice*> touchDevices = QTouchDevice::devices(); | ||
779 | 82 | Q_FOREACH(const QTouchDevice *device, touchDevices) { | ||
780 | 83 | if (device->type() == QTouchDevice::TouchScreen) { | ||
781 | 84 | m_touchDevice = const_cast<QTouchDevice*>(device); | ||
782 | 85 | break; | ||
783 | 86 | } | ||
784 | 87 | } | ||
785 | 88 | } | ||
786 | 89 | // if none, register one | ||
787 | 90 | if (!m_touchDevice) { | ||
788 | 91 | m_touchDevice = new QTouchDevice; | ||
789 | 92 | m_touchDevice->setType(QTouchDevice::TouchScreen); | ||
790 | 93 | QWindowSystemInterface::registerTouchDevice(m_touchDevice); | ||
791 | 94 | } | ||
792 | 95 | } | ||
793 | 96 | |||
794 | 97 | /*! | ||
795 | 98 | * \qmlmethod TestExtras::touchPress(touchId, item, point) | ||
796 | 99 | * The function triggers a touch press event for a given \a touchId on a specific | ||
797 | 100 | * \a item. The \a point contains the (x,y) coordinates of the event in \a item | ||
798 | 101 | * coordinates. | ||
799 | 102 | */ | ||
800 | 103 | void UCTestExtras::touchPress(int touchId, QQuickItem *item, const QPoint &point) | ||
801 | 104 | { | ||
802 | 105 | CHECK_TOUCH_DEVICE(touchId, item); | ||
803 | 106 | QTest::touchEvent(item->window(), m_touchDevice).press(touchId, item->mapToScene(point).toPoint(), item->window()); | ||
804 | 107 | } | ||
805 | 108 | /*! | ||
806 | 109 | * \qmlmethod TestExtras::touchRelease(touchId, item, point) | ||
807 | 110 | * The function produces a touch release event on a given \a touchId performed on | ||
808 | 111 | * \a item at a \a point. | ||
809 | 112 | */ | ||
810 | 113 | void UCTestExtras::touchRelease(int touchId, QQuickItem *item, const QPoint &point) | ||
811 | 114 | { | ||
812 | 115 | CHECK_TOUCH_DEVICE(touchId, item); | ||
813 | 116 | QTest::touchEvent(item->window(), m_touchDevice).release(touchId, item->mapToScene(point).toPoint(), item->window()); | ||
814 | 117 | } | ||
815 | 118 | /*! | ||
816 | 119 | * \qmlmethod TestExtras::touchClick(touchId, item, point) | ||
817 | 120 | * The function performs a pair of \l touchPress and \l touchRelease calls on the same | ||
818 | 121 | * point resulting in a click like event. | ||
819 | 122 | */ | ||
820 | 123 | void UCTestExtras::touchClick(int touchId, QQuickItem *item, const QPoint &point) | ||
821 | 124 | { | ||
822 | 125 | CHECK_TOUCH_DEVICE(touchId, item); | ||
823 | 126 | touchPress(touchId, item, point); | ||
824 | 127 | QTest::qWait(100); | ||
825 | 128 | touchRelease(touchId, item, point); | ||
826 | 129 | } | ||
827 | 130 | /*! | ||
828 | 131 | * \qmlmethod TestExtras::touchLongPress(touchId, item, point) | ||
829 | 132 | * The function produces a \l touchPress event with a timeout equivalent to the | ||
830 | 133 | * mouse \c pressAndHold timeout, after which the function returns. | ||
831 | 134 | */ | ||
832 | 135 | void UCTestExtras::touchLongPress(int touchId, QQuickItem *item, const QPoint &point) | ||
833 | 136 | { | ||
834 | 137 | CHECK_TOUCH_DEVICE(touchId, item); | ||
835 | 138 | touchPress(touchId, item, point); | ||
836 | 139 | // 800 miliseconds + 200 to let events processed | ||
837 | 140 | QTest::qWait(1000); | ||
838 | 141 | } | ||
839 | 142 | /*! | ||
840 | 143 | * \qmlmethod TestExtras::touchDoubleClick(touchId, item, point) | ||
841 | 144 | * The function performs two consecutive \l touchClick events with a slight delay | ||
842 | 145 | * in between each click event. | ||
843 | 146 | */ | ||
844 | 147 | void UCTestExtras::touchDoubleClick(int touchId, QQuickItem *item, const QPoint &point) | ||
845 | 148 | { | ||
846 | 149 | CHECK_TOUCH_DEVICE(touchId, item); | ||
847 | 150 | touchClick(touchId, item, point); | ||
848 | 151 | QTest::qWait(100); | ||
849 | 152 | touchClick(touchId, item, point); | ||
850 | 153 | } | ||
851 | 154 | /*! | ||
852 | 155 | * \qmlmethod TestExtras::touchMove(touchId, item, point) | ||
853 | 156 | * The function moves the touch point identified by the \a touchId to the destination | ||
854 | 157 | * \a point. The point is in \a item coordinates. The touch point identified by the | ||
855 | 158 | * \a touchId must be pressed before calling this function in order to produce the | ||
856 | 159 | * desired functionality. The event can be captured in a \c MultiPointTouchArea through | ||
857 | 160 | * \c updated() signal. | ||
858 | 161 | */ | ||
859 | 162 | void UCTestExtras::touchMove(int touchId, QQuickItem *item, const QPoint &point) | ||
860 | 163 | { | ||
861 | 164 | CHECK_TOUCH_DEVICE(touchId, item); | ||
862 | 165 | QTest::touchEvent(item->window(), m_touchDevice).move(touchId, item->mapToScene(point).toPoint(), item->window()); | ||
863 | 166 | } | ||
864 | 167 | /*! | ||
865 | 168 | * \qmlmethod TestExtras::touchDrag(touchId, item, from, delta, steps = 5) | ||
866 | 169 | * The function performs a drag gesture on a touch point identified by \a touchId | ||
867 | 170 | * over an \a item from the starting point \a from with a \a delta. The gesture | ||
868 | 171 | * is realized with a touch press, \a step moves and a release event. | ||
869 | 172 | * | ||
870 | 173 | * By default the function uses 5 steps to produce the gesture. This value can be any | ||
871 | 174 | * positive number, driving the gesture appliance to be faster (less than 5 moves) or | ||
872 | 175 | * slower (more than 5 moves). If a negative or 0 value is given, the function will | ||
873 | 176 | * use the default 5 steps to produce the gesture. | ||
874 | 177 | */ | ||
875 | 178 | void UCTestExtras::touchDrag(int touchId, QQuickItem *item, const QPoint &from, const QPoint &delta, int steps) | ||
876 | 179 | { | ||
877 | 180 | CHECK_TOUCH_DEVICE(touchId, item); | ||
878 | 181 | if (delta.isNull()) { | ||
879 | 182 | qWarning() << "delta point is invalid"; | ||
880 | 183 | return; | ||
881 | 184 | } | ||
882 | 185 | if (steps <= 0) { | ||
883 | 186 | steps = 5; | ||
884 | 187 | } | ||
885 | 188 | touchPress(touchId, item, from); | ||
886 | 189 | QTest::qWait(10); | ||
887 | 190 | touchMove(touchId, item, from); | ||
888 | 191 | QPoint movePoint(from); | ||
889 | 192 | qreal stepDx = delta.x() / steps; | ||
890 | 193 | qreal stepDy = delta.y() / steps; | ||
891 | 194 | if (!delta.isNull()) { | ||
892 | 195 | for (int i = 0; i < steps - 1; i++) { | ||
893 | 196 | QTest::qWait(10); | ||
894 | 197 | movePoint += QPoint(stepDx, stepDy); | ||
895 | 198 | touchMove(touchId, item, movePoint); | ||
896 | 199 | } | ||
897 | 200 | } | ||
898 | 201 | QTest::qWait(10); | ||
899 | 202 | touchRelease(touchId, item, from + delta); | ||
900 | 203 | } | ||
901 | 0 | 204 | ||
902 | === added file 'modules/Ubuntu/Test/plugin/uctestextras.h' | |||
903 | --- modules/Ubuntu/Test/plugin/uctestextras.h 1970-01-01 00:00:00 +0000 | |||
904 | +++ modules/Ubuntu/Test/plugin/uctestextras.h 2014-06-25 19:24:49 +0000 | |||
905 | @@ -0,0 +1,46 @@ | |||
906 | 1 | /* | ||
907 | 2 | * Copyright 2014 Canonical Ltd. | ||
908 | 3 | * | ||
909 | 4 | * This program is free software; you can redistribute it and/or modify | ||
910 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
911 | 6 | * the Free Software Foundation; version 3. | ||
912 | 7 | * | ||
913 | 8 | * This program is distributed in the hope that it will be useful, | ||
914 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
915 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
916 | 11 | * GNU Lesser General Public License for more details. | ||
917 | 12 | * | ||
918 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
919 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
920 | 15 | */ | ||
921 | 16 | |||
922 | 17 | #ifndef TESTEXTRAS_H | ||
923 | 18 | #define TESTEXTRAS_H | ||
924 | 19 | |||
925 | 20 | #include <QtCore/QObject> | ||
926 | 21 | |||
927 | 22 | class QQuickItem; | ||
928 | 23 | class QTouchDevice; | ||
929 | 24 | class UCTestExtras : public QObject | ||
930 | 25 | { | ||
931 | 26 | Q_OBJECT | ||
932 | 27 | Q_PROPERTY(bool touchPresent READ touchDevicePresent) | ||
933 | 28 | public: | ||
934 | 29 | explicit UCTestExtras(QObject *parent = 0); | ||
935 | 30 | |||
936 | 31 | static bool touchDevicePresent(); | ||
937 | 32 | public Q_SLOTS: | ||
938 | 33 | static void registerTouchDevice(); | ||
939 | 34 | static void touchPress(int touchId, QQuickItem *item, const QPoint &point); | ||
940 | 35 | static void touchRelease(int touchId, QQuickItem *item, const QPoint &point); | ||
941 | 36 | static void touchClick(int touchId, QQuickItem *item, const QPoint &point); | ||
942 | 37 | static void touchLongPress(int touchId, QQuickItem *item, const QPoint &point); | ||
943 | 38 | static void touchDoubleClick(int touchId, QQuickItem *item, const QPoint &point); | ||
944 | 39 | static void touchMove(int touchId, QQuickItem *item, const QPoint &point); | ||
945 | 40 | static void touchDrag(int touchId, QQuickItem *item, const QPoint &from, const QPoint &delta, int steps = 5); | ||
946 | 41 | |||
947 | 42 | private: | ||
948 | 43 | static QTouchDevice *m_touchDevice; | ||
949 | 44 | }; | ||
950 | 45 | |||
951 | 46 | #endif // TESTEXTRAS_H | ||
952 | 0 | 47 | ||
953 | === modified file 'modules/Ubuntu/Test/qmldir' | |||
954 | --- modules/Ubuntu/Test/qmldir 2014-04-20 19:25:12 +0000 | |||
955 | +++ modules/Ubuntu/Test/qmldir 2014-06-25 19:24:49 +0000 | |||
956 | @@ -1,4 +1,5 @@ | |||
957 | 1 | module Ubuntu.Test | 1 | module Ubuntu.Test |
958 | 2 | plugin UbuntuTest | ||
959 | 2 | UbuntuTestCase 0.1 UbuntuTestCase.qml | 3 | UbuntuTestCase 0.1 UbuntuTestCase.qml |
960 | 3 | 4 | ||
961 | 4 | #version 1.0 | 5 | #version 1.0 |
962 | 5 | 6 | ||
963 | === modified file 'tests/autopilot/ubuntuuitoolkit/fixture_setup.py' | |||
964 | --- tests/autopilot/ubuntuuitoolkit/fixture_setup.py 2014-05-26 06:40:24 +0000 | |||
965 | +++ tests/autopilot/ubuntuuitoolkit/fixture_setup.py 2014-06-25 19:24:49 +0000 | |||
966 | @@ -20,6 +20,7 @@ | |||
967 | 20 | import tempfile | 20 | import tempfile |
968 | 21 | 21 | ||
969 | 22 | import fixtures | 22 | import fixtures |
970 | 23 | from autopilot import display | ||
971 | 23 | 24 | ||
972 | 24 | from ubuntuuitoolkit import base, environment | 25 | from ubuntuuitoolkit import base, environment |
973 | 25 | 26 | ||
974 | @@ -29,7 +30,7 @@ | |||
975 | 29 | import Ubuntu.Components 1.1 | 30 | import Ubuntu.Components 1.1 |
976 | 30 | 31 | ||
977 | 31 | MainView { | 32 | MainView { |
979 | 32 | width: units.gu(48) | 33 | width: units.gu(80) |
980 | 33 | height: units.gu(60) | 34 | height: units.gu(60) |
981 | 34 | 35 | ||
982 | 35 | Label { | 36 | Label { |
983 | @@ -105,7 +106,6 @@ | |||
984 | 105 | super(InitctlEnvironmentVariable, self).__init__() | 106 | super(InitctlEnvironmentVariable, self).__init__() |
985 | 106 | self.variables = kwargs | 107 | self.variables = kwargs |
986 | 107 | 108 | ||
987 | 108 | def setUp(self): | ||
988 | 109 | super(InitctlEnvironmentVariable, self).setUp() | 109 | super(InitctlEnvironmentVariable, self).setUp() |
989 | 110 | for variable, value in self.variables.items(): | 110 | for variable, value in self.variables.items(): |
990 | 111 | self._add_variable_cleanup(variable) | 111 | self._add_variable_cleanup(variable) |
991 | @@ -163,3 +163,37 @@ | |||
992 | 163 | shutil.copyfile( | 163 | shutil.copyfile( |
993 | 164 | xauthority_file_path, | 164 | xauthority_file_path, |
994 | 165 | os.path.join(directory, '.Xauthority')) | 165 | os.path.join(directory, '.Xauthority')) |
995 | 166 | |||
996 | 167 | |||
997 | 168 | class SimulateDevice(fixtures.Fixture): | ||
998 | 169 | |||
999 | 170 | def __init__(self, app_width, app_height, grid_unit_px): | ||
1000 | 171 | super(SimulateDevice, self).__init__() | ||
1001 | 172 | self.app_width = app_width | ||
1002 | 173 | self.app_height = app_height | ||
1003 | 174 | self.grid_unit_px = grid_unit_px | ||
1004 | 175 | |||
1005 | 176 | def setUp(self): | ||
1006 | 177 | super(SimulateDevice, self).setUp() | ||
1007 | 178 | if self._is_geometry_larger_than_display( | ||
1008 | 179 | self.app_width, self.app_height): | ||
1009 | 180 | scale_divisor = self._get_scale_divisor() | ||
1010 | 181 | grid_unit_px = self.grid_unit_px // scale_divisor | ||
1011 | 182 | grid_unit_px = self.grid_unit_px | ||
1012 | 183 | self.useFixture( | ||
1013 | 184 | fixtures.EnvironmentVariable( | ||
1014 | 185 | 'GRID_UNIT_PX', str(grid_unit_px))) | ||
1015 | 186 | |||
1016 | 187 | def _is_geometry_larger_than_display(self, width, height): | ||
1017 | 188 | screen = display.Display.create() | ||
1018 | 189 | screen_width = screen.get_screen_width() | ||
1019 | 190 | screen_height = screen.get_screen_height() | ||
1020 | 191 | return (width > screen_width) or (height > screen_height) | ||
1021 | 192 | |||
1022 | 193 | def _get_scale_divisor(self): | ||
1023 | 194 | scale_divisor = 2 | ||
1024 | 195 | while self._is_geometry_larger_than_display( | ||
1025 | 196 | self.app_width // scale_divisor, | ||
1026 | 197 | self.app_height // scale_divisor): | ||
1027 | 198 | scale_divisor = scale_divisor * 2 | ||
1028 | 199 | return scale_divisor | ||
1029 | 166 | 200 | ||
1030 | === added file 'tests/autopilot/ubuntuuitoolkit/scenarios.py' | |||
1031 | --- tests/autopilot/ubuntuuitoolkit/scenarios.py 1970-01-01 00:00:00 +0000 | |||
1032 | +++ tests/autopilot/ubuntuuitoolkit/scenarios.py 2014-06-25 19:24:49 +0000 | |||
1033 | @@ -0,0 +1,45 @@ | |||
1034 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | ||
1035 | 2 | # | ||
1036 | 3 | # Copyright (C) 2014 Canonical Ltd. | ||
1037 | 4 | # | ||
1038 | 5 | # This program is free software; you can redistribute it and/or modify | ||
1039 | 6 | # it under the terms of the GNU Lesser General Public License as published by | ||
1040 | 7 | # the Free Software Foundation; version 3. | ||
1041 | 8 | # | ||
1042 | 9 | # This program is distributed in the hope that it will be useful, | ||
1043 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1044 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1045 | 12 | # GNU Lesser General Public License for more details. | ||
1046 | 13 | # | ||
1047 | 14 | # You should have received a copy of the GNU Lesser General Public License | ||
1048 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1049 | 16 | |||
1050 | 17 | |||
1051 | 18 | NEXUS4_DEVICE = 'Nexus4' | ||
1052 | 19 | NEXUS10_DEVICE = 'Nexus10' | ||
1053 | 20 | DEFAULT_DEVICES = (NEXUS4_DEVICE, NEXUS10_DEVICE) | ||
1054 | 21 | |||
1055 | 22 | |||
1056 | 23 | def get_device_simulation_scenarios(devices=DEFAULT_DEVICES): | ||
1057 | 24 | """Return a list of devices to be simulated on tests. | ||
1058 | 25 | |||
1059 | 26 | :param devices: The device or devices to simulate. Default value is all the | ||
1060 | 27 | officially supported devices. | ||
1061 | 28 | :type devices: string or sequence of strings. | ||
1062 | 29 | :return: A list of scenarios to be used with the testscenarios python | ||
1063 | 30 | module, with the values of app_width, app_height and grid_unit | ||
1064 | 31 | corresponding to the selected device. | ||
1065 | 32 | |||
1066 | 33 | """ | ||
1067 | 34 | scenarios = [] | ||
1068 | 35 | if NEXUS4_DEVICE in devices: | ||
1069 | 36 | scenarios.append( | ||
1070 | 37 | ('Simulating Nexus 4 in desktop', | ||
1071 | 38 | dict(app_width=768, app_height=1280, grid_unit_px=18)) | ||
1072 | 39 | ) | ||
1073 | 40 | if NEXUS10_DEVICE in devices: | ||
1074 | 41 | scenarios.append( | ||
1075 | 42 | ('Simulating Nexus 10 in desktop', | ||
1076 | 43 | dict(app_width=2560, app_height=1600, grid_unit_px=20)) | ||
1077 | 44 | ) | ||
1078 | 45 | return scenarios | ||
1079 | 0 | 46 | ||
1080 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py' | |||
1081 | --- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py 2014-05-30 08:21:45 +0000 | |||
1082 | +++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_flickable.py 2014-06-25 19:24:49 +0000 | |||
1083 | @@ -15,6 +15,7 @@ | |||
1084 | 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/>. |
1085 | 16 | 16 | ||
1086 | 17 | import os | 17 | import os |
1087 | 18 | import subprocess | ||
1088 | 18 | 19 | ||
1089 | 19 | import testtools | 20 | import testtools |
1090 | 20 | import ubuntuuitoolkit | 21 | import ubuntuuitoolkit |
1091 | @@ -206,8 +207,11 @@ | |||
1092 | 206 | if os.path.exists(path_to_local_launcher): | 207 | if os.path.exists(path_to_local_launcher): |
1093 | 207 | return path_to_local_launcher | 208 | return path_to_local_launcher |
1094 | 208 | else: | 209 | else: |
1095 | 210 | arch = subprocess.check_output( | ||
1096 | 211 | ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"], | ||
1097 | 212 | universal_newlines=True).strip() | ||
1098 | 209 | path_to_installed_launcher = os.path.join( | 213 | path_to_installed_launcher = os.path.join( |
1100 | 210 | '/', 'usr', 'lib', 'ubuntu-ui-toolkit', 'launcher') | 214 | '/', 'usr', 'lib', arch, 'ubuntu-ui-toolkit', 'launcher') |
1101 | 211 | return path_to_installed_launcher | 215 | return path_to_installed_launcher |
1102 | 212 | 216 | ||
1103 | 213 | def test_get_unity_top_container(self): | 217 | def test_get_unity_top_container(self): |
1104 | 214 | 218 | ||
1105 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py' | |||
1106 | --- tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py 2014-06-03 20:10:53 +0000 | |||
1107 | +++ tests/autopilot/ubuntuuitoolkit/tests/test_fixture_setup.py 2014-06-25 19:24:49 +0000 | |||
1108 | @@ -27,7 +27,7 @@ | |||
1109 | 27 | from autopilot import testcase as autopilot_testcase | 27 | from autopilot import testcase as autopilot_testcase |
1110 | 28 | from testtools.matchers import Contains, FileExists, Not | 28 | from testtools.matchers import Contains, FileExists, Not |
1111 | 29 | 29 | ||
1113 | 30 | from ubuntuuitoolkit import base, environment, fixture_setup | 30 | from ubuntuuitoolkit import base, environment, fixture_setup, scenarios |
1114 | 31 | 31 | ||
1115 | 32 | 32 | ||
1116 | 33 | class FakeApplicationTestCase(testtools.TestCase): | 33 | class FakeApplicationTestCase(testtools.TestCase): |
1117 | @@ -304,3 +304,25 @@ | |||
1118 | 304 | self.assertTrue( | 304 | self.assertTrue( |
1119 | 305 | os.path.exists( | 305 | os.path.exists( |
1120 | 306 | os.path.join(os.environ.get('HOME'), '.Xauthority'))) | 306 | os.path.join(os.environ.get('HOME'), '.Xauthority'))) |
1121 | 307 | |||
1122 | 308 | |||
1123 | 309 | class SimulateDeviceTestCase(autopilot_testcase.AutopilotTestCase): | ||
1124 | 310 | |||
1125 | 311 | scenarios = scenarios.get_device_simulation_scenarios() | ||
1126 | 312 | |||
1127 | 313 | def test(self): | ||
1128 | 314 | self.useFixture(fixture_setup.SimulateDevice( | ||
1129 | 315 | self.app_width, self.app_height, self.grid_unit_px)) | ||
1130 | 316 | |||
1131 | 317 | fake_application = fixture_setup.FakeApplication() | ||
1132 | 318 | self.useFixture(fake_application) | ||
1133 | 319 | |||
1134 | 320 | self.application = self.launch_test_application( | ||
1135 | 321 | base.get_qmlscene_launch_command(), | ||
1136 | 322 | fake_application.qml_file_path, | ||
1137 | 323 | '--desktop_file_hint={0}'.format( | ||
1138 | 324 | fake_application.desktop_file_path), | ||
1139 | 325 | app_type='qt') | ||
1140 | 326 | |||
1141 | 327 | # We can select a component from the application. | ||
1142 | 328 | self.application.select_single('Label', objectName='testLabel') | ||
1143 | 307 | 329 | ||
1144 | === added file 'tests/autopilot/ubuntuuitoolkit/tests/test_scenarios.py' | |||
1145 | --- tests/autopilot/ubuntuuitoolkit/tests/test_scenarios.py 1970-01-01 00:00:00 +0000 | |||
1146 | +++ tests/autopilot/ubuntuuitoolkit/tests/test_scenarios.py 2014-06-25 19:24:49 +0000 | |||
1147 | @@ -0,0 +1,50 @@ | |||
1148 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | ||
1149 | 2 | # | ||
1150 | 3 | # Copyright (C) 2014 Canonical Ltd. | ||
1151 | 4 | # | ||
1152 | 5 | # This program is free software; you can redistribute it and/or modify | ||
1153 | 6 | # it under the terms of the GNU Lesser General Public License as published by | ||
1154 | 7 | # the Free Software Foundation; version 3. | ||
1155 | 8 | # | ||
1156 | 9 | # This program is distributed in the hope that it will be useful, | ||
1157 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1158 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1159 | 12 | # GNU Lesser General Public License for more details. | ||
1160 | 13 | # | ||
1161 | 14 | # You should have received a copy of the GNU Lesser General Public License | ||
1162 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1163 | 16 | |||
1164 | 17 | import testtools | ||
1165 | 18 | |||
1166 | 19 | from ubuntuuitoolkit import scenarios | ||
1167 | 20 | |||
1168 | 21 | |||
1169 | 22 | class ScenariosTestCase(testtools.TestCase): | ||
1170 | 23 | |||
1171 | 24 | def test_get_nexus_4_scenario(self): | ||
1172 | 25 | expected_scenarios = [ | ||
1173 | 26 | ('Simulating Nexus 4 in desktop', | ||
1174 | 27 | dict(app_width=768, app_height=1280, grid_unit_px=18)), | ||
1175 | 28 | ] | ||
1176 | 29 | test_scenarios = scenarios.get_device_simulation_scenarios( | ||
1177 | 30 | devices=scenarios.NEXUS4_DEVICE) | ||
1178 | 31 | self.assertEqual(expected_scenarios, test_scenarios) | ||
1179 | 32 | |||
1180 | 33 | def test_get_nexus_10_scenario(self): | ||
1181 | 34 | expected_scenarios = [ | ||
1182 | 35 | ('Simulating Nexus 10 in desktop', | ||
1183 | 36 | dict(app_width=2560, app_height=1600, grid_unit_px=20)) | ||
1184 | 37 | ] | ||
1185 | 38 | test_scenarios = scenarios.get_device_simulation_scenarios( | ||
1186 | 39 | devices=scenarios.NEXUS10_DEVICE) | ||
1187 | 40 | self.assertEqual(expected_scenarios, test_scenarios) | ||
1188 | 41 | |||
1189 | 42 | def test_get_default_scenarios_must_return_supported_devices(self): | ||
1190 | 43 | expected_scenarios = [ | ||
1191 | 44 | ('Simulating Nexus 4 in desktop', | ||
1192 | 45 | dict(app_width=768, app_height=1280, grid_unit_px=18)), | ||
1193 | 46 | ('Simulating Nexus 10 in desktop', | ||
1194 | 47 | dict(app_width=2560, app_height=1600, grid_unit_px=20)) | ||
1195 | 48 | ] | ||
1196 | 49 | test_scenarios = scenarios.get_device_simulation_scenarios() | ||
1197 | 50 | self.assertEqual(expected_scenarios, test_scenarios) | ||
1198 | 0 | 51 | ||
1199 | === added file 'tests/launcher/MouseTouchAdaptor.cpp' | |||
1200 | --- tests/launcher/MouseTouchAdaptor.cpp 1970-01-01 00:00:00 +0000 | |||
1201 | +++ tests/launcher/MouseTouchAdaptor.cpp 2014-06-25 19:24:49 +0000 | |||
1202 | @@ -0,0 +1,159 @@ | |||
1203 | 1 | /* | ||
1204 | 2 | * Copyright 2014 Canonical Ltd. | ||
1205 | 3 | * | ||
1206 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1207 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1208 | 6 | * the Free Software Foundation; version 3. | ||
1209 | 7 | * | ||
1210 | 8 | * This program is distributed in the hope that it will be useful, | ||
1211 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1212 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1213 | 11 | * GNU Lesser General Public License for more details. | ||
1214 | 12 | * | ||
1215 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1216 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1217 | 15 | * | ||
1218 | 16 | * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com> | ||
1219 | 17 | * | ||
1220 | 18 | */ | ||
1221 | 19 | |||
1222 | 20 | #include "MouseTouchAdaptor.h" | ||
1223 | 21 | |||
1224 | 22 | #include <qpa/qwindowsysteminterface.h> | ||
1225 | 23 | |||
1226 | 24 | #include <QtGui/QMouseEvent> | ||
1227 | 25 | #include <QtTest/QTest> | ||
1228 | 26 | |||
1229 | 27 | using QTest::QTouchEventSequence; | ||
1230 | 28 | |||
1231 | 29 | namespace { | ||
1232 | 30 | Qt::MouseButton translateMouseButton(xcb_button_t detail) | ||
1233 | 31 | { | ||
1234 | 32 | switch (detail) { | ||
1235 | 33 | case 1: return Qt::LeftButton; | ||
1236 | 34 | case 2: return Qt::MidButton; | ||
1237 | 35 | case 3: return Qt::RightButton; | ||
1238 | 36 | // Button values 4-7 are Wheel events | ||
1239 | 37 | default: return Qt::NoButton; | ||
1240 | 38 | } | ||
1241 | 39 | } | ||
1242 | 40 | } // end of anonymous namespace | ||
1243 | 41 | |||
1244 | 42 | MouseTouchAdaptor::MouseTouchAdaptor() | ||
1245 | 43 | : m_leftButtonIsPressed(false) | ||
1246 | 44 | { | ||
1247 | 45 | m_touchDevice = new QTouchDevice; | ||
1248 | 46 | m_touchDevice->setType(QTouchDevice::TouchScreen); | ||
1249 | 47 | QWindowSystemInterface::registerTouchDevice(m_touchDevice); | ||
1250 | 48 | } | ||
1251 | 49 | |||
1252 | 50 | bool MouseTouchAdaptor::nativeEventFilter(const QByteArray & eventType, | ||
1253 | 51 | void * message, long * /*result*/) | ||
1254 | 52 | { | ||
1255 | 53 | if (eventType != "xcb_generic_event_t") { | ||
1256 | 54 | // wrong backend. | ||
1257 | 55 | qWarning("MouseTouchAdaptor: XCB backend not in use. Adaptor inoperative!"); | ||
1258 | 56 | return false; | ||
1259 | 57 | } | ||
1260 | 58 | |||
1261 | 59 | xcb_generic_event_t *xcbEvent = static_cast<xcb_generic_event_t *>(message); | ||
1262 | 60 | |||
1263 | 61 | switch (xcbEvent->response_type & ~0x80) { | ||
1264 | 62 | case XCB_BUTTON_PRESS: | ||
1265 | 63 | return handleButtonPress(reinterpret_cast<xcb_button_press_event_t *>(xcbEvent)); | ||
1266 | 64 | break; | ||
1267 | 65 | case XCB_BUTTON_RELEASE: | ||
1268 | 66 | return handleButtonRelease(reinterpret_cast<xcb_button_release_event_t *>(xcbEvent)); | ||
1269 | 67 | break; | ||
1270 | 68 | case XCB_MOTION_NOTIFY: | ||
1271 | 69 | return handleMotionNotify(reinterpret_cast<xcb_motion_notify_event_t *>(xcbEvent)); | ||
1272 | 70 | break; | ||
1273 | 71 | default: | ||
1274 | 72 | return false; | ||
1275 | 73 | break; | ||
1276 | 74 | }; | ||
1277 | 75 | } | ||
1278 | 76 | |||
1279 | 77 | bool MouseTouchAdaptor::handleButtonPress(xcb_button_press_event_t *pressEvent) | ||
1280 | 78 | { | ||
1281 | 79 | Qt::MouseButton button = translateMouseButton(pressEvent->detail); | ||
1282 | 80 | |||
1283 | 81 | // Skip the event if it wasn't a left mouse press | ||
1284 | 82 | if (button != Qt::LeftButton) { | ||
1285 | 83 | return false; | ||
1286 | 84 | } | ||
1287 | 85 | |||
1288 | 86 | QPoint windowPos(pressEvent->event_x, pressEvent->event_y); | ||
1289 | 87 | |||
1290 | 88 | QWindow *targetWindow = findQWindowWithXWindowID(static_cast<WId>(pressEvent->event)); | ||
1291 | 89 | |||
1292 | 90 | // no autoCommit | ||
1293 | 91 | QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice, false); | ||
1294 | 92 | touchEvent.press(0, windowPos); | ||
1295 | 93 | // do not process events when committed, let the events be processed with next event loop | ||
1296 | 94 | touchEvent.commit(false); | ||
1297 | 95 | |||
1298 | 96 | m_leftButtonIsPressed = true; | ||
1299 | 97 | return true; | ||
1300 | 98 | } | ||
1301 | 99 | |||
1302 | 100 | bool MouseTouchAdaptor::handleButtonRelease(xcb_button_release_event_t *releaseEvent) | ||
1303 | 101 | { | ||
1304 | 102 | Qt::MouseButton button = translateMouseButton(releaseEvent->detail); | ||
1305 | 103 | |||
1306 | 104 | // Skip the event if it wasn't a left mouse release | ||
1307 | 105 | if (button != Qt::LeftButton) { | ||
1308 | 106 | return false; | ||
1309 | 107 | } | ||
1310 | 108 | |||
1311 | 109 | QPoint windowPos(releaseEvent->event_x, releaseEvent->event_y); | ||
1312 | 110 | |||
1313 | 111 | QWindow *targetWindow = findQWindowWithXWindowID(static_cast<WId>(releaseEvent->event)); | ||
1314 | 112 | |||
1315 | 113 | // no autoCommit | ||
1316 | 114 | QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice, false); | ||
1317 | 115 | touchEvent.release(0, windowPos); | ||
1318 | 116 | // do not process events when committed, let the events be processed with next event loop | ||
1319 | 117 | touchEvent.commit(false); | ||
1320 | 118 | |||
1321 | 119 | m_leftButtonIsPressed = false; | ||
1322 | 120 | return true; | ||
1323 | 121 | } | ||
1324 | 122 | |||
1325 | 123 | bool MouseTouchAdaptor::handleMotionNotify(xcb_motion_notify_event_t *event) | ||
1326 | 124 | { | ||
1327 | 125 | if (!m_leftButtonIsPressed) { | ||
1328 | 126 | return false; | ||
1329 | 127 | } | ||
1330 | 128 | |||
1331 | 129 | QPoint windowPos(event->event_x, event->event_y); | ||
1332 | 130 | |||
1333 | 131 | QWindow *targetWindow = findQWindowWithXWindowID(static_cast<WId>(event->event)); | ||
1334 | 132 | |||
1335 | 133 | // no autoCommit | ||
1336 | 134 | QTouchEventSequence touchEvent = QTest::touchEvent(targetWindow, m_touchDevice, false); | ||
1337 | 135 | touchEvent.move(0, windowPos); | ||
1338 | 136 | // do not process events when committed, let the events be processed with next event loop | ||
1339 | 137 | touchEvent.commit(false); | ||
1340 | 138 | |||
1341 | 139 | return true; | ||
1342 | 140 | } | ||
1343 | 141 | |||
1344 | 142 | QWindow *MouseTouchAdaptor::findQWindowWithXWindowID(WId windowId) | ||
1345 | 143 | { | ||
1346 | 144 | QWindowList windowList = QGuiApplication::topLevelWindows(); | ||
1347 | 145 | QWindow *foundWindow = 0; | ||
1348 | 146 | |||
1349 | 147 | int i = 0; | ||
1350 | 148 | while (!foundWindow && i < windowList.count()) { | ||
1351 | 149 | QWindow *window = windowList[i]; | ||
1352 | 150 | if (window->winId() == windowId) { | ||
1353 | 151 | foundWindow = window; | ||
1354 | 152 | } else { | ||
1355 | 153 | ++i; | ||
1356 | 154 | } | ||
1357 | 155 | } | ||
1358 | 156 | |||
1359 | 157 | Q_ASSERT(foundWindow); | ||
1360 | 158 | return foundWindow; | ||
1361 | 159 | } | ||
1362 | 0 | 160 | ||
1363 | === added file 'tests/launcher/MouseTouchAdaptor.h' | |||
1364 | --- tests/launcher/MouseTouchAdaptor.h 1970-01-01 00:00:00 +0000 | |||
1365 | +++ tests/launcher/MouseTouchAdaptor.h 2014-06-25 19:24:49 +0000 | |||
1366 | @@ -0,0 +1,50 @@ | |||
1367 | 1 | /* | ||
1368 | 2 | * Copyright 2014 Canonical Ltd. | ||
1369 | 3 | * | ||
1370 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1371 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1372 | 6 | * the Free Software Foundation; version 3. | ||
1373 | 7 | * | ||
1374 | 8 | * This program is distributed in the hope that it will be useful, | ||
1375 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1376 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1377 | 11 | * GNU Lesser General Public License for more details. | ||
1378 | 12 | * | ||
1379 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1380 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1381 | 15 | * | ||
1382 | 16 | * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com> | ||
1383 | 17 | * | ||
1384 | 18 | */ | ||
1385 | 19 | |||
1386 | 20 | #ifndef MOUSE_TOUCH_ADAPTOR_H | ||
1387 | 21 | #define MOUSE_TOUCH_ADAPTOR_H | ||
1388 | 22 | |||
1389 | 23 | #include <QtCore/QAbstractNativeEventFilter> | ||
1390 | 24 | #include <QWindow> | ||
1391 | 25 | #include <xcb/xcb.h> | ||
1392 | 26 | |||
1393 | 27 | class QMouseEvent; | ||
1394 | 28 | class QTouchDevice; | ||
1395 | 29 | |||
1396 | 30 | // Transforms QMouseEvents into single-finger QTouchEvents. | ||
1397 | 31 | class MouseTouchAdaptor : public QAbstractNativeEventFilter { | ||
1398 | 32 | |||
1399 | 33 | public: | ||
1400 | 34 | MouseTouchAdaptor(); | ||
1401 | 35 | |||
1402 | 36 | // Filters mouse events and posts the equivalent QTouchEvents. | ||
1403 | 37 | virtual bool nativeEventFilter(const QByteArray & eventType, void *message, long *result); | ||
1404 | 38 | |||
1405 | 39 | private: | ||
1406 | 40 | |||
1407 | 41 | bool handleButtonPress(xcb_button_press_event_t *pressEvent); | ||
1408 | 42 | bool handleButtonRelease(xcb_button_release_event_t *releaseEvent); | ||
1409 | 43 | bool handleMotionNotify(xcb_motion_notify_event_t *event); | ||
1410 | 44 | QWindow *findQWindowWithXWindowID(WId windowId); | ||
1411 | 45 | |||
1412 | 46 | QTouchDevice *m_touchDevice; | ||
1413 | 47 | bool m_leftButtonIsPressed; | ||
1414 | 48 | }; | ||
1415 | 49 | |||
1416 | 50 | #endif // MOUSE_TOUCH_ADAPTOR_H | ||
1417 | 0 | 51 | ||
1418 | === modified file 'tests/launcher/launcher.cpp' | |||
1419 | --- tests/launcher/launcher.cpp 2014-06-09 08:26:24 +0000 | |||
1420 | +++ tests/launcher/launcher.cpp 2014-06-25 19:24:49 +0000 | |||
1421 | @@ -30,16 +30,18 @@ | |||
1422 | 30 | #include <QOpenGLContext> | 30 | #include <QOpenGLContext> |
1423 | 31 | #include <QtGui/private/qopenglcontext_p.h> | 31 | #include <QtGui/private/qopenglcontext_p.h> |
1424 | 32 | #include <QtQuick/private/qsgcontext_p.h> | 32 | #include <QtQuick/private/qsgcontext_p.h> |
1425 | 33 | #include <QtCore/QCommandLineParser> | ||
1426 | 34 | #include <QtCore/QCommandLineOption> | ||
1427 | 35 | #include "MouseTouchAdaptor.h" | ||
1428 | 36 | #include <QtGui/QTouchDevice> | ||
1429 | 33 | 37 | ||
1431 | 34 | int usage() | 38 | bool touchDevicePresent() |
1432 | 35 | { | 39 | { |
1440 | 36 | QString self(QGuiApplication::instance()->arguments().at(0)); | 40 | Q_FOREACH(const QTouchDevice *device, QTouchDevice::devices()) { |
1441 | 37 | std::cout << "Usage\n " | 41 | if (device->type() == QTouchDevice::TouchScreen) |
1442 | 38 | << qPrintable(self) | 42 | return true; |
1443 | 39 | << " -testability -frameless -engine" | 43 | } |
1444 | 40 | << " --desktop_file_path=DESKTOP_FILE" | 44 | return false; |
1438 | 41 | << " -I MODULE_PATH FILENAME\n"; | ||
1439 | 42 | return 1; | ||
1445 | 43 | } | 45 | } |
1446 | 44 | 46 | ||
1447 | 45 | int main(int argc, const char *argv[]) | 47 | int main(int argc, const char *argv[]) |
1448 | @@ -58,25 +60,40 @@ | |||
1449 | 58 | #endif | 60 | #endif |
1450 | 59 | QGuiApplication::setApplicationName("UITK Launcher"); | 61 | QGuiApplication::setApplicationName("UITK Launcher"); |
1451 | 60 | QGuiApplication application(argc, (char**)argv); | 62 | QGuiApplication application(argc, (char**)argv); |
1467 | 61 | QStringList args (application.arguments()); | 63 | |
1468 | 62 | 64 | QCommandLineParser args; | |
1469 | 63 | int _testability(args.indexOf("-testability")); | 65 | QCommandLineOption _import("I", "Add <path> to the list of import paths", "path"); |
1470 | 64 | args.removeAt(_testability); | 66 | QCommandLineOption _enableTouch("touch", "Enables mouse to touch conversion on desktop"); |
1471 | 65 | int _frameless(args.indexOf("-frameless")); | 67 | QCommandLineOption _testability("testability", "Loads the testability driver"); |
1472 | 66 | args.removeAt(_frameless); | 68 | QCommandLineOption _frameless("frameless", "Run without borders"); |
1473 | 67 | int _engine(args.indexOf("-engine")); | 69 | QCommandLineOption _engine("engine", "Use quick engine from quick view"); |
1474 | 68 | args.removeAt(_engine); | 70 | QCommandLineOption _desktop_file_hint("desktop_file_hint", "Desktop file - ignored", "desktop_file"); |
1475 | 69 | 71 | ||
1476 | 70 | Q_FOREACH(QString arg, args) { | 72 | args.addOption(_import); |
1477 | 71 | if (arg.startsWith("--desktop_file_hint")) { | 73 | args.addOption(_enableTouch); |
1478 | 72 | // This will not be used - it only needs to be ignored | 74 | args.addOption(_testability); |
1479 | 73 | int _desktop_file_hint(args.indexOf(arg)); | 75 | args.addOption(_frameless); |
1480 | 74 | args.removeAt(_desktop_file_hint); | 76 | args.addOption(_engine); |
1481 | 75 | } | 77 | args.addOption(_desktop_file_hint); |
1482 | 78 | args.addPositionalArgument("filename", "Document to be viewed"); | ||
1483 | 79 | args.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); | ||
1484 | 80 | args.addHelpOption(); | ||
1485 | 81 | if (!args.parse(application.arguments())) { | ||
1486 | 82 | qWarning() << args.errorText(); | ||
1487 | 83 | args.showHelp(1); | ||
1488 | 84 | } | ||
1489 | 85 | |||
1490 | 86 | QString filename; | ||
1491 | 87 | if (args.positionalArguments().count() > 0) { | ||
1492 | 88 | filename = args.positionalArguments()[0]; | ||
1493 | 89 | } | ||
1494 | 90 | if (filename.isEmpty()) { | ||
1495 | 91 | // show usage and exit | ||
1496 | 92 | args.showHelp(1); | ||
1497 | 76 | } | 93 | } |
1498 | 77 | 94 | ||
1499 | 78 | // Testability is only supported out of the box by QApplication not QGuiApplication | 95 | // Testability is only supported out of the box by QApplication not QGuiApplication |
1501 | 79 | if (_testability > -1 || getenv("QT_LOAD_TESTABILITY")) { | 96 | if (args.isSet(_testability) || getenv("QT_LOAD_TESTABILITY")) { |
1502 | 80 | QLibrary testLib(QLatin1String("qttestability")); | 97 | QLibrary testLib(QLatin1String("qttestability")); |
1503 | 81 | if (testLib.load()) { | 98 | if (testLib.load()) { |
1504 | 82 | typedef void (*TasInitialize)(void); | 99 | typedef void (*TasInitialize)(void); |
1505 | @@ -96,7 +113,7 @@ | |||
1506 | 96 | QQmlEngine* engine; | 113 | QQmlEngine* engine; |
1507 | 97 | // The default constructor affects the components tree (autopilot vis) | 114 | // The default constructor affects the components tree (autopilot vis) |
1508 | 98 | QQuickView* view; | 115 | QQuickView* view; |
1510 | 99 | if (_engine > -1) { | 116 | if (args.isSet(_engine)) { |
1511 | 100 | view = new QQuickView(); | 117 | view = new QQuickView(); |
1512 | 101 | engine = view->engine(); | 118 | engine = view->engine(); |
1513 | 102 | } else { | 119 | } else { |
1514 | @@ -104,43 +121,31 @@ | |||
1515 | 104 | view = new QQuickView(engine, NULL); | 121 | view = new QQuickView(engine, NULL); |
1516 | 105 | } | 122 | } |
1517 | 106 | 123 | ||
1525 | 107 | int _import(args.indexOf("-I")); | 124 | if (args.isSet(_import)) { |
1526 | 108 | args.removeAt(_import); | 125 | QStringList paths = args.values(_import); |
1527 | 109 | if (_import > -1) { | 126 | Q_FOREACH(const QString &path, paths) { |
1528 | 110 | if (args.count() > _import) { | 127 | engine->addImportPath(path); |
1522 | 111 | QString importPath(args.at(_import)); | ||
1523 | 112 | args.removeAt(_import); | ||
1524 | 113 | engine->addImportPath(importPath); | ||
1529 | 114 | } | 128 | } |
1530 | 115 | } | 129 | } |
1531 | 116 | 130 | ||
1532 | 117 | view->setResizeMode(QQuickView::SizeRootObjectToView); | 131 | view->setResizeMode(QQuickView::SizeRootObjectToView); |
1533 | 118 | view->setTitle("UI Toolkit QQuickView"); | 132 | view->setTitle("UI Toolkit QQuickView"); |
1535 | 119 | if (_frameless > -1) { | 133 | if (args.isSet(_frameless)) { |
1536 | 120 | view->setFlags(Qt::FramelessWindowHint); | 134 | view->setFlags(Qt::FramelessWindowHint); |
1537 | 121 | } | 135 | } |
1538 | 122 | 136 | ||
1543 | 123 | // The remaining unnamed argument must be a filename | 137 | if (args.isSet(_enableTouch) && !touchDevicePresent()) { |
1544 | 124 | if (args.count() == 1) { | 138 | // has no effect if we have touch screen |
1545 | 125 | qCritical() << "Missing filename"; | 139 | application.installNativeEventFilter(new MouseTouchAdaptor); |
1542 | 126 | return usage(); | ||
1546 | 127 | } | 140 | } |
1547 | 128 | QString filename(args.at(1)); | ||
1548 | 129 | // The first argument is the launcher itself | ||
1549 | 130 | args.removeAt(0); | ||
1550 | 131 | 141 | ||
1551 | 132 | QUrl source(QUrl::fromLocalFile(filename)); | 142 | QUrl source(QUrl::fromLocalFile(filename)); |
1552 | 133 | view->setSource(source); | 143 | view->setSource(source); |
1553 | 134 | if (view->errors().count() > 0) { | 144 | if (view->errors().count() > 0) { |
1555 | 135 | return usage(); | 145 | args.showHelp(3); |
1556 | 136 | } | 146 | } |
1557 | 137 | view->show(); | 147 | view->show(); |
1558 | 138 | 148 | ||
1559 | 139 | if (args.count() > 1) { | ||
1560 | 140 | qCritical() << "Invalid arguments passed" << args; | ||
1561 | 141 | return usage(); | ||
1562 | 142 | } | ||
1563 | 143 | |||
1564 | 144 | return application.exec(); | 149 | return application.exec(); |
1565 | 145 | } | 150 | } |
1566 | 146 | 151 | ||
1567 | 147 | 152 | ||
1568 | === modified file 'tests/launcher/launcher.pro' | |||
1569 | --- tests/launcher/launcher.pro 2014-05-14 11:00:20 +0000 | |||
1570 | +++ tests/launcher/launcher.pro 2014-06-25 19:24:49 +0000 | |||
1571 | @@ -1,11 +1,13 @@ | |||
1572 | 1 | TEMPLATE = app | 1 | TEMPLATE = app |
1573 | 2 | QT += qml quick | 2 | QT += qml quick |
1574 | 3 | # For setSharedOpenGLContext | 3 | # For setSharedOpenGLContext |
1576 | 4 | QT += core-private gui-private quick-private | 4 | QT += core-private gui-private testlib quick-private |
1577 | 5 | CONFIG += no_keywords | 5 | CONFIG += no_keywords |
1581 | 6 | SOURCES += \ | 6 | HEADERS += MouseTouchAdaptor.h |
1582 | 7 | launcher.cpp | 7 | SOURCES += launcher.cpp \ |
1583 | 8 | launcher.path = /usr/lib/ubuntu-ui-toolkit | 8 | MouseTouchAdaptor.cpp |
1584 | 9 | installPath = $$[QT_INSTALL_LIBS]/ubuntu-ui-toolkit | ||
1585 | 10 | launcher.path = $$installPath | ||
1586 | 9 | launcher.files = launcher | 11 | launcher.files = launcher |
1587 | 10 | INSTALLS += launcher | 12 | INSTALLS += launcher |
1588 | 11 | 13 | ||
1589 | 12 | 14 | ||
1590 | === modified file 'tests/qmlapicheck.sh' | |||
1591 | --- tests/qmlapicheck.sh 2014-04-23 13:45:41 +0000 | |||
1592 | +++ tests/qmlapicheck.sh 2014-06-25 19:24:49 +0000 | |||
1593 | @@ -16,7 +16,7 @@ | |||
1594 | 16 | # | 16 | # |
1595 | 17 | ################################################################################ | 17 | ################################################################################ |
1596 | 18 | QML="modules/Ubuntu/*/qmldir modules/Ubuntu/Components/Colors/UbuntuColors.qml modules/Ubuntu/Components/*/qmldir modules/Ubuntu/Components/Pickers/PickerPanel.qml" | 18 | QML="modules/Ubuntu/*/qmldir modules/Ubuntu/Components/Colors/UbuntuColors.qml modules/Ubuntu/Components/*/qmldir modules/Ubuntu/Components/Pickers/PickerPanel.qml" |
1598 | 19 | CPP="Ubuntu.Components Ubuntu.Layouts Ubuntu.PerformanceMetrics" | 19 | CPP="Ubuntu.Components Ubuntu.Layouts Ubuntu.PerformanceMetrics Ubuntu.Test" |
1599 | 20 | 20 | ||
1600 | 21 | echo Dumping QML API of C++ components | 21 | echo Dumping QML API of C++ components |
1601 | 22 | echo '' > plugins.qmltypes | 22 | echo '' > plugins.qmltypes |
1602 | 23 | 23 | ||
1603 | === modified file 'tests/unit/tst_components/tst_label.qml' | |||
1604 | --- tests/unit/tst_components/tst_label.qml 2014-05-26 10:13:41 +0000 | |||
1605 | +++ tests/unit/tst_components/tst_label.qml 2014-06-25 19:24:49 +0000 | |||
1606 | @@ -21,6 +21,11 @@ | |||
1607 | 21 | TestCase { | 21 | TestCase { |
1608 | 22 | name: "LabelAPI" | 22 | name: "LabelAPI" |
1609 | 23 | 23 | ||
1610 | 24 | function test_0_defaults() { | ||
1611 | 25 | compare(textCustom.font.family, "Ubuntu", "Default font family"); | ||
1612 | 26 | compare(textCustom.font.weight, Font.Light, "Default font weight"); | ||
1613 | 27 | } | ||
1614 | 28 | |||
1615 | 24 | function test_fontSize() { | 29 | function test_fontSize() { |
1616 | 25 | compare(textCustom.fontSize,"medium","fontSize is 'medium' by default") | 30 | compare(textCustom.fontSize,"medium","fontSize is 'medium' by default") |
1617 | 26 | 31 | ||
1618 | 27 | 32 | ||
1619 | === modified file 'tests/unit_x11/tst_components/tst_textarea.qml' | |||
1620 | --- tests/unit_x11/tst_components/tst_textarea.qml 2014-06-10 14:22:42 +0000 | |||
1621 | +++ tests/unit_x11/tst_components/tst_textarea.qml 2014-06-25 19:24:49 +0000 | |||
1622 | @@ -705,6 +705,7 @@ | |||
1623 | 705 | } | 705 | } |
1624 | 706 | 706 | ||
1625 | 707 | function test_clear_selection_by_click_beside_selection() { | 707 | function test_clear_selection_by_click_beside_selection() { |
1626 | 708 | skip("The test fails and will be overruled by future UX."); | ||
1627 | 708 | longText.focus = true; | 709 | longText.focus = true; |
1628 | 709 | var handler = findChild(longText, "input_handler"); | 710 | var handler = findChild(longText, "input_handler"); |
1629 | 710 | var y = longText.height / 2; | 711 | var y = longText.height / 2; |
1630 | 711 | 712 | ||
1631 | === modified file 'tests/unit_x11/tst_inversemousearea/tst_inversemouseareatest.cpp' | |||
1632 | --- tests/unit_x11/tst_inversemousearea/tst_inversemouseareatest.cpp 2014-06-11 11:24:39 +0000 | |||
1633 | +++ tests/unit_x11/tst_inversemousearea/tst_inversemouseareatest.cpp 2014-06-25 19:24:49 +0000 | |||
1634 | @@ -22,7 +22,7 @@ | |||
1635 | 22 | #include <QtQuick/QQuickItem> | 22 | #include <QtQuick/QQuickItem> |
1636 | 23 | #include <QtCore/QEvent> | 23 | #include <QtCore/QEvent> |
1637 | 24 | 24 | ||
1639 | 25 | #include "uctestcase.h" | 25 | #include "uctestextras.h" |
1640 | 26 | #include "inversemouseareatype.h" | 26 | #include "inversemouseareatype.h" |
1641 | 27 | #include "ucunits.h" | 27 | #include "ucunits.h" |
1642 | 28 | #include <private/qquickevents_p_p.h> | 28 | #include <private/qquickevents_p_p.h> |
1643 | @@ -89,7 +89,7 @@ | |||
1644 | 89 | void initTestCase() | 89 | void initTestCase() |
1645 | 90 | { | 90 | { |
1646 | 91 | // make sure we have a touch device installed | 91 | // make sure we have a touch device installed |
1648 | 92 | UbuntuTestCase::registerTouchDevice(); | 92 | UCTestExtras::registerTouchDevice(); |
1649 | 93 | QString modules("../../../modules"); | 93 | QString modules("../../../modules"); |
1650 | 94 | QVERIFY(QDir(modules).exists()); | 94 | QVERIFY(QDir(modules).exists()); |
1651 | 95 | 95 | ||
1652 | @@ -513,7 +513,7 @@ | |||
1653 | 513 | QCOMPARE(imaSpy.count(), 1); | 513 | QCOMPARE(imaSpy.count(), 1); |
1654 | 514 | 514 | ||
1655 | 515 | imaSpy.clear(); | 515 | imaSpy.clear(); |
1657 | 516 | UbuntuTestCase::touchClick(0, quickView, guPoint(20, 5)); | 516 | UCTestExtras::touchClick(0, quickView->rootObject(), guPoint(20, 5)); |
1658 | 517 | QCOMPARE(imaSpy.count(), 1); | 517 | QCOMPARE(imaSpy.count(), 1); |
1659 | 518 | } | 518 | } |
1660 | 519 | 519 | ||
1661 | 520 | 520 | ||
1662 | === modified file 'tests/unit_x11/tst_test/tst_ubuntutestcase.qml' | |||
1663 | --- tests/unit_x11/tst_test/tst_ubuntutestcase.qml 2014-04-20 19:25:12 +0000 | |||
1664 | +++ tests/unit_x11/tst_test/tst_ubuntutestcase.qml 2014-06-25 19:24:49 +0000 | |||
1665 | @@ -25,11 +25,19 @@ | |||
1666 | 25 | 25 | ||
1667 | 26 | Column { | 26 | Column { |
1668 | 27 | anchors.fill: parent | 27 | anchors.fill: parent |
1669 | 28 | MultiPointTouchArea { | ||
1670 | 29 | id: topTouchArea | ||
1671 | 30 | width: parent.width | ||
1672 | 31 | height: 100 | ||
1673 | 32 | touchPoints: TouchPoint { | ||
1674 | 33 | // id: point | ||
1675 | 34 | } | ||
1676 | 35 | } | ||
1677 | 28 | MouseArea { | 36 | MouseArea { |
1678 | 29 | id: mouseArea | 37 | id: mouseArea |
1679 | 30 | objectName: "myMouseArea" | 38 | objectName: "myMouseArea" |
1680 | 31 | width: parent.width | 39 | width: parent.width |
1682 | 32 | height: 300 | 40 | height: 200 |
1683 | 33 | hoverEnabled: true | 41 | hoverEnabled: true |
1684 | 34 | acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton | 42 | acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton |
1685 | 35 | property int testX : 0 | 43 | property int testX : 0 |
1686 | @@ -42,6 +50,15 @@ | |||
1687 | 42 | steps++; | 50 | steps++; |
1688 | 43 | } | 51 | } |
1689 | 44 | } | 52 | } |
1690 | 53 | MultiPointTouchArea { | ||
1691 | 54 | id: touchArea | ||
1692 | 55 | width: parent.width | ||
1693 | 56 | height: 100 | ||
1694 | 57 | touchPoints: TouchPoint { | ||
1695 | 58 | id: point | ||
1696 | 59 | } | ||
1697 | 60 | } | ||
1698 | 61 | |||
1699 | 45 | Flickable { | 62 | Flickable { |
1700 | 46 | id: flicker | 63 | id: flicker |
1701 | 47 | width: parent.width | 64 | width: parent.width |
1702 | @@ -62,18 +79,28 @@ | |||
1703 | 62 | name: "TestTheUbuntuTestCase" | 79 | name: "TestTheUbuntuTestCase" |
1704 | 63 | when: windowShown | 80 | when: windowShown |
1705 | 64 | 81 | ||
1706 | 82 | function initTestCase() { | ||
1707 | 83 | TestExtras.registerTouchDevice(); | ||
1708 | 84 | } | ||
1709 | 85 | |||
1710 | 65 | function init() { | 86 | function init() { |
1711 | 66 | mouseArea.steps = 0; | 87 | mouseArea.steps = 0; |
1712 | 67 | } | 88 | } |
1713 | 68 | function cleanup() { | 89 | function cleanup() { |
1714 | 69 | movementSpy.clear(); | 90 | movementSpy.clear(); |
1715 | 70 | longPressSpy.clear(); | 91 | longPressSpy.clear(); |
1716 | 92 | touchPressSpy.clear(); | ||
1717 | 93 | touchReleaseSpy.clear(); | ||
1718 | 94 | touchUpdateSpy.clear(); | ||
1719 | 95 | touchPressSpy.target = null; | ||
1720 | 96 | touchReleaseSpy.target = null; | ||
1721 | 97 | touchUpdateSpy.target = null; | ||
1722 | 71 | } | 98 | } |
1723 | 72 | 99 | ||
1724 | 73 | function test_mouseMoveSlowly() { | 100 | function test_mouseMoveSlowly() { |
1726 | 74 | mouseMoveSlowly(root,0,0,800,300,10,100); | 101 | mouseMoveSlowly(mouseArea,0,0,800,200,10,100); |
1727 | 75 | compare(mouseArea.testX,800); | 102 | compare(mouseArea.testX,800); |
1729 | 76 | compare(mouseArea.testY,300); | 103 | compare(mouseArea.testY,200); |
1730 | 77 | compare(mouseArea.steps,10); | 104 | compare(mouseArea.steps,10); |
1731 | 78 | } | 105 | } |
1732 | 79 | 106 | ||
1733 | @@ -146,5 +173,129 @@ | |||
1734 | 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); |
1735 | 147 | movementSpy.wait(); | 174 | movementSpy.wait(); |
1736 | 148 | } | 175 | } |
1737 | 176 | |||
1738 | 177 | SignalSpy { | ||
1739 | 178 | id: touchPressSpy | ||
1740 | 179 | signalName: "onPressed" | ||
1741 | 180 | target: touchArea | ||
1742 | 181 | } | ||
1743 | 182 | SignalSpy { | ||
1744 | 183 | id: touchReleaseSpy | ||
1745 | 184 | signalName: "onReleased" | ||
1746 | 185 | target: touchArea | ||
1747 | 186 | } | ||
1748 | 187 | SignalSpy { | ||
1749 | 188 | id: touchUpdateSpy | ||
1750 | 189 | signalName: "onUpdated" | ||
1751 | 190 | target: touchArea | ||
1752 | 191 | } | ||
1753 | 192 | |||
1754 | 193 | function test_has_property() { | ||
1755 | 194 | verify(TestExtras.hasOwnProperty("touchPresent"), "touchPresent property missing"); | ||
1756 | 195 | } | ||
1757 | 196 | |||
1758 | 197 | function test_touchPress_data() { | ||
1759 | 198 | return [ | ||
1760 | 199 | {touch: touchArea}, | ||
1761 | 200 | {touch: topTouchArea} | ||
1762 | 201 | ]; | ||
1763 | 202 | } | ||
1764 | 203 | function test_touchPress(data) { | ||
1765 | 204 | touchPressSpy.target = data.touch; | ||
1766 | 205 | TestExtras.touchPress(0, data.touch, Qt.point(10, 10)); | ||
1767 | 206 | touchPressSpy.wait(); | ||
1768 | 207 | // cleanup | ||
1769 | 208 | TestExtras.touchRelease(0, data.touch, Qt.point(10, 10)); | ||
1770 | 209 | } | ||
1771 | 210 | |||
1772 | 211 | function test_touchRelease_data() { | ||
1773 | 212 | return [ | ||
1774 | 213 | {touch: touchArea}, | ||
1775 | 214 | {touch: topTouchArea} | ||
1776 | 215 | ]; | ||
1777 | 216 | } | ||
1778 | 217 | function test_touchRelease(data) { | ||
1779 | 218 | // prerequisite: do a press so we get a release | ||
1780 | 219 | TestExtras.touchPress(0, data.touch, Qt.point(10, 10)); | ||
1781 | 220 | |||
1782 | 221 | touchReleaseSpy.target = data.touch; | ||
1783 | 222 | TestExtras.touchRelease(0, data.touch, Qt.point(10, 10)); | ||
1784 | 223 | touchReleaseSpy.wait(); | ||
1785 | 224 | } | ||
1786 | 225 | |||
1787 | 226 | function test_touchClick_data() { | ||
1788 | 227 | return [ | ||
1789 | 228 | {touch: touchArea}, | ||
1790 | 229 | {touch: topTouchArea} | ||
1791 | 230 | ]; | ||
1792 | 231 | } | ||
1793 | 232 | function test_touchClick(data) { | ||
1794 | 233 | touchPressSpy.target = data.touch; | ||
1795 | 234 | touchReleaseSpy.target = data.touch; | ||
1796 | 235 | TestExtras.touchClick(0, data.touch, Qt.point(10, 10)); | ||
1797 | 236 | touchReleaseSpy.wait(); | ||
1798 | 237 | compare(touchPressSpy.count, 1, "Not pressed?"); | ||
1799 | 238 | compare(touchReleaseSpy.count, 1, "Not released?"); | ||
1800 | 239 | } | ||
1801 | 240 | |||
1802 | 241 | function test_touchDoubleClick_data() { | ||
1803 | 242 | return [ | ||
1804 | 243 | {touch: touchArea}, | ||
1805 | 244 | {touch: topTouchArea} | ||
1806 | 245 | ]; | ||
1807 | 246 | } | ||
1808 | 247 | function test_touchDoubleClick(data) { | ||
1809 | 248 | touchPressSpy.target = data.touch; | ||
1810 | 249 | touchReleaseSpy.target = data.touch; | ||
1811 | 250 | TestExtras.touchDoubleClick(0, data.touch, Qt.point(10, 10)); | ||
1812 | 251 | compare(touchPressSpy.count, 2, "Not pressed twice?"); | ||
1813 | 252 | compare(touchReleaseSpy.count, 2, "Not released twice?"); | ||
1814 | 253 | } | ||
1815 | 254 | |||
1816 | 255 | function test_touchMove_data() { | ||
1817 | 256 | return [ | ||
1818 | 257 | {touch: touchArea}, | ||
1819 | 258 | {touch: topTouchArea} | ||
1820 | 259 | ]; | ||
1821 | 260 | } | ||
1822 | 261 | function test_touchMove(data) { | ||
1823 | 262 | touchUpdateSpy.target = data.touch; | ||
1824 | 263 | TestExtras.touchPress(0, data.touch, Qt.point(0, 0)); | ||
1825 | 264 | TestExtras.touchMove(0, data.touch, Qt.point(10, 10)); | ||
1826 | 265 | touchUpdateSpy.wait(); | ||
1827 | 266 | TestExtras.touchRelease(0, data.touch, Qt.point(10, 10)); | ||
1828 | 267 | } | ||
1829 | 268 | |||
1830 | 269 | function test_touchDrag_default_steps_data() { | ||
1831 | 270 | return [ | ||
1832 | 271 | {touch: touchArea}, | ||
1833 | 272 | {touch: topTouchArea} | ||
1834 | 273 | ]; | ||
1835 | 274 | } | ||
1836 | 275 | function test_touchDrag_default_steps(data) { | ||
1837 | 276 | touchPressSpy.target = data.touch; | ||
1838 | 277 | touchReleaseSpy.target = data.touch; | ||
1839 | 278 | touchUpdateSpy.target = data.touch; | ||
1840 | 279 | TestExtras.touchDrag(0, data.touch, Qt.point(0, 0), Qt.point(10, 10)); | ||
1841 | 280 | compare(touchPressSpy.count, 1, "Not pressed?"); | ||
1842 | 281 | compare(touchReleaseSpy.count, 1, "Not released?"); | ||
1843 | 282 | compare(touchUpdateSpy.count, 5, "Not moved?"); | ||
1844 | 283 | } | ||
1845 | 284 | |||
1846 | 285 | function test_touchDrag_10_steps_data() { | ||
1847 | 286 | return [ | ||
1848 | 287 | {touch: touchArea}, | ||
1849 | 288 | {touch: topTouchArea} | ||
1850 | 289 | ]; | ||
1851 | 290 | } | ||
1852 | 291 | function test_touchDrag_10_steps(data) { | ||
1853 | 292 | touchPressSpy.target = data.touch; | ||
1854 | 293 | touchReleaseSpy.target = data.touch; | ||
1855 | 294 | touchUpdateSpy.target = data.touch; | ||
1856 | 295 | TestExtras.touchDrag(0, data.touch, Qt.point(0, 0), Qt.point(100, 100), 10); | ||
1857 | 296 | compare(touchPressSpy.count, 1, "Not pressed?"); | ||
1858 | 297 | compare(touchReleaseSpy.count, 1, "Not released?"); | ||
1859 | 298 | compare(touchUpdateSpy.count, 10, "Not moved?"); | ||
1860 | 299 | } | ||
1861 | 149 | } | 300 | } |
1862 | 150 | } | 301 | } |