on xenial help sign in
added test for lp#1534541
606508aNick Dedekind
tests/mocks/Unity/Application/ApplicationTestInterface.cpp+4−4
@@ -36,7 +36,7 @@ ApplicationTestInterface::ApplicationTestInterface(QObject* parent)
36 connection.registerObject("/com/canonical/Unity8/Mocks", parent);
36 connection.registerObject("/com/canonical/Unity8/Mocks", parent);
37}
37}
38
38
39−Session* ApplicationTestInterface::addChildSession(Session* existingSession, const QString& surfaceImage)
39+Session* ApplicationTestInterface::addChildSession(Session* existingSession, const QString& surfaceImage, bool addSurface)
40{
40{
41 if (!existingSession) return nullptr;
41 if (!existingSession) return nullptr;
42
42
@@ -49,7 +49,7 @@ Session* ApplicationTestInterface::addChildSession(Session* existingSession, con
49 .arg(existingSession->childSessions()->count()),
49 .arg(existingSession->childSessions()->count()),
50 screenshotUrl);
50 screenshotUrl);
51 existingSession->addChildSession(session);
51 existingSession->addChildSession(session);
52− session->createSurface();
52+ if (addSurface) session->createSurface();
53
53
54 return session;
54 return session;
55}
55}
@@ -70,7 +70,7 @@ void ApplicationTestInterface::removeSurface(MirSurface* existingSurface)
70 existingSurface->setLive(false);
70 existingSurface->setLive(false);
71}
71}
72
72
73−quint32 ApplicationTestInterface::addChildSession(const QString& appId, quint32 existingSessionId, const QString& surfaceImage)
73+quint32 ApplicationTestInterface::addChildSession(const QString& appId, quint32 existingSessionId, const QString& surfaceImage, bool addSurface)
74{
74{
75 qDebug() << "ApplicationTestInterface::addChildSession to " << appId;
75 qDebug() << "ApplicationTestInterface::addChildSession to " << appId;
76
76
@@ -100,7 +100,7 @@ quint32 ApplicationTestInterface::addChildSession(const QString& appId, quint32
100 .arg(parentSession->childSessions()->count()),
100 .arg(parentSession->childSessions()->count()),
101 screenshotUrl);
101 screenshotUrl);
102 parentSession->addChildSession(session);
102 parentSession->addChildSession(session);
103− session->createSurface();
103+ if (addSurface) { session->createSurface(); }
104 m_childSessions[sessionId] = session;
104 m_childSessions[sessionId] = session;
105
105
106 return sessionId;
106 return sessionId;
tests/mocks/Unity/Application/ApplicationTestInterface.h+2−2
@@ -30,12 +30,12 @@ class ApplicationTestInterface : public QDBusAbstractAdaptor
30public:
30public:
31 ApplicationTestInterface(QObject* parent = 0);
31 ApplicationTestInterface(QObject* parent = 0);
32
32
33− Q_INVOKABLE Session* addChildSession(Session* existingSession, const QString& surfaceImage);
33+ Q_INVOKABLE Session* addChildSession(Session* existingSession, const QString& surfaceImage, bool addSurface);
34 Q_INVOKABLE void removeSession(Session* existingSession);
34 Q_INVOKABLE void removeSession(Session* existingSession);
35 Q_INVOKABLE void removeSurface(MirSurface* existingSurface);
35 Q_INVOKABLE void removeSurface(MirSurface* existingSurface);
36
36
37public Q_SLOTS:
37public Q_SLOTS:
38− quint32 addChildSession(const QString& appId, quint32 existingSessionId, const QString& surfaceImage);
38+ quint32 addChildSession(const QString& appId, quint32 existingSessionId, const QString& surfaceImage, bool addSurface);
39 void removeSession(quint32 sessionId);
39 void removeSession(quint32 sessionId);
40
40
41private:
41private:
tests/qmltests/Stages/RecursingChildSessionControl.qml+3−3
@@ -88,7 +88,7 @@ ColumnLayout {
88
88
89 CheckBox {
89 CheckBox {
90 id: _surfaceCheckbox;
90 id: _surfaceCheckbox;
91− checked: false;
91+ checked: root.session.lastSurface ? true : false
92 activeFocusOnPress: false
92 activeFocusOnPress: false
93 enabled: root.session
93 enabled: root.session
94 onCheckedChanged: {
94 onCheckedChanged: {
@@ -101,7 +101,7 @@ ColumnLayout {
101
101
102 Connections {
102 Connections {
103 target: root.session ? root.session : null
103 target: root.session ? root.session : null
104− onSurfaceChanged: {
104+ onLastSurfaceChanged: {
105 surfaceCheckbox.checked = root.session.lastSurface !== null
105 surfaceCheckbox.checked = root.session.lastSurface !== null
106 }
106 }
107 }
107 }
@@ -137,7 +137,7 @@ ColumnLayout {
137 text: "Add Child"
137 text: "Add Child"
138 onClicked: {
138 onClicked: {
139 var screenshot = Math.round(Math.random()*100 % (screenshotIds.length-1));
139 var screenshot = Math.round(Math.random()*100 % (screenshotIds.length-1));
140− var session = ApplicationTest.addChildSession(root.session, root.screenshotIds[screenshot]);
140+ var session = ApplicationTest.addChildSession(root.session, root.screenshotIds[screenshot], true);
141 }
141 }
142 }
142 }
143 }
143 }
tests/qmltests/Stages/tst_SessionContainer.qml+27−5
@@ -155,7 +155,8 @@ Rectangle {
155 var sessions = [];
155 var sessions = [];
156 for (i = 0; i < data.count; i++) {
156 for (i = 0; i < data.count; i++) {
157 var session = ApplicationTest.addChildSession(sessionContainer.session,
157 var session = ApplicationTest.addChildSession(sessionContainer.session,
158− "gallery");
158+ "gallery",
159+ true);
159 session.createSurface();
160 session.createSurface();
160 sessionContainer.session.addChildSession(session);
161 sessionContainer.session.addChildSession(session);
161 compare(sessionContainer.childSessions.count(), i+1);
162 compare(sessionContainer.childSessions.count(), i+1);
@@ -180,7 +181,7 @@ Rectangle {
180 // 3 sessions should cover all edge cases
181 // 3 sessions should cover all edge cases
181 for(i = 0; i < 3; i++) {
182 for(i = 0; i < 3; i++) {
182 var a_session = ApplicationTest.addChildSession(
183 var a_session = ApplicationTest.addChildSession(
183− sessionContainer.session, "gallery"
184+ sessionContainer.session, "gallery", true
184 )
185 )
185
186
186 a_session.createSurface();
187 a_session.createSurface();
@@ -226,7 +227,8 @@ Rectangle {
226 var container = sessionContainer;
227 var container = sessionContainer;
227 for (i = 0; i < data.depth; i++) {
228 for (i = 0; i < data.depth; i++) {
228 var session = ApplicationTest.addChildSession(lastSession,
229 var session = ApplicationTest.addChildSession(lastSession,
229− "gallery");
230+ "gallery",
231+ true);
230 session.createSurface();
232 session.createSurface();
231 lastSession.addChildSession(session);
233 lastSession.addChildSession(session);
232 compare(container.childSessions.count(), 1);
234 compare(container.childSessions.count(), 1);
@@ -250,7 +252,8 @@ Rectangle {
250 var sessionContainer = sessionContainerLoader.item;
252 var sessionContainer = sessionContainerLoader.item;
251
253
252 var session = ApplicationTest.addChildSession(sessionContainer.session,
254 var session = ApplicationTest.addChildSession(sessionContainer.session,
253− "gallery");
255+ "gallery",
256+ true);
254 session.createSurface();
257 session.createSurface();
255 sessionContainer.session.addChildSession(session);
258 sessionContainer.session.addChildSession(session);
256
259
@@ -288,7 +291,8 @@ Rectangle {
288 var sessionContainer = sessionContainerLoader.item;
291 var sessionContainer = sessionContainerLoader.item;
289
292
290 var session = ApplicationTest.addChildSession(sessionContainer.session,
293 var session = ApplicationTest.addChildSession(sessionContainer.session,
291− "gallery");
294+ "gallery",
295+ true);
292
296
293 var delegate = findChild(sessionContainer, "childDelegate0");
297 var delegate = findChild(sessionContainer, "childDelegate0");
294 var childContainer = findChild(delegate, "sessionContainer");
298 var childContainer = findChild(delegate, "sessionContainer");
@@ -304,6 +308,24 @@ Rectangle {
304 tryCompareFunction(function() { return isContainerAnimating(childContainer); }, true);
308 tryCompareFunction(function() { return isContainerAnimating(childContainer); }, true);
305 // wait for animation to end
309 // wait for animation to end
306 tryCompareFunction(function() { return isContainerAnimating(childContainer); }, false);
310 tryCompareFunction(function() { return isContainerAnimating(childContainer); }, false);
311+
312+ tryCompareFunction(function() { return sessionContainer.childSessions.count() }, 0);
313+ }
314+
315+ function test_childSessionsRemovedOnStopWhenNotLive() {
316+ sessionCheckbox.checked = true;
317+ var sessionContainer = sessionContainerLoader.item;
318+
319+ var session = ApplicationTest.addChildSession(sessionContainer.session,
320+ "gallery",
321+ false);
322+
323+ var delegate = findChild(sessionContainer, "childDelegate0");
324+ var childContainer = findChild(delegate, "sessionContainer");
325+
326+ ApplicationTest.removeSession(session);
327+
328+ tryCompareFunction(function() { return sessionContainer.childSessions.count() }, 0);
307 }
329 }
308 }
330 }
309}
331}