on xenial help sign in
Test case fixed for tst_PreviewExpandable and don't bind widgetData[expanded]
74fad7aGary.Wzl
qml/Dash/Previews/PreviewExpandable.qml+5−2
@@ -25,7 +25,7 @@ import "../../Components"
25 all the widgets are shown, when collapsed only the first
25 all the widgets are shown, when collapsed only the first
26 widgetData["collapsed-widgets"] are shown. It has a title that comes
26 widgetData["collapsed-widgets"] are shown. It has a title that comes
27 in via widgetData["title"]. This widget expands all child widgets
27 in via widgetData["title"]. This widget expands all child widgets
28− when construction by specifying widgetData["expanded"] == true.
28+ when initialized by specifying widgetData["expanded"] == true.
29 It's in unexpanded mode by default.
29 It's in unexpanded mode by default.
30 */
30 */
31
31
@@ -33,7 +33,10 @@ PreviewWidget {
33 id: root
33 id: root
34 implicitHeight: childrenRect.height
34 implicitHeight: childrenRect.height
35
35
36− expanded: widgetData["expanded"] == undefined? false : widgetData["expanded"];
36+ property var initialExpanded:widgetData["expanded"]
37+ onInitialExpandedChanged: {
38+ expanded = initialExpanded === undefined? false : initialExpanded;
39+ }
37
40
38 Label {
41 Label {
39 id: titleLabel
42 id: titleLabel
qml/Dash/Previews/PreviewWidgetFactory.qml+1−1
@@ -77,7 +77,7 @@ Loader {
77 item.scopeStyle = Qt.binding(function() { return root.scopeStyle } )
77 item.scopeStyle = Qt.binding(function() { return root.scopeStyle } )
78
78
79 if (widgetType !== "expandable")
79 if (widgetType !== "expandable")
80− item.expanded = Qt.binding(function() { return root.expanded } )
80+ item.expanded = Qt.binding(function() { return root.expanded } )
81 }
81 }
82
82
83 Connections {
83 Connections {
tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml+2−4
@@ -123,8 +123,6 @@ Rectangle {
123 function test_expand_collapse_when_initialized() {
123 function test_expand_collapse_when_initialized() {
124 previewExpandable.widgetData = widgetData1;
124 previewExpandable.widgetData = widgetData1;
125
125
126− compare(previewExpandable.expanded, true);
127−
128 var repeater = findChild(previewExpandable, "repeater")
126 var repeater = findChild(previewExpandable, "repeater")
129 compare(repeater.count, 4)
127 compare(repeater.count, 4)
130
128
@@ -141,8 +139,6 @@ Rectangle {
141 function test_collapsed_when_initialized() {
139 function test_collapsed_when_initialized() {
142 previewExpandable.widgetData = widgetData2;
140 previewExpandable.widgetData = widgetData2;
143
141
144− compare(previewExpandable.expanded, false);
145−
146 var repeater = findChild(previewExpandable, "repeater")
142 var repeater = findChild(previewExpandable, "repeater")
147 compare(repeater.count, 4)
143 compare(repeater.count, 4)
148
144
@@ -152,6 +148,8 @@ Rectangle {
152 compare (repeater.itemAt(3).visible, false);
148 compare (repeater.itemAt(3).visible, false);
153 compare (repeater.itemAt(0).expanded, false);
149 compare (repeater.itemAt(0).expanded, false);
154 compare (repeater.itemAt(1).expanded, false);
150 compare (repeater.itemAt(1).expanded, false);
151+ compare (repeater.itemAt(2).expanded, false);
152+ compare (repeater.itemAt(3).expanded, false);
155 }
153 }
156 }
154 }
157}
155}