Esempio n. 1
0
 /// <summary>
 ///     Performs the action.
 /// </summary>
 public async Task Perform(CancellationToken cancellationToken = new CancellationToken())
 {
     if (ActionLocation != null)
     {
         await TouchScreen.Flick(ActionLocation, offsetX, offsetY, speed, cancellationToken).ConfigureAwait(false);
     }
     else
     {
         await TouchScreen.Flick(speedX, speedY, cancellationToken).ConfigureAwait(false);
     }
 }
        public void Swipe()
        {
            var touchable   = AppSession.FindElementByAccessibilityId("Touchable");
            var startCoords = touchable.Coordinates.LocationInViewport;

            // Not supported
            //var startX = startCoords.X + touchable.Size.Width / 2;
            //var startY = startCoords.Y + touchable.Size.Width / 2;
            //var endX = startX + TouchDistance.Short;
            //var endY = startY + TouchDistance.Short;
            //AppSession.Swipe(startX, startY, endX, endY, TouchDuration.Short);

            TouchScreen.Flick(touchable.Coordinates, TouchDistance.Short, TouchDistance.Short, TouchSpeed.Slow);

            var endCoords = touchable.Coordinates.LocationInViewport;

            Assert.IsTrue(endCoords.X > startCoords.X);
            Assert.IsTrue(endCoords.Y > startCoords.Y);
            Assert.IsTrue(endCoords.X - startCoords.X <= TouchDistance.Short);
            Assert.IsTrue(endCoords.Y - startCoords.Y <= TouchDistance.Short);
        }