Merge lp:~saviq/unity8/new-preview into lp:unity8
- new-preview
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~saviq/unity8/new-preview |
Merge into: | lp:unity8 |
Prerequisite: | lp:~aacid/unity8/action_preview_widget |
Diff against target: |
654 lines (+572/-0) 11 files modified
qml/Dash/Previews/Preview.qml (+103/-0) qml/Dash/Previews/PreviewWidget.qml (+2/-0) qml/Dash/Previews/PreviewWidgetFactory.qml (+64/-0) tests/mocks/Unity/CMakeLists.txt (+1/-0) tests/mocks/Unity/fake_unity_plugin.cpp (+5/-0) tests/mocks/Unity/scopes-ng/fake_preview_model.cpp (+96/-0) tests/mocks/Unity/scopes-ng/fake_preview_model.h (+68/-0) tests/qmltests/CMakeLists.txt (+2/-0) tests/qmltests/Dash/Previews/MockPreviewWidget.qml (+27/-0) tests/qmltests/Dash/Previews/tst_Preview.qml (+112/-0) tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml (+92/-0) |
To merge this branch: | bzr merge lp:~saviq/unity8/new-preview |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Albert Astals Cid (community) | Needs Fixing | ||
Review via email: mp+205086@code.launchpad.net |
This proposal has been superseded by a proposal from 2014-02-07.
Commit message
Add Preview for new generation scopes.
Description of the change
* Are there any related MPs required for this MP to build/function as expected? Please list.
lp:~aacid/unity8/action_preview_widget needs to land before.
* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes.
* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A
* If you changed the UI, has there been a design review?
Will be reviewed with the whole switch to new scopes.
PS Jenkins bot (ps-jenkins) wrote : | # |
Albert Astals Cid (aacid) wrote : | # |
Why a Row with a Repeater with model:1 with a ListView inside? Isn't it enough to have the ListView by itself?
Albert Astals Cid (aacid) wrote : | # |
In PreviewModel:
Albert Astals Cid (aacid) wrote : | # |
Should the switch of the factory over widgetType instead of over type?
Albert Astals Cid (aacid) wrote : | # |
There's a few imports i think you don't need, not listing them all but i thing most Ubuntu.Components 0.1 are not needed and you're also including Multimedia that i don't see you using.
- 680. By Albert Astals Cid
-
Unit tests
Michał Sawicz (saviq) wrote : | # |
On 06.02.2014 09:54, Albert Astals Cid wrote:
> Why a Row with a Repeater with model:1 with a ListView inside? Isn't it enough to have the ListView by itself?
There will be multiple columns when the API gives them up, that's a
preparation for it.
> In PreviewModel:
Of course <facepalm>.
> Should the switch of the factory over widgetType instead of over type?
Huh, (how) did that work at all??
> There's a few imports i think you don't need, not listing them all but i thing most Ubuntu.Components 0.1 are not needed and you're also including Multimedia that i don't see you using.
Cleaned up.
Also added tests for the automagic positioning.
Albert Astals Cid (aacid) wrote : | # |
> On 06.02.2014 09:54, Albert Astals Cid wrote:
> > Should the switch of the factory over widgetType instead of over type?
>
> Huh, (how) did that work at all??
Because of this
widgetType: model.type
type is also defined on the delegate and you always use it as delegate so it was always defined
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:694
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 681. By Albert Astals Cid
-
Buttons just pass their id up, not the whole data
- 682. By Albert Astals Cid
-
longer name
- 683. By Albert Astals Cid
-
Use PreviewActionButton in PreviewActionCombo
And other minor stuff
- 684. By Albert Astals Cid
-
Missing ;
- 685. By Albert Astals Cid
-
One line less!
- 686. By Albert Astals Cid
-
better docu-comment
- 687. By Albert Astals Cid
-
Hide "actions" from the outside users
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:695
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 688. By Albert Astals Cid
-
Right align and make the width implcitWidth
- 689. By Albert Astals Cid
-
The condition makes more sense in topMargin than in spacing
- 690. By Albert Astals Cid
-
Saviq doesn't want to see two anchors. one after the other
- 691. By Albert Astals Cid
-
Animate height of the combo
- 692. By Albert Astals Cid
-
Wait for the height animation to finish
otherwise we click on something that is still not there and the test fails
- 693. By Albert Astals Cid
-
move clear into cleanup
- 694. By Albert Astals Cid
-
The button sizing comes from the parent
Albert Astals Cid (aacid) wrote : | # |
* Did you perform an exploratory manual test run of the code change and any related functionality?
Yes, run the tests, the code is not hooked into the main app yet
* Did CI run pass? If not, please explain why.
Yes
- 695. By Albert Astals Cid
-
color instead of gradient
- 696. By Albert Astals Cid
-
typo--
- 697. By Albert Astals Cid
-
better width setting
- 698. By Albert Astals Cid
-
more tweaking suggested by saviq
- 699. By Michał Sawicz
-
Merge audioPlayer.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:696
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 700. By Michał Sawicz
-
Add PreviewWidgetFa
ctory. - 701. By Michał Sawicz
-
Add widgetId property and triggered signal to PreviewWidget.
- 702. By Michał Sawicz
-
Type and id are not available in widgetData, only as roles from the model.
- 703. By Michał Sawicz
-
Introduce Preview.qml, along with tests.
- 704. By Michał Sawicz
-
Fix and add test for processingMouse
Area. - 705. By Michał Sawicz
-
Add more tests and fix review comments.
- 706. By Michał Sawicz
-
Drop spurious imports.
- 707. By Michał Sawicz
-
Add test that ensures correct widget mapping.
Unmerged revisions
Preview Diff
1 | === added file 'qml/Dash/Previews/Preview.qml' |
2 | --- qml/Dash/Previews/Preview.qml 1970-01-01 00:00:00 +0000 |
3 | +++ qml/Dash/Previews/Preview.qml 2014-02-06 16:59:06 +0000 |
4 | @@ -0,0 +1,103 @@ |
5 | +/* |
6 | + * Copyright (C) 2014 Canonical, Ltd. |
7 | + * |
8 | + * This program is free software; you can redistribute it and/or modify |
9 | + * it under the terms of the GNU General Public License as published by |
10 | + * the Free Software Foundation; version 3. |
11 | + * |
12 | + * This program is distributed in the hope that it will be useful, |
13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | + * GNU General Public License for more details. |
16 | + * |
17 | + * You should have received a copy of the GNU General Public License |
18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | + */ |
20 | + |
21 | +import QtQuick 2.0 |
22 | +import Ubuntu.Components 0.1 |
23 | + |
24 | +/*! \brief This component constructs the Preview UI. |
25 | + * |
26 | + * Currently it displays all the widgets in a flickable column. |
27 | + */ |
28 | + |
29 | +Item { |
30 | + id: root |
31 | + |
32 | + /*! \brief Model containing preview widgets. |
33 | + * |
34 | + * The model should expose "widgetId", "type" and "properties" roles, as well as |
35 | + * have a triggered(QString widgetId, QString actionId, QVariantMap data) method, |
36 | + * that's called when actions are executed in widgets. |
37 | + */ |
38 | + property var previewModel |
39 | + |
40 | + //! \brief Should be set to true if this preview is currently displayed. |
41 | + property bool isCurrent: false |
42 | + |
43 | + clip: true |
44 | + |
45 | + Connections { |
46 | + target: shell.applicationManager |
47 | + onMainStageFocusedApplicationChanged: { |
48 | + root.close(); |
49 | + } |
50 | + onSideStageFocusedApplicationChanged: { |
51 | + root.close(); |
52 | + } |
53 | + } |
54 | + |
55 | + onPreviewModelChanged: processingMouseArea.enabled = false |
56 | + |
57 | + MouseArea { |
58 | + anchors.fill: parent |
59 | + } |
60 | + |
61 | + Row { |
62 | + id: row |
63 | + |
64 | + spacing: units.gu(1) |
65 | + anchors { fill: parent; margins: spacing } |
66 | + |
67 | + Repeater { |
68 | + model: 1 |
69 | + |
70 | + delegate: ListView { |
71 | + id: column |
72 | + anchors { top: parent.top; bottom: parent.bottom } |
73 | + width: row.width |
74 | + spacing: row.spacing |
75 | + bottomMargin: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0 |
76 | + |
77 | + model: previewModel |
78 | + |
79 | + Behavior on contentY { UbuntuNumberAnimation { } } |
80 | + |
81 | + delegate: PreviewWidgetFactory { |
82 | + widgetId: model.widgetId |
83 | + widgetType: model.type |
84 | + widgetData: model.properties |
85 | + isCurrentPreview: root.isCurrent |
86 | + anchors { left: parent.left; right: parent.right } |
87 | + |
88 | + onTriggered: { |
89 | + processingMouseArea.enabled = true; |
90 | + previewModel.triggered(widgetId, actionId, data); |
91 | + } |
92 | + |
93 | + onFocusChanged: if (focus) column.positionViewAtIndex(index, ListView.Contain) |
94 | + |
95 | + onHeightChanged: if (focus) column.positionViewAtIndex(index, ListView.Contain) |
96 | + } |
97 | + } |
98 | + } |
99 | + } |
100 | + |
101 | + MouseArea { |
102 | + id: processingMouseArea |
103 | + objectName: "processingMouseArea" |
104 | + anchors.fill: parent |
105 | + enabled: false |
106 | + } |
107 | +} |
108 | |
109 | === modified file 'qml/Dash/Previews/PreviewWidget.qml' |
110 | --- qml/Dash/Previews/PreviewWidget.qml 2014-02-06 16:59:06 +0000 |
111 | +++ qml/Dash/Previews/PreviewWidget.qml 2014-02-06 16:59:06 +0000 |
112 | @@ -34,4 +34,6 @@ |
113 | * \param data Optional widget-specific data sent to the scope. |
114 | */ |
115 | signal triggered(string widgetId, string actionId, var data) |
116 | + |
117 | + objectName: widgetId |
118 | } |
119 | |
120 | === added file 'qml/Dash/Previews/PreviewWidgetFactory.qml' |
121 | --- qml/Dash/Previews/PreviewWidgetFactory.qml 1970-01-01 00:00:00 +0000 |
122 | +++ qml/Dash/Previews/PreviewWidgetFactory.qml 2014-02-06 16:59:06 +0000 |
123 | @@ -0,0 +1,64 @@ |
124 | +/* |
125 | + * Copyright 2014 Canonical Ltd. |
126 | + * |
127 | + * This program is free software; you can redistribute it and/or modify |
128 | + * it under the terms of the GNU Lesser General Public License as published by |
129 | + * the Free Software Foundation; version 3. |
130 | + * |
131 | + * This program is distributed in the hope that it will be useful, |
132 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
133 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
134 | + * GNU Lesser General Public License for more details. |
135 | + * |
136 | + * You should have received a copy of the GNU Lesser General Public License |
137 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
138 | + * |
139 | + */ |
140 | + |
141 | +import QtQuick 2.0 |
142 | + |
143 | +//! \brief This component loads the widgets based on widgetData["type"]. |
144 | + |
145 | +Loader { |
146 | + id: root |
147 | + |
148 | + //! Identifier of the widget. |
149 | + property string widgetId: "" |
150 | + |
151 | + //! Type of the widget to display. |
152 | + property string widgetType: "" |
153 | + |
154 | + //! Widget data, forwarded to the widget as is. |
155 | + property var widgetData: null |
156 | + |
157 | + //! Set to true if the parent preview is displayed. |
158 | + property bool isCurrentPreview: false |
159 | + |
160 | + //! Triggered signal forwarded from the widgets. |
161 | + signal triggered(string widgetId, string actionId, var data) |
162 | + |
163 | + source: widgetSource |
164 | + |
165 | + //! \cond private |
166 | + property url widgetSource: { |
167 | + switch (widgetType) { |
168 | + case "audio": return "PreviewAudioPlayback.qml"; |
169 | + case "text": return "PreviewTextSummary.qml"; |
170 | + case "gallery": return "PreviewImageGallery.qml"; |
171 | + case "actions": return "PreviewActions.qml"; |
172 | + default: return ""; |
173 | + } |
174 | + } |
175 | + //! \endcond |
176 | + |
177 | + onLoaded: { |
178 | + item.widgetId = Qt.binding(function() { return root.widgetId } ) |
179 | + item.widgetData = Qt.binding(function() { return root.widgetData } ) |
180 | + item.isCurrentPreview = Qt.binding(function() { return root.isCurrentPreview } ) |
181 | + } |
182 | + |
183 | + Connections { |
184 | + target: root.item |
185 | + onTriggered: root.triggered(widgetId, actionId, data) |
186 | + } |
187 | +} |
188 | |
189 | === modified file 'tests/mocks/Unity/CMakeLists.txt' |
190 | --- tests/mocks/Unity/CMakeLists.txt 2014-01-16 17:30:40 +0000 |
191 | +++ tests/mocks/Unity/CMakeLists.txt 2014-02-06 16:59:06 +0000 |
192 | @@ -25,6 +25,7 @@ |
193 | fake_scope.cpp |
194 | fake_scopes.cpp |
195 | fake_categories.cpp |
196 | + scopes-ng/fake_preview_model.cpp |
197 | fake_unity_plugin.cpp |
198 | ) |
199 | |
200 | |
201 | === modified file 'tests/mocks/Unity/fake_unity_plugin.cpp' |
202 | --- tests/mocks/Unity/fake_unity_plugin.cpp 2013-10-31 15:13:50 +0000 |
203 | +++ tests/mocks/Unity/fake_unity_plugin.cpp 2014-02-06 16:59:06 +0000 |
204 | @@ -25,6 +25,9 @@ |
205 | #include "fake_preview.h" |
206 | #include "categoryresults.h" |
207 | |
208 | +// scopes-ng |
209 | +#include "scopes-ng/fake_preview_model.h" |
210 | + |
211 | // External |
212 | #include <glib-object.h> |
213 | |
214 | @@ -44,4 +47,6 @@ |
215 | qmlRegisterType<Categories>(uri, 0, 1, "Categories"); |
216 | qmlRegisterUncreatableType<CategoryResults>(uri, 0, 1, "CategoryResults", "Can't create"); |
217 | qmlRegisterType<DeeListModel>(uri, 0, 1, "DeeListModel"); |
218 | + |
219 | + qmlRegisterType<scopes_ng::PreviewModel>(uri, 0, 1, "FakePreviewModel"); |
220 | } |
221 | |
222 | === added directory 'tests/mocks/Unity/scopes-ng' |
223 | === added file 'tests/mocks/Unity/scopes-ng/fake_preview_model.cpp' |
224 | --- tests/mocks/Unity/scopes-ng/fake_preview_model.cpp 1970-01-01 00:00:00 +0000 |
225 | +++ tests/mocks/Unity/scopes-ng/fake_preview_model.cpp 2014-02-06 16:59:06 +0000 |
226 | @@ -0,0 +1,96 @@ |
227 | +/* |
228 | + * Copyright (C) 2014 Canonical, Ltd. |
229 | + * |
230 | + * Authors: |
231 | + * Michał Sawicz <michal.sawicz@canonical.com> |
232 | + * Michal Hruby <michal.hruby@canonical.com> |
233 | + * |
234 | + * This program is free software; you can redistribute it and/or modify |
235 | + * it under the terms of the GNU General Public License as published by |
236 | + * the Free Software Foundation; version 3. |
237 | + * |
238 | + * This program is distributed in the hope that it will be useful, |
239 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
240 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
241 | + * GNU General Public License for more details. |
242 | + * |
243 | + * You should have received a copy of the GNU General Public License |
244 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
245 | + */ |
246 | + |
247 | +// self |
248 | +#include "fake_preview_model.h" |
249 | + |
250 | +// Qt |
251 | +#include <QVariantMap> |
252 | + |
253 | +namespace scopes_ng |
254 | +{ |
255 | + |
256 | +struct PreviewData |
257 | +{ |
258 | + QString id; |
259 | + QString type; |
260 | + QVariantMap data; |
261 | + |
262 | + PreviewData(QString const& id_, QString const& type_, QVariantMap const& data_): id(id_), type(type_), data(data_) |
263 | + { |
264 | + } |
265 | +}; |
266 | + |
267 | +PreviewModel::PreviewModel(QObject* parent) : QAbstractListModel(parent) |
268 | +{ |
269 | + m_roles[Roles::RoleWidgetId] = "widgetId"; |
270 | + m_roles[Roles::RoleType] = "type"; |
271 | + m_roles[Roles::RoleProperties] = "properties"; |
272 | + |
273 | + populateWidgets(); |
274 | +} |
275 | + |
276 | +void PreviewModel::populateWidgets() |
277 | +{ |
278 | + beginResetModel(); |
279 | + m_previewWidgets.clear(); |
280 | + for (int i = 0; i <= 20; i++) { |
281 | + // FIXME: the API will expose nicer getters soon, use those! |
282 | + QVariantMap attributes; |
283 | + attributes["text"] = QVariant::fromValue(QString("Widget %1").arg(i)); |
284 | + attributes["title"] = QVariant::fromValue(QString("Title %1").arg(i)); |
285 | + PreviewData* preview_data = new PreviewData(QString("widget-%1").arg(i), QString("text"), attributes); |
286 | + m_previewWidgets.append(QSharedPointer<PreviewData>(preview_data)); |
287 | + } |
288 | + endResetModel(); |
289 | + |
290 | +} |
291 | + |
292 | +void PreviewModel::triggered(QString widgetId, QString actionId, QVariantMap data) |
293 | +{ |
294 | + Q_EMIT actionTriggered(widgetId, actionId, data); |
295 | +} |
296 | + |
297 | +QHash<int, QByteArray> PreviewModel::roleNames() const |
298 | +{ |
299 | + return m_roles; |
300 | +} |
301 | + |
302 | +int PreviewModel::rowCount(const QModelIndex&) const |
303 | +{ |
304 | + return m_previewWidgets.size(); |
305 | +} |
306 | + |
307 | +QVariant PreviewModel::data(const QModelIndex& index, int role) const |
308 | +{ |
309 | + auto widget_data = m_previewWidgets.at(index.row()); |
310 | + switch (role) { |
311 | + case RoleWidgetId: |
312 | + return widget_data->id; |
313 | + case RoleType: |
314 | + return widget_data->type; |
315 | + case RoleProperties: |
316 | + return widget_data->data; |
317 | + default: |
318 | + return QVariant(); |
319 | + } |
320 | +} |
321 | + |
322 | +} // namespace scopes_ng |
323 | |
324 | === added file 'tests/mocks/Unity/scopes-ng/fake_preview_model.h' |
325 | --- tests/mocks/Unity/scopes-ng/fake_preview_model.h 1970-01-01 00:00:00 +0000 |
326 | +++ tests/mocks/Unity/scopes-ng/fake_preview_model.h 2014-02-06 16:59:06 +0000 |
327 | @@ -0,0 +1,68 @@ |
328 | +/* |
329 | + * Copyright (C) 2014 Canonical, Ltd. |
330 | + * |
331 | + * This program is free software; you can redistribute it and/or modify |
332 | + * it under the terms of the GNU General Public License as published by |
333 | + * the Free Software Foundation; version 3. |
334 | + * |
335 | + * This program is distributed in the hope that it will be useful, |
336 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
337 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
338 | + * GNU General Public License for more details. |
339 | + * |
340 | + * You should have received a copy of the GNU General Public License |
341 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
342 | + */ |
343 | + |
344 | + |
345 | +#ifndef NG_FAKE_PREVIEW_H |
346 | +#define NG_FAKE_PREVIEW_H |
347 | + |
348 | +#include <QAbstractListModel> |
349 | +#include <QSharedPointer> |
350 | +#include <QVariantMap> |
351 | + |
352 | +namespace scopes_ng |
353 | +{ |
354 | + |
355 | +class PreviewData; |
356 | + |
357 | +class Q_DECL_EXPORT PreviewModel : public QAbstractListModel |
358 | +{ |
359 | + Q_OBJECT |
360 | + |
361 | + Q_ENUMS(Roles) |
362 | + |
363 | +public: |
364 | + explicit PreviewModel(QObject* parent = 0); |
365 | + |
366 | + enum Roles { |
367 | + RoleWidgetId, |
368 | + RoleType, |
369 | + RoleProperties |
370 | + }; |
371 | + |
372 | + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; |
373 | + QHash<int, QByteArray> roleNames() const override; |
374 | + int rowCount(const QModelIndex& parent = QModelIndex()) const override; |
375 | + |
376 | +Q_SIGNALS: |
377 | + void actionTriggered(QString widgetId, QString actionId, QVariantMap data); |
378 | + |
379 | +public Q_SLOTS: |
380 | + void triggered(QString widgetId, QString actionId, QVariantMap data); |
381 | + |
382 | +private: |
383 | + QHash<int, QByteArray> m_roles; |
384 | + QList<QSharedPointer<PreviewData>> m_previewWidgets; |
385 | + |
386 | + void populateWidgets(); |
387 | + |
388 | +}; |
389 | + |
390 | +} // namespace scopes_ng |
391 | + |
392 | + |
393 | +Q_DECLARE_METATYPE(scopes_ng::PreviewModel*) |
394 | + |
395 | +#endif // NG_FAKE_PREVIW_H |
396 | |
397 | === modified file 'tests/qmltests/CMakeLists.txt' |
398 | --- tests/qmltests/CMakeLists.txt 2014-02-06 16:59:06 +0000 |
399 | +++ tests/qmltests/CMakeLists.txt 2014-02-06 16:59:06 +0000 |
400 | @@ -55,6 +55,8 @@ |
401 | add_qml_test(Dash/Apps AppPreview IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks) |
402 | add_qml_test(Dash/Movie MoviePreview IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks) |
403 | add_qml_test(Dash/Music MusicPreview IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks) |
404 | +add_qml_test(Dash/Previews Preview IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks) |
405 | +add_qml_test(Dash/Previews PreviewWidgetFactory IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks) |
406 | add_qml_test(Dash/Previews PreviewActions IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks) |
407 | add_qml_test(Dash/Previews PreviewAudioPlayback IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks) |
408 | add_qml_test(Dash/Previews PreviewImageGallery IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/tests/mocks) |
409 | |
410 | === added file 'tests/qmltests/Dash/Previews/MockPreviewWidget.qml' |
411 | --- tests/qmltests/Dash/Previews/MockPreviewWidget.qml 1970-01-01 00:00:00 +0000 |
412 | +++ tests/qmltests/Dash/Previews/MockPreviewWidget.qml 2014-02-06 16:59:06 +0000 |
413 | @@ -0,0 +1,27 @@ |
414 | +/* |
415 | + * Copyright 2014 Canonical Ltd. |
416 | + * |
417 | + * This program is free software; you can redistribute it and/or modify |
418 | + * it under the terms of the GNU Lesser General Public License as published by |
419 | + * the Free Software Foundation; version 3. |
420 | + * |
421 | + * This program is distributed in the hope that it will be useful, |
422 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
423 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
424 | + * GNU Lesser General Public License for more details. |
425 | + * |
426 | + * You should have received a copy of the GNU Lesser General Public License |
427 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
428 | + * |
429 | + */ |
430 | + |
431 | +import QtQuick 2.0 |
432 | +import "../../../../qml/Dash/Previews" |
433 | + |
434 | +PreviewWidget { |
435 | + objectName: "mockPreviewWidget" |
436 | + |
437 | + function trigger() { |
438 | + triggered("mockWidget", "mockAction", {"mock": "data"}) |
439 | + } |
440 | +} |
441 | |
442 | === added file 'tests/qmltests/Dash/Previews/tst_Preview.qml' |
443 | --- tests/qmltests/Dash/Previews/tst_Preview.qml 1970-01-01 00:00:00 +0000 |
444 | +++ tests/qmltests/Dash/Previews/tst_Preview.qml 2014-02-06 16:59:06 +0000 |
445 | @@ -0,0 +1,112 @@ |
446 | +/* |
447 | + * Copyright 2014 Canonical Ltd. |
448 | + * |
449 | + * This program is free software; you can redistribute it and/or modify |
450 | + * it under the terms of the GNU General Public License as published by |
451 | + * the Free Software Foundation; version 3. |
452 | + * |
453 | + * This program is distributed in the hope that it will be useful, |
454 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
455 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
456 | + * GNU General Public License for more details. |
457 | + * |
458 | + * You should have received a copy of the GNU General Public License |
459 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
460 | + */ |
461 | + |
462 | +import QtQuick 2.0 |
463 | +import QtTest 1.0 |
464 | +import "../../../../qml/Dash/Previews" |
465 | +import Unity.Test 0.1 as UT |
466 | +import Unity 0.1 as Unity |
467 | + |
468 | +Rectangle { |
469 | + id: root |
470 | + width: units.gu(60) |
471 | + height: units.gu(80) |
472 | + color: Theme.palette.selected.background |
473 | + |
474 | + Item { |
475 | + id: shell |
476 | + |
477 | + anchors.fill: parent |
478 | + property var applicationManager: null |
479 | + } |
480 | + |
481 | + Unity.FakePreviewModel { |
482 | + id: mockPreviewModel |
483 | + } |
484 | + |
485 | + Preview { |
486 | + id: preview |
487 | + anchors.fill: parent |
488 | + |
489 | + previewModel: mockPreviewModel |
490 | + } |
491 | + |
492 | + SignalSpy { |
493 | + id: triggeredSpy |
494 | + target: mockPreviewModel |
495 | + signalName: "actionTriggered" |
496 | + } |
497 | + |
498 | + UT.UnityTestCase { |
499 | + name: "Preview" |
500 | + when: windowShown |
501 | + |
502 | + function test_triggered() { |
503 | + waitForRendering(preview); |
504 | + var widget = findChild(preview, "widget-3"); |
505 | + |
506 | + compare(typeof widget, "object", "Could not find the widget object."); |
507 | + |
508 | + widget.triggered(widget.widgetId, "mockAction", {"mock": "data"}); |
509 | + |
510 | + triggeredSpy.wait(); |
511 | + |
512 | + var args = triggeredSpy.signalArguments[0]; |
513 | + |
514 | + compare(args[0], "widget-3", "Widget id not passed correctly."); |
515 | + compare(args[1], "mockAction", "Action id not passed correctly."); |
516 | + compare(args[2]["mock"], "data", "Data not passed correctly."); |
517 | + } |
518 | + |
519 | + function test_showProcessing() { |
520 | + waitForRendering(preview); |
521 | + var widget = findChild(preview, "widget-3"); |
522 | + widget.triggered(widget.widgetId, "mockAction", {"mock": "data"}); |
523 | + |
524 | + var processing = findChild(preview, "processingMouseArea"); |
525 | + |
526 | + tryCompare(processing, "enabled", true); |
527 | + |
528 | + preview.previewModelChanged(); |
529 | + |
530 | + tryCompare(processing, "enabled", false); |
531 | + } |
532 | + |
533 | + function test_containOnFocus() { |
534 | + waitForRendering(preview); |
535 | + var widget = findChild(preview, "widget-13"); |
536 | + |
537 | + widget.forceActiveFocus(); |
538 | + |
539 | + var bottomLeft = preview.mapFromItem(widget, 0, widget.height); |
540 | + |
541 | + tryCompareFunction(function () { return bottomLeft.y <= preview.height }, true); |
542 | + } |
543 | + |
544 | + function test_containOnGrow() { |
545 | + waitForRendering(preview); |
546 | + var widget = findChild(preview, "widget-13"); |
547 | + |
548 | + widget.forceActiveFocus(); |
549 | + widget.height += 200; |
550 | + |
551 | + tryCompareFunction(function () { |
552 | + var bottomLeft = preview.mapFromItem(widget, 0, widget.height); |
553 | + return bottomLeft.y <= preview.height |
554 | + }, true); |
555 | + } |
556 | + } |
557 | +} |
558 | |
559 | === added file 'tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml' |
560 | --- tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml 1970-01-01 00:00:00 +0000 |
561 | +++ tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml 2014-02-06 16:59:06 +0000 |
562 | @@ -0,0 +1,92 @@ |
563 | +/* |
564 | + * Copyright 2014 Canonical Ltd. |
565 | + * |
566 | + * This program is free software; you can redistribute it and/or modify |
567 | + * it under the terms of the GNU General Public License as published by |
568 | + * the Free Software Foundation; version 3. |
569 | + * |
570 | + * This program is distributed in the hope that it will be useful, |
571 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
572 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
573 | + * GNU General Public License for more details. |
574 | + * |
575 | + * You should have received a copy of the GNU General Public License |
576 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
577 | + */ |
578 | + |
579 | +import QtQuick 2.0 |
580 | +import QtTest 1.0 |
581 | +import "../../../../qml/Dash/Previews" |
582 | +import Unity.Test 0.1 as UT |
583 | + |
584 | +Rectangle { |
585 | + id: root |
586 | + width: units.gu(60) |
587 | + height: units.gu(80) |
588 | + color: Theme.palette.selected.background |
589 | + |
590 | + PreviewWidgetFactory { |
591 | + id: factory |
592 | + anchors { |
593 | + left: parent.left |
594 | + right: parent.right |
595 | + } |
596 | + } |
597 | + |
598 | + SignalSpy { |
599 | + id: triggeredSpy |
600 | + target: factory |
601 | + signalName: "triggered" |
602 | + } |
603 | + |
604 | + UT.UnityTestCase { |
605 | + name: "PreviewWidgetFactory" |
606 | + when: windowShown |
607 | + |
608 | + property Item mockWidget: findChild(factory, "mockPreviewWidget") |
609 | + |
610 | + function cleanup() { |
611 | + factory.source = Qt.binding(function() { return factory.widgetSource }); |
612 | + } |
613 | + |
614 | + function test_previewData() { |
615 | + factory.source = Qt.resolvedUrl("MockPreviewWidget.qml"); |
616 | + |
617 | + verify(typeof mockWidget === "object", "Could not find the mock preview widget."); |
618 | + |
619 | + tryCompare(mockWidget, "widgetData", factory.widgetData); |
620 | + } |
621 | + |
622 | + function test_triggered() { |
623 | + factory.source = Qt.resolvedUrl("MockPreviewWidget.qml"); |
624 | + |
625 | + verify(typeof mockWidget === "object", "Could not find the mock preview widget."); |
626 | + |
627 | + mockWidget.trigger(); |
628 | + |
629 | + triggeredSpy.wait(); |
630 | + |
631 | + var args = triggeredSpy.signalArguments[0]; |
632 | + |
633 | + compare(args[0], "mockWidget", "Widget id not passed correctly."); |
634 | + compare(args[1], "mockAction", "Action id not passed correctly."); |
635 | + compare(args[2]["mock"], "data", "Data not passed correctly."); |
636 | + } |
637 | + |
638 | + function test_mapping_data() { |
639 | + return [ |
640 | + { tag: "Audio", type: "audio", source: "PreviewAudioPlayback.qml" }, |
641 | + { tag: "Text", type: "text", source: "PreviewTextSummary.qml" }, |
642 | + { tag: "Gallery", type: "gallery", source: "PreviewImageGallery.qml" }, |
643 | + { tag: "Actions", type: "actions", source: "PreviewActions.qml" }, |
644 | + ]; |
645 | + } |
646 | + |
647 | + function test_mapping(data) { |
648 | + factory.widgetData = { type: data.type }; |
649 | + factory.widgetType = data.type; |
650 | + |
651 | + verify(("" + factory.source).indexOf(data.source) != -1); |
652 | + } |
653 | + } |
654 | +} |
FAILED: Continuous integration, rev:692 jenkins. qa.ubuntu. com/job/ unity8- ci/2242/ jenkins. qa.ubuntu. com/job/ generic- mediumtests- trusty/ 2947 jenkins. qa.ubuntu. com/job/ generic- mediumtests- trusty- touch/2683 jenkins. qa.ubuntu. com/job/ unity-phablet- qmluitests- trusty/ 1113 jenkins. qa.ubuntu. com/job/ unity8- trusty- amd64-ci/ 764 jenkins. qa.ubuntu. com/job/ unity8- trusty- armhf-ci/ 766 jenkins. qa.ubuntu. com/job/ unity8- trusty- armhf-ci/ 766/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ unity8- trusty- i386-ci/ 764 jenkins. qa.ubuntu. com/job/ autopilot- testrunner- otto-trusty/ 2586 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- amd64/2949 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- amd64/2949/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- armhf/2684 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- armhf/2684/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- runner- mako/5108 s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 3676
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity8- ci/2242/ rebuild
http://