on xenial help sign in
Update/Fix Drawer tests
3d5a91fDalton Durst
qml/Launcher/Drawer.qml+4
@@ -105,6 +105,9 @@ FocusScope {
105 hadFocus = false;
105 hadFocus = false;
106 oldSelectionStart = null;
106 oldSelectionStart = null;
107 oldSelectionEnd = null;
107 oldSelectionEnd = null;
108+ appList.currentIndex = 0;
109+ searchField.focus = false;
110+ appList.focus = false;
108 }
111 }
109
112
110 function focusInput() {
113 function focusInput() {
@@ -258,6 +261,7 @@ FocusScope {
258
261
259 DrawerGridView {
262 DrawerGridView {
260 id: appList
263 id: appList
264+ objectName: "drawerAppList"
261 anchors {
265 anchors {
262 left: parent.left
266 left: parent.left
263 right: parent.right
267 right: parent.right
tests/qmltests/Launcher/tst_Drawer.qml+64−47
@@ -112,6 +112,14 @@ StyledItem {
112 return drawer;
112 return drawer;
113 }
113 }
114
114
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");
121+ }
122+
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();
195
203
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);
199
207
200 tryCompare(launcher, "lastSelectedApplication", "dialer-app");
208 tryCompare(launcher, "lastSelectedApplication", "dialer-app");
@@ -207,8 +215,8 @@ StyledItem {
207
215
208 tryCompare(launcher, "focus", true);
216 tryCompare(launcher, "focus", true);
209
217
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);
213
221
214 tryCompare(launcher, "focus", false);
222 tryCompare(launcher, "focus", false);
@@ -289,58 +297,70 @@ StyledItem {
289
297
290 }
298 }
291
299
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, "");
297−
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");
303−
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() {
309− wait(10)
310− keyClick(Qt.Key_Down);
311− return sections.activeFocus;
312− }, true)
313
304
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);
316
310
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);
314+ }
315+
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");
321+
322+ tryCompare(searchField, "focus", false);
323+ tryCompare(appList, "focus", false);
324+ tryCompare(appList, "currentIndex", 0);
319
325
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);
323
329
324− keyClick(Qt.Key_Enter);
330+ keyClick(Qt.Key_Right);
331+ tryCompare(appList, "currentIndex", 1);
325
332
326− compare(launcher.lastSelectedApplication, "calendar-app");
333+ keyClick(Qt.Key_Escape);
334+ tryCompare(appList, "currentIndex", 0);
335+ tryCompare(appList, "focus", false);
327 }
336 }
328
337
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");
333
343
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);
337
348
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);
354+ }
355+
356+ function test_focusAppFromLauncherWhileDrawerIsOpen() {
357+ openDrawerAndWait();
338 var appIcon = findChild(launcher, "launcherDelegate4")
358 var appIcon = findChild(launcher, "launcherDelegate4")
339
359
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);
342
362
343− tryCompare(launcher, "state", "visibleTemporary");
363+ tryCompare(launcher, "state", "");
344 }
364 }
345
365
346 function test_focusMovesCorrectlyBetweenLauncherAndDrawer() {
366 function test_focusMovesCorrectlyBetweenLauncherAndDrawer() {
@@ -365,14 +385,11 @@ StyledItem {
365 }
385 }
366
386
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);
371−
372− var drawer = findChild(launcher, "drawer");
373 tryCompare(drawer.anchors, "rightMargin", -drawer.width);
390 tryCompare(drawer.anchors, "rightMargin", -drawer.width);
374
391
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);
378
395