on xenial help sign in
fix tests, add another
commit6c5ea7ac027dca8091b2bef53b9e8d14123d2f4f authorMichael Zanetti <michael.zanetti@canonical.com> dateMon 28 Sep 2015, 18:38 (11 years ago) parent08c984f
1 file changed+35−2
tests/qmltests/Stages/tst_WindowResizeArea.qml+35−2
tests/qmltests/Stages/tst_WindowResizeArea.qml+35−2
@@ -44,8 +44,11 @@ Item {
4444 width: units.gu(20)
4545 property int windowHeight: height
4646 property int windowWidth: width
47− onWindowHeightChanged: height = windowHeight
48− onWindowWidthChanged: width = windowWidth
47+ state: "normal"
48+
49+ function maximize() {
50+ state = "maximized"
51+ }
4952
5053 WindowResizeArea {
5154 id: windowResizeArea
@@ -214,5 +217,35 @@ Item {
214217 tryCompare(fakeWindow, "width", initialWindowWidth);
215218 tryCompare(fakeWindow, "height", initialWindowHeight);
216219 }
220+
221+ function test_saveRestoreMaximized() {
222+ var initialWindowX = fakeWindow.x;
223+ var initialWindowY = fakeWindow.y;
224+
225+ var moveDelta = units.gu(5);
226+
227+ fakeWindow.x = initialWindowX + moveDelta
228+ fakeWindow.y = initialWindowY + moveDelta
229+
230+ // Now change the state to maximized. The window should not keep updating the stored values
231+ fakeWindow.state = "maximized"
232+ fakeWindow.x = 31415 // 0 is too risky to pass the test even when broken
233+ fakeWindow.y = 31415
234+
235+ // This will destroy the window and recreate it
236+ windowLoader.active = false;
237+ waitForRendering(root);
238+ windowLoader.active = true;
239+
240+ // Make sure it's again where we left it in normal state before destroying
241+ tryCompare(fakeWindow, "x", initialWindowX + moveDelta)
242+ tryCompare(fakeWindow, "y", initialWindowX + moveDelta)
243+
244+ // Make sure maximize() has been called after restoring
245+ tryCompare(fakeWindow, "state", "maximized")
246+
247+ // clean up
248+ fakeWindow.state = "normal"
249+ }
217250 }
218251}