on xenial help sign in
added test for lp#1534541
commit606508a087cf39cfbc51b50e2dd887fa179f7984 authorNick Dedekind <nick.dedekind@canonical.com> dateWed 3 Feb 2016, 14:07 (11 years ago) parent0eea7af
4 files changed+36−14
tests/mocks/Unity/Application/ApplicationTestInterface.cpp+4−4 tests/mocks/Unity/Application/ApplicationTestInterface.h+2−2 tests/qmltests/Stages/RecursingChildSessionControl.qml+3−3 tests/qmltests/Stages/tst_SessionContainer.qml+27−5
tests/mocks/Unity/Application/ApplicationTestInterface.cpp+4−4
@@ -36,7 +36,7 @@ ApplicationTestInterface::ApplicationTestInterface(QObject* parent)
3636 connection.registerObject("/com/canonical/Unity8/Mocks", parent);
3737}
3838
39−Session* ApplicationTestInterface::addChildSession(Session* existingSession, const QString& surfaceImage)
39+Session* ApplicationTestInterface::addChildSession(Session* existingSession, const QString& surfaceImage, bool addSurface)
4040{
4141 if (!existingSession) return nullptr;
4242
@@ -49,7 +49,7 @@ Session* ApplicationTestInterface::addChildSession(Session* existingSession, con
4949 .arg(existingSession->childSessions()->count()),
5050 screenshotUrl);
5151 existingSession->addChildSession(session);
52− session->createSurface();
52+ if (addSurface) session->createSurface();
5353
5454 return session;
5555}
@@ -70,7 +70,7 @@ void ApplicationTestInterface::removeSurface(MirSurface* existingSurface)
7070 existingSurface->setLive(false);
7171}
7272
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)
7474{
7575 qDebug() << "ApplicationTestInterface::addChildSession to " << appId;
7676
@@ -100,7 +100,7 @@ quint32 ApplicationTestInterface::addChildSession(const QString& appId, quint32
100100 .arg(parentSession->childSessions()->count()),
101101 screenshotUrl);
102102 parentSession->addChildSession(session);
103− session->createSurface();
103+ if (addSurface) { session->createSurface(); }
104104 m_childSessions[sessionId] = session;
105105
106106 return sessionId;
tests/mocks/Unity/Application/ApplicationTestInterface.h+2−2
@@ -30,12 +30,12 @@ class ApplicationTestInterface : public QDBusAbstractAdaptor
3030public:
3131 ApplicationTestInterface(QObject* parent = 0);
3232
33− Q_INVOKABLE Session* addChildSession(Session* existingSession, const QString& surfaceImage);
33+ Q_INVOKABLE Session* addChildSession(Session* existingSession, const QString& surfaceImage, bool addSurface);
3434 Q_INVOKABLE void removeSession(Session* existingSession);
3535 Q_INVOKABLE void removeSurface(MirSurface* existingSurface);
3636
3737public 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);
3939 void removeSession(quint32 sessionId);
4040
4141private:
tests/qmltests/Stages/RecursingChildSessionControl.qml+3−3
@@ -88,7 +88,7 @@ ColumnLayout {
8888
8989 CheckBox {
9090 id: _surfaceCheckbox;
91− checked: false;
91+ checked: root.session.lastSurface ? true : false
9292 activeFocusOnPress: false
9393 enabled: root.session
9494 onCheckedChanged: {
@@ -101,7 +101,7 @@ ColumnLayout {
101101
102102 Connections {
103103 target: root.session ? root.session : null
104− onSurfaceChanged: {
104+ onLastSurfaceChanged: {
105105 surfaceCheckbox.checked = root.session.lastSurface !== null
106106 }
107107 }
@@ -137,7 +137,7 @@ ColumnLayout {
137137 text: "Add Child"
138138 onClicked: {
139139 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);
141141 }
142142 }
143143 }
tests/qmltests/Stages/tst_SessionContainer.qml+27−5
@@ -155,7 +155,8 @@ Rectangle {
155155 var sessions = [];
156156 for (i = 0; i < data.count; i++) {
157157 var session = ApplicationTest.addChildSession(sessionContainer.session,
158− "gallery");
158+ "gallery",
159+ true);
159160 session.createSurface();
160161 sessionContainer.session.addChildSession(session);
161162 compare(sessionContainer.childSessions.count(), i+1);
@@ -180,7 +181,7 @@ Rectangle {
180181 // 3 sessions should cover all edge cases
181182 for(i = 0; i < 3; i++) {
182183 var a_session = ApplicationTest.addChildSession(
183− sessionContainer.session, "gallery"
184+ sessionContainer.session, "gallery", true
184185 )
185186
186187 a_session.createSurface();
@@ -226,7 +227,8 @@ Rectangle {
226227 var container = sessionContainer;
227228 for (i = 0; i < data.depth; i++) {
228229 var session = ApplicationTest.addChildSession(lastSession,
229− "gallery");
230+ "gallery",
231+ true);
230232 session.createSurface();
231233 lastSession.addChildSession(session);
232234 compare(container.childSessions.count(), 1);
@@ -250,7 +252,8 @@ Rectangle {
250252 var sessionContainer = sessionContainerLoader.item;
251253
252254 var session = ApplicationTest.addChildSession(sessionContainer.session,
253− "gallery");
255+ "gallery",
256+ true);
254257 session.createSurface();
255258 sessionContainer.session.addChildSession(session);
256259
@@ -288,7 +291,8 @@ Rectangle {
288291 var sessionContainer = sessionContainerLoader.item;
289292
290293 var session = ApplicationTest.addChildSession(sessionContainer.session,
291− "gallery");
294+ "gallery",
295+ true);
292296
293297 var delegate = findChild(sessionContainer, "childDelegate0");
294298 var childContainer = findChild(delegate, "sessionContainer");
@@ -304,6 +308,24 @@ Rectangle {
304308 tryCompareFunction(function() { return isContainerAnimating(childContainer); }, true);
305309 // wait for animation to end
306310 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);
307329 }
308330 }
309331}