@@ -14,7 +14,8 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17−import QtQuick 2.0
17+import QtQuick 2.1
18+import QtQuick.Layouts 1.1
18import QtTest 1.0
19import QtTest 1.0
19import Unity.Test 0.1 as UT
20import Unity.Test 0.1 as UT
20import ".."
21import ".."
@@ -40,7 +41,7 @@ Rectangle {
40 Connections {
41 Connections {
41 target: fakeApplication
42 target: fakeApplication
42 onSessionChanged: {
43 onSessionChanged: {
43− surfaceCheckbox.checked = fakeApplication.session !== null
44+ sessionCheckbox.checked = fakeApplication.session !== null
@@ -71,30 +72,51 @@ Rectangle {
71 right: parent.right
72 right: parent.right
74− Column {
75+ ColumnLayout {
75 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
76 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
76 spacing: units.gu(1)
77 spacing: units.gu(1)
78− anchors { left: parent.left; right: parent.right }
79+ RowLayout {
80+ Layout.fillWidth: true
79 CheckBox {
82 CheckBox {
80− id: surfaceCheckbox; checked: false
83+ id: sessionCheckbox; checked: false
81 onCheckedChanged: {
84 onCheckedChanged: {
82 if (applicationWindowLoader.status !== Loader.Ready)
85 if (applicationWindowLoader.status !== Loader.Ready)
85 if (checked && !fakeApplication.session) {
88 if (checked && !fakeApplication.session) {
86 fakeApplication.createSession();
89 fakeApplication.createSession();
87− fakeSession.createSurface();
88 } else if (!checked && fakeApplication.session) {
90 } else if (!checked && fakeApplication.session) {
89 fakeApplication.session.release();
91 fakeApplication.session.release();
94− text: "Surface"
96+ text: "Session"
95 anchors.verticalCenter: parent.verticalCenter
97 anchors.verticalCenter: parent.verticalCenter
110+ Layout.preferredHeight: sessionControl.height
112+ RecursingChildSessionControl {
114+ anchors { left: parent.left; right: parent.right; }
116+ session: fakeSession
98 ListItem.ItemSelector {
120 ListItem.ItemSelector {
99 id: appStateSelector
121 id: appStateSelector
100 anchors { left: parent.left; right: parent.right }
122 anchors { left: parent.left; right: parent.right }
@@ -119,6 +141,7 @@ Rectangle {
119 fakeApplication.setState(selectedApplicationState);
141 fakeApplication.setState(selectedApplicationState);
@@ -175,6 +198,14 @@ Rectangle {
175 findInterestingApplicationWindowChildren();
198 findInterestingApplicationWindowChildren();
201+ function initSession() {
202+ sessionCheckbox.checked = true;
203+ sessionControl.surfaceCheckbox.checked = true;
205+ function cleanupSession() {
206+ sessionCheckbox.checked = false;
178 function cleanup() {
209 function cleanup() {
179 forgetApplicationWindowChildren();
210 forgetApplicationWindowChildren();
@@ -182,7 +213,7 @@ Rectangle {
182 applicationWindowLoader.active = false;
213 applicationWindowLoader.active = false;
184 appStateSelector.selectedIndex = 0;
215 appStateSelector.selectedIndex = 0;
185− surfaceCheckbox.checked = false;
216+ cleanupSession();
187 if (fakeApplication.session)
218 if (fakeApplication.session)
188 fakeApplication.session.release();
219 fakeApplication.session.release();
@@ -202,7 +233,7 @@ Rectangle {
202 verify(stateGroup.state === "splashScreen");
233 verify(stateGroup.state === "splashScreen");
204 if (data.swapInitOrder) {
235 if (data.swapInitOrder) {
205− surfaceCheckbox.checked = true;
236+ initSession();
207 setApplicationState(appRunning);
238 setApplicationState(appRunning);
@@ -212,14 +243,14 @@ Rectangle {
212 if (data.swapInitOrder) {
243 if (data.swapInitOrder) {
213 setApplicationState(appRunning);
244 setApplicationState(appRunning);
215− surfaceCheckbox.checked = true;
246+ initSession();
218 tryCompare(stateGroup, "state", "surface");
249 tryCompare(stateGroup, "state", "surface");
221 function test_suspendedAppShowsSurface() {
252 function test_suspendedAppShowsSurface() {
222− surfaceCheckbox.checked = true;
253+ initSession();
223 setApplicationState(appRunning);
254 setApplicationState(appRunning);
225 tryCompare(stateGroup, "state", "surface");
256 tryCompare(stateGroup, "state", "surface");
@@ -233,7 +264,7 @@ Rectangle {
235 function test_killedAppShowsScreenshot() {
266 function test_killedAppShowsScreenshot() {
236− surfaceCheckbox.checked = true;
267+ initSession();
237 setApplicationState(appRunning);
268 setApplicationState(appRunning);
238 tryCompare(stateGroup, "state", "surface");
269 tryCompare(stateGroup, "state", "surface");
@@ -252,7 +283,7 @@ Rectangle {
252 function test_restartApp() {
283 function test_restartApp() {
253 var screenshotImage = findChild(applicationWindowLoader.item, "screenshotImage");
284 var screenshotImage = findChild(applicationWindowLoader.item, "screenshotImage");
255− surfaceCheckbox.checked = true;
286+ initSession();
256 setApplicationState(appRunning);
287 setApplicationState(appRunning);
257 tryCompare(stateGroup, "state", "surface");
288 tryCompare(stateGroup, "state", "surface");
258 waitUntilTransitionsEnd();
289 waitUntilTransitionsEnd();
@@ -278,14 +309,14 @@ Rectangle {
278 waitUntilTransitionsEnd();
309 waitUntilTransitionsEnd();
279 verify(stateGroup.state === "screenshot");
310 verify(stateGroup.state === "screenshot");
281− surfaceCheckbox.checked = true;
312+ initSession();
283 tryCompare(stateGroup, "state", "surface");
314 tryCompare(stateGroup, "state", "surface");
284 tryCompare(screenshotImage, "status", Image.Null);
315 tryCompare(screenshotImage, "status", Image.Null);
287 function test_appCrashed() {
318 function test_appCrashed() {
288− surfaceCheckbox.checked = true;
319+ initSession();
289 setApplicationState(appRunning);
320 setApplicationState(appRunning);
290 tryCompare(stateGroup, "state", "surface");
321 tryCompare(stateGroup, "state", "surface");
291 waitUntilTransitionsEnd();
322 waitUntilTransitionsEnd();
@@ -298,7 +329,7 @@ Rectangle {
300 function test_keepSurfaceWhileInvisible() {
331 function test_keepSurfaceWhileInvisible() {
301− surfaceCheckbox.checked = true;
332+ initSession();
302 setApplicationState(appRunning);
333 setApplicationState(appRunning);
303 tryCompare(stateGroup, "state", "surface");
334 tryCompare(stateGroup, "state", "surface");
304 waitUntilTransitionsEnd();
335 waitUntilTransitionsEnd();
@@ -319,7 +350,7 @@ Rectangle {
320 function test_touchesReachSurfaceWhenItsShown() {
351 function test_touchesReachSurfaceWhenItsShown() {
321 setApplicationState(appRunning);
352 setApplicationState(appRunning);
322− surfaceCheckbox.checked = true;
353+ initSession();
324 tryCompare(stateGroup, "state", "surface");
355 tryCompare(stateGroup, "state", "surface");
@@ -338,12 +369,12 @@ Rectangle {
340 function test_showNothingOnSuddenSurfaceLoss() {
371 function test_showNothingOnSuddenSurfaceLoss() {
341− surfaceCheckbox.checked = true;
372+ initSession();
342 setApplicationState(appRunning);
373 setApplicationState(appRunning);
343 tryCompare(stateGroup, "state", "surface");
374 tryCompare(stateGroup, "state", "surface");
344 waitUntilTransitionsEnd();
375 waitUntilTransitionsEnd();
346− surfaceCheckbox.checked = false;
377+ cleanupSession();
348 verify(stateGroup.state === "void");
379 verify(stateGroup.state === "void");