on xenial help sign in
Make touchFlick flick instead of snap

Prior to this change, NaN was stored in 'distance' and every touchFlick would snap the touch point from the start to the end instantly. After fixing this, touchFlick took much longer, so I also increased the default speed. The only test that this broke was test_rightEdgePushWithOpenIndicators, so I replaced the touchFlick with showIndicators(). While I was in the file I left it a little nicer than I came by placing all utility functions above the test functions.

commit7fb19799f97960cfec654f79a1c41578ba08fd8e authorDalton Durst <dalton@ubports.com> dateTue 24 Dec 2019, 10:33 (7 years ago) parentc2ffdb9
2 files changed+28−33
tests/qmltests/tst_Shell.qml+26−31 tests/utils/modules/Unity/Test/UnityTestCase.qml+2−2
tests/qmltests/tst_Shell.qml+26−31
@@ -1,5 +1,6 @@
11/*
22 * Copyright (C) 2013-2016 Canonical, Ltd.
3+ * Copyright (C) 2019 UBports Foundation
34 *
45 * This program is free software; you can redistribute it and/or modify
56 * it under the terms of the GNU General Public License as published by
@@ -869,6 +870,30 @@ Rectangle {
869870 tryCompare(launcher, "state", "visibleTemporary");
870871 }
871872
873+ function waitUntilFocusedApplicationIsShowingItsSurface()
874+ {
875+ var spreadDelegate = findChild(shell, "appDelegate_" + topLevelSurfaceList.idAt(0));
876+ var appState = findInvisibleChild(spreadDelegate, "applicationWindowStateGroup");
877+ tryCompare(appState, "state", "surface");
878+ var transitions = appState.transitions;
879+ for (var i = 0; i < transitions.length; ++i) {
880+ var transition = transitions[i];
881+ tryCompare(transition, "running", false, 2000);
882+ }
883+ }
884+
885+ function swipeFromRightEdgeToShowAppSpread()
886+ {
887+ // perform a right-edge drag to show the spread
888+ var touchStartX = shell.width - (shell.edgeSize / 2)
889+ var touchStartY = shell.height / 2;
890+ touchFlick(shell, touchStartX, touchStartY, units.gu(1) /* endX */, touchStartY /* endY */);
891+
892+ // check if it's indeed showing the spread
893+ var stage = findChild(shell, "stage");
894+ tryCompare(stage, "state", "spread");
895+ }
896+
872897 function test_snapDecisionDismissalReturnsFocus() {
873898 loadShell("phone");
874899 swipeAwayGreeter();
@@ -1351,30 +1376,6 @@ Rectangle {
13511376 tryCompare(topmostSurfaceItem, "touchReleaseCount", 0);
13521377 }
13531378
1354− function waitUntilFocusedApplicationIsShowingItsSurface()
1355− {
1356− var spreadDelegate = findChild(shell, "appDelegate_" + topLevelSurfaceList.idAt(0));
1357− var appState = findInvisibleChild(spreadDelegate, "applicationWindowStateGroup");
1358− tryCompare(appState, "state", "surface");
1359− var transitions = appState.transitions;
1360− for (var i = 0; i < transitions.length; ++i) {
1361− var transition = transitions[i];
1362− tryCompare(transition, "running", false, 2000);
1363− }
1364− }
1365−
1366− function swipeFromRightEdgeToShowAppSpread()
1367− {
1368− // perform a right-edge drag to show the spread
1369− var touchStartX = shell.width - (shell.edgeSize / 2)
1370− var touchStartY = shell.height / 2;
1371− touchFlick(shell, touchStartX, touchStartY, units.gu(1) /* endX */, touchStartY /* endY */);
1372−
1373− // check if it's indeed showing the spread
1374− var stage = findChild(shell, "stage");
1375− tryCompare(stage, "state", "spread");
1376− }
1377−
13781379 function test_physicalHomeKeyPressDoesNothingWithActiveGreeter() {
13791380 loadShell("phone");
13801381
@@ -2652,13 +2653,7 @@ Rectangle {
26522653 var cursor = findChild(shell, "cursor");
26532654 var indicators = findChild(shell, "indicators");
26542655
2655− // Open indicators
2656− var touchX = shell.width - units.gu(5);
2657− touchFlick(shell,
2658− touchX /* fromX */, indicators.minimizedPanelHeight * 0.5 /* fromY */,
2659− touchX /* toX */, shell.height * 0.9 /* toY */,
2660− true /* beginTouch */, true /* endTouch */);
2661− tryCompare(indicators, "fullyOpened", true);
2656+ showIndicators();
26622657
26632658 // push the right edge
26642659 mouseMove(shell, shell.width - 1, units.gu(10));
tests/utils/modules/Unity/Test/UnityTestCase.qml+2−2
@@ -323,12 +323,12 @@ TestCase {
323323 endTouch = (endTouch !== undefined) ? endTouch : true
324324
325325 // Set a default speed if not specified
326− speed = (speed !== undefined) ? speed : units.gu(10)
326+ speed = (speed !== undefined) ? speed : units.gu(100)
327327
328328 // Set a default iterations if not specified
329329 var iterations = (iterations !== undefined) ? iterations : 10
330330
331− var distance = Math.sqrt(Math.pow(rootTo.x - rootFrom.x, 2) + Math.pow(rootTo.Y - rootFrom.y, 2))
331+ var distance = Math.sqrt(Math.pow(rootTo.x - rootFrom.x, 2) + Math.pow(rootTo.y - rootFrom.y, 2))
332332 var totalTime = (distance / speed) * 1000 /* converting speed to pixels/ms */
333333
334334 var timeStep = totalTime / iterations