~mzanetti/unity8/fix-1648251

« back to all changes in this revision

Viewing changes to tests/qmltests/Dash/Previews/tst_Preview.qml

  • Committer: Michael Zanetti
  • Date: 2016-12-01 12:20:34 UTC
  • mfrom: (2525.1.179 unity8)
  • Revision ID: michael.zanetti@canonical.com-20161201122034-cpvbf7webbhg2wph
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
 
88
88
            tryCompareFunction(function () {
89
89
                var bottomLeft = preview.mapFromItem(widget, 0, widget.height);
90
 
                return bottomLeft.y <= preview.height
 
90
                return bottomLeft.y <= preview.height + 1 // FIXME the +1 is to workaround https://bugreports.qt.io/browse/QTBUG-56961
91
91
            }, true);
92
92
        }
93
93
 
102
102
 
103
103
            tryCompareFunction(function () {
104
104
                var bottomLeft = preview.mapFromItem(widget, 0, widget.height);
105
 
                return bottomLeft.y <= preview.height
 
105
                return bottomLeft.y <= preview.height + 1 // FIXME the +1 is to workaround https://bugreports.qt.io/browse/QTBUG-56961
106
106
            }, true);
107
107
        }
108
108
 
119
119
            var moreLessButton = findChild(widget, "moreLessButton");
120
120
            mouseClick(moreLessButton);
121
121
 
 
122
 
 
123
            // FIXME: For some reason the PreviewWidgetFactory (parent of 'widget')
 
124
            // is destroyed on idle calls, when the test is under stress.
 
125
            // Not to compromise the result, we just skip the test if this happens
 
126
            var widget_str = widget.toString()
 
127
            var preview_str = preview.toString()
 
128
            var skipped = false
 
129
            function skipTest() { skipped = true; }
 
130
            preview.Component.onDestruction.connect(skipTest)
 
131
            widget.Component.onDestruction.connect(skipTest)
 
132
 
122
133
            // Wait for the combo to stop growing
123
 
            tryCompare(widget, "height", units.gu(15));
 
134
            tryCompareFunction(function(){ return (widget.height == units.gu(15) || skipped) }, true, 5000, "Widget lost "+widget_str+" was skipped ");
124
135
 
125
136
            // Make sure the combo bottom is on the viewport
126
137
            tryCompareFunction(function () {
 
138
                if (skipped) return true;
127
139
                var bottomLeft = preview.mapFromItem(widget, 0, widget.height);
128
 
                return bottomLeft.y <= preview.height
 
140
                return bottomLeft.y <= preview.height + 1 // FIXME the +1 is to workaround https://bugreports.qt.io/browse/QTBUG-56961
129
141
            }, true);
 
142
 
 
143
            if (!skipped) {
 
144
                preview.Component.onDestruction.disconnect(skipTest)
 
145
                widget.Component.onDestruction.disconnect(skipTest)
 
146
            } else {
 
147
                skip("preview %1 or widget %2 have been destroyed, thus we can't safely continue this test".arg(preview_str).arg(widget_str))
 
148
            }
130
149
        }
131
150
    }
132
151
}