@@ -19,6 +19,7 @@ import QtQuick.Layouts 1.1
19import QtTest 1.0
19import QtTest 1.0
20import Unity.Test 0.1
20import Unity.Test 0.1
21import ".."
21import ".."
22+import "../../../qml/Components/PanelState"
22import "../../../qml/Stages"
23import "../../../qml/Stages"
23import Ubuntu.Components 0.1
24import Ubuntu.Components 0.1
24import Ubuntu.Components.ListItems 1.0 as ListItem
25import Ubuntu.Components.ListItems 1.0 as ListItem
@@ -31,6 +32,12 @@ Item {
32 property var fakeWindow: windowLoader.item
33 property var fakeWindow: windowLoader.item
37+ property: "panelHeight"
34 Component {
41 Component {
35 id: fakeWindowComponent
42 id: fakeWindowComponent
@@ -57,6 +64,8 @@ Item {
57 minWidth: units.gu(15)
64 minWidth: units.gu(15)
58 minHeight: units.gu(10)
65 minHeight: units.gu(10)
59 windowId: "test-window-id"
66 windowId: "test-window-id"
67+ screenWidth: root.width
68+ screenHeight: root.height
62 Rectangle {
71 Rectangle {
@@ -228,5 +237,39 @@ Item {
228 // clean up
237 // clean up
229 fakeWindow.state = "normal"
238 fakeWindow.state = "normal"
242+ function test_restoreMovesIntoBounds_data() {
244+ {tag: "left off", x: -units.gu(5), y: units.gu(5), w: units.gu(10), h: units.gu(10)},
245+ {tag: "top off", x: units.gu(5), y: -units.gu(5), w: units.gu(10), h: units.gu(10)},
246+ {tag: "right off", x: root.width - units.gu(5), y: units.gu(5), w: units.gu(10), h: units.gu(10)},
247+ {tag: "bottom off", x: units.gu(5), y: root.height - units.gu(5), w: units.gu(10), h: units.gu(10)},
248+ {tag: "width too large", x: units.gu(5), y: units.gu(5), w: root.width * 2, h: units.gu(10)},
249+ {tag: "height too large", x: units.gu(5), y: units.gu(5), w: units.gu(10), h: root.height * 2}
253+ function test_restoreMovesIntoBounds(data) {
254+ fakeWindow.x = data.x;
255+ fakeWindow.y = data.y;
256+ fakeWindow.width = data.w;
257+ fakeWindow.height = data.h;
258+ waitForRendering(root);
260+ // This will destroy the window and recreate it
261+ windowLoader.active = false;
262+ waitForRendering(root);
263+ windowLoader.active = true;
264+ waitForRendering(root)
266+ // Make sure it's again where we left it in normal state before destroying
267+ compare(fakeWindow.x >= 0, true)
268+ compare(fakeWindow.y >= PanelState.panelHeight, true)
269+ compare(fakeWindow.x + fakeWindow.width <= root.width, true)
270+ compare(fakeWindow.y + fakeWindow.height <= root.height, true)
272+ waitForRendering(root)