on xenial help sign in
[CHECKPOINT COMMIT]

A potentially working mess

commit408e13929380d89ed4a00fe35b383d3f1eb84ab8 authorjosharenson <joshua.arenson@canonical.com> dateThu 23 Oct 2014, 10:15 (12 years ago) parent1ff2631
3 files changed+57−1
qml/Stages/SessionContainer.qml+9 tests/mocks/Unity/Application/Session.h+1−1 tests/qmltests/Stages/tst_SessionContainer.qml+47
qml/Stages/SessionContainer.qml+9
@@ -36,6 +36,7 @@ Item {
3636
3737
3838 Repeater {
39+ id: theRepeater
3940 model: root.childSessions
4041
4142 delegate: Loader {
@@ -69,6 +70,14 @@ Item {
6970 target: item; when: item
7071 property: "orientation"; value: root.orientation
7172 }
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+ }
7281 }
7382 }
7483
tests/mocks/Unity/Application/Session.h+1−1
@@ -56,7 +56,7 @@ public:
5656
5757 Q_INVOKABLE void addChildSession(Session* session);
5858 void insertChildSession(uint index, Session* session);
59− void removeChildSession(Session* session);
59+ Q_INVOKABLE void removeChildSession(Session* session);
6060
6161Q_SIGNALS:
6262 void applicationChanged(ApplicationInfo*);
tests/qmltests/Stages/tst_SessionContainer.qml+47
@@ -185,6 +185,53 @@ Rectangle {
185185 tryCompare(sessionSpy, "count", data.count);
186186 }
187187
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+
188235 function test_nestedChildSessions_data() {
189236 return [ { tag: "depth=2", depth: 2 },
190237 { tag: "depth=8", depth: 8 }