on xenial help sign in
merge prereq
commit391bd947a32246cfbbe6cf09f3e7400b6f4715fa authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 25 Feb 2016, 19:16 (11 years ago) parent61828154fa59ae
2 files changed+15−4
qml/Launcher/Launcher.qml+2−1 tests/qmltests/Launcher/tst_Launcher.qml+13−3
qml/Launcher/Launcher.qml+2−1
@@ -175,7 +175,7 @@ FocusScope {
175175 event.accepted = true;
176176 break;
177177 case Qt.Key_Escape:
178− panel.highlightIndex = -2
178+ panel.highlightIndex = -2;
179179 // Falling through intentionally
180180 case Qt.Key_Enter:
181181 case Qt.Key_Return:
@@ -186,6 +186,7 @@ FocusScope {
186186 launcherApplicationSelected(LauncherModel.get(panel.highlightIndex).appId);
187187 }
188188 root.hide();
189+ panel.highlightIndex = -2
189190 event.accepted = true;
190191 root.focus = false;
191192 }
tests/qmltests/Launcher/tst_Launcher.qml+13−3
@@ -320,14 +320,21 @@ Item {
320320 }
321321
322322 function assertFocusOnIndex(index) {
323+ var launcherPanel = findChild(launcher, "launcherPanel");
323324 var launcherListView = findChild(launcher, "launcherListView");
324325 var bfbFocusHighlight = findChild(launcher, "bfbFocusHighlight");
325326
326327 waitForRendering(launcher);
328+ tryCompare(launcherPanel, "highlightIndex", index);
327329 compare(bfbFocusHighlight.visible, index === -1);
328330 for (var i = 0; i < launcherListView.count; i++) {
329− var focusRing = findChild(findChild(launcher, "launcherDelegate" + i), "focusRing")
330− compare(focusRing.visible, index === i);
331+ var item = findChild(launcher, "launcherDelegate" + i);
332+ // Delegates might be destroyed when not visible. We can't check if they paint a focus highlight.
333+ // Make sure the requested index does have focus. for the others, try best effort to check if they don't
334+ if (index === i || item) {
335+ var focusRing = findChild(item, "focusRing")
336+ tryCompare(focusRing, "visible", index === i);
337+ }
331338 }
332339 }
333340
@@ -1129,7 +1136,6 @@ Item {
11291136 var last = launcherListView.count - 1;
11301137
11311138 compare(bfbFocusHighlight.visible, false);
1132−
11331139 launcher.openForKeyboardNavigation();
11341140 tryCompare(launcherPanel, "x", 0);
11351141 waitForRendering(launcher);
@@ -1154,6 +1160,7 @@ Item {
11541160
11551161 // The list should wrap around
11561162 keyClick(Qt.Key_Up);
1163+ waitForRendering(launcher);
11571164 assertFocusOnIndex(last);
11581165
11591166 keyClick(Qt.Key_Down);
@@ -1186,6 +1193,9 @@ Item {
11861193 // Go bar to top by wrapping around
11871194 keyClick(Qt.Key_Down);
11881195 assertFocusOnIndex(1);
1196+
1197+ keyClick(Qt.Key_Enter);
1198+ assertFocusOnIndex(-2);
11891199 }
11901200
11911201 function test_selectQuicklistItemByKeyboard() {