@@ -34,21 +34,122 @@ Rectangle {
3434 "values": [ [ "Long Label 1", "Value 1"], [ "Label 2", "Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
3535 }
3636
37+ property var actionsData: {
38+ "actions": [ {"label": "Some Label", "id": "someid"} ]
39+ }
40+
41+ property var audioData: {
42+ "tracks": [ { title: "Some track name", length: "30", source: "/not/existing/path/testsound1" } ]
43+ }
44+
45+ property var commentData: {
46+ "author": "Claire Thompson",
47+ "comment": "C.",
48+ "source": "../../graphics/avatars/amanda@12.png"
49+ }
50+
51+ property var commentInputData: {
52+ "submit-label": "TestSubmitLabel"
53+ }
54+
55+ property var galleryData: {
56+ "sources": [
57+ "../../graphics/phone_background.jpg",
58+ "../../graphics/tablet_background.jpg",
59+ "../../graphics/clock@18.png",
60+ "../../graphics/borked"
61+ ]
62+ }
63+
64+ property var headerData: {
65+ "title": "THE TITLE",
66+ "subtitle": "Something catchy"
67+ }
68+
69+ property var iconActionsData: {
70+ "actions": [ {"label": "10", "id": "s", "icon": Qt.resolvedUrl("../artwork/avatar@12.png") } ]
71+ }
72+
73+ property var imageData: {
74+ "source": "../../graphics/phone_background.jpg",
75+ "zoomable": false
76+ }
77+
78+ property var paymentsData: {
79+ "source": { "price" : 0.99, "currency": "USD", "store_item_id": "com.example.package" }
80+ }
81+
82+ property var progressData: {
83+ "type": "progress",
84+ "source": { "dbus-name" : "somename", "dbus-object": "somestring" }
85+ }
86+
87+ property var ratingInputData: {
88+ "visible": "both",
89+ "required": "both"
90+ }
91+
92+ property var ratingEditData: {
93+ "visible": "both",
94+ "required": "both",
95+ author: "Some dude",
96+ rating: 4.5,
97+ review: "Very cool app"
98+ }
99+
100+ property var reviewsData: {
101+ "reviews": [ { author: "Some dude", rating: 4.5, review: "Very cool app" } ]
102+ }
103+
104+ property var videoData: {
105+ "source": "",
106+ "screenshot": "../../../tests/qmltests/Components/tst_LazyImage/square.png"
107+ }
108+
37109 ListModel {
38110 id: widgetsModel
39111 }
40112
113+ ListModel {
114+ id: allWidgetsModel
115+ }
116+
41117 property var widgetData: {
42118 "title": "Title here",
43119 "collapsed-widgets": 2,
44120 "widgets": widgetsModel
45121 }
46122
123+ property var allWidgetsData: {
124+ "title": "Title here",
125+ "collapsed-widgets": 0,
126+ "widgets": allWidgetsModel
127+ }
128+
129+
47130 Component.onCompleted: {
48131 widgetsModel.append({"type": "text", "widgetId": "text1", "properties": { "text": longText }});
49132 widgetsModel.append({"type": "table", "widgetId": "table1", "properties": tableData });
50133 widgetsModel.append({"type": "text", "widgetId": "text3", "properties": { "text": shortText }});
51134 widgetsModel.append({"type": "text", "widgetId": "text4", "properties": { "text": longText2 }});
135+
136+ allWidgetsModel.append({"type": "actions", "widgetId": "actions1", "properties": actionsData });
137+ allWidgetsModel.append({"type": "audio", "widgetId": "audio1", "properties": audioData });
138+ allWidgetsModel.append({"type": "comment", "widgetId": "comment1", "properties": commentData });
139+ allWidgetsModel.append({"type": "comment-input", "widgetId": "comment-input1", "properties": commentInputData });
140+ // "expandable" For now we're not testing inception of expandables
141+ allWidgetsModel.append({"type": "gallery", "widgetId": "gallery1", "properties": galleryData });
142+ allWidgetsModel.append({"type": "header", "widgetId": "header1", "properties": headerData });
143+ allWidgetsModel.append({"type": "icon-actions", "widgetId": "icon-actions1", "properties": iconActionsData } );
144+ allWidgetsModel.append({"type": "image", "widgetId": "image1", "properties": imageData });
145+ allWidgetsModel.append({"type": "payments", "widgetId": "payments1", "properties": paymentsData });
146+ allWidgetsModel.append({"type": "progress", "widgetId": "progress1", "properties": progressData });
147+ allWidgetsModel.append({"type": "rating-input", "widgetId": "rating-input1", "properties": ratingInputData });
148+ allWidgetsModel.append({"type": "rating-edit", "widgetId": "rating-edit1", "properties": ratingEditData });
149+ allWidgetsModel.append({"type": "reviews", "widgetId": "reviews1", "properties": reviewsData });
150+ allWidgetsModel.append({"type": "table", "widgetId": "table1", "properties": tableData });
151+ allWidgetsModel.append({"type": "text", "widgetId": "text1", "properties": { "text": longText }});
152+ allWidgetsModel.append({"type": "video", "widgetId": "video1", "properties": videoData });
52153 }
53154
54155 PreviewWidgetFactory {
@@ -58,6 +159,12 @@ Rectangle {
58159 widgetData: root.widgetData
59160 }
60161
162+ PreviewWidgetFactory {
163+ id: previewWidgetFactory
164+ anchors { left: parent.left; right: parent.right; top: previewExpandable.bottom }
165+ opacity: 0
166+ }
167+
61168 UT.UnityTestCase {
62169 name: "PreviewExpandableTest"
63170 when: windowShown
@@ -78,13 +185,10 @@ Rectangle {
78185 }
79186
80187 function init() {
188+ previewExpandable.widgetData = widgetData;
81189 checkInitialState();
82190 }
83191
84− function test_collapsed_by_default() {
85− // Nothing init does this already
86− }
87−
88192 function test_expand_collapse() {
89193 var expandButton = findChild(previewExpandable, "expandButton")
90194 mouseClick(expandButton);
@@ -105,5 +209,42 @@ Rectangle {
105209
106210 checkInitialState();
107211 }
212+
213+ function test_all_widgets_height() {
214+ previewExpandable.widgetData = allWidgetsData;
215+
216+ var repeater = findChild(previewExpandable, "repeater")
217+ for (var i = 0; i < repeater.count; ++i) {
218+ tryCompare(repeater.itemAt(i), "height", 0);
219+ }
220+
221+ var expandButton = findChild(previewExpandable, "expandButton")
222+ mouseClick(expandButton);
223+
224+ var repeater = findChild(previewExpandable, "repeater")
225+ for (var i = 0; i < repeater.count; ++i) {
226+ previewWidgetFactory.active = false;
227+ wait(0); // spin the event loop otherwise we get warnings because the previous item from the
228+ // widget factory has still not been deleted and we change the widgetData
229+ previewWidgetFactory.widgetData = allWidgetsModel.get(i).properties;
230+ previewWidgetFactory.widgetType = allWidgetsModel.get(i).type;
231+ previewWidgetFactory.active = true;
232+
233+ // Wait for the height ot settle by waiting twice the time of the
234+ // longest of the height behaviour animations
235+ wait(UbuntuAnimation.SnapDuration * 2);
236+
237+ // Check the item inside the expandable has the same height
238+ // as the one straight from the factory
239+ verify(repeater.itemAt(i).height > 0);
240+ tryCompare(repeater.itemAt(i), "height", previewWidgetFactory.height);
241+ }
242+
243+ mouseClick(expandButton);
244+ compare(previewExpandable.expanded, false);
245+ for (var i = 0; i < repeater.count; ++i) {
246+ tryCompare(repeater.itemAt(i), "height", 0);
247+ }
248+ }
108249 }
109250}