@@ -112,6 +112,14 @@ StyledItem {
112 return drawer;
112 return drawer;
115+ function openDrawerAndWait() {
116+ // Open the drawer by directly calling on the Launcher, then wait for it to animate in
117+ launcher.toggleDrawer(true);
118+ waitForRendering(launcher);
119+ waitUntilTransitionsEnd(launcher);
120+ return findChild(launcher, "drawer");
115 function revealByEdgePush() {
123 function revealByEdgePush() {
116 // Place the mouse against the window/screen edge and push beyond the barrier threshold
124 // Place the mouse against the window/screen edge and push beyond the barrier threshold
117 // If the mouse did not move between two revealByEdgePush(), we need it to move out the
125 // If the mouse did not move between two revealByEdgePush(), we need it to move out the
@@ -193,8 +201,8 @@ StyledItem {
193 function test_launchAppFromDrawer() {
201 function test_launchAppFromDrawer() {
194 dragDrawerIntoView();
202 dragDrawerIntoView();
196− var drawerList = findChild(launcher, "drawerItemList");
204+ var appList = findChild(launcher, "drawerAppList");
197− var dialerApp = findChild(drawerList, "drawerItem_dialer-app");
205+ var dialerApp = findChild(appList, "drawerItem_dialer-app");
198 mouseClick(dialerApp, dialerApp.width / 2, dialerApp.height / 2);
206 mouseClick(dialerApp, dialerApp.width / 2, dialerApp.height / 2);
200 tryCompare(launcher, "lastSelectedApplication", "dialer-app");
208 tryCompare(launcher, "lastSelectedApplication", "dialer-app");
@@ -207,8 +215,8 @@ StyledItem {
208 tryCompare(launcher, "focus", true);
216 tryCompare(launcher, "focus", true);
210− var drawerList = findChild(launcher, "drawerItemList");
218+ var appList = findChild(launcher, "drawerAppList");
211− var dialerApp = findChild(drawerList, "drawerItem_dialer-app");
219+ var dialerApp = findChild(appList, "drawerItem_dialer-app");
212 mouseClick(dialerApp, dialerApp.width / 2, dialerApp.height / 2);
220 mouseClick(dialerApp, dialerApp.width / 2, dialerApp.height / 2);
214 tryCompare(launcher, "focus", false);
222 tryCompare(launcher, "focus", false);
@@ -289,58 +297,70 @@ StyledItem {
292− function test_kbdNavigation() {
300+ function test_kbdSearch() {
293− launcher.toggleDrawer(true);
301+ // Try out the keyboard navigation for the search field
294− waitForRendering(launcher);
302+ var drawer = openDrawerAndWait();
295− waitUntilTransitionsEnd(launcher);
296− compare(launcher.lastSelectedApplication, "");
298− var drawer = findChild(launcher, "drawer");
299 var searchField = findChild(drawer, "searchField");
303 var searchField = findChild(drawer, "searchField");
300− var sections = findChild(drawer, "drawerSections");
301− var header = findChild(drawer, "headerFocusScope");
302− var listLoader = findChild(drawer, "drawerListLoader");
304− tryCompare(searchField, "activeFocus", true);
305− // for some reason, even when the searchField has activeFocus already,
306− // it won't react on key down events if they're coming in too early...
307− // let's repeat the press for a bit before giving up
308− tryCompareFunction(function() {
310− keyClick(Qt.Key_Down);
311− return sections.activeFocus;
305+ tryCompare(searchField, "focus", false);
314− keyClick(Qt.Key_Down);
306+ keyClick(Qt.Key_Up);
315− tryCompare(header, "activeFocus", true);
307+ tryCompare(searchField, "focus", true);
308+ keyClick(Qt.Key_Escape);
309+ tryCompare(searchField, "focus", false);
317− keyClick(Qt.Key_Down);
311+ // Make sure the focus doesn't get put back when reopening
318− tryCompare(listLoader, "activeFocus", true);
312+ openDrawerAndWait();
313+ tryCompare(searchField, "focus", false);
316+ function test_kbdGrid() {
317+ // Try out the keyboard navigation around the grid
318+ var drawer = openDrawerAndWait();
319+ var searchField = findChild(drawer, "searchField");
320+ var appList = findChild(drawer, "drawerAppList");
322+ tryCompare(searchField, "focus", false);
323+ tryCompare(appList, "focus", false);
324+ tryCompare(appList, "currentIndex", 0);
320 keyClick(Qt.Key_Down);
326 keyClick(Qt.Key_Down);
321− keyClick(Qt.Key_Left);
327+ tryCompare(appList, "focus", true);
322− tryCompare(listLoader, "activeFocus", true);
328+ tryCompare(appList, "currentIndex", 0);
324− keyClick(Qt.Key_Enter);
330+ keyClick(Qt.Key_Right);
331+ tryCompare(appList, "currentIndex", 1);
326− compare(launcher.lastSelectedApplication, "calendar-app");
333+ keyClick(Qt.Key_Escape);
334+ tryCompare(appList, "currentIndex", 0);
335+ tryCompare(appList, "focus", false);
329− function test_focusAppFromLauncherWhileDrawerIsOpen() {
338+ function test_kbdFocusMoves() {
330− // FIXME: Skipping this test because of a bug in Qt. Please enable
339+ // Make sure keyboard focus can move between the search field and grid
331− // once https://codereview.qt-project.org/#/c/184942/ is accepted
340+ var drawer = openDrawerAndWait();
332− skip();
341+ var searchField = findChild(drawer, "searchField");
342+ var appList = findChild(drawer, "drawerAppList");
334− launcher.toggleDrawer(true);
344+ keyClick(Qt.Key_Up);
335− waitForRendering(launcher);
345+ keyClick(Qt.Key_Down);
336− waitUntilTransitionsEnd(launcher);
346+ tryCompare(appList, "focus", true);
347+ tryCompare(appList, "currentIndex", 0);
349+ // Down once more to move the focus further into the app grid
350+ keyClick(Qt.Key_Down);
351+ keyClick(Qt.Key_Up);
352+ keyClick(Qt.Key_Up);
353+ tryCompare(searchField, "focus", true);
356+ function test_focusAppFromLauncherWhileDrawerIsOpen() {
357+ openDrawerAndWait();
338 var appIcon = findChild(launcher, "launcherDelegate4")
358 var appIcon = findChild(launcher, "launcherDelegate4")
340− mouseMove(launcher, units.gu(4), launcher.height / 2)
360+ mouseMove(appIcon, appIcon.width / 2, appIcon.height / 2);
341 mouseClick(appIcon, appIcon.width / 2, appIcon.height / 2);
361 mouseClick(appIcon, appIcon.width / 2, appIcon.height / 2);
343− tryCompare(launcher, "state", "visibleTemporary");
363+ tryCompare(launcher, "state", "");
346 function test_focusMovesCorrectlyBetweenLauncherAndDrawer() {
366 function test_focusMovesCorrectlyBetweenLauncherAndDrawer() {
@@ -365,14 +385,11 @@ StyledItem {
367 function test_closeWhileDragging() {
387 function test_closeWhileDragging() {
368− launcher.toggleDrawer(true);
388+ var drawer = openDrawerAndWait();
369− waitForRendering(launcher);
389+ var handle = findChild(drawer, "drawerHandle");
370− waitUntilTransitionsEnd(launcher);
372− var drawer = findChild(launcher, "drawer");
373 tryCompare(drawer.anchors, "rightMargin", -drawer.width);
390 tryCompare(drawer.anchors, "rightMargin", -drawer.width);
375− mousePress(drawer, drawer.width / 2, drawer.height / 2);
392+ mousePress(handle);
376 mouseMove(drawer, drawer.width / 4, drawer.height / 2);
393 mouseMove(drawer, drawer.width / 4, drawer.height / 2);
377 tryCompare(drawer, "draggingHorizontally", true);
394 tryCompare(drawer, "draggingHorizontally", true);