Esempio n. 1
0
        public void Drag()
        {
            using var app = Application.AttachOrLaunch(ExeFileName, WindowName);
            var window = app.MainWindow;
            var area   = window.FindGroupBox("Touch area");
            var events = window.FindListBox("Events");

            Touch.Drag(area.Bounds.Center(), area.Bounds.Center() + new Vector(10, 10));
            var expected = new[]
            {
                "TouchEnter Position: 250,300",
                "PreviewTouchDown Position: 250,300",
                "TouchDown Position: 250,300",
                "ManipulationStarting",
                "ManipulationStarted",
                "StylusSystemGesture SystemGesture: Drag",
                "PreviewTouchMove Position: 260,310",
                "TouchMove Position: 260,310",
                "ManipulationDelta",
                "PreviewTouchUp Position: 260,310",
                "TouchUp Position: 260,310",
                "ManipulationInertiaStarting",
                "ManipulationCompleted",
                "TouchLeave Position: 260,310",
            };

            CollectionAssert.AreEqual(expected, events.Items.Select(x => x.Text).ToArray(), EventStringComparer.Default);
        }
Esempio n. 2
0
        public void Drag()
        {
            if (WindowsVersion.IsAppVeyor())
            {
                Assert.Inconclusive("We need a Win 10 image on AppVeyor for testing touch.");
            }

            using (var app = Application.AttachOrLaunch(ExeFileName, WindowName))
            {
                var window = app.MainWindow;
                var area   = window.FindGroupBox("Touch area");
                var events = window.FindListBox("Events");

                Touch.Drag(area.Bounds.Center(), area.Bounds.TopLeft);
                var expected = new[]
                {
                    "TouchEnter Position: 99,299",
                    "PreviewTouchDown Position: 99,299",
                    "TouchDown Position: 99,299",
                    "ManipulationStarting",
                    "ManipulationStarted",
                    "PreviewTouchMove Position: -1,-1",
                    "TouchMove Position: -1,-1",
                    "ManipulationDelta",
                    "PreviewTouchUp Position: -1,-1",
                    "TouchUp Position: -1,-1",
                    "ManipulationInertiaStarting",
                    "ManipulationCompleted",
                    "TouchLeave Position: -1,-1",
                };

                CollectionAssert.AreEqual(expected, events.Items.Select(x => x.Text).ToArray());
            }
        }
Esempio n. 3
0
        protected override string DoImpl()
        {
            var startEndPoints = this.ExecutedCommand.Parameters["startEndPoints"].ToObject <List <Dictionary <String, Object> > >();

            var duration     = Convert.ToInt32(this.ExecutedCommand.Parameters["duration"]);
            var durationHold = Convert.ToInt32(this.ExecutedCommand.Parameters["durationHold"]);

            List <Tuple <Point, Point> > pointsList = new List <Tuple <Point, Point> >();

            startEndPoints.ForEach(p =>
            {
                p.TryGetValue("x1", out object x1);
                p.TryGetValue("y1", out object y1);

                p.TryGetValue("x2", out object x2);
                p.TryGetValue("y2", out object y2);

                Point p1 = new Point(Convert.ToInt32(x1), Convert.ToInt32(y1));
                Point p2 = new Point(Convert.ToInt32(x2), Convert.ToInt32(y2));

                pointsList.Add(Tuple.Create(p1, p2));
            });


            Touch.Drag(TimeSpan.FromMilliseconds(duration), pointsList.ToArray(), TimeSpan.FromMilliseconds(durationHold));

            return(this.JsonResponse());
        }
Esempio n. 4
0
        public void Test()
        {
            var currPos = Mouse.Position;

            Touch.Tap(currPos);

            Touch.Hold(TimeSpan.FromSeconds(2), currPos);

            Touch.Pinch(currPos, 0, 100, TimeSpan.FromSeconds(2));

            Touch.Drag(TimeSpan.FromSeconds(2), currPos, Point.Add(currPos, new Size(100, 0)));

            Touch.Rotate(currPos, 200, 0, 2 * Math.PI, TimeSpan.FromSeconds(3));
        }
Esempio n. 5
0
        public void DragWithDuration(int milliseconds)
        {
            using var app = Application.AttachOrLaunch(ExeFileName, WindowName);
            var window = app.MainWindow;
            var area   = window.FindGroupBox("Touch area");
            var events = window.FindListBox("Events");

            Touch.Drag(area.Bounds.Center(), area.Bounds.Center() + new Vector(10, 10), TimeSpan.FromMilliseconds(milliseconds));

            var expected = new[]
            {
                "TouchEnter Position: 250,300",
                "PreviewTouchDown Position: 250,300",
                "TouchDown Position: 250,300",
                "ManipulationStarting",
                "ManipulationStarted",
                "StylusSystemGesture SystemGesture: Drag",
                "PreviewTouchMove Position: 260,310",
                "TouchMove Position: 260,310",
                "ManipulationDelta",
                "PreviewTouchUp Position: 260,310",
                "TouchUp Position: 260,310",
                "ManipulationInertiaStarting",
                "ManipulationCompleted",
                "TouchLeave Position: 260,310",
            };

            if (milliseconds == 0)
            {
                CollectionAssert.AreEqual(expected, events.Items.Select(x => x.Text).ToArray(), EventStringComparer.Default);
            }
            else
            {
                Assert.Inconclusive("No assert here.");
                //// CollectionAssert.IsSubsetOf(expected, events.Items.Select(x => x.Text).ToArray(), EventStringComparer.Default);
            }
        }