@@ -34,21 +34,122 @@ Rectangle {
34 "values": [ [ "Long Label 1", "Value 1"], [ "Label 2", "Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
34 "values": [ [ "Long Label 1", "Value 1"], [ "Label 2", "Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
37+ property var actionsData: {
38+ "actions": [ {"label": "Some Label", "id": "someid"} ]
41+ property var audioData: {
42+ "tracks": [ { title: "Some track name", length: "30", source: "/not/existing/path/testsound1" } ]
45+ property var commentData: {
46+ "author": "Claire Thompson",
48+ "source": "../../graphics/avatars/amanda@12.png"
51+ property var commentInputData: {
52+ "submit-label": "TestSubmitLabel"
55+ property var galleryData: {
57+ "../../graphics/phone_background.jpg",
58+ "../../graphics/tablet_background.jpg",
59+ "../../graphics/clock@18.png",
60+ "../../graphics/borked"
64+ property var headerData: {
65+ "title": "THE TITLE",
66+ "subtitle": "Something catchy"
69+ property var iconActionsData: {
70+ "actions": [ {"label": "10", "id": "s", "icon": Qt.resolvedUrl("../artwork/avatar@12.png") } ]
73+ property var imageData: {
74+ "source": "../../graphics/phone_background.jpg",
78+ property var paymentsData: {
79+ "source": { "price" : 0.99, "currency": "USD", "store_item_id": "com.example.package" }
82+ property var progressData: {
84+ "source": { "dbus-name" : "somename", "dbus-object": "somestring" }
87+ property var ratingInputData: {
92+ property var ratingEditData: {
97+ review: "Very cool app"
100+ property var reviewsData: {
101+ "reviews": [ { author: "Some dude", rating: 4.5, review: "Very cool app" } ]
104+ property var videoData: {
106+ "screenshot": "../../../tests/qmltests/Components/tst_LazyImage/square.png"
37 ListModel {
109 ListModel {
38 id: widgetsModel
110 id: widgetsModel
41 property var widgetData: {
117 property var widgetData: {
42 "title": "Title here",
118 "title": "Title here",
43 "collapsed-widgets": 2,
119 "collapsed-widgets": 2,
44 "widgets": widgetsModel
120 "widgets": widgetsModel
123+ property var allWidgetsData: {
124+ "title": "Title here",
125+ "collapsed-widgets": 0,
126+ "widgets": allWidgetsModel
47 Component.onCompleted: {
130 Component.onCompleted: {
48 widgetsModel.append({"type": "text", "widgetId": "text1", "properties": { "text": longText }});
131 widgetsModel.append({"type": "text", "widgetId": "text1", "properties": { "text": longText }});
49 widgetsModel.append({"type": "table", "widgetId": "table1", "properties": tableData });
132 widgetsModel.append({"type": "table", "widgetId": "table1", "properties": tableData });
50 widgetsModel.append({"type": "text", "widgetId": "text3", "properties": { "text": shortText }});
133 widgetsModel.append({"type": "text", "widgetId": "text3", "properties": { "text": shortText }});
51 widgetsModel.append({"type": "text", "widgetId": "text4", "properties": { "text": longText2 }});
134 widgetsModel.append({"type": "text", "widgetId": "text4", "properties": { "text": longText2 }});
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 });
54 PreviewWidgetFactory {
155 PreviewWidgetFactory {
@@ -58,6 +159,12 @@ Rectangle {
58 widgetData: root.widgetData
159 widgetData: root.widgetData
162+ PreviewWidgetFactory {
163+ id: previewWidgetFactory
164+ anchors { left: parent.left; right: parent.right; top: previewExpandable.bottom }
61 UT.UnityTestCase {
168 UT.UnityTestCase {
62 name: "PreviewExpandableTest"
169 name: "PreviewExpandableTest"
63 when: windowShown
170 when: windowShown
@@ -78,13 +185,10 @@ Rectangle {
80 function init() {
187 function init() {
188+ previewExpandable.widgetData = widgetData;
81 checkInitialState();
189 checkInitialState();
84− function test_collapsed_by_default() {
85− // Nothing init does this already
88 function test_expand_collapse() {
192 function test_expand_collapse() {
89 var expandButton = findChild(previewExpandable, "expandButton")
193 var expandButton = findChild(previewExpandable, "expandButton")
90 mouseClick(expandButton);
194 mouseClick(expandButton);
@@ -105,5 +209,42 @@ Rectangle {
106 checkInitialState();
210 checkInitialState();
213+ function test_all_widgets_height() {
214+ previewExpandable.widgetData = allWidgetsData;
216+ var repeater = findChild(previewExpandable, "repeater")
217+ for (var i = 0; i < repeater.count; ++i) {
218+ tryCompare(repeater.itemAt(i), "height", 0);
221+ var expandButton = findChild(previewExpandable, "expandButton")
222+ mouseClick(expandButton);
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;
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);
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);
243+ mouseClick(expandButton);
244+ compare(previewExpandable.expanded, false);
245+ for (var i = 0; i < repeater.count; ++i) {
246+ tryCompare(repeater.itemAt(i), "height", 0);