@@ -29,68 +29,17 @@ Rectangle {
29 width: units.gu(70)
29 width: units.gu(70)
30 height: units.gu(70)
30 height: units.gu(70)
32− Component {
32+ Component.onCompleted: {
33− id: fakeSurfaceComponent
33+ root.fakeApplication = ApplicationManager.add("gallery-app");
34− Image {
34+ root.fakeApplication.manualSurfaceCreation = true;
35− source: "../../../qml/Dash/graphics/phone/screenshots/gallery@12.png"
35+ root.fakeApplication.setState(ApplicationInfo.Starting);
36− width: applicationWindowLoader.width
37− height: applicationWindowLoader.height
39− property var application: fakeApplication
40− property int touchPressCount: 0
41− property int touchReleaseCount: 0
48− fontSizeMode: Text.Fit
49− minimumPixelSize: 10; font.pixelSize: 200
50− verticalAlignment: Text.AlignVCenter
53− MultiPointTouchArea {
55− onPressed: { touchPressCount++; }
56− onReleased: { touchReleaseCount++; }
62− fakeApplication.surface = null;
65− surfaceCheckbox.checked = false;
37+ property QtObject fakeApplication: null
70− QtObject {
39+ Connections {
71− id: fakeApplication
40+ target: fakeApplication
72− property url screenshot: ""
41+ onSurfaceChanged: {
73−
42+ surfaceCheckbox.checked = fakeApplication.surface !== null;
74− function updateScreenshot() {
75− fakeScreenshotTimer.start();
78− function discardScreenshot() {
82− property alias state: appStateSelector.selectedApplicationState
83− property string name: "Gallery"
84− property url icon: "../../../qml/graphics/applicationIcons/gallery.png"
85− property var surface: null
86− property bool fullscreen: true
87− property list<Item> childSurfaces
90− id: fakeScreenshotTimer
93− fakeApplication.screenshot = "../../../qml/Dash/graphics/phone/screenshots/gallery@12.png";
@@ -133,7 +82,7 @@ Rectangle {
135 if (checked && !fakeApplication.surface) {
84 if (checked && !fakeApplication.surface) {
136− fakeApplication.surface = fakeSurfaceComponent.createObject(null, {});
85+ fakeApplication.createSurface();
137 } else if (!checked && fakeApplication.surface) {
86 } else if (!checked && fakeApplication.surface) {
138 fakeApplication.surface.release();
87 fakeApplication.surface.release();
@@ -160,6 +109,10 @@ Rectangle {
160 return ApplicationInfo.Stopped;
109 return ApplicationInfo.Stopped;
112+ onSelectedApplicationStateChanged: {
113+ // state is a read-only property, thus we have to call the setter function
114+ fakeApplication.setState(selectedApplicationState);
@@ -199,9 +152,8 @@ Rectangle {
199 appStateSelector.selectedIndex = 0;
152 appStateSelector.selectedIndex = 0;
200 surfaceCheckbox.checked = false;
153 surfaceCheckbox.checked = false;
202− fakeScreenshotTimer.stop();
203− fakeApplication.screenshot = "";
155+ if (fakeApplication.surface)
204− fakeApplication.surface = null;
156+ fakeApplication.surface.release();
206 applicationWindowLoader.active = true;
158 applicationWindowLoader.active = true;
@@ -270,6 +222,7 @@ Rectangle {
271 function test_restartApp() {
223 function test_restartApp() {
272 var stateGroup = findInvisibleChild(applicationWindowLoader.item, "applicationWindowStateGroup");
224 var stateGroup = findInvisibleChild(applicationWindowLoader.item, "applicationWindowStateGroup");
225+ var screenshotImage = findChild(applicationWindowLoader.item, "screenshotImage");
274 surfaceCheckbox.checked = true;
227 surfaceCheckbox.checked = true;
275 setApplicationState(appRunning);
228 setApplicationState(appRunning);
@@ -298,7 +251,7 @@ Rectangle {
298 surfaceCheckbox.checked = true;
251 surfaceCheckbox.checked = true;
300 tryCompare(stateGroup, "state", "surface");
253 tryCompare(stateGroup, "state", "surface");
301− tryCompare(fakeApplication, "screenshot", "");
254+ tryCompare(screenshotImage, "status", Image.Null);
304 function test_appCrashed() {
257 function test_appCrashed() {
@@ -347,14 +300,16 @@ Rectangle {
347 // wait until any transition animation has finished
300 // wait until any transition animation has finished
348 tryCompare(stateGroup, "transitioning", false, 2000);
301 tryCompare(stateGroup, "transitioning", false, 2000);
303+ // Because doing stuff in C++ is a PITA we keep the counter in the interal qml impl.
304+ var fakeSurface = findChild(fakeApplication.surface, "fakeSurfaceQML");
350− fakeApplication.surface.touchPressCount = 0;
305+ fakeSurface.touchPressCount = 0;
351− fakeApplication.surface.touchReleaseCount = 0;
306+ fakeSurface.touchReleaseCount = 0;
353 tap(applicationWindowLoader.item,
308 tap(applicationWindowLoader.item,
354 applicationWindowLoader.item.width / 2, applicationWindowLoader.item.height / 2);
309 applicationWindowLoader.item.width / 2, applicationWindowLoader.item.height / 2);
356− verify(fakeApplication.surface.touchPressCount === 1);
311+ verify(fakeSurface.touchPressCount === 1);
357− verify(fakeApplication.surface.touchReleaseCount === 1);
312+ verify(fakeSurface.touchReleaseCount === 1);