Merge lp:~aacid/unity8/testExpandableHeights into lp:unity8

Proposed by Albert Astals Cid
Status: Merged
Approved by: Andrea Cimitan
Approved revision: 1903
Merged at revision: 1913
Proposed branch: lp:~aacid/unity8/testExpandableHeights
Merge into: lp:unity8
Prerequisite: lp:~aacid/unity8/expandable_test_fixes
Diff against target: 236 lines (+148/-7)
4 files modified
qml/Dash/Previews/PreviewActions.qml (+1/-1)
qml/Dash/Previews/PreviewHeader.qml (+1/-1)
qml/Dash/Previews/PreviewRatingDisplay.qml (+1/-1)
tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml (+145/-4)
To merge this branch: bzr merge lp:~aacid/unity8/testExpandableHeights
Reviewer Review Type Date Requested Status
Andrea Cimitan (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+266876@code.launchpad.net

Commit message

Add a test that checks that items in an expandable are the correct size after expanding the expandable

Description of the change

 * Are there any related MPs required for this MP to build/function as expected?
No

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

 * Did you make sure that your branch does not contain spurious tags?
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?
N/A

To post a comment you must log in.
1903. By Albert Astals Cid

even -> event

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andrea Cimitan (cimi) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
y
 * Did CI run pass? If not, please explain why.
unrelated
 * Did you make sure that the branch does not contain spurious tags?
y

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Dash/Previews/PreviewActions.qml'
2--- qml/Dash/Previews/PreviewActions.qml 2015-02-12 10:44:27 +0000
3+++ qml/Dash/Previews/PreviewActions.qml 2015-08-04 14:01:54 +0000
4@@ -25,7 +25,7 @@
5 PreviewWidget {
6 id: root
7
8- height: row.height + units.gu(1)
9+ implicitHeight: row.height + units.gu(1)
10
11 Row {
12 id: row
13
14=== modified file 'qml/Dash/Previews/PreviewHeader.qml'
15--- qml/Dash/Previews/PreviewHeader.qml 2015-05-06 15:05:06 +0000
16+++ qml/Dash/Previews/PreviewHeader.qml 2015-08-04 14:01:54 +0000
17@@ -30,7 +30,7 @@
18 PreviewWidget {
19 id: root
20
21- height: childrenRect.height
22+ implicitHeight: childrenRect.height
23
24 Item {
25 id: headerRoot
26
27=== modified file 'qml/Dash/Previews/PreviewRatingDisplay.qml'
28--- qml/Dash/Previews/PreviewRatingDisplay.qml 2015-05-11 07:33:41 +0000
29+++ qml/Dash/Previews/PreviewRatingDisplay.qml 2015-08-04 14:01:54 +0000
30@@ -38,7 +38,7 @@
31
32 PreviewWidget {
33 id: root
34- height: childrenRect.height
35+ implicitHeight: childrenRect.height
36
37 Column {
38 anchors { left: parent.left; right: parent.right; }
39
40=== modified file 'tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml'
41--- tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml 2015-08-04 14:01:54 +0000
42+++ tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml 2015-08-04 14:01:54 +0000
43@@ -34,21 +34,122 @@
44 "values": [ [ "Long Label 1", "Value 1"], [ "Label 2", "Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
45 }
46
47+ property var actionsData: {
48+ "actions": [ {"label": "Some Label", "id": "someid"} ]
49+ }
50+
51+ property var audioData: {
52+ "tracks": [ { title: "Some track name", length: "30", source: "/not/existing/path/testsound1" } ]
53+ }
54+
55+ property var commentData: {
56+ "author": "Claire Thompson",
57+ "comment": "C.",
58+ "source": "../../graphics/avatars/amanda@12.png"
59+ }
60+
61+ property var commentInputData: {
62+ "submit-label": "TestSubmitLabel"
63+ }
64+
65+ property var galleryData: {
66+ "sources": [
67+ "../../graphics/phone_background.jpg",
68+ "../../graphics/tablet_background.jpg",
69+ "../../graphics/clock@18.png",
70+ "../../graphics/borked"
71+ ]
72+ }
73+
74+ property var headerData: {
75+ "title": "THE TITLE",
76+ "subtitle": "Something catchy"
77+ }
78+
79+ property var iconActionsData: {
80+ "actions": [ {"label": "10", "id": "s", "icon": Qt.resolvedUrl("../artwork/avatar@12.png") } ]
81+ }
82+
83+ property var imageData: {
84+ "source": "../../graphics/phone_background.jpg",
85+ "zoomable": false
86+ }
87+
88+ property var paymentsData: {
89+ "source": { "price" : 0.99, "currency": "USD", "store_item_id": "com.example.package" }
90+ }
91+
92+ property var progressData: {
93+ "type": "progress",
94+ "source": { "dbus-name" : "somename", "dbus-object": "somestring" }
95+ }
96+
97+ property var ratingInputData: {
98+ "visible": "both",
99+ "required": "both"
100+ }
101+
102+ property var ratingEditData: {
103+ "visible": "both",
104+ "required": "both",
105+ author: "Some dude",
106+ rating: 4.5,
107+ review: "Very cool app"
108+ }
109+
110+ property var reviewsData: {
111+ "reviews": [ { author: "Some dude", rating: 4.5, review: "Very cool app" } ]
112+ }
113+
114+ property var videoData: {
115+ "source": "",
116+ "screenshot": "../../../tests/qmltests/Components/tst_LazyImage/square.png"
117+ }
118+
119 ListModel {
120 id: widgetsModel
121 }
122
123+ ListModel {
124+ id: allWidgetsModel
125+ }
126+
127 property var widgetData: {
128 "title": "Title here",
129 "collapsed-widgets": 2,
130 "widgets": widgetsModel
131 }
132
133+ property var allWidgetsData: {
134+ "title": "Title here",
135+ "collapsed-widgets": 0,
136+ "widgets": allWidgetsModel
137+ }
138+
139+
140 Component.onCompleted: {
141 widgetsModel.append({"type": "text", "widgetId": "text1", "properties": { "text": longText }});
142 widgetsModel.append({"type": "table", "widgetId": "table1", "properties": tableData });
143 widgetsModel.append({"type": "text", "widgetId": "text3", "properties": { "text": shortText }});
144 widgetsModel.append({"type": "text", "widgetId": "text4", "properties": { "text": longText2 }});
145+
146+ allWidgetsModel.append({"type": "actions", "widgetId": "actions1", "properties": actionsData });
147+ allWidgetsModel.append({"type": "audio", "widgetId": "audio1", "properties": audioData });
148+ allWidgetsModel.append({"type": "comment", "widgetId": "comment1", "properties": commentData });
149+ allWidgetsModel.append({"type": "comment-input", "widgetId": "comment-input1", "properties": commentInputData });
150+ // "expandable" For now we're not testing inception of expandables
151+ allWidgetsModel.append({"type": "gallery", "widgetId": "gallery1", "properties": galleryData });
152+ allWidgetsModel.append({"type": "header", "widgetId": "header1", "properties": headerData });
153+ allWidgetsModel.append({"type": "icon-actions", "widgetId": "icon-actions1", "properties": iconActionsData } );
154+ allWidgetsModel.append({"type": "image", "widgetId": "image1", "properties": imageData });
155+ allWidgetsModel.append({"type": "payments", "widgetId": "payments1", "properties": paymentsData });
156+ allWidgetsModel.append({"type": "progress", "widgetId": "progress1", "properties": progressData });
157+ allWidgetsModel.append({"type": "rating-input", "widgetId": "rating-input1", "properties": ratingInputData });
158+ allWidgetsModel.append({"type": "rating-edit", "widgetId": "rating-edit1", "properties": ratingEditData });
159+ allWidgetsModel.append({"type": "reviews", "widgetId": "reviews1", "properties": reviewsData });
160+ allWidgetsModel.append({"type": "table", "widgetId": "table1", "properties": tableData });
161+ allWidgetsModel.append({"type": "text", "widgetId": "text1", "properties": { "text": longText }});
162+ allWidgetsModel.append({"type": "video", "widgetId": "video1", "properties": videoData });
163 }
164
165 PreviewWidgetFactory {
166@@ -58,6 +159,12 @@
167 widgetData: root.widgetData
168 }
169
170+ PreviewWidgetFactory {
171+ id: previewWidgetFactory
172+ anchors { left: parent.left; right: parent.right; top: previewExpandable.bottom }
173+ opacity: 0
174+ }
175+
176 UT.UnityTestCase {
177 name: "PreviewExpandableTest"
178 when: windowShown
179@@ -78,13 +185,10 @@
180 }
181
182 function init() {
183+ previewExpandable.widgetData = widgetData;
184 checkInitialState();
185 }
186
187- function test_collapsed_by_default() {
188- // Nothing init does this already
189- }
190-
191 function test_expand_collapse() {
192 var expandButton = findChild(previewExpandable, "expandButton")
193 mouseClick(expandButton);
194@@ -105,5 +209,42 @@
195
196 checkInitialState();
197 }
198+
199+ function test_all_widgets_height() {
200+ previewExpandable.widgetData = allWidgetsData;
201+
202+ var repeater = findChild(previewExpandable, "repeater")
203+ for (var i = 0; i < repeater.count; ++i) {
204+ tryCompare(repeater.itemAt(i), "height", 0);
205+ }
206+
207+ var expandButton = findChild(previewExpandable, "expandButton")
208+ mouseClick(expandButton);
209+
210+ var repeater = findChild(previewExpandable, "repeater")
211+ for (var i = 0; i < repeater.count; ++i) {
212+ previewWidgetFactory.active = false;
213+ wait(0); // spin the event loop otherwise we get warnings because the previous item from the
214+ // widget factory has still not been deleted and we change the widgetData
215+ previewWidgetFactory.widgetData = allWidgetsModel.get(i).properties;
216+ previewWidgetFactory.widgetType = allWidgetsModel.get(i).type;
217+ previewWidgetFactory.active = true;
218+
219+ // Wait for the height ot settle by waiting twice the time of the
220+ // longest of the height behaviour animations
221+ wait(UbuntuAnimation.SnapDuration * 2);
222+
223+ // Check the item inside the expandable has the same height
224+ // as the one straight from the factory
225+ verify(repeater.itemAt(i).height > 0);
226+ tryCompare(repeater.itemAt(i), "height", previewWidgetFactory.height);
227+ }
228+
229+ mouseClick(expandButton);
230+ compare(previewExpandable.expanded, false);
231+ for (var i = 0; i < repeater.count; ++i) {
232+ tryCompare(repeater.itemAt(i), "height", 0);
233+ }
234+ }
235 }
236 }

Subscribers

People subscribed via source and target branches