@@ -148,6 +148,7 @@ Item {
148148 when: windowShown
149149
150150 property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
151+ property QtObject topLevelSurfaceList: null
151152
152153 function init() {
153154 tryCompare(shell, "waitingOnGreeter", false); // will be set when greeter is all ready
@@ -161,11 +162,21 @@ Item {
161162 var panel = findChild(launcher, "launcherPanel");
162163 verify(!!panel);
163164 panel.dismissTimer = fakeDismissTimer;
165+
166+ topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
167+ verify(topLevelSurfaceList);
168+
169+ var dashSurfaceId = topLevelSurfaceList.nextId;
170+ ApplicationManager.startApplication("unity8-dash");
171+ tryCompare(topLevelSurfaceList, "count", 1);
172+ waitUntilAppWindowIsFullyLoaded(dashSurfaceId);
164173 }
165174
166175 function cleanup() {
167176 tryCompare(shell, "waitingOnGreeter", false); // make sure greeter didn't leave us in disabled state
168177
178+ topLevelSurfaceList = null;
179+
169180 shellLoader.itemDestroyed = false
170181
171182 shellLoader.active = false
@@ -213,6 +224,27 @@ Item {
213224 }
214225 }
215226
227+ function findAppWindowForSurfaceId(surfaceId) {
228+ // for PhoneStage and TabletStage
229+ var delegate = findChild(shell, "spreadDelegate_" + surfaceId, 0 /* timeout */);
230+ if (!delegate) {
231+ // for DesktopStage
232+ delegate = findChild(shell, "appDelegate_" + surfaceId);
233+ }
234+ verify(delegate);
235+ var appWindow = findChild(delegate, "appWindow");
236+ return appWindow;
237+ }
238+
239+ // Wait until the ApplicationWindow for the given Application object is fully loaded
240+ // (ie, the real surface has replaced the splash screen)
241+ function waitUntilAppWindowIsFullyLoaded(surfaceId) {
242+ var appWindow = findAppWindowForSurfaceId(surfaceId);
243+ var appWindowStateGroup = findInvisibleChild(appWindow, "applicationWindowStateGroup");
244+ tryCompareFunction(function() { return appWindowStateGroup.state === "surface" }, true);
245+ waitUntilTransitionsEnd(appWindowStateGroup);
246+ }
247+
216248 function enterPin(pin) {
217249 typeString(pin);
218250 }
@@ -301,13 +333,15 @@ Item {
301333 }
302334
303335 function test_emergencyCallCrash() {
336+ var dialerSurfaceId = topLevelSurfaceList.nextId;
304337 var greeter = findChild(shell, "greeter");
305338 var emergencyButton = findChild(greeter, "emergencyCallLabel");
306339 tap(emergencyButton)
307−
340+ tryCompare(topLevelSurfaceList, "count", 2);
341+ waitUntilAppWindowIsFullyLoaded(dialerSurfaceId);
308342
309343 tryCompare(greeter, "shown", false);
310− killApps() // kill dialer-app, as if it crashed
344+ ApplicationManager.stopApplication("dialer-app"); // kill dialer-app, as if it crashed
311345 tryCompare(greeter, "shown", true);
312346 tryCompare(findChild(greeter, "lockscreen"), "shown", true);
313347 tryCompare(findChild(greeter, "coverPage"), "shown", false);
@@ -406,7 +440,7 @@ Item {
406440 compare(stage.usageScenario, "phone");
407441
408442 // And when we kill the app, we go back to locked tablet mode
409− killApps()
443+ ApplicationManager.stopApplication("dialer-app");
410444 var greeter = findChild(shell, "greeter")
411445 tryCompare(greeter, "fullyShown", true)
412446 compare(stage.usageScenario, "tablet");