Merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-set-shapes-debug-description into lp:ubuntu-ui-toolkit

Proposed by Loïc Molinari
Status: Superseded
Proposed branch: lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-set-shapes-debug-description
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 807 lines (+480/-78)
19 files modified
debian/control (+1/-0)
documentation/autopilot-helpers/conf.py (+1/-1)
examples/ubuntu-ui-toolkit-gallery/Sliders.qml (+25/-0)
examples/ubuntu-ui-toolkit-gallery/Toolbar.qml (+0/-49)
examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml (+1/-6)
modules/Ubuntu/Components/TextCursor.qml (+1/-1)
modules/Ubuntu/Components/Themes/Ambiance/SliderStyle.qml (+4/-1)
modules/Ubuntu/Components/plugin/adapters/alarmsadapter_organizer.cpp (+6/-7)
modules/Ubuntu/Components/plugin/adapters/alarmsadapter_p.h (+5/-3)
modules/Ubuntu/Components/plugin/ucalarm_p.h (+1/-0)
modules/Ubuntu/Components/plugin/ucalarmmodel.cpp (+9/-1)
modules/Ubuntu/Components/plugin/ucubuntushape.cpp (+3/-0)
modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.cpp (+3/-0)
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_qquicklistview.py (+123/-8)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_listitem.ListViewWithLiveDraggingTestCase.qml (+62/-0)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_listitem.ListViewWithoutLiveDraggingTestCase.qml (+65/-0)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_qquicklistview.py (+76/-0)
tests/unit_x11/tst_components/tst_components.pro (+2/-1)
tests/unit_x11/tst_components/tst_stress_alarmmodel.qml (+92/-0)
To merge this branch: bzr merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-set-shapes-debug-description
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu SDK team Pending
Review via email: mp+254380@code.launchpad.net

Commit message

Set QSGNode debug description on the shape-based nodes to ease renderer debugging.

Description of the change

