on xenial help sign in
[CHECKPOINT COMMIT]
408e139josharenson
qml/Stages/SessionContainer.qml+9
@@ -36,6 +36,7 @@ Item {
36
36
37
37
38 Repeater {
38 Repeater {
39+ id: theRepeater
39 model: root.childSessions
40 model: root.childSessions
40
41
41 delegate: Loader {
42 delegate: Loader {
@@ -69,6 +70,14 @@ Item {
69 target: item; when: item
70 target: item; when: item
70 property: "orientation"; value: root.orientation
71 property: "orientation"; value: root.orientation
71 }
72 }
73+
74+ Component.onDestruction: {
75+ //console.log("FAIL: count: " + root.childSessions.count())
76+ //console.log("FAIL: " + theRepeater.itemAt(0));
77+ var nextSession = root.childSessions.count() ? theRepeater.itemAt(root.childSessions.count() - 1) : root.session;
78+ console.log("FAIL: " + nextSession);
79+ nextSession.forceActiveFocus()
80+ }
72 }
81 }
73 }
82 }
74
83
tests/mocks/Unity/Application/Session.h+1−1
@@ -56,7 +56,7 @@ public:
56
56
57 Q_INVOKABLE void addChildSession(Session* session);
57 Q_INVOKABLE void addChildSession(Session* session);
58 void insertChildSession(uint index, Session* session);
58 void insertChildSession(uint index, Session* session);
59− void removeChildSession(Session* session);
59+ Q_INVOKABLE void removeChildSession(Session* session);
60
60
61Q_SIGNALS:
61Q_SIGNALS:
62 void applicationChanged(ApplicationInfo*);
62 void applicationChanged(ApplicationInfo*);
tests/qmltests/Stages/tst_SessionContainer.qml+47
@@ -185,6 +185,53 @@ Rectangle {
185 tryCompare(sessionSpy, "count", data.count);
185 tryCompare(sessionSpy, "count", data.count);
186 }
186 }
187
187
188+ function test_childSessionDestructionReturnsFocusToSiblingOrParent() {
189+ console.log("FAIL: entering childSessionDestriction....")
190+ sessionCheckbox.checked = true;
191+
192+ var sessionContainer = sessionContainerLoader.item;
193+
194+ // Without this, we cannot get active focus
195+ sessionContainer.interactive = true;
196+ compare(sessionContainer.childSessions.count(), 0);
197+
198+ /*
199+ * Build a stack of fake sessions
200+ * 3 sessions should cover all edge cases
201+ * - Focus from departing session goes to sibling
202+ * - Focus from last child goes to parent
203+ */
204+ var i;
205+ var sessions = [];
206+ for(i = 0; i < 3; i++) {
207+ var session = ApplicationTest.addChildSession(
208+ sessionContainer.session, "gallery");
209+ session.createSurface();
210+ sessionContainer.session.addChildSession(session);
211+ compare(sessionContainer.childSessions.count(), i+1);
212+
213+ sessions.push(session);
214+ }
215+
216+ // Traverse the fake session stack, following and testing focus
217+ var sessionUnderTest;
218+ while(sessionUnderTest = sessions.pop()) {
219+ var surface = sessionUnderTest.surface;
220+ surface.forceActiveFocus();
221+ compare(surface.activeFocus, true);
222+
223+ var nextSession = sessions.pop();
224+ if(nextSession != undefined) {
225+ sessions.push(nextSession);
226+ sessionContainer.session.removeChildSession(sessionUnderTest);
227+ compare(surface.activeFocus, false);
228+
229+ compare(nextSession.surface.activeFocus, true)
230+ }
231+ }
232+ console.log("FAIL: exiting childSessionDestriction....")
233+ }
234+
188 function test_nestedChildSessions_data() {
235 function test_nestedChildSessions_data() {
189 return [ { tag: "depth=2", depth: 2 },
236 return [ { tag: "depth=2", depth: 2 },
190 { tag: "depth=8", depth: 8 }
237 { tag: "depth=8", depth: 8 }