on xenial help sign in
Test case fixed for tst_PreviewExpandable and don't bind widgetData[expanded]

to expanded property

commit74fad7a7efebcaa528496993500f8c826da395c1 authorGary.Wzl <Gary.Wang@canonical.com> dateWed 26 Aug 2015, 14:18 (11 years ago) parentf1c2ae6
3 files changed+8−7
qml/Dash/Previews/PreviewExpandable.qml+5−2 qml/Dash/Previews/PreviewWidgetFactory.qml+1−1 tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml+2−4
qml/Dash/Previews/PreviewExpandable.qml+5−2
@@ -25,7 +25,7 @@ import "../../Components"
2525 all the widgets are shown, when collapsed only the first
2626 widgetData["collapsed-widgets"] are shown. It has a title that comes
2727 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.
2929 It's in unexpanded mode by default.
3030 */
3131
@@ -33,7 +33,10 @@ PreviewWidget {
3333 id: root
3434 implicitHeight: childrenRect.height
3535
36− expanded: widgetData["expanded"] == undefined? false : widgetData["expanded"];
36+ property var initialExpanded:widgetData["expanded"]
37+ onInitialExpandedChanged: {
38+ expanded = initialExpanded === undefined? false : initialExpanded;
39+ }
3740
3841 Label {
3942 id: titleLabel
qml/Dash/Previews/PreviewWidgetFactory.qml+1−1
@@ -77,7 +77,7 @@ Loader {
7777 item.scopeStyle = Qt.binding(function() { return root.scopeStyle } )
7878
7979 if (widgetType !== "expandable")
80− item.expanded = Qt.binding(function() { return root.expanded } )
80+ item.expanded = Qt.binding(function() { return root.expanded } )
8181 }
8282
8383 Connections {
tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml+2−4
@@ -123,8 +123,6 @@ Rectangle {
123123 function test_expand_collapse_when_initialized() {
124124 previewExpandable.widgetData = widgetData1;
125125
126− compare(previewExpandable.expanded, true);
127−
128126 var repeater = findChild(previewExpandable, "repeater")
129127 compare(repeater.count, 4)
130128
@@ -141,8 +139,6 @@ Rectangle {
141139 function test_collapsed_when_initialized() {
142140 previewExpandable.widgetData = widgetData2;
143141
144− compare(previewExpandable.expanded, false);
145−
146142 var repeater = findChild(previewExpandable, "repeater")
147143 compare(repeater.count, 4)
148144
@@ -152,6 +148,8 @@ Rectangle {
152148 compare (repeater.itemAt(3).visible, false);
153149 compare (repeater.itemAt(0).expanded, false);
154150 compare (repeater.itemAt(1).expanded, false);
151+ compare (repeater.itemAt(2).expanded, false);
152+ compare (repeater.itemAt(3).expanded, false);
155153 }
156154 }
157155}