on xenial help sign in
add launcher test goodness
69c0e80Michael Zanetti
tests/qmltests/Launcher/tst_Launcher.qml+101
@@ -104,6 +104,12 @@ Item {
104 Layout.fillWidth: true
104 Layout.fillWidth: true
105 }
105 }
106
106
107+ Button {
108+ text: "open for kbd navigation"
109+ onClicked: launcherLoader.item.openForKeyboardNavigation()
110+ Layout.fillWidth: true
111+ }
112+
107 Row {
113 Row {
108 spacing: units.gu(1)
114 spacing: units.gu(1)
109
115
@@ -257,6 +263,18 @@ Item {
257 }
263 }
258 }
264 }
259
265
266+ function assertFocusOnIndex(index) {
267+ var launcherListView = findChild(launcher, "launcherListView");
268+ var bfbFocusHighlight = findChild(launcher, "bfbFocusHighlight");
269+
270+ waitForRendering(launcher);
271+ tryCompare(bfbFocusHighlight, "visible", index === -1);
272+ for (var i = 0; i < launcherListView.count; i++) {
273+ var focusRing = findChild(findChild(launcher, "launcherDelegate" + i), "focusRing")
274+ tryCompare(focusRing, "visible", index === i);
275+ }
276+ }
277+
260 // Drag from the left edge of the screen rightwards and check that the launcher
278 // Drag from the left edge of the screen rightwards and check that the launcher
261 // appears (as if being dragged by the finger/pointer)
279 // appears (as if being dragged by the finger/pointer)
262 function test_dragLeftEdgeToRevealLauncherAndTapCenterToDismiss() {
280 function test_dragLeftEdgeToRevealLauncherAndTapCenterToDismiss() {
@@ -942,5 +960,88 @@ Item {
942 tryCompare(launcher, "state", "");
960 tryCompare(launcher, "state", "");
943 tryCompare(shortCutHint0, "visible", false);
961 tryCompare(shortCutHint0, "visible", false);
944 }
962 }
963+
964+ function test_keyboardNavigation() {
965+ var bfbFocusHighlight = findChild(launcher, "bfbFocusHighlight");
966+ var quickList = findChild(launcher, "quickList");
967+ var launcherListView = findChild(launcher, "launcherListView");
968+ var last = launcherListView.count - 1;
969+
970+ compare(bfbFocusHighlight.visible, false);
971+
972+ launcher.openForKeyboardNavigation();
973+
974+ assertFocusOnIndex(-1);
975+
976+ // Down should go down
977+ keyClick(Qt.Key_Down);
978+ assertFocusOnIndex(0);
979+
980+ // Tab should go down
981+ keyClick(Qt.Key_Tab);
982+ assertFocusOnIndex(1);
983+
984+ // Up should go up
985+ keyClick(Qt.Key_Up);
986+ assertFocusOnIndex(0);
987+
988+ // Backtab should go up
989+ keyClick(Qt.Key_Backtab);
990+ assertFocusOnIndex(-1); // BFB
991+
992+ // The list should wrap around
993+ keyClick(Qt.Key_Up);
994+ assertFocusOnIndex(last);
995+
996+ keyClick(Qt.Key_Down);
997+ keyClick(Qt.Key_Down);
998+ assertFocusOnIndex(0); // Back to Top
999+
1000+ // Right opens the quicklist
1001+
1002+ keyClick(Qt.Key_Right);
1003+ assertFocusOnIndex(0); // Navigating the quicklist... the launcher focus should not move
1004+ tryCompare(quickList, "visible", true);
1005+ tryCompare(quickList, "selectedIndex", 0)
1006+
1007+ // Down should move down the quicklist
1008+ keyClick(Qt.Key_Down);
1009+ tryCompare(quickList, "selectedIndex", 1)
1010+
1011+ // The quicklist should wrap around too
1012+ keyClick(Qt.Key_Down);
1013+ keyClick(Qt.Key_Down);
1014+ keyClick(Qt.Key_Down);
1015+ tryCompare(quickList, "selectedIndex", 0)
1016+
1017+ // Left gets us back to the launcher
1018+ keyClick(Qt.Key_Left);
1019+ assertFocusOnIndex(0);
1020+ tryCompare(quickList, "visible", false);
1021+
1022+ // Launcher navigation should still work
1023+ // Go bar to top by wrapping around
1024+ keyClick(Qt.Key_Down);
1025+ assertFocusOnIndex(1);
1026+ }
1027+
1028+ function test_selectQuicklistItemByKeyboard() {
1029+ launcher.openForKeyboardNavigation();
1030+ waitForRendering(launcher);
1031+
1032+ signalSpy.clear();
1033+ signalSpy.signalName = "quickListTriggered"
1034+
1035+ keyClick(Qt.Key_Down); // Down to launcher item 0
1036+ keyClick(Qt.Key_Down); // Down to launcher item 1
1037+ keyClick(Qt.Key_Right); // Into quicklist
1038+ keyClick(Qt.Key_Down); // Down to quicklist item 1
1039+ keyClick(Qt.Key_Down); // Down to quicklist item 2
1040+ keyClick(Qt.Key_Enter); // Trigger it
1041+
1042+ compare(signalSpy.count, 1, "Quicklist signal wasn't triggered")
1043+ compare(signalSpy.signalArguments[0][0], LauncherModel.get(1).appId)
1044+ compare(signalSpy.signalArguments[0][1], 2)
1045+ }
945 }
1046 }
946}
1047}