2 * Copyright 2016 Canonical Ltd.
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
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18import QtMir.Application 0.1
19import Lomiri.Components 1.3
24 property QtObject topLevelSurfaceList: null
27 Wait until the ApplicationWindow for the given surface id (from TopLevelWindowModel) is fully loaded
28 (ie, the real surface has replaced the splash screen)
30 function waitUntilAppWindowIsFullyLoaded(surfaceId) {
31 var appDelegate = findChild(stage, "appDelegate_" + surfaceId);
33 var appWindow = findChild(appDelegate, "appWindow");
35 var appWindowStates = findInvisibleChild(appWindow, "applicationWindowStateGroup");
36 verify(appWindowStates);
37 tryCompare(appWindowStates, "state", "surface");
38 waitUntilTransitionsEnd(appWindowStates);
42 Returns the appDelegate of the first surface created by the app with the specified appId
44 function startApplication(appId) {
45 var app = ApplicationManager.findApplication(appId);
47 for (var i = 0; i < topLevelSurfaceList.count; i++) {
48 if (topLevelSurfaceList.applicationAt(i).appId === appId) {
49 var appRepeater = findChild(stage, "appRepeater");
51 return appRepeater.itemAt(i);
56 var surfaceId = topLevelSurfaceList.nextId;
57 app = ApplicationManager.startApplication(appId);
59 waitUntilAppWindowIsFullyLoaded(surfaceId);
60 compare(app.surfaceList.count, 1);
62 return findChild(stage, "appDelegate_" + surfaceId);