Esempio n. 1
0
        public static void DragToTarget(UIObject obj, UIObject obj2)
        {
            Point startPoint = obj.GetClickablePoint();

            Log.Comment("Start Point X:{0} Y:{1}", startPoint.X, startPoint.Y);

            Point end = obj2.GetClickablePoint();

            Log.Comment("End Point X:{0} Y:{1}", end.X, end.Y);

            uint dragDuration = 2000;

            using (var waiter = GetWaiterForInputEvent(obj, InputEvent.Drag))
            {
                if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
                {
                    Log.Warning("Touch input is not available on OS versions less than RS5. Falling back to mouse input.");
                    Log.Comment("Move input to Start Point.");
                    PointerInput.Move(startPoint);
                    Log.Comment("Begin Drag.");
                    PointerInput.ClickDrag(end, PointerButtons.Primary, dragDuration);
                    Log.Comment("Drag Complete.");
                }
                else
                {
                    Log.Comment("Move input to Start Point.");
                    SinglePointGesture.Current.Move(startPoint);
                    Log.Comment("Begin Drag.");
                    SinglePointGesture.Current.PressAndDrag(end, dragDuration, 500);
                    Log.Comment("Drag Complete.");
                }
            }
            Wait.ForIdle();
        }
Esempio n. 2
0
        internal static ResponseStatus SendMouseMoveToElementCenter(
            string mouseMoveType,
            UIObject element)
        {
            var rectangleCenterPosition = element.GetAdjustedBoundingRectangleCenterPosition();

            using (InputController.Activate(inputType: PointerInputType.Mouse)) {
                PointerInput.Move(point: rectangleCenterPosition);
                return(ResponseStatus.Success);
            }
        }
Esempio n. 3
0
 internal static ResponseStatus SendMouseMoveToRelative(
     string mouseMoveType,
     int xOffset,
     int yOffset)
 {
     using (InputController.Activate(inputType: PointerInputType.Mouse)) {
         var location = PointerInput.Location;
         location.X += xOffset;
         location.Y += yOffset;
         PointerInput.Move(point: location);
         return(ResponseStatus.Success);
     }
 }
Esempio n. 4
0
        public static void MoveMouse(UIObject obj, int offsetX, int offsetY)
        {
            Log.Comment("Move mouse on {0} to offset ({1}, {2}).", obj.GetIdentifier(), offsetX, offsetY);
            using (var waiter = GetWaiterForInputEvent(obj, InputEvent.MouseMove))
            {
                var point = obj.GetClickablePoint();

                point.X += offsetX;
                point.Y += offsetY;

                PointerInput.Move(point);
            }
            Wait.ForIdle();
        }
Esempio n. 5
0
        internal static ResponseStatus SendMouseMoveToElementRelative(
            string mouseMoveType,
            UIObject element,
            int xOffset,
            int yOffset)
        {
            var topLeft = element.GetAdjustedBoundingRectangle().TopLeft;

            topLeft.X += xOffset;
            topLeft.Y += yOffset;
            using (InputController.Activate(inputType: PointerInputType.Mouse)) {
                PointerInput.Move(point: topLeft);
                return(ResponseStatus.Success);
            }
        }
Esempio n. 6
0
 public static void TapAndHold(UIObject obj, uint durationMs)
 {
     Log.Comment("Tap and hold on {0} for {1} ms.", obj.GetIdentifier(), durationMs);
     using (var waiter = GetWaiterForInputEvent(obj, InputEvent.Tap))
     {
         if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
         {
             Log.Warning("Touch input is not available on OS versions less than RS5. Falling back to mouse input.");
             PointerInput.Move(obj);
             PointerInput.Press(PointerButtons.Primary);
             Wait.ForMilliseconds(durationMs);
             PointerInput.Release(PointerButtons.Primary);
         }
         else
         {
             obj.TapAndHold(durationMs);
         }
     }
     Wait.ForIdle();
 }
Esempio n. 7
0
        internal static ResponseStatus SendTouchTypePress(string touchType, int x, int y)
        {
            var responseStatus = ResponseStatus.UnknownError;
            var point          = new PointI(x: x, y: y);

            if (!(touchType == "down"))
            {
                if (!(touchType == "move"))
                {
                    if (touchType == "up")
                    {
                        using (InputController.Activate(inputType: PointerInputType.MultiTouch)) {
                            PointerInput.Move(point: point);
                            PointerInput.Release(button: PointerButtons.Primary);
                        }

                        responseStatus = ResponseStatus.Success;
                    }
                }
                else
                {
                    using (InputController.Activate(inputType: PointerInputType.MultiTouch)) {
                        PointerInput.Move(point: point);
                    }

                    responseStatus = ResponseStatus.Success;
                }
            }
            else
            {
                using (InputController.Activate(inputType: PointerInputType.MultiTouch)) {
                    PointerInput.Move(point: point);
                    PointerInput.Press(button: PointerButtons.Primary);
                }

                responseStatus = ResponseStatus.Success;
            }

            return(responseStatus);
        }
