on xenial help sign in
fix tests, add another
6c5ea7aMichael Zanetti
tests/qmltests/Stages/tst_WindowResizeArea.qml+35−2
@@ -44,8 +44,11 @@ Item {
44 width: units.gu(20)
44 width: units.gu(20)
45 property int windowHeight: height
45 property int windowHeight: height
46 property int windowWidth: width
46 property int windowWidth: width
47− onWindowHeightChanged: height = windowHeight
47+ state: "normal"
48− onWindowWidthChanged: width = windowWidth
48+
49+ function maximize() {
50+ state = "maximized"
51+ }
49
52
50 WindowResizeArea {
53 WindowResizeArea {
51 id: windowResizeArea
54 id: windowResizeArea
@@ -214,5 +217,35 @@ Item {
214 tryCompare(fakeWindow, "width", initialWindowWidth);
217 tryCompare(fakeWindow, "width", initialWindowWidth);
215 tryCompare(fakeWindow, "height", initialWindowHeight);
218 tryCompare(fakeWindow, "height", initialWindowHeight);
216 }
219 }
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+ }
217 }
250 }
218}
251}