@@ -29,68 +29,17 @@ Rectangle {
2929 width: units.gu(70)
3030 height: units.gu(70)
3131
32− Component {
33− id: fakeSurfaceComponent
34− Image {
35− source: "../../../qml/Dash/graphics/phone/screenshots/gallery@12.png"
36− width: applicationWindowLoader.width
37− height: applicationWindowLoader.height
38−
39− property var application: fakeApplication
40− property int touchPressCount: 0
41− property int touchReleaseCount: 0
42−
43− Text {
44− anchors.fill: parent
45− text: "SURFACE"
46− color: "yellow"
47− font.bold: true
48− fontSizeMode: Text.Fit
49− minimumPixelSize: 10; font.pixelSize: 200
50− verticalAlignment: Text.AlignVCenter
51− }
52−
53− MultiPointTouchArea {
54− anchors.fill: parent
55− onPressed: { touchPressCount++; }
56− onReleased: { touchReleaseCount++; }
57− }
58−
59− signal removed()
60−
61− function release() {
62− fakeApplication.surface = null;
63− parent = null;
64− removed();
65− surfaceCheckbox.checked = false;
66− }
67− }
32+ Component.onCompleted: {
33+ root.fakeApplication = ApplicationManager.add("gallery-app");
34+ root.fakeApplication.manualSurfaceCreation = true;
35+ root.fakeApplication.setState(ApplicationInfo.Starting);
6836 }
37+ property QtObject fakeApplication: null
6938
70− QtObject {
71− id: fakeApplication
72− property url screenshot: ""
73−
74− function updateScreenshot() {
75− fakeScreenshotTimer.start();
76− }
77−
78− function discardScreenshot() {
79− screenshot = "";
80− }
81−
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
88− }
89− Timer {
90− id: fakeScreenshotTimer
91− interval: 100
92− onTriggered: {
93− fakeApplication.screenshot = "../../../qml/Dash/graphics/phone/screenshots/gallery@12.png";
39+ Connections {
40+ target: fakeApplication
41+ onSurfaceChanged: {
42+ surfaceCheckbox.checked = fakeApplication.surface !== null;
9443 }
9544 }
9645
@@ -133,7 +82,7 @@ Rectangle {
13382 return;
13483
13584 if (checked && !fakeApplication.surface) {
136− fakeApplication.surface = fakeSurfaceComponent.createObject(null, {});
85+ fakeApplication.createSurface();
13786 } else if (!checked && fakeApplication.surface) {
13887 fakeApplication.surface.release();
13988 }
@@ -160,6 +109,10 @@ Rectangle {
160109 return ApplicationInfo.Stopped;
161110 }
162111 }
112+ onSelectedApplicationStateChanged: {
113+ // state is a read-only property, thus we have to call the setter function
114+ fakeApplication.setState(selectedApplicationState);
115+ }
163116 }
164117 }
165118 }
@@ -199,9 +152,8 @@ Rectangle {
199152 appStateSelector.selectedIndex = 0;
200153 surfaceCheckbox.checked = false;
201154
202− fakeScreenshotTimer.stop();
203− fakeApplication.screenshot = "";
204− fakeApplication.surface = null;
155+ if (fakeApplication.surface)
156+ fakeApplication.surface.release();
205157
206158 applicationWindowLoader.active = true;
207159 }
@@ -270,6 +222,7 @@ Rectangle {
270222
271223 function test_restartApp() {
272224 var stateGroup = findInvisibleChild(applicationWindowLoader.item, "applicationWindowStateGroup");
225+ var screenshotImage = findChild(applicationWindowLoader.item, "screenshotImage");
273226
274227 surfaceCheckbox.checked = true;
275228 setApplicationState(appRunning);
@@ -298,7 +251,7 @@ Rectangle {
298251 surfaceCheckbox.checked = true;
299252
300253 tryCompare(stateGroup, "state", "surface");
301− tryCompare(fakeApplication, "screenshot", "");
254+ tryCompare(screenshotImage, "status", Image.Null);
302255 }
303256
304257 function test_appCrashed() {
@@ -347,14 +300,16 @@ Rectangle {
347300 // wait until any transition animation has finished
348301 tryCompare(stateGroup, "transitioning", false, 2000);
349302
350− fakeApplication.surface.touchPressCount = 0;
351− fakeApplication.surface.touchReleaseCount = 0;
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");
305+ fakeSurface.touchPressCount = 0;
306+ fakeSurface.touchReleaseCount = 0;
352307
353308 tap(applicationWindowLoader.item,
354309 applicationWindowLoader.item.width / 2, applicationWindowLoader.item.height / 2);
355310
356− verify(fakeApplication.surface.touchPressCount === 1);
357− verify(fakeApplication.surface.touchReleaseCount === 1);
311+ verify(fakeSurface.touchPressCount === 1);
312+ verify(fakeSurface.touchReleaseCount === 1);
358313 }
359314 }
360315}