on xenial help sign in
Make touchFlick flick instead of snap
7fb1979Dalton Durst
tests/qmltests/tst_Shell.qml+26−31
@@ -1,5 +1,6 @@
1/*
1/*
2 * Copyright (C) 2013-2016 Canonical, Ltd.
2 * Copyright (C) 2013-2016 Canonical, Ltd.
3+ * Copyright (C) 2019 UBports Foundation
3 *
4 *
4 * This program is free software; you can redistribute it and/or modify
5 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * it under the terms of the GNU General Public License as published by
@@ -869,6 +870,30 @@ Rectangle {
869 tryCompare(launcher, "state", "visibleTemporary");
870 tryCompare(launcher, "state", "visibleTemporary");
870 }
871 }
871
872
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+
872 function test_snapDecisionDismissalReturnsFocus() {
897 function test_snapDecisionDismissalReturnsFocus() {
873 loadShell("phone");
898 loadShell("phone");
874 swipeAwayGreeter();
899 swipeAwayGreeter();
@@ -1351,30 +1376,6 @@ Rectangle {
1351 tryCompare(topmostSurfaceItem, "touchReleaseCount", 0);
1376 tryCompare(topmostSurfaceItem, "touchReleaseCount", 0);
1352 }
1377 }
1353
1378
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−
1378 function test_physicalHomeKeyPressDoesNothingWithActiveGreeter() {
1379 function test_physicalHomeKeyPressDoesNothingWithActiveGreeter() {
1379 loadShell("phone");
1380 loadShell("phone");
1380
1381
@@ -2652,13 +2653,7 @@ Rectangle {
2652 var cursor = findChild(shell, "cursor");
2653 var cursor = findChild(shell, "cursor");
2653 var indicators = findChild(shell, "indicators");
2654 var indicators = findChild(shell, "indicators");
2654
2655
2655− // Open indicators
2656+ showIndicators();
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);
2662
2657
2663 // push the right edge
2658 // push the right edge
2664 mouseMove(shell, shell.width - 1, units.gu(10));
2659 mouseMove(shell, shell.width - 1, units.gu(10));
tests/utils/modules/Unity/Test/UnityTestCase.qml+2−2
@@ -323,12 +323,12 @@ TestCase {
323 endTouch = (endTouch !== undefined) ? endTouch : true
323 endTouch = (endTouch !== undefined) ? endTouch : true
324
324
325 // Set a default speed if not specified
325 // Set a default speed if not specified
326− speed = (speed !== undefined) ? speed : units.gu(10)
326+ speed = (speed !== undefined) ? speed : units.gu(100)
327
327
328 // Set a default iterations if not specified
328 // Set a default iterations if not specified
329 var iterations = (iterations !== undefined) ? iterations : 10
329 var iterations = (iterations !== undefined) ? iterations : 10
330
330
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))
332 var totalTime = (distance / speed) * 1000 /* converting speed to pixels/ms */
332 var totalTime = (distance / speed) * 1000 /* converting speed to pixels/ms */
333
333
334 var timeStep = totalTime / iterations
334 var timeStep = totalTime / iterations