~josharenson/unity8/slim_greeter_real_lightdm

« back to all changes in this revision

Viewing changes to tests/qmltests/Stages/tst_WindowResizeArea.qml

  • Committer: Josh Arenson
  • Date: 2016-06-29 14:44:41 UTC
  • mfrom: (1789.412.85 unity8)
  • Revision ID: joshua.arenson@canonical.com-20160629144441-du2vd7vu97b2n8pc
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
            id: fakeWindow
45
45
            property alias resizeAreaMinWidth: windowResizeArea.minWidth
46
46
            property alias resizeAreaMinHeight: windowResizeArea.minHeight
47
 
            x: units.gu(20)
48
 
            y: units.gu(20)
 
47
            x: requestedX
 
48
            y: requestedY
 
49
            property real requestedX: units.gu(20)
 
50
            property real requestedY: units.gu(20)
49
51
            width: requestedWidth
50
52
            height: requestedHeight
51
53
            property real requestedWidth
226
228
        property var fakeWindow: windowLoader.item
227
229
 
228
230
        function init() {
229
 
            fakeWindow.x = units.gu(20)
230
 
            fakeWindow.y = units.gu(20)
 
231
            fakeWindow.requestedX = units.gu(20)
 
232
            fakeWindow.requestedY = units.gu(20)
231
233
            fakeWindow.requestedWidth = units.gu(20)
232
234
            fakeWindow.requestedHeight = units.gu(20)
233
235
            fakeWindow.resizeAreaMinWidth = units.gu(15);
254
256
        }
255
257
 
256
258
        function test_resizeWindowRightBottom(data) {
257
 
            var initialWindowX = fakeWindow.x;
258
 
            var initialWindowY = fakeWindow.y;
 
259
            var initialWindowX = fakeWindow.requestedX;
 
260
            var initialWindowY = fakeWindow.requestedY;
259
261
            var initialWindowWidth = fakeWindow.width
260
262
            var initialWindowHeight = fakeWindow.height
261
263
 
266
268
            tryCompare(fakeWindow, "width", Math.max(initialWindowWidth + data.dx, fakeWindow.resizeAreaMinWidth));
267
269
            tryCompare(fakeWindow, "height", Math.max(initialWindowHeight + data.dy, fakeWindow.resizeAreaMinHeight));
268
270
 
269
 
            compare(fakeWindow.x, initialWindowX);
270
 
            compare(fakeWindow.y, initialWindowY);
 
271
            compare(fakeWindow.requestedX, initialWindowX);
 
272
            compare(fakeWindow.requestedY, initialWindowY);
271
273
        }
272
274
 
273
275
        function test_resizeWindowLeftTop_data() {
280
282
        }
281
283
 
282
284
        function test_resizeWindowLeftTop(data) {
283
 
            var initialWindowX = fakeWindow.x;
284
 
            var initialWindowY = fakeWindow.y;
 
285
            var initialWindowX = fakeWindow.requestedX;
 
286
            var initialWindowY = fakeWindow.requestedY;
285
287
            var initialWindowWidth = fakeWindow.width
286
288
            var initialWindowHeight = fakeWindow.height
287
289
 
294
296
 
295
297
            var maxMoveX = initialWindowWidth - fakeWindow.resizeAreaMinWidth;
296
298
            var maxMoveY = initialWindowHeight - fakeWindow.resizeAreaMinHeight;
297
 
            compare(fakeWindow.x, Math.min(initialWindowX + data.dx, initialWindowX + maxMoveX));
298
 
            compare(fakeWindow.y, Math.min(initialWindowY + data.dy, initialWindowY + maxMoveY));
 
299
            compare(fakeWindow.requestedX, Math.min(initialWindowX + data.dx, initialWindowX + maxMoveX));
 
300
            compare(fakeWindow.requestedY, Math.min(initialWindowY + data.dy, initialWindowY + maxMoveY));
299
301
        }
300
302
 
301
303
        function test_saveRestoreSize() {
302
 
            var initialWindowX = fakeWindow.x;
303
 
            var initialWindowY = fakeWindow.y;
 
304
            var initialWindowX = fakeWindow.requestedX;
 
305
            var initialWindowY = fakeWindow.requestedY;
304
306
            var initialWindowWidth = fakeWindow.width
305
307
            var initialWindowHeight = fakeWindow.height
306
308
 
332
334
        }
333
335
 
