Merge lp:~zsombi/ubuntu-ui-toolkit/fixActionListTrunk into lp:ubuntu-ui-toolkit

Proposed by Zsombor Egri
Status: Merged
Approved by: Zoltan Balogh
Approved revision: 1356
Merged at revision: 1356
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/fixActionListTrunk
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 196 lines (+95/-25)
5 files modified
components.api (+2/-1)
src/Ubuntu/UbuntuToolkit/actionlist.cpp (+3/-0)
src/Ubuntu/UbuntuToolkit/actionlist_p.h (+4/-1)
tests/unit/components/tst_action.qml (+0/-23)
tests/unit/visual/tst_actionlist.13.qml (+86/-0)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/fixActionListTrunk
Reviewer Review Type Date Requested Status
Olivier Tilloy (community) Approve
Zoltan Balogh Approve
Review via email: mp+305845@code.launchpad.net

Commit message

Fix ActionList API break.

Description of the change

Fix ActionList API break.

To post a comment you must log in.
Revision history for this message
Zoltan Balogh (bzoltan) :
review: Approve
Revision history for this message
Olivier Tilloy (osomon) wrote :

Fixes webbrowser-app context menus and its unit tests.

review: Approve

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 2016-08-22 16:01:43 +0000
3+++ components.api 2016-09-15 15:12:08 +0000
4@@ -64,7 +64,8 @@
5 property list<Action> actions
6 default property list<Action> children
7 Ubuntu.Components.ActionList 1.3 ActionList: QtObject
8- default property list<Action> actions
9+ property list<Action> actions
10+ default property list<Action> children
11 signal added(Action action)
12 signal removed(Action action)
13 function addAction(Action action)
14
15=== modified file 'src/Ubuntu/UbuntuToolkit/actionlist.cpp'
16--- src/Ubuntu/UbuntuToolkit/actionlist.cpp 2016-07-18 14:54:46 +0000
17+++ src/Ubuntu/UbuntuToolkit/actionlist.cpp 2016-09-15 15:12:08 +0000
18@@ -79,6 +79,7 @@
19 }
20 m_actions.append(action);
21 Q_EMIT added(action);
22+ Q_EMIT childrenChanged();
23 }
24
25 /*!
26@@ -94,6 +95,7 @@
27 }
28 if (m_actions.removeOne(action)) {
29 Q_EMIT removed(action);
30+ Q_EMIT childrenChanged();
31 }
32 }
33
34@@ -134,6 +136,7 @@
35 ActionList *actionList = qobject_cast<ActionList*>(list->object);
36 if (actionList) {
37 actionList->m_actions.clear();
38+ Q_EMIT actionList->childrenChanged();
39 }
40 }
41
42
43=== modified file 'src/Ubuntu/UbuntuToolkit/actionlist_p.h'
44--- src/Ubuntu/UbuntuToolkit/actionlist_p.h 2016-07-18 14:54:46 +0000
45+++ src/Ubuntu/UbuntuToolkit/actionlist_p.h 2016-09-15 15:12:08 +0000
46@@ -28,7 +28,9 @@
47 {
48 Q_OBJECT
49 Q_PROPERTY(QQmlListProperty<UT_PREPEND_NAMESPACE(UCAction)> actions READ actions)
50- Q_CLASSINFO("DefaultProperty", "actions")
51+ // children alias
52+ Q_PROPERTY(QQmlListProperty<UT_PREPEND_NAMESPACE(UCAction)> children READ actions NOTIFY childrenChanged)
53+ Q_CLASSINFO("DefaultProperty", "children")
54 public:
55 explicit ActionList(QObject *parent = 0);
56
57@@ -41,6 +43,7 @@
58 void removeAction(UT_PREPEND_NAMESPACE(UCAction) *action);
59
60 Q_SIGNALS:
61+ void childrenChanged();
62 void added(UCAction *action);
63 void removed(UCAction *action);
64
65
66=== modified file 'tests/unit/components/tst_action.qml'
67--- tests/unit/components/tst_action.qml 2016-06-24 13:07:32 +0000
68+++ tests/unit/components/tst_action.qml 2016-09-15 15:12:08 +0000
69@@ -185,17 +185,6 @@
70 compare(checkableAction.checked, false, "Non-checkable action should never be checked");
71 }
72
73- function test_actionlist() {
74- verify(actionList.actions.length, 2, "Default actions not added to actionList");
75- }
76-
77- function test_actionlist_dynamic_actions() {
78- actionList.addAction(dynamicListAction);
79- verify(actionList.actions.length, 3, "Dynamic action not added to actionList");
80- actionList.removeAction(dynamicListAction);
81- verify(actionList.actions.length, 2, "Dynamic action not remove from actionList");
82- }
83-
84 function test_exclusive_group() {
85 compare(exclusiveGroup.actions.length, 3, "Incorrect number of actions");
86 }
87@@ -311,18 +300,6 @@
88 checkable: true
89 }
90
91- ActionList {
92- id: actionList
93- Action {
94- }
95- Action {
96- }
97- }
98-
99- Action {
100- id: dynamicListAction
101- }
102-
103 ExclusiveGroup {
104 id: exclusiveGroup
105 Action {
106
107=== added file 'tests/unit/visual/tst_actionlist.13.qml'
108--- tests/unit/visual/tst_actionlist.13.qml 1970-01-01 00:00:00 +0000
109+++ tests/unit/visual/tst_actionlist.13.qml 2016-09-15 15:12:08 +0000
110@@ -0,0 +1,86 @@
111+/*
112+ * Copyright 2016 Canonical Ltd.
113+ *
114+ * This program is free software; you can redistribute it and/or modify
115+ * it under the terms of the GNU Lesser General Public License as published by
116+ * the Free Software Foundation; version 3.
117+ *
118+ * This program is distributed in the hope that it will be useful,
119+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
120+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
121+ * GNU Lesser General Public License for more details.
122+ *
123+ * You should have received a copy of the GNU Lesser General Public License
124+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
125+ */
126+
127+import QtTest 1.0
128+import Ubuntu.Test 1.3
129+import Ubuntu.Components 1.3
130+import QtQuick 2.4
131+import Ubuntu.Components.Popups 1.3
132+
133+Button {
134+ id: root
135+ width: units.gu(50)
136+ height: units.gu(50)
137+
138+ property Item popup: null
139+
140+ Component {
141+ id: menuFactory
142+ ActionSelectionPopover {
143+ delegate: ListItemLayout {
144+ property Action action
145+ title.text: action.text
146+ }
147+
148+ actions: ActionList {
149+ Action {
150+ objectName: "foo"
151+ text: "foo"
152+ }
153+ Action {
154+ objectName: "bar"
155+ text: "bar"
156+ }
157+ }
158+ }
159+ }
160+ onClicked: popup = PopupUtils.open(menuFactory, root)
161+
162+ ActionList {
163+ id: actionList
164+ Action {
165+ }
166+ Action {
167+ }
168+ }
169+
170+ Action {
171+ id: dynamicListAction
172+ }
173+
174+ UbuntuTestCase {
175+ when: windowShown
176+
177+ function test_actionlist() {
178+ verify(actionList.actions.length, 2, "Default actions not added to actionList");
179+ }
180+
181+ function test_actionlist_dynamic_actions() {
182+ actionList.addAction(dynamicListAction);
183+ verify(actionList.actions.length, 3, "Dynamic action not added to actionList");
184+ actionList.removeAction(dynamicListAction);
185+ verify(actionList.actions.length, 2, "Dynamic action not remove from actionList");
186+ }
187+
188+ function test_bug1623841() {
189+ mouseClick(root, centerOf(root).x, centerOf(root).y);
190+ waitForRendering(root.popup, 500);
191+ // check if the delegates are shown
192+ verify(findChild(root.popup, "foo_button"));
193+ verify(findChild(root.popup, "bar_button"));
194+ }
195+ }
196+}

Subscribers

People subscribed via source and target branches

to status/vote changes: