@@ -28,7 +28,7 @@ import Unity.Application 0.1
30 height: units.gu(60)
30 height: units.gu(60)
31− width: units.gu(60)
31+ width: units.gu(85)
34 target: PanelState
34 target: PanelState
@@ -41,14 +41,20 @@ Item {
43 id: fakeWindow
43 id: fakeWindow
44− property alias minWidth: windowResizeArea.minWidth
44+ property alias resizeAreaMinWidth: windowResizeArea.minWidth
45− property alias minHeight: windowResizeArea.minHeight
45+ property alias resizeAreaMinHeight: windowResizeArea.minHeight
46 x: units.gu(20)
46 x: units.gu(20)
47 y: units.gu(20)
47 y: units.gu(20)
48 width: requestedWidth
48 width: requestedWidth
49 height: requestedHeight
49 height: requestedHeight
50 property real requestedWidth
50 property real requestedWidth
51 property real requestedHeight
51 property real requestedHeight
52+ property real minimumWidth: 0
53+ property real minimumHeight: 0
54+ property real maximumWidth: 0
55+ property real maximumHeight: 0
56+ property real widthIncrement: 0
57+ property real heightIncrement: 0
52 state: "normal"
58 state: "normal"
54 function maximize() {
60 function maximize() {
@@ -80,6 +86,10 @@ Item {
80 anchors.fill: parent
86 anchors.fill: parent
81 hoverEnabled: true
87 hoverEnabled: true
90+ text: parent.width + "x" + parent.height
@@ -90,27 +100,107 @@ Item {
90 active: windowLoaderCheckbox.checked
100 active: windowLoaderCheckbox.checked
104+ anchors.right: parent.right
105+ anchors.top: parent.top
106+ anchors.bottom: parent.bottom
93− Column {
109+ Column {
111+ spacing: units.gu(1)
94− MouseTouchEmulationCheckbox {
112+ MouseTouchEmulationCheckbox {
95− checked: false
113+ checked: false
96− color: "black"
114+ color: "black"
98− RowLayout {
116+ RowLayout {
99− Layout.fillWidth: true
117+ Layout.fillWidth: true
100− CheckBox {
118+ CheckBox {
101− id: windowLoaderCheckbox
119+ id: windowLoaderCheckbox
102− checked: true
120+ checked: true
103− activeFocusOnPress: false
121+ activeFocusOnPress: false
125+ text: "Window loader active"
126+ anchors.verticalCenter: parent.verticalCenter
106− id: label
130+ color: "black"; font.bold: true
133+ SizeHintField { id: minWidthText; text: "min width" }
134+ SizeHintField { id: maxWidthText; text: "max width" }
135+ SizeHintField { id: minHeightText; text: "min height" }
136+ SizeHintField { id: maxHeightText; text: "max height" }
137+ SizeHintField { id: widthIncrText; text: "width incr" }
138+ SizeHintField { id: heightIncrText; text: "height incr" }
107 color: "black"
140 color: "black"
108− text: "Window loader active"
141+ anchors.horizontalCenter: parent.horizontalCenter
109− anchors.verticalCenter: parent.verticalCenter
142+ text: "Apply"
144+ var value = parseInt(minWidthText.value);
146+ windowLoader.item.minimumWidth = 0;
148+ windowLoader.item.resizeAreaMinWidth = 1; // get it out of the way
149+ windowLoader.item.minimumWidth = value;
152+ value = parseInt(maxWidthText.value);
154+ windowLoader.item.maximumWidth = 0;
156+ windowLoader.item.maximumWidth = value;
159+ value = parseInt(minHeightText.value);
161+ windowLoader.item.minimumHeight = 0;
163+ windowLoader.item.resizeAreaMinHeight = 1; // get it out of the way
164+ windowLoader.item.minimumHeight = value;
167+ value = parseInt(maxHeightText.value);
169+ windowLoader.item.maximumHeight = 0;
171+ windowLoader.item.maximumHeight = value;
174+ value = parseInt(widthIncrText.value);
176+ windowLoader.item.widthIncrement = 0;
178+ windowLoader.item.widthIncrement = value;
181+ value = parseInt(heightIncrText.value);
183+ windowLoader.item.heightIncrement = 0;
185+ windowLoader.item.heightIncrement = value;
193+ id: windowRequestedWidthSpy
194+ target: windowLoader.item
195+ signalName: "onRequestedWidthChanged"
199+ id: windowRequestedHeightSpy
200+ target: windowLoader.item
201+ signalName: "onRequestedHeightChanged"
114 UnityTestCase {
204 UnityTestCase {
115 name: "WindowResizeArea"
205 name: "WindowResizeArea"
116 when: windowShown
206 when: windowShown
@@ -122,6 +212,18 @@ Item {
122 fakeWindow.y = units.gu(20)
212 fakeWindow.y = units.gu(20)
123 fakeWindow.requestedWidth = units.gu(20)
213 fakeWindow.requestedWidth = units.gu(20)
124 fakeWindow.requestedHeight = units.gu(20)
214 fakeWindow.requestedHeight = units.gu(20)
215+ fakeWindow.resizeAreaMinWidth = units.gu(15);
216+ fakeWindow.resizeAreaMinHeight = units.gu(10);
217+ fakeWindow.minimumWidth = 0;
218+ fakeWindow.minimumHeight = 0;
219+ fakeWindow.maximumWidth = 0;
220+ fakeWindow.maximumHeight = 0;
221+ fakeWindow.widthIncrement = 0;
222+ fakeWindow.heightIncrement = 0;
224+ // Our test window resizes instantly
225+ compare(fakeWindow.width, fakeWindow.requestedWidth);
226+ compare(fakeWindow.height, fakeWindow.requestedHeight);
127 function test_resizeWindowRightBottom_data() {
229 function test_resizeWindowRightBottom_data() {
@@ -143,8 +245,8 @@ Item {
143 var startDragY = initialWindowY + initialWindowHeight + 1
245 var startDragY = initialWindowY + initialWindowHeight + 1
144 mouseFlick(root, startDragX, startDragY, startDragX + data.dx, startDragY + data.dy, true, true, units.gu(.5), 10);
246 mouseFlick(root, startDragX, startDragY, startDragX + data.dx, startDragY + data.dy, true, true, units.gu(.5), 10);
146− tryCompare(fakeWindow, "width", Math.max(initialWindowWidth + data.dx, fakeWindow.minWidth));
248+ tryCompare(fakeWindow, "width", Math.max(initialWindowWidth + data.dx, fakeWindow.resizeAreaMinWidth));
147− tryCompare(fakeWindow, "height", Math.max(initialWindowHeight + data.dy, fakeWindow.minHeight));
249+ tryCompare(fakeWindow, "height", Math.max(initialWindowHeight + data.dy, fakeWindow.resizeAreaMinHeight));
149 compare(fakeWindow.x, initialWindowX);
251 compare(fakeWindow.x, initialWindowX);
150 compare(fakeWindow.y, initialWindowY);
252 compare(fakeWindow.y, initialWindowY);
@@ -169,11 +271,11 @@ Item {
169 var startDragY = initialWindowY - 1
271 var startDragY = initialWindowY - 1
170 mouseFlick(root, startDragX, startDragY, startDragX + data.dx, startDragY + data.dy, true, true, units.gu(.5), 10);
272 mouseFlick(root, startDragX, startDragY, startDragX + data.dx, startDragY + data.dy, true, true, units.gu(.5), 10);
172− tryCompare(fakeWindow, "width", Math.max(initialWindowWidth - data.dx, fakeWindow.minWidth));
274+ tryCompare(fakeWindow, "width", Math.max(initialWindowWidth - data.dx, fakeWindow.resizeAreaMinWidth));
173− tryCompare(fakeWindow, "height", Math.max(initialWindowHeight - data.dy, fakeWindow.minHeight));
275+ tryCompare(fakeWindow, "height", Math.max(initialWindowHeight - data.dy, fakeWindow.resizeAreaMinHeight));
175− var maxMoveX = initialWindowWidth - fakeWindow.minWidth;
277+ var maxMoveX = initialWindowWidth - fakeWindow.resizeAreaMinWidth;
176− var maxMoveY = initialWindowHeight - fakeWindow.minHeight;
278+ var maxMoveY = initialWindowHeight - fakeWindow.resizeAreaMinHeight;
177 compare(fakeWindow.x, Math.min(initialWindowX + data.dx, initialWindowX + maxMoveX));
279 compare(fakeWindow.x, Math.min(initialWindowX + data.dx, initialWindowX + maxMoveX));
178 compare(fakeWindow.y, Math.min(initialWindowY + data.dy, initialWindowY + maxMoveY));
280 compare(fakeWindow.y, Math.min(initialWindowY + data.dy, initialWindowY + maxMoveY));
@@ -189,8 +291,8 @@ Item {
189 var startDragY = initialWindowY + initialWindowHeight + 1
291 var startDragY = initialWindowY + initialWindowHeight + 1
190 mouseFlick(root, startDragX, startDragY, startDragX + resizeDelta, startDragY + resizeDelta, true, true, units.gu(.5), 10);
292 mouseFlick(root, startDragX, startDragY, startDragX + resizeDelta, startDragY + resizeDelta, true, true, units.gu(.5), 10);
192− tryCompare(fakeWindow, "width", Math.max(initialWindowWidth + resizeDelta, fakeWindow.minWidth));
294+ tryCompare(fakeWindow, "width", Math.max(initialWindowWidth + resizeDelta, fakeWindow.resizeAreaMinWidth));
193− tryCompare(fakeWindow, "height", Math.max(initialWindowHeight + resizeDelta, fakeWindow.minHeight));
295+ tryCompare(fakeWindow, "height", Math.max(initialWindowHeight + resizeDelta, fakeWindow.resizeAreaMinHeight));
195 // This will destroy the window and recreate it
297 // This will destroy the window and recreate it
196 windowLoader.active = false;
298 windowLoader.active = false;
@@ -198,8 +300,8 @@ Item {
198 windowLoader.active = true;
300 windowLoader.active = true;
200 // Make sure its size is again the same as before
302 // Make sure its size is again the same as before
201− tryCompare(fakeWindow, "width", Math.max(initialWindowWidth + resizeDelta, fakeWindow.minWidth));
303+ tryCompare(fakeWindow, "width", Math.max(initialWindowWidth + resizeDelta, fakeWindow.resizeAreaMinWidth));
202− tryCompare(fakeWindow, "height", Math.max(initialWindowHeight + resizeDelta, fakeWindow.minHeight));
304+ tryCompare(fakeWindow, "height", Math.max(initialWindowHeight + resizeDelta, fakeWindow.resizeAreaMinHeight));
205 // This tests if dragging smaller than minSize and then larger again, will keep the edge sticking
307 // This tests if dragging smaller than minSize and then larger again, will keep the edge sticking
@@ -220,8 +322,8 @@ Item {
220 var startDragX = initialWindowX + data.startX
322 var startDragX = initialWindowX + data.startX
221 var startDragY = initialWindowY + data.startY
323 var startDragY = initialWindowY + data.startY
222 mouseFlick(root, startDragX, startDragY, startDragX + data.dx, startDragY + data.dy, true, false, units.gu(.05), 10);
324 mouseFlick(root, startDragX, startDragY, startDragX + data.dx, startDragY + data.dy, true, false, units.gu(.05), 10);
223− tryCompare(fakeWindow, "width", Math.max(initialWindowWidth - Math.abs(data.dx), fakeWindow.minWidth));
325+ tryCompare(fakeWindow, "width", Math.max(initialWindowWidth - Math.abs(data.dx), fakeWindow.resizeAreaMinWidth));
224− tryCompare(fakeWindow, "height", Math.max(initialWindowHeight - Math.abs(data.dy), fakeWindow.minHeight));
326+ tryCompare(fakeWindow, "height", Math.max(initialWindowHeight - Math.abs(data.dy), fakeWindow.resizeAreaMinHeight));
225 mouseFlick(root, startDragX + data.dx, startDragY + data.dy, startDragX, startDragY, false, true, units.gu(.05), 10);
327 mouseFlick(root, startDragX + data.dx, startDragY + data.dy, startDragX, startDragY, false, true, units.gu(.05), 10);
226 tryCompare(fakeWindow, "width", initialWindowWidth);
328 tryCompare(fakeWindow, "width", initialWindowWidth);
227 tryCompare(fakeWindow, "height", initialWindowHeight);
329 tryCompare(fakeWindow, "height", initialWindowHeight);
@@ -257,7 +359,6 @@ Item {
257 fakeWindow.state = "normal"
359 fakeWindow.state = "normal"
261 function test_restoreMovesIntoBounds_data() {
362 function test_restoreMovesIntoBounds_data() {
263 {tag: "left off", x: -units.gu(5), y: units.gu(5), w: units.gu(10), h: units.gu(10)},
364 {tag: "left off", x: -units.gu(5), y: units.gu(5), w: units.gu(10), h: units.gu(10)},
@@ -290,5 +391,99 @@ Item {
291 waitForRendering(root)
392 waitForRendering(root)
396+ Tests that even though you dragged the window bottom right corner continously (ie,
397+ through multiple intermediate steps), its (requested) width and height changed only
398+ once. And, furthermore, its dimensions increased by a multiple of its size (width
399+ and height) increment value.
401+ function test_sizeIncrement() {
402+ var initialWindowX = fakeWindow.x;
403+ var initialWindowY = fakeWindow.y;
404+ var initialWindowWidth = fakeWindow.width
405+ var initialWindowHeight = fakeWindow.height
407+ fakeWindow.widthIncrement = 70;
408+ fakeWindow.heightIncrement = 70;
410+ var startDragX = initialWindowX + initialWindowWidth + 1
411+ var startDragY = initialWindowY + initialWindowHeight + 1
415+ windowRequestedWidthSpy.clear();
416+ verify(windowRequestedWidthSpy.valid);
418+ windowRequestedHeightSpy.clear();
419+ verify(windowRequestedHeightSpy.valid);
421+ mouseFlick(root, startDragX, startDragY, startDragX + deltaX, startDragY + deltaY, true, true, units.gu(.5), 10);
423+ compare(windowRequestedWidthSpy.count, 1);
424+ compare(fakeWindow.width, initialWindowWidth + fakeWindow.widthIncrement);
425+ compare(windowRequestedHeightSpy.count, 1);
426+ compare(fakeWindow.height, initialWindowHeight + fakeWindow.heightIncrement);
430+ Tests that when dragging a window border you cannot make it bigger than its maximum size
432+ function test_maximumSize() {
433+ fakeWindow.x = units.gu(1);
434+ fakeWindow.y = units.gu(1);
435+ fakeWindow.resizeAreaMinWidth = 1; // so it does not interfere with anything
436+ fakeWindow.resizeAreaMinHeight = 1; // so it does not interfere with anything
437+ fakeWindow.requestedWidth = units.gu(10);
438+ fakeWindow.requestedHeight = units.gu(10);
440+ fakeWindow.maximumWidth = units.gu(20);
441+ fakeWindow.maximumHeight = units.gu(20);
443+ // Our test window resizes instantly
444+ compare(fakeWindow.width, fakeWindow.requestedWidth);
445+ compare(fakeWindow.height, fakeWindow.requestedHeight);
447+ var startDragX = fakeWindow.width + 1
448+ var startDragY = fakeWindow.height + 1
449+ var endDragX = (fakeWindow.maximumWidth * 2) + 1;
450+ var endDragY = (fakeWindow.maximumHeight * 2) + 1;
452+ mouseFlick(fakeWindow, startDragX, startDragY, endDragX, endDragY,
453+ true/*pressMouse*/, true/*releaseMouse*/, units.gu(.5)/*speed*/, 20/*iterations*/);
455+ compare(fakeWindow.requestedWidth, fakeWindow.maximumWidth);
456+ compare(fakeWindow.requestedHeight, fakeWindow.maximumHeight);
460+ Tests that when dragging a window border you cannot make it smaller than its minimum size
462+ function test_minimumSize() {
463+ fakeWindow.x = units.gu(1);
464+ fakeWindow.y = units.gu(1);
465+ fakeWindow.resizeAreaMinWidth = 1; // so it does not interfere with anything
466+ fakeWindow.resizeAreaMinHeight = 1; // so it does not interfere with anything
467+ fakeWindow.requestedWidth = units.gu(20);
468+ fakeWindow.requestedHeight = units.gu(20);
470+ fakeWindow.minimumWidth = units.gu(10);
471+ fakeWindow.minimumHeight = units.gu(10);
473+ // Our test window resizes instantly
474+ compare(fakeWindow.width, fakeWindow.requestedWidth);
475+ compare(fakeWindow.height, fakeWindow.requestedHeight);
477+ var startDragX = fakeWindow.width + 1
478+ var startDragY = fakeWindow.height + 1
479+ var endDragX = (fakeWindow.minimumWidth * 0.5) + 1;
480+ var endDragY = (fakeWindow.minimumHeight * 0.5) + 1;
482+ mouseFlick(fakeWindow, startDragX, startDragY, endDragX, endDragY,
483+ true/*pressMouse*/, true/*releaseMouse*/, units.gu(.5)/*speed*/, 20/*iterations*/);
485+ compare(fakeWindow.requestedWidth, fakeWindow.minimumWidth);
486+ compare(fakeWindow.requestedHeight, fakeWindow.minimumHeight);