on xenial help sign in
Fix tst_SurfaceContainer
ed94a00Daniel d'Andrada
tests/mocks/Unity/Application/ApplicationInfo.h+2
@@ -44,6 +44,8 @@ class ApplicationInfo : public ApplicationInfoInterface {
44 // whether the test code will explicitly control the creation of the application surface
44 // whether the test code will explicitly control the creation of the application surface
45 Q_PROPERTY(bool manualSurfaceCreation READ manualSurfaceCreation WRITE setManualSurfaceCreation NOTIFY manualSurfaceCreationChanged)
45 Q_PROPERTY(bool manualSurfaceCreation READ manualSurfaceCreation WRITE setManualSurfaceCreation NOTIFY manualSurfaceCreationChanged)
46
46
47+ Q_PROPERTY(QString screenshot READ screenshot CONSTANT)
48+
47public:
49public:
48 ApplicationInfo(QObject *parent = nullptr);
50 ApplicationInfo(QObject *parent = nullptr);
49 ApplicationInfo(const QString &appId, QObject *parent = nullptr);
51 ApplicationInfo(const QString &appId, QObject *parent = nullptr);
tests/qmltests/Stages/tst_SurfaceContainer.qml+17−5
@@ -39,10 +39,12 @@ Rectangle {
39 id: surfaceContainerComponent
39 id: surfaceContainerComponent
40
40
41 SurfaceContainer {
41 SurfaceContainer {
42− id: surfaceContainer
43 anchors.fill: parent
42 anchors.fill: parent
44 focus: true
43 focus: true
45 interactive: interactiveCheckbox.checked
44 interactive: interactiveCheckbox.checked
45+ Component.onDestruction: {
46+ surfaceContainerLoader.itemDestroyed = true;
47+ }
46 }
48 }
47 }
49 }
48
50
@@ -56,6 +58,7 @@ Rectangle {
56 left: parent.left
58 left: parent.left
57 }
59 }
58 width: units.gu(40)
60 width: units.gu(40)
61+ property bool itemDestroyed: false
59 sourceComponent: surfaceContainerComponent
62 sourceComponent: surfaceContainerComponent
60 }
63 }
61
64
@@ -102,7 +105,7 @@ Rectangle {
102 application.setState(ApplicationInfoInterface.Starting);
105 application.setState(ApplicationInfoInterface.Starting);
103
106
104 surfaceContainerLoader.item.surface = SurfaceManager.createSurface("foo",
107 surfaceContainerLoader.item.surface = SurfaceManager.createSurface("foo",
105− Mir.NormalType, Mir.MaximizedState, application);
108+ Mir.NormalType, Mir.MaximizedState, application.screenshot);
106
109
107 application.setState(ApplicationInfoInterface.Running);
110 application.setState(ApplicationInfoInterface.Running);
108 } else {
111 } else {
@@ -143,18 +146,27 @@ Rectangle {
143
146
144 UT.UnityTestCase {
147 UT.UnityTestCase {
145 id: testCase
148 id: testCase
146− name: "SessionContainer"
149+ name: "SurfaceContainer"
147
150
148 property Item surfaceContainer: surfaceContainerLoader.status === Loader.Ready ? surfaceContainerLoader.item : null
151 property Item surfaceContainer: surfaceContainerLoader.status === Loader.Ready ? surfaceContainerLoader.item : null
149
152
150 function cleanup() {
153 function cleanup() {
151 // reload our test subject to get it in a fresh state once again
154 // reload our test subject to get it in a fresh state once again
155+
156+ surfaceContainerLoader.itemDestroyed = false;
152 surfaceContainerLoader.active = false;
157 surfaceContainerLoader.active = false;
158+
159+ tryCompare(surfaceContainerLoader, "status", Loader.Null);
160+ tryCompare(surfaceContainerLoader, "item", null);
161+ tryCompare(surfaceContainerLoader, "itemDestroyed", true);
162+
163+ killApps();
164+
153 surfaceCheckbox.checked = false;
165 surfaceCheckbox.checked = false;
154 interactiveCheckbox.checked = true;
166 interactiveCheckbox.checked = true;
155− surfaceContainerLoader.active = true;
156
167
168+ surfaceContainerLoader.active = true;
157− tryCompare(surfaceContainerLoader.item, "surface", null);
169+ tryCompare(surfaceContainerLoader, "status", Loader.Ready);
158 }
170 }
159
171
160 when: windowShown
172 when: windowShown