Esempio n. 8
0
        public static void Pan(UIObject obj, Point start, Point end, uint holdDuration = DefaultPanHoldDuration, float panAcceleration = DefaultPanAcceleration, uint dragDuration = DefaultDragDuration, bool waitForIdle = true)
        {
            Log.Comment("Pan on {0}, starting at ({1}, {2}), ending at ({3}, {4}), after holding {5} ms, with acceleration {6}.",
                        obj.GetIdentifier(), start.X, start.Y, end.X, end.Y, holdDuration, panAcceleration);

            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
            {
                using (var waiter = GetWaiterForInputEvent(obj, InputEvent.Drag))
                {
                    Log.Warning("Touch input is not available on OS versions less than RS5. Falling back to mouse input.");
                    PointerInput.Move(start);
                    PointerInput.ClickDrag(end, PointerButtons.Primary, dragDuration);
                }
            }
            else
            {
                if (panAcceleration == 0.0f)
                {
                    using (var waiter = GetWaiterForInputEvent(obj, InputEvent.Drag))
                    {
                        SinglePointGesture.Current.Move(start);
                        SinglePointGesture.Current.PressAndDrag(end, dragDuration, holdDuration);
                    }
                }
                else
                {
                    using (var waiter = GetWaiterForInputEvent(obj, InputEvent.Pan))
                    {
                        SinglePointGesture.Current.Move(start);
                        SinglePointGesture.Current.Pan(end, holdDuration, panAcceleration);
                    }
                }
            }

            if (waitForIdle)
            {
                Wait.ForIdle();
            }
        }
Esempio n. 9
0
        public void VerifyFlyoutClosingBehavior()
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2))
            {
                Log.Warning("Test is disabled pre-RS2 because CommandBarFlyout is not supported pre-RS2");
                return;
            }

            using (var setup = new CommandBarFlyoutTestSetupHelper())
            {
                Button showCommandBarFlyoutButton = FindElement.ByName <Button>("Show CommandBarFlyout with sub-menu");

                Log.Comment("Tapping on a button to show the CommandBarFlyout.");
                showCommandBarFlyoutButton.Click();

                // Pre-RS5, CommandBarFlyouts always open expanded,
                // so we don't need to tap on the more button in that case.
                if (PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone5))
                {
                    Log.Comment("Expanding the CommandBar by invoking the more button.");
                    FindElement.ById <Button>("MoreButton").InvokeAndWait();
                }

                // Click item to open flyout
                FindElement.ById <Button>("ProofingButton").Click();

                // Move around over the first item to keep flyout open safely
                // This also verifies that the flyout is open as it would crash otherwise
                PointerInput.Move(FindElement.ByName("FirstFlyoutItem"), 5, 5);
                PointerInput.Move(FindElement.ByName("FirstFlyoutItem"), 6, 5);
                PointerInput.Move(FindElement.ByName("FirstFlyoutItem"), 5, 6);

                // Click outside of the flyout to close it
                InputHelper.Tap(FindElement.ByName <Button>("Show CommandBarFlyout"));

                // Check that the flyout item is not present anymore
                VerifyElement.NotFound("FirstFlyoutItem", FindBy.Name);
            }
        }
Esempio n. 10
0
        public static void DragDistance(UIObject obj, int distance, Direction direction, uint duration = 4000)
        {
            Log.Comment("Drag {0} {1} pixels in the {2} direction.", obj.GetIdentifier(), distance, direction);
            Point  startPoint       = obj.GetClickablePoint();
            double directionRadians = DirectionToAngle(direction) * Math.PI / 180d;

            Log.Comment("Start Point X:{0} Y:{1}", startPoint.X, startPoint.Y);

            Point end = new Point()
            {
                X = startPoint.X + (int)Math.Round(distance * Math.Cos(directionRadians)),
                Y = startPoint.Y - (int)Math.Round(distance * Math.Sin(directionRadians))
            };

            Log.Comment("End Point X:{0} Y:{1}", end.X, end.Y);

            using (var waiter = GetWaiterForInputEvent(obj, InputEvent.Drag))
            {
                if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
                {
                    Log.Warning("Touch input is not available on OS versions less than RS5. Falling back to mouse input.");
                    Log.Comment("Move input to Start Point.");
                    PointerInput.Move(startPoint);
                    Log.Comment("Begin Drag.");
                    PointerInput.ClickDrag(end, PointerButtons.Primary, duration);
                    Log.Comment("Drag Complete.");
                }
                else
                {
                    Log.Comment("Move input to Start Point.");
                    SinglePointGesture.Current.Move(startPoint);
                    Log.Comment("Begin Drag.");
                    SinglePointGesture.Current.ClickDrag(end, PointerButtons.Primary, duration);
                    Log.Comment("Drag Complete.");
                }
            }
            Wait.ForIdle();
        }
Esempio n. 11
0
        public static void LeftMouseButtonUp(UIObject obj, int offsetX = 0, int offsetY = 0)
        {
            if (offsetX == 0 && offsetY == 0)
            {
                Log.Comment("Left mouse button up on {0}.", obj.GetIdentifier());
            }
            else
            {
                Log.Comment("Left mouse button up on {0} at offset ({1}, {2}).",
                            obj.GetIdentifier(), offsetX, offsetY);
            }

            using (var waiter = GetWaiterForInputEvent(obj, InputEvent.MouseUp))
            {
                var point = obj.GetClickablePoint();

                point.X += offsetX;
                point.Y += offsetY;

                PointerInput.Move(point);
                PointerInput.Release(PointerButtons.Primary);
            }
            Wait.ForIdle();
        }