on xenial help sign in
fixup WindowResizeArea tests
c0eb0e4Lukáš Tinkl
qml/Stages/WindowResizeArea.qml+2
@@ -82,6 +82,8 @@ MouseArea {
82
82
83 var windowState = windowStateStorage.getState(root.windowId, WindowStateStorage.WindowStateNormal)
83 var windowState = windowStateStorage.getState(root.windowId, WindowStateStorage.WindowStateNormal)
84 switch (windowState) {
84 switch (windowState) {
85+ case WindowStateStorage.WindowStateNormal:
86+ break;
85 case WindowStateStorage.WindowStateMaximized:
87 case WindowStateStorage.WindowStateMaximized:
86 target.maximize(false);
88 target.maximize(false);
87 break;
89 break;
tests/qmltests/Stages/tst_WindowResizeArea.qml+16−5
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2014-2015 Canonical Ltd.
2+ * Copyright 2014-2016 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@ import "../../../qml/Stages"
24import Ubuntu.Components 1.3
24import Ubuntu.Components 1.3
25import Ubuntu.Components.ListItems 1.3 as ListItem
25import Ubuntu.Components.ListItems 1.3 as ListItem
26import Unity.Application 0.1
26import Unity.Application 0.1
27+import Utils 0.1
27
28
28Item {
29Item {
29 id: root
30 id: root
@@ -55,10 +56,20 @@ Item {
55 property real maximumHeight: 0
56 property real maximumHeight: 0
56 property real widthIncrement: 0
57 property real widthIncrement: 0
57 property real heightIncrement: 0
58 property real heightIncrement: 0
58− state: "normal"
59+
60+ property int windowState: WindowStateStorage.WindowStateNormal
61+
62+ states: [
63+ State { name: "normal"; when: windowState == WindowStateStorage.WindowStateNormal },
64+ State { name: "maximized"; when: windowState == WindowStateStorage.WindowStateMaximized }
65+ ]
59
66
60 function maximize() {
67 function maximize() {
61− state = "maximized"
68+ windowState = WindowStateStorage.WindowStateMaximized
69+ }
70+
71+ function restoreFromMaximized() {
72+ windowState = WindowStateStorage.WindowStateNormal
62 }
73 }
63
74
64 WindowResizeArea {
75 WindowResizeArea {
@@ -346,7 +357,7 @@ Item {
346 fakeWindow.y = initialWindowY + moveDelta
357 fakeWindow.y = initialWindowY + moveDelta
347
358
348 // Now change the state to maximized. The window should not keep updating the stored values
359 // Now change the state to maximized. The window should not keep updating the stored values
349− fakeWindow.state = "maximized"
360+ fakeWindow.maximize()
350 fakeWindow.x = 31415 // 0 is too risky to pass the test even when broken
361 fakeWindow.x = 31415 // 0 is too risky to pass the test even when broken
351 fakeWindow.y = 31415
362 fakeWindow.y = 31415
352
363
@@ -363,7 +374,7 @@ Item {
363 tryCompare(fakeWindow, "state", "maximized")
374 tryCompare(fakeWindow, "state", "maximized")
364
375
365 // clean up
376 // clean up
366− fakeWindow.state = "normal"
377+ fakeWindow.restoreFromMaximized()
367 }
378 }
368
379
369 function test_restoreMovesIntoBounds_data() {
380 function test_restoreMovesIntoBounds_data() {