Set QSGNode debug description on the shape-based nodes to ease renderer debugging.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2015-03-02 13:55:42 +0000
3+++ debian/control 2015-03-27 11:25:30 +0000
4@@ -47,6 +47,7 @@
5 locales,
6 suru-icon-theme,
7 uuid-runtime,
8+ python-autopilot (>= 1.4),
9 python3-sphinx,
10 Standards-Version: 3.9.4
11 Homepage: https://launchpad.net/ubuntu-ui-toolkit
12
13=== modified file 'documentation/autopilot-helpers/conf.py'
14--- documentation/autopilot-helpers/conf.py 2015-01-26 16:22:07 +0000
15+++ documentation/autopilot-helpers/conf.py 2015-03-27 11:25:30 +0000
16@@ -19,7 +19,7 @@
17 # If extensions (or modules to document with autodoc) are in another directory,
18 # add these directories to sys.path here. If the directory is relative to the
19 # documentation root, use os.path.abspath to make it absolute, like shown here.
20-# sys.path.insert(0, os.path.abspath('.'))
21+sys.path.insert(0, os.path.join(os.path.abspath('../..'), 'tests/autopilot/'))
22
23 # -- General configuration ------------------------------------------------
24
25
26=== modified file 'examples/ubuntu-ui-toolkit-gallery/Sliders.qml'
27--- examples/ubuntu-ui-toolkit-gallery/Sliders.qml 2015-03-03 13:20:06 +0000
28+++ examples/ubuntu-ui-toolkit-gallery/Sliders.qml 2015-03-27 11:25:30 +0000
29@@ -69,5 +69,30 @@
30 font.weight: Font.Light
31 }
32 }
33+
34+ TemplateFlow {
35+ title: i18n.tr("Labels")
36+
37+ Slider {
38+ id: longBubbleSlider
39+ objectName: "slider_long_bubble"
40+ width: parent.width
41+ value: 50
42+ minimumValue: 0
43+ maximumValue: 100
44+ function formatValue(v) {
45+ if (v < maximumValue/4)
46+ return i18n.tr("Small")
47+ else if (v < maximumValue/1.5)
48+ return i18n.tr("Medium")
49+ else
50+ return i18n.tr("Large")
51+ }
52+ }
53+ Label {
54+ text: i18n.tr("Actual value: %1").arg(longBubbleSlider.value)
55+ font.weight: Font.Light
56+ }
57+ }
58 }
59 }
60
61=== removed file 'examples/ubuntu-ui-toolkit-gallery/Toolbar.qml'
62--- examples/ubuntu-ui-toolkit-gallery/Toolbar.qml 2015-03-11 17:10:20 +0000
63+++ examples/ubuntu-ui-toolkit-gallery/Toolbar.qml 1970-01-01 00:00:00 +0000
64@@ -1,49 +0,0 @@
65-/*
66- * Copyright 2014 Canonical Ltd.
67- *
68- * This program is free software; you can redistribute it and/or modify
69- * it under the terms of the GNU Lesser General Public License as published by
70- * the Free Software Foundation; version 3.
71- *
72- * This program is distributed in the hope that it will be useful,
73- * but WITHOUT ANY WARRANTY; without even the implied warranty of
74- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
75- * GNU Lesser General Public License for more details.
76- *
77- * You should have received a copy of the GNU Lesser General Public License
78- * along with this program. If not, see <http://www.gnu.org/licenses/>.
79- */
80-
81-import QtQuick 2.0
82-import Ubuntu.Components 0.1
83-import Ubuntu.Components.Popups 0.1
84-
85-Template {
86- objectName: "popoversTemplate"
87-
88- tools: ToolbarItems {
89- ToolbarButton {
90- text: "Call"
91- iconName: "call-start"
92- }
93- ToolbarButton {
94- text: i18n.tr("Share")
95- iconName: "share"
96- }
97- ToolbarButton {
98- iconName: "settings"
99- }
100- ToolbarButton {
101- iconName: "speaker"
102- }
103- }
104-
105- TemplateSection {
106- className: "Toolbar"
107- documentation: "qml-ubuntu-components-toolbaritems.html".arg(className.toLowerCase())
108-
109- TemplateRow {
110- title: i18n.tr("See below")
111- }
112- }
113-}
114
115=== modified file 'examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml'
116--- examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml 2015-03-03 13:20:06 +0000
117+++ examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml 2015-03-27 11:25:30 +0000
118@@ -1,5 +1,5 @@
119 /*
120- * Copyright 2013 Canonical Ltd.
121+ * Copyright 2013-2015 Canonical Ltd.
122 *
123 * This program is free software; you can redistribute it and/or modify
124 * it under the terms of the GNU Lesser General Public License as published by
125@@ -39,11 +39,6 @@
126 source: "Toggles.qml"
127 }
128 ListElement {
129- objectName: "toolbarElement"
130- label: "Toolbar"
131- source: "Toolbar.qml"
132- }
133- ListElement {
134 objectName: "buttonsElement"
135 label: "Buttons"
136 source: "Buttons.qml"
137
138=== modified file 'modules/Ubuntu/Components/TextCursor.qml'
139--- modules/Ubuntu/Components/TextCursor.qml 2015-03-10 11:49:27 +0000
140+++ modules/Ubuntu/Components/TextCursor.qml 2015-03-27 11:25:30 +0000
141@@ -54,7 +54,7 @@
142 var flickable = handler.main;
143 do {
144 flickable = flickable.parent;
145- } while (!flickable.contentY && flickable != fakeCursor.parent);
146+ } while (flickable && !flickable.contentY && flickable != fakeCursor.parent);
147 return fakeCursor.parent.mapFromItem(handler.main, cursorItem.x, cursorItem.y).y
148 }
149
150
151=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/SliderStyle.qml'
152--- modules/Ubuntu/Components/Themes/Ambiance/SliderStyle.qml 2015-03-10 12:16:04 +0000
153+++ modules/Ubuntu/Components/Themes/Ambiance/SliderStyle.qml 2015-03-27 11:25:30 +0000
154@@ -87,7 +87,10 @@
155 BubbleShape {
156 id: bubbleShape
157
158- width: units.gu(8)
159+ property real minimumWidth: units.gu(8)
160+ property real horizontalPadding: units.gu(1)
161+
162+ width: Math.max(minimumWidth, label.implicitWidth + 2*horizontalPadding)
163 height: units.gu(6)
164
165 // FIXME: very temporary implementation
166
167=== modified file 'modules/Ubuntu/Components/plugin/adapters/alarmsadapter_organizer.cpp'
168--- modules/Ubuntu/Components/plugin/adapters/alarmsadapter_organizer.cpp 2015-02-26 15:09:23 +0000
169+++ modules/Ubuntu/Components/plugin/adapters/alarmsadapter_organizer.cpp 2015-03-27 11:25:30 +0000
170@@ -292,6 +292,12 @@
171 }
172 }
173
174+void AlarmDataAdapter::copyAlarmData(const UCAlarm &other)
175+{
176+ AlarmDataAdapter *pOther = static_cast<AlarmDataAdapter*>(AlarmDataAdapter::get(&other));
177+ setData(pOther->data());
178+}
179+
180 void AlarmDataAdapter::adjustDowSettings(UCAlarm::AlarmType type, UCAlarm::DaysOfWeek days)
181 {
182 QOrganizerItemRecurrence old = event.detail(QOrganizerItemDetail::TypeRecurrence);
183@@ -369,13 +375,6 @@
184 }
185 }
186
187-void AlarmDataAdapter::copyData(const UCAlarm &other)
188-{
189- AlarmDataAdapter *pOther = static_cast<AlarmDataAdapter*>(AlarmDataAdapter::get(&other));
190- setData(pOther->data());
191-}
192-
193-
194 /*-----------------------------------------------------------------------------
195 * Adaptation layer for Alarms.
196 */
197
198=== modified file 'modules/Ubuntu/Components/plugin/adapters/alarmsadapter_p.h'
199--- modules/Ubuntu/Components/plugin/adapters/alarmsadapter_p.h 2015-02-26 15:09:23 +0000
200+++ modules/Ubuntu/Components/plugin/adapters/alarmsadapter_p.h 2015-03-27 11:25:30 +0000
201@@ -58,6 +58,7 @@
202 bool wait(int msec);
203 void completeSave();
204 void completeCancel();
205+ void copyAlarmData(const UCAlarm &other);
206
207 // adaptation specific data
208 void adjustDowSettings(UCAlarm::AlarmType type, UCAlarm::DaysOfWeek days);
209@@ -69,7 +70,6 @@
210 return event;
211 }
212 void setData(const QOrganizerTodo &data);
213- void copyData(const UCAlarm &other);
214
215 protected:
216 QOrganizerTodo event;
217@@ -108,7 +108,7 @@
218 UCAlarm *oldAlarm = takeAt(index);
219 // copy the other alarm data
220 AlarmDataAdapter *pAlarm = static_cast<AlarmDataAdapter*>(AlarmDataAdapter::get(oldAlarm));
221- pAlarm->copyData(alarm);
222+ pAlarm->copyAlarmData(alarm);
223 // and insert it back
224 QDateTime dt = oldAlarm->date();
225 QOrganizerItemId id = oldAlarm->cookie().value<QOrganizerItemId>();
226@@ -123,7 +123,7 @@
227 QOrganizerItemId id = alarm.cookie().value<QOrganizerItemId>();
228 idHash.insert(id, dt);
229 UCAlarm *newAlarm = new UCAlarm;
230- static_cast<AlarmDataAdapter*>(AlarmDataAdapter::get(newAlarm))->copyData(alarm);
231+ UCAlarmPrivate::get(newAlarm)->copyAlarmData(alarm);
232 data.insert(QPair<QDateTime, QOrganizerItemId>(dt, id), newAlarm);
233 return indexOf(id);
234 }
235@@ -140,6 +140,8 @@
236 UCAlarm *alarm = takeAt(index);
237 delete alarm;
238 }
239+
240+protected:
241 // removes alarm data at index and returns the alarm pointer
242 UCAlarm *takeAt(int index)
243 {
244
245=== modified file 'modules/Ubuntu/Components/plugin/ucalarm_p.h'
246--- modules/Ubuntu/Components/plugin/ucalarm_p.h 2014-12-02 11:21:22 +0000
247+++ modules/Ubuntu/Components/plugin/ucalarm_p.h 2015-03-27 11:25:30 +0000
248@@ -59,6 +59,7 @@
249 virtual void reset() = 0;
250 virtual void completeSave() = 0;
251 virtual void completeCancel() = 0;
252+ virtual void copyAlarmData(const UCAlarm &other) = 0;
253
254 // common privates
255 UCAlarm *q_ptr;
256
257=== modified file 'modules/Ubuntu/Components/plugin/ucalarmmodel.cpp'
258--- modules/Ubuntu/Components/plugin/ucalarmmodel.cpp 2015-03-03 13:47:48 +0000
259+++ modules/Ubuntu/Components/plugin/ucalarmmodel.cpp 2015-03-27 11:25:30 +0000
260@@ -22,6 +22,7 @@
261 #include "alarmmanager_p.h"
262 #include <QtQml/QQmlPropertyMap>
263 #include <QtQml/QQmlInfo>
264+#include <QtQml/QQmlEngine>
265
266 /*!
267 * \qmltype AlarmModel
268@@ -213,7 +214,14 @@
269 */
270 UCAlarm* UCAlarmModel::get(int index)
271 {
272- return AlarmManager::instance().alarmAt(index);
273+ UCAlarm *alarm = AlarmManager::instance().alarmAt(index);
274+ if (alarm) {
275+ UCAlarm *tempAlarm = new UCAlarm(this);
276+ UCAlarmPrivate::get(tempAlarm)->copyAlarmData(*alarm);
277+ alarm = tempAlarm;
278+ QQmlEngine::setObjectOwnership(tempAlarm, QQmlEngine::JavaScriptOwnership);
279+ }
280+ return alarm;
281 }
282
283 /*!
284
285=== modified file 'modules/Ubuntu/Components/plugin/ucubuntushape.cpp'
286--- modules/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-03-10 13:25:19 +0000
287+++ modules/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-03-27 11:25:30 +0000
288@@ -162,6 +162,9 @@
289 m_geometry.setVertexDataPattern(vertexDataPattern);
290 setMaterial(&m_material);
291 setGeometry(&m_geometry);
292+#ifdef QSG_RUNTIME_DESCRIPTION
293+ qsgnode_set_description(this, QLatin1String("ubuntushape"));
294+#endif
295 }
296
297 // static
298
299=== modified file 'modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.cpp'
300--- modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.cpp 2015-03-10 12:16:04 +0000
301+++ modules/Ubuntu/Components/plugin/ucubuntushapeoverlay.cpp 2015-03-27 11:25:30 +0000
302@@ -67,6 +67,9 @@
303 m_geometry.setVertexDataPattern(ShapeNode::vertexDataPattern);
304 setMaterial(&m_material);
305 setGeometry(&m_geometry);
306+#ifdef QSG_RUNTIME_DESCRIPTION
307+ qsgnode_set_description(this, QLatin1String("ubuntushapeoverlay"));
308+#endif
309 }
310
311 // static
312
313=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_qquicklistview.py'
314--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_qquicklistview.py 2015-02-17 06:57:53 +0000
315+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_qquicklistview.py 2015-03-27 11:25:30 +0000
316@@ -1,6 +1,6 @@
317 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
318 #
319-# Copyright (C) 2012, 2013, 2014 Canonical Ltd.
320+# Copyright (C) 2012, 2013, 2014, 2015 Canonical Ltd.
321 #
322 # This program is free software; you can redistribute it and/or modify
323 # it under the terms of the GNU Lesser General Public License as published by
324@@ -15,8 +15,13 @@
325 # along with this program. If not, see <http://www.gnu.org/licenses/>.
326
327 import logging
328+import time
329
330-from autopilot import logging as autopilot_logging
331+from autopilot import (
332+ input,
333+ logging as autopilot_logging,
334+ platform
335+)
336 from autopilot.introspection import dbus
337
338 from ubuntuuitoolkit._custom_proxy_objects import _common, _flickable
339@@ -86,12 +91,6 @@
340 containers = self._get_containers()
341 return self._is_child_visible(child, containers)
342
343- def _get_first_item(self):
344- """Returns the first item from the ListView."""
345- items = self.get_children_by_type('QQuickItem')[0].get_children()
346- items = sorted(items, key=lambda item: item.globalRect.y)
347- return items[0]
348-
349 @autopilot_logging.log_action(logger.info)
350 def enable_select_mode(self):
351 """Default implementation to enable select mode. Performs a long tap
352@@ -107,3 +106,119 @@
353 except dbus.StateNotFoundError:
354 raise _common.ToolkitException(
355 'ListView delegate is not a ListItem or not in selectMode')
356+
357+ def _get_first_item(self):
358+ """Returns the first item from the ListView."""
359+ items = self.get_children_by_type('QQuickItem')[0].get_children()
360+ items = sorted(items, key=lambda item: item.globalRect.y)
361+ return items[0]
362+
363+ @autopilot_logging.log_action(logger.info)
364+ def drag_item(self, from_index, to_index):
365+ if platform.model() != 'Desktop':
366+ raise NotImplementedError(
367+ 'Drag does not work on the phone because of bug #1266601')
368+
369+ self._enable_drag_mode()
370+
371+ both_items_visible = (
372+ self._is_drag_panel_visible(from_index) and
373+ self._is_drag_panel_visible(to_index))
374+ if both_items_visible:
375+ self._drag_both_items_visible(from_index, to_index)
376+ else:
377+ self._drag_item_with_pagination(from_index, to_index)
378+ # wait 1 second till all animations complete
379+ time.sleep(1)
380+
381+ @autopilot_logging.log_action(logger.debug)
382+ def _enable_drag_mode(self):
383+ self.swipe_to_top()
384+ first_item = self._get_first_item()
385+ self.pointing_device.click_object(first_item, press_duration=2)
386+ self._get_drag_panel(wait=True)
387+
388+ def _is_drag_panel_visible(self, index):
389+ try:
390+ drag_panel = self._get_drag_panel(index)
391+ except:
392+ return False
393+ else:
394+ return self.is_child_visible(drag_panel)
395+
396+ def _get_drag_panel(self, index=0, wait=False):
397+ select_method = self.wait_select_single if wait else self.select_single
398+ try:
399+ return select_method(
400+ 'QQuickItem', objectName='drag_panel{}'.format(index))
401+ except ValueError:
402+ # While we are dragging, each panel item is duplicated.
403+ # A ValueError will be raised in this scenario. We can take
404+ # any of the returned elements, as they have the same position.
405+ return self.select_many(
406+ 'QQuickItem', objectName='drag_panel{}'.format(index))[0]
407+
408+ def _drag_both_items_visible(self, from_index, to_index):
409+ from_drag_handler = self._get_drag_panel(from_index)
410+ to_drag_handler = self._get_drag_panel(to_index)
411+ start_x, start_y = input.get_center_point(from_drag_handler)
412+ stop_x, stop_y = input.get_center_point(to_drag_handler)
413+ self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
414+
415+ def _drag_item_with_pagination(self, from_index, to_index):
416+ # the from_index might be invisible
417+ from_item = self._find_element('listitem{}'.format(from_index))
418+ from_item.swipe_into_view()
419+ from_drag_panel = self._get_drag_panel(from_index)
420+ containers = self._get_containers()
421+ if from_index < to_index:
422+ self._drag_downwards(from_drag_panel, to_index, containers)
423+ else:
424+ self._drag_upwards(from_drag_panel, to_index, containers)
425+
426+ def _drag_downwards(self, drag_panel, to_index, containers):
427+ visible_bottom = _flickable._get_visible_container_bottom(
428+ containers)
429+ start_x, start_y = input.get_center_point(drag_panel)
430+
431+ self.pointing_device.move(start_x, start_y)
432+ self.pointing_device.press()
433+ stop_x = start_x
434+ self.pointing_device.move(stop_x, visible_bottom)
435+ to_drag_panel = self._get_drag_panel(to_index, wait=True)
436+ while not self.is_child_visible(to_drag_panel):
437+ pass
438+ # stop moving
439+ h = to_drag_panel.height / 2
440+ self.pointing_device.move(stop_x, self.pointing_device.y - h)
441+ # move under the item with the to_index
442+ to_drag_panel = self._get_drag_panel(to_index - 1)
443+ stop_y = (
444+ to_drag_panel.globalRect.y +
445+ to_drag_panel.globalRect.height)
446+ self.pointing_device.move(stop_x, stop_y)
447+ self.pointing_device.release()
448+
449+ def _drag_upwards(self, handler, to_index, containers):
450+ visible_top = _flickable._get_visible_container_top(
451+ containers)
452+ start_x, start_y = input.get_center_point(handler)
453+
454+ self.pointing_device.move(start_x, start_y)
455+ self.pointing_device.press()
456+ stop_x = start_x
457+ # Header alters topMargin, therefore drag only till that edge
458+ self.pointing_device.move(stop_x, visible_top + self.topMargin)
459+ to_drag_panel = self._get_drag_panel(to_index, wait=True)
460+ while not self.is_child_visible(to_drag_panel):
461+ pass
462+ # stop moving
463+ h = to_drag_panel.height / 2
464+ self.pointing_device.move(stop_x, self.pointing_device.y + h)
465+ # move after the item with the to_index
466+ to_drag_panel = self._get_drag_panel(to_index)
467+ stop_y = (
468+ to_drag_panel.globalRect.y +
469+ to_drag_panel.globalRect.height)
470+ self.pointing_device.move(stop_x, stop_y)
471+ self.pointing_device.release()
472
473=== added file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_listitem.ListViewWithLiveDraggingTestCase.qml'
474--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_listitem.ListViewWithLiveDraggingTestCase.qml 1970-01-01 00:00:00 +0000
475+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_listitem.ListViewWithLiveDraggingTestCase.qml 2015-03-27 11:25:30 +0000
476@@ -0,0 +1,62 @@
477+/*
478+ * Copyright 2015 Canonical Ltd.
479+ *
480+ * This program is free software; you can redistribute it and/or modify
481+ * it under the terms of the GNU Lesser General Public License as published by
482+ * the Free Software Foundation; version 3.
483+ *
484+ * This program is distributed in the hope that it will be useful,
485+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
486+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
487+ * GNU Lesser General Public License for more details.
488+ *
489+ * You should have received a copy of the GNU Lesser General Public License
490+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
491+ */
492+
493+import QtQuick 2.0
494+import Ubuntu.Components 1.2
495+
496+MainView {
497+ width: units.gu(48)
498+ height: units.gu(60)
499+ objectName: "mainView"
500+
501+ Page {
502+ id: testPage
503+ objectName: "test_page"
504+ title: listView.ViewItems.dragMode ? "In drag mode" : "Test app"
505+ ListView {
506+ id: listView
507+ objectName: "test_view"
508+ ViewItems.objectName: "test_attached"
509+ ViewItems.onDragUpdated: {
510+ if (event.status == ListItemDrag.Moving) {
511+ model.move(event.from, event.to, 1)
512+ }
513+ }
514+
515+ anchors.fill: parent
516+ model: ListModel {
517+ Component.onCompleted: {
518+ for (var i = 0; i < 25; i++) {
519+ append({data: i});
520+ }
521+ }
522+ }
523+ moveDisplaced: Transition {
524+ UbuntuNumberAnimation {
525+ properties: "y";
526+ }
527+ }
528+ delegate: ListItem {
529+ objectName: "listitem" + index
530+ ListView.objectName: "bumm"
531+ onPressAndHold: ListView.view.ViewItems.dragMode = !ListView.view.ViewItems.dragMode
532+ Label {
533+ text: "List item #" + modelData
534+ }
535+ }
536+ }
537+ }
538+}
539
540=== added file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_listitem.ListViewWithoutLiveDraggingTestCase.qml'
541--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_listitem.ListViewWithoutLiveDraggingTestCase.qml 1970-01-01 00:00:00 +0000
542+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_listitem.ListViewWithoutLiveDraggingTestCase.qml 2015-03-27 11:25:30 +0000
543@@ -0,0 +1,65 @@
544+/*
545+ * Copyright 2015 Canonical Ltd.
546+ *
547+ * This program is free software; you can redistribute it and/or modify
548+ * it under the terms of the GNU Lesser General Public License as published by
549+ * the Free Software Foundation; version 3.
550+ *
551+ * This program is distributed in the hope that it will be useful,
552+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
553+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
554+ * GNU Lesser General Public License for more details.
555+ *
556+ * You should have received a copy of the GNU Lesser General Public License
557+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
558+ */
559+
560+import QtQuick 2.0
561+import Ubuntu.Components 1.2
562+
563+MainView {
564+ width: units.gu(48)
565+ height: units.gu(60)
566+ objectName: "mainView"
567+
568+ Page {
569+ id: testPage
570+ objectName: "test_page"
571+ title: listView.ViewItems.dragMode ? "In drag mode" : "Test app"
572+ ListView {
573+ id: listView
574+ objectName: "test_view"
575+ ViewItems.objectName: "test_attached"
576+ ViewItems.onDragUpdated: {
577+ if (event.status == ListItemDrag.Moving) {
578+ // disable live move.
579+ event.accept = false;
580+ } else if (event.status == ListItemDrag.Dropped) {
581+ model.move(event.from, event.to, 1)
582+ }
583+ }
584+
585+ anchors.fill: parent
586+ model: ListModel {
587+ Component.onCompleted: {
588+ for (var i = 0; i < 25; i++) {
589+ append({data: i});
590+ }
591+ }
592+ }
593+ moveDisplaced: Transition {
594+ UbuntuNumberAnimation {
595+ properties: "y";
596+ }
597+ }
598+ delegate: ListItem {
599+ objectName: "listitem" + index
600+ ListView.objectName: "bumm"
601+ onPressAndHold: ListView.view.ViewItems.dragMode = !ListView.view.ViewItems.dragMode
602+ Label {
603+ text: "List item #" + modelData
604+ }
605+ }
606+ }
607+ }
608+}
609
610=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_qquicklistview.py'
611--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_qquicklistview.py 2015-03-03 13:20:06 +0000
612+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_qquicklistview.py 2015-03-27 11:25:30 +0000
613@@ -19,6 +19,10 @@
614 except ImportError:
615 import mock
616
617+import os
618+
619+import testscenarios
620+from autopilot import platform
621 from autopilot.introspection import dbus
622
623 import ubuntuuitoolkit
624@@ -224,3 +228,75 @@
625
626 self.list_view.click_element('testListElement9')
627 self.assertEqual(self.label.text, 'testListElement9')
628+
629+
630+class QQuickListViewDraggingBaseTestCase(tests.QMLFileAppTestCase):
631+
632+ def setUp(self):
633+ path = os.path.abspath(__file__)
634+ dir_path = os.path.dirname(path)
635+ self.test_qml_file_path = os.path.join(
636+ dir_path, self.qml_file_name)
637+
638+ super(QQuickListViewDraggingBaseTestCase, self).setUp()
639+ self.list_view = self.main_view.select_single(
640+ ubuntuuitoolkit.QQuickListView, objectName='test_view')
641+
642+
643+class QQuickListViewDraggingTestCase(QQuickListViewDraggingBaseTestCase):
644+
645+ qml_file_name = 'test_listitem.ListViewWithLiveDraggingTestCase.qml'
646+
647+ def test_long_press_must_enable_drag_mode(self):
648+ list_item = self.list_view.select_single(
649+ 'UCListItem', objectName='listitem0')
650+ self.assertFalse(list_item.dragMode)
651+ self.list_view._enable_drag_mode()
652+ self.assertTrue(list_item.dragMode)
653+
654+
655+class QQuickListViewReorderingTestCase(QQuickListViewDraggingBaseTestCase):
656+
657+ dragging_scenarios = [
658+ ('with live dragging', {
659+ 'qml_file_name': (
660+ 'test_listitem.ListViewWithLiveDraggingTestCase.qml')}),
661+ ('without live dragging', {
662+ 'qml_file_name': (
663+ 'test_listitem.ListViewWithoutLiveDraggingTestCase.qml')}),
664+ ]
665+ reorder_scenarios = [
666+ ('both items visible, to bottom', {'from_index': 0, 'to_index': 1}),
667+ ('both items visible, to top', {'from_index': 1, 'to_index': 0}),
668+ ('both items visible, to bottom, first non visible', {
669+ 'from_index': 0, 'to_index': 7}),
670+ ('to item not visible, to top', {'from_index': 15, 'to_index': 0}),
671+ ('to item not visible, to middle down', {
672+ 'from_index': 0, 'to_index': 15}),
673+ ('to item not visible, to bottom', {'from_index': 0, 'to_index': 24})
674+ ]
675+ scenarios = testscenarios.multiply_scenarios(
676+ dragging_scenarios, reorder_scenarios)
677+
678+ def _find_item(self, index):
679+ object_name = 'listitem{}'.format(index)
680+ try:
681+ return self.list_view.select_single(objectName=object_name)
682+ except dbus.StateNotFoundError:
683+ return self.list_view._find_element(object_name)
684+
685+ def _get_item_text(self, index):
686+ item = self._find_item(index)
687+ return item.select_single('Label').text
688+
689+ def test_drag_item_must_reorder_list(self):
690+ if platform.model() != 'Desktop':
691+ self.skipTest(
692+ 'Drag does not work on the phone because of bug #1266601')
693+
694+ original_from_text = self._get_item_text(self.from_index)
695+
696+ self.list_view.drag_item(self.from_index, self.to_index)
697+
698+ self.assertEqual(
699+ original_from_text, self._get_item_text(self.to_index))
700
701=== modified file 'tests/unit_x11/tst_components/tst_components.pro'
702--- tests/unit_x11/tst_components/tst_components.pro 2014-08-01 15:26:23 +0000
703+++ tests/unit_x11/tst_components/tst_components.pro 2015-03-27 11:25:30 +0000
704@@ -7,4 +7,5 @@
705 SOURCES += tst_components.cpp tabsmodel.cpp
706 HEADERS += tabsmodel.h
707
708-OTHER_FILES += $$system(ls *.qml)
709+OTHER_FILES += $$system(ls *.qml) \
710+ tst_stress_alarmmodel.qml
711
712=== added file 'tests/unit_x11/tst_components/tst_stress_alarmmodel.qml'
713--- tests/unit_x11/tst_components/tst_stress_alarmmodel.qml 1970-01-01 00:00:00 +0000
714+++ tests/unit_x11/tst_components/tst_stress_alarmmodel.qml 2015-03-27 11:25:30 +0000
715@@ -0,0 +1,92 @@
716+/*
717+ * Copyright 2013 Canonical Ltd.
718+ *
719+ * This program is free software; you can redistribute it and/or modify
720+ * it under the terms of the GNU Lesser General Public License as published by
721+ * the Free Software Foundation; version 3.
722+ *
723+ * This program is distributed in the hope that it will be useful,
724+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
725+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
726+ * GNU Lesser General Public License for more details.
727+ *
728+ * You should have received a copy of the GNU Lesser General Public License
729+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
730+ */
731+
732+import QtQuick 2.0
733+import QtTest 1.0
734+import Ubuntu.Test 1.0
735+import Ubuntu.Components 1.2
736+
737+MainView {
738+ width: units.gu(40)
739+ height: units.gu(71)
740+
741+ AlarmModel {
742+ id: model
743+ }
744+
745+ Alarm {
746+ id: testAlarm
747+ }
748+
749+ UbuntuTestCase {
750+ name: "AlarmModelStressTest"
751+ when: windowShown
752+
753+ SignalSpy {
754+ id: modelSpy
755+ signalName: "modelReset"
756+ target: model
757+ }
758+
759+ property string testAlarmMessage: "test_"
760+
761+ function createAlarm(pattern, idx) {
762+ testAlarm.reset();
763+ testAlarm.message = pattern + idx;
764+ var dt = new Date();
765+ dt.setMinutes(dt.getMinutes() + 10);
766+ testAlarm.date = dt;
767+ modelSpy.signalName = "rowsInserted";
768+ testAlarm.save();
769+ modelSpy.wait();
770+ }
771+
772+ function clearTestAlarms(pattern) {
773+ var i = 0;
774+ modelSpy.signalName = "rowsRemoved";
775+ while (i < model.count) {
776+ var alarm = model.get(i);
777+ // this will fail if get() returns NULL
778+ if (alarm.message.indexOf(pattern) == 0) {
779+ alarm.cancel();
780+ modelSpy.wait();
781+ modelSpy.clear();
782+ i = 0;
783+ } else {
784+ i++;
785+ }
786+ }
787+ }
788+
789+ // need to create a huge amount of alarms then cleanone part of it
790+ function initTestCase() {
791+ for (var i = 0; i < 20; i++) {
792+ createAlarm(testAlarmMessage, i)
793+ }
794+ for (var i = 0; i < 40; i++) {
795+ createAlarm("testAlarm_", i)
796+ }
797+ }
798+ function cleanupTestCase() {
799+ clearTestAlarms(testAlarmMessage);
800+ }
801+
802+ function test_remove_alarms()
803+ {
804+ clearTestAlarms("testAlarm_");
805+ }
806+ }
807+}

Subscribers

People subscribed via source and target branches

to status/vote changes: