on xenial help sign in
fix an issue where the highlight might not be removed after launching
commit4fa59aeb5c83700999b0b69f552c1c9ba7ec9f21 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 25 Feb 2016, 19:08 (11 years ago) parent53f85f7
2 files changed+18−8
qml/Launcher/Launcher.qml+2−1 tests/qmltests/Launcher/tst_Launcher.qml+16−7
qml/Launcher/Launcher.qml+2−1
@@ -162,7 +162,7 @@ FocusScope {
162162 event.accepted = true;
163163 break;
164164 case Qt.Key_Escape:
165− panel.highlightIndex = -2
165+ panel.highlightIndex = -2;
166166 // Falling through intentionally
167167 case Qt.Key_Enter:
168168 case Qt.Key_Return:
@@ -172,6 +172,7 @@ FocusScope {
172172 } else if (panel.highlightIndex >= 0) {
173173 launcherApplicationSelected(LauncherModel.get(panel.highlightIndex).appId);
174174 }
175+ panel.highlightIndex = -2
175176 root.state = ""
176177 event.accepted = true;
177178 root.focus = false;
tests/qmltests/Launcher/tst_Launcher.qml+16−7
@@ -288,14 +288,20 @@ Item {
288288 }
289289
290290 function assertFocusOnIndex(index) {
291− var launcherListView = findChild(launcher, "launcherListView");
292− var bfbFocusHighlight = findChild(launcher, "bfbFocusHighlight");
293−
294− waitForRendering(launcher);
291+ var launcherPanel = findChild(launcherLoader.item, "launcherPanel");
292+ var launcherListView = findChild(launcherLoader.item, "launcherListView");
293+ var bfbFocusHighlight = findChild(launcherLoader.item, "bfbFocusHighlight");
294+ waitForRendering(launcherLoader.item);
295+ tryCompare(launcherPanel, "highlightIndex", index);
295296 tryCompare(bfbFocusHighlight, "visible", index === -1);
296297 for (var i = 0; i < launcherListView.count; i++) {
297− var focusRing = findChild(findChild(launcher, "launcherDelegate" + i), "focusRing")
298− tryCompare(focusRing, "visible", index === i);
298+ var item = findChild(launcher, "launcherDelegate" + i);
299+ // Delegates might be destroyed when not visible. We can't check if they paint a focus highlight.
300+ // Make sure the requested index does have focus. for the others, try best effort to check if they don't
301+ if (index === i || item) {
302+ var focusRing = findChild(item, "focusRing")
303+ tryCompare(focusRing, "visible", index === i);
304+ }
299305 }
300306 }
301307
@@ -1090,7 +1096,6 @@ Item {
10901096 var last = launcherListView.count - 1;
10911097
10921098 compare(bfbFocusHighlight.visible, false);
1093−
10941099 launcher.openForKeyboardNavigation();
10951100
10961101 assertFocusOnIndex(-1);
@@ -1113,6 +1118,7 @@ Item {
11131118
11141119 // The list should wrap around
11151120 keyClick(Qt.Key_Up);
1121+ waitForRendering(launcher);
11161122 assertFocusOnIndex(last);
11171123
11181124 keyClick(Qt.Key_Down);
@@ -1145,6 +1151,9 @@ Item {
11451151 // Go bar to top by wrapping around
11461152 keyClick(Qt.Key_Down);
11471153 assertFocusOnIndex(1);
1154+
1155+ keyClick(Qt.Key_Enter);
1156+ assertFocusOnIndex(-2);
11481157 }
11491158
11501159 function test_selectQuicklistItemByKeyboard() {