@@ -29,20 +29,33 @@ Item {
29 height: units.gu(60)
29 height: units.gu(60)
30 width: units.gu(60)
30 width: units.gu(60)
32+ property var fakeWindow: windowLoader.item
35+ id: fakeWindowComponent
32− Rectangle {
37+ Rectangle {
33− id: fakeWindow
38+ id: fakeWindow
36− color: "khaki"
39+ color: "khaki"
40+ property alias minWidth: moveResizeArea.minWidth
41+ property alias minHeight: moveResizeArea.minHeight
37− WindowMoveResizeArea {
43+ WindowMoveResizeArea {
38− id: moveResizeArea
44+ id: moveResizeArea
39− target: fakeWindow
45+ target: fakeWindow
40− resizeHandleWidth: units.gu(0.5)
46+ resizeHandleWidth: units.gu(0.5)
41− minWidth: units.gu(15)
47+ minWidth: units.gu(15)
42− minHeight: units.gu(10)
48+ minHeight: units.gu(10)
49+ windowId: "test-window-id"
56+ sourceComponent: fakeWindowComponent
46 UT.UnityTestCase {
59 UT.UnityTestCase {
47 when: windowShown
60 when: windowShown
@@ -100,8 +113,8 @@ Item {
100 var startDragY = initialWindowY + initialWindowHeight + 1
113 var startDragY = initialWindowY + initialWindowHeight + 1
101 mouseFlick(root, startDragX, startDragY, startDragX + data.dx, startDragY + data.dy, true, true, units.gu(.5), 10);
114 mouseFlick(root, startDragX, startDragY, startDragX + data.dx, startDragY + data.dy, true, true, units.gu(.5), 10);
103− tryCompare(fakeWindow, "width", Math.max(initialWindowWidth + data.dx, moveResizeArea.minWidth));
116+ tryCompare(fakeWindow, "width", Math.max(initialWindowWidth + data.dx, fakeWindow.minWidth));
104− tryCompare(fakeWindow, "height", Math.max(initialWindowHeight + data.dy, moveResizeArea.minHeight));
117+ tryCompare(fakeWindow, "height", Math.max(initialWindowHeight + data.dy, fakeWindow.minHeight));
106 compare(fakeWindow.x, initialWindowX);
119 compare(fakeWindow.x, initialWindowX);
107 compare(fakeWindow.y, initialWindowY);
120 compare(fakeWindow.y, initialWindowY);
@@ -126,13 +139,59 @@ Item {
126 var startDragY = initialWindowY - 1
139 var startDragY = initialWindowY - 1
127 mouseFlick(root, startDragX, startDragY, startDragX + data.dx, startDragY + data.dy, true, true, units.gu(.5), 10);
140 mouseFlick(root, startDragX, startDragY, startDragX + data.dx, startDragY + data.dy, true, true, units.gu(.5), 10);
129− tryCompare(fakeWindow, "width", Math.max(initialWindowWidth - data.dx, moveResizeArea.minWidth));
142+ tryCompare(fakeWindow, "width", Math.max(initialWindowWidth - data.dx, fakeWindow.minWidth));
130− tryCompare(fakeWindow, "height", Math.max(initialWindowHeight - data.dy, moveResizeArea.minHeight));
143+ tryCompare(fakeWindow, "height", Math.max(initialWindowHeight - data.dy, fakeWindow.minHeight));
132− var maxMoveX = initialWindowWidth - moveResizeArea.minWidth;
145+ var maxMoveX = initialWindowWidth - fakeWindow.minWidth;
133− var maxMoveY = initialWindowHeight - moveResizeArea.minHeight;
146+ var maxMoveY = initialWindowHeight - fakeWindow.minHeight;
134 compare(fakeWindow.x, Math.min(initialWindowX + data.dx, initialWindowX + maxMoveX));
147 compare(fakeWindow.x, Math.min(initialWindowX + data.dx, initialWindowX + maxMoveX));
135 compare(fakeWindow.y, Math.min(initialWindowY + data.dy, initialWindowY + maxMoveY));
148 compare(fakeWindow.y, Math.min(initialWindowY + data.dy, initialWindowY + maxMoveY));
151+ function test_saveRestorePosition() {
152+ var initialWindowX = fakeWindow.x;
153+ var initialWindowY = fakeWindow.y;
154+ var initialWindowWidth = fakeWindow.width;
155+ var initialWindowHeight = fakeWindow.height;
157+ var moveDelta = units.gu(5);
158+ var startDragX = initialWindowX + fakeWindow.width / 2;
159+ var startDragY = initialWindowY + fakeWindow.height / 2;
160+ mouseFlick(root, startDragX, startDragY, startDragX + moveDelta, startDragY + moveDelta, true, true, units.gu(.5), 10)
162+ tryCompare(fakeWindow, "x", initialWindowX + moveDelta)
163+ tryCompare(fakeWindow, "y", initialWindowX + moveDelta)
165+ // This will destroy the window and recreate it
166+ windowLoader.active = false;
167+ windowLoader.active = true;
169+ // Make sure it's again where we left it before destroying
170+ tryCompare(fakeWindow, "x", initialWindowX + moveDelta)
171+ tryCompare(fakeWindow, "y", initialWindowX + moveDelta)
174+ function test_saveRestoreSize() {
175+ var initialWindowX = fakeWindow.x;
176+ var initialWindowY = fakeWindow.y;
177+ var initialWindowWidth = fakeWindow.width
178+ var initialWindowHeight = fakeWindow.height
180+ var resizeDelta = units.gu(5)
181+ var startDragX = initialWindowX + initialWindowWidth + 1
182+ var startDragY = initialWindowY + initialWindowHeight + 1
183+ mouseFlick(root, startDragX, startDragY, startDragX + resizeDelta, startDragY + resizeDelta, true, true, units.gu(.5), 10);
185+ tryCompare(fakeWindow, "width", Math.max(initialWindowWidth + resizeDelta, fakeWindow.minWidth));
186+ tryCompare(fakeWindow, "height", Math.max(initialWindowHeight + resizeDelta, fakeWindow.minHeight));
188+ // This will destroy the window and recreate it
189+ windowLoader.active = false;
190+ windowLoader.active = true;
192+ // Make sure its size is again the same as before
193+ tryCompare(fakeWindow, "width", Math.max(initialWindowWidth + resizeDelta, fakeWindow.minWidth));
194+ tryCompare(fakeWindow, "height", Math.max(initialWindowHeight + resizeDelta, fakeWindow.minHeight));