334
336
        function test_resizeSmallerAndLarger(data) {
335
 
            var initialWindowX = fakeWindow.x;
336
 
            var initialWindowY = fakeWindow.y;
 
337
            var initialWindowX = fakeWindow.requestedX;
 
338
            var initialWindowY = fakeWindow.requestedY;
337
339
            var initialWindowWidth = fakeWindow.width
338
340
            var initialWindowHeight = fakeWindow.height
339
341
 
348
350
        }
349
351
 
350
352
        function test_saveRestoreMaximized() {
351
 
            var initialWindowX = fakeWindow.x;
352
 
            var initialWindowY = fakeWindow.y;
 
353
            var initialWindowX = fakeWindow.requestedX;
 
354
            var initialWindowY = fakeWindow.requestedY;
353
355
 
354
356
            var moveDelta = units.gu(5);
355
357
 
356
 
            fakeWindow.x = initialWindowX + moveDelta
357
 
            fakeWindow.y = initialWindowY + moveDelta
 
358
            fakeWindow.requestedX = initialWindowX + moveDelta
 
359
            fakeWindow.requestedY = initialWindowY + moveDelta
358
360
 
359
361
            // Now change the state to maximized. The window should not keep updating the stored values
360
362
            fakeWindow.maximize()
361
 
            fakeWindow.x = 31415 // 0 is too risky to pass the test even when broken
362
 
            fakeWindow.y = 31415
 
363
            fakeWindow.requestedX = 31415 // 0 is too risky to pass the test even when broken
 
364
            fakeWindow.requestedY = 31415
363
365
 
364
366
            // This will destroy the window and recreate it
365
367
            windowLoader.active = false;
389
391
        }
390
392
 
391
393
        function test_restoreMovesIntoBounds(data) {
392
 
            fakeWindow.x = data.x;
393
 
            fakeWindow.y = data.y;
 
394
            fakeWindow.requestedX = data.x;
 
395
            fakeWindow.requestedY = data.y;
394
396
            fakeWindow.width = data.w;
395
397
            fakeWindow.height = data.h;
396
398
            waitForRendering(root);
402
404
            waitForRendering(root)
403
405
 
404
406
            // Make sure it's again where we left it in normal state before destroying
405
 
            compare(fakeWindow.x >= 0, true)
406
 
            compare(fakeWindow.y >= PanelState.panelHeight, true)
407
 
            compare(fakeWindow.x + fakeWindow.width <= root.width, true)
408
 
            compare(fakeWindow.y + fakeWindow.height <= root.height, true)
 
407
            compare(fakeWindow.requestedX >= 0, true)
 
408
            compare(fakeWindow.requestedY >= PanelState.panelHeight, true)
 
409
            compare(fakeWindow.requestedX + fakeWindow.width <= root.width, true)
 
410
            compare(fakeWindow.requestedY + fakeWindow.height <= root.height, true)
409
411
 
410
412
            waitForRendering(root)
411
413
        }
417
419
            and height) increment value.
418
420
         */
419
421
        function test_sizeIncrement() {
420
 
            var initialWindowX = fakeWindow.x;
421
 
            var initialWindowY = fakeWindow.y;
 
422
            var initialWindowX = fakeWindow.requestedX;
 
423
            var initialWindowY = fakeWindow.requestedY;
422
424
            var initialWindowWidth = fakeWindow.width
423
425
            var initialWindowHeight = fakeWindow.height
424
426
 
448
450
            Tests that when dragging a window border you cannot make it bigger than its maximum size
449
451
         */
450
452
        function test_maximumSize() {
451
 
            fakeWindow.x = units.gu(1);
452
 
            fakeWindow.y = units.gu(1);
 
453
            fakeWindow.requestedX = units.gu(1);
 
454
            fakeWindow.requestedY = units.gu(1);
453
455
            fakeWindow.resizeAreaMinWidth = 1; // so it does not interfere with anything
454
456
            fakeWindow.resizeAreaMinHeight = 1; // so it does not interfere with anything
455
457
            fakeWindow.requestedWidth = units.gu(10);
478
480
            Tests that when dragging a window border you cannot make it smaller than its minimum size
479
481
         */
480
482
        function test_minimumSize() {
481
 
            fakeWindow.x = units.gu(1);
482
 
            fakeWindow.y = units.gu(1);
 
483
            fakeWindow.requestedX = units.gu(1);
 
484
            fakeWindow.requestedY = units.gu(1);
483
485
            fakeWindow.resizeAreaMinWidth = 1; // so it does not interfere with anything
484
486
            fakeWindow.resizeAreaMinHeight = 1; // so it does not interfere with anything
485
487
            fakeWindow.requestedWidth = units.gu(20);