예제 #1
0
        public void Manipulation_Begin_WithAnotherDevice()
        {
            var sut = new GestureRecognizer {
                GestureSettings = GestureSettingsHelper.Manipulations
            };
            var result = new ManipulationRecorder(sut);

            sut.ProcessDownEvent(25, 25, id: 1);
            sut.ProcessDownEvent(25, 25, id: 2, device: PointerDeviceType.Pen);

            result.ShouldBe(
                v => v.Starting()
                );
        }
예제 #2
0
        public void Manipulation_Begin_MultiPointer()
        {
            var sut = new GestureRecognizer {
                GestureSettings = GestureSettingsHelper.Manipulations
            };
            var result = new ManipulationRecorder(sut);

            sut.ProcessDownEvent(25, 25, id: 1);
            sut.ProcessDownEvent(25, 25, id: 2);

            result.ShouldBe(
                v => v.Starting(),
                v => v.Started()
                );
        }
예제 #3
0
        public void Manipulation_Begin()
        {
            var sut = new GestureRecognizer {
                GestureSettings = GestureSettingsHelper.Manipulations
            };
            var result = new ManipulationRecorder(sut);
            var step   = GestureRecognizer.MinManipulationDeltaTranslateX;

            sut.ProcessDownEvent(25, 25);
            sut.ProcessMoveEvent(25 + 1, 25);             // Ignored
            sut.ProcessMoveEvent(25 + step, 25);

            result.ShouldBe(
                v => v.Starting(),
                v => v.Started().At(25 + step, 25).WithCumulative(step, 0)
                );
        }
예제 #4
0
        public void Manipulation_Translate_MultiTouch_Negative()
        {
            var sut = new GestureRecognizer {
                GestureSettings = GestureSettings.ManipulationTranslateX | GestureSettings.ManipulationTranslateY
            };
            var result = new ManipulationRecorder(sut);

            sut.ProcessDownEvent(0, 0, id: 1);

            sut.ProcessDownEvent(200, 200, id: 2);
            sut.ProcessMoveEvent(50, 50, id: 2);

            result.ShouldBe(
                v => v.Starting(),
                v => v.Started().At(100, 100).WithEmptyCumulative(),
                v => v.Delta().At(25, 25).WithDelta(tX: -75, tY: -75).WithCumulative(tX: -75, tY: -75)
                );
        }
예제 #5
0
        public void Manipulation_End()
        {
            var sut = new GestureRecognizer {
                GestureSettings = GestureSettingsHelper.Manipulations
            };
            var result = new ManipulationRecorder(sut);
            var step   = GestureRecognizer.Manipulation.StartTouch.TranslateX + 1;

            sut.ProcessDownEvent(25, 25);
            sut.ProcessMoveEvent(25 + step, 25);
            sut.ProcessUpEvent(25 + step + 1, 25);

            result.ShouldBe(
                v => v.Starting(),
                v => v.Started().At(25, 25).WithEmptyCumulative(),
                v => v.Delta().At(25 + step, 25).WithDelta(step, 0).WithCumulative(step, 0),
                v => v.End().At(25 + step + 1, 25).WithCumulative(step + 1, 0)
                );
        }
예제 #6
0
        public void Manipulation_ScaleOnly_Negative()
        {
            var sut = new GestureRecognizer {
                GestureSettings = GestureSettings.ManipulationScale
            };
            var result = new ManipulationRecorder(sut);

            sut.ProcessDownEvent(25, 25, id: 1);

            sut.ProcessDownEvent(150, 25, id: 2);
            sut.ProcessMoveEvent(100, 25, id: 2);
            sut.ProcessMoveEvent(75, 25, id: 2);

            result.ShouldBe(
                v => v.Starting(),
                v => v.Started().WithCumulative(scale: 1),
                v => v.Delta().WithDelta(scale: .6F, exp: -50).WithCumulative(scale: .6F, exp: -50),
                v => v.Delta().WithDelta(scale: 2F / 3F, exp: -25).WithCumulative(scale: .4F, exp: -75)
                );
        }
예제 #7
0
        public void Manipulation_RotateOnly_AntiTrigonometric_InForthQuadrant()
        {
            var sut = new GestureRecognizer {
                GestureSettings = GestureSettings.ManipulationRotate
            };
            var result = new ManipulationRecorder(sut);

            sut.ProcessDownEvent(25, 25, id: 1);

            sut.ProcessDownEvent(50, 25, id: 2);             // Angle = 0
            sut.ProcessMoveEvent(50, 50, id: 2);             // Angle = -Pi/4
            sut.ProcessMoveEvent(25, 50, id: 2);             // Angle = -Pi/2

            result.ShouldBe(
                v => v.Starting(),
                v => v.Started().WithCumulative(angle: 0),
                v => v.Delta().WithDelta(angle: 45).WithCumulative(angle: 45),
                v => v.Delta().WithDelta(angle: 45).WithCumulative(angle: 90)
                );
        }
예제 #8
0
        public void Manipulation_TranslateYOnly_Negative()
        {
            var sut = new GestureRecognizer {
                GestureSettings = GestureSettings.ManipulationTranslateY
            };
            var result = new ManipulationRecorder(sut);
            var stepX  = GestureRecognizer.MinManipulationDeltaTranslateX + 1;
            var stepY  = GestureRecognizer.MinManipulationDeltaTranslateY + 1;

            sut.ProcessDownEvent(25, 25);
            sut.ProcessMoveEvent(25 - stepX, 25);                 // Invalid move that should NOT cause the started
            sut.ProcessMoveEvent(25 - stepX, 25 - stepY);         // Valid move that should cause a started ... but without Y
            sut.ProcessMoveEvent(25 - stepX * 2, 25 - stepY);     // Invalid move that should also be muted
            sut.ProcessMoveEvent(25 - stepX * 2, 25 - stepY * 2); // Invalid move that should also be muted
            sut.ProcessUpEvent(25 - stepX * 2 - 1, 25 - stepY * 2 - 1);

            result.ShouldBe(
                v => v.Starting(),
                v => v.Started().At(25 - stepX, 25 - stepY).WithCumulative(0, -stepY),
                v => v.Delta().At(25 - stepX * 2, 25 - stepY * 2).WithDelta(0, -stepY).WithCumulative(0, -stepY * 2),
                v => v.End().At(25 - stepX * 2 - 1, 25 - stepY * 2 - 1).WithCumulative(0, -stepX * 2 - 1)
                );
        }
예제 #9
0
        public void Manipulation_Mixed()
        {
            var sut = new GestureRecognizer {
                GestureSettings = GestureSettingsHelper.Manipulations
            };
            var result = new ManipulationRecorder(sut);

            sut.ProcessDownEvent(50, 50, id: 1);             // 1.
            sut.ProcessDownEvent(50, 200, id: 2);            // 2.

            sut.ProcessMoveEvent(200, 200, id: 2);           // 3.
            sut.ProcessMoveEvent(50, 200, id: 1);            // 4.

            sut.ProcessMoveEvent(200, 50, id: 2);            // 5.
            sut.ProcessMoveEvent(200, 200, id: 1);           // 6.

            sut.ProcessMoveEvent(50, 50, id: 2);             // 7.
            sut.ProcessMoveEvent(200, 50, id: 1);            // 8.

            sut.ProcessMoveEvent(50, 200, id: 2);            // 9.
            sut.ProcessMoveEvent(50, 50, id: 1);             // 10.

            // At same point (0 proof ?)
            sut.ProcessMoveEvent(50, 50, id: 2);             // 11.

            var s = (float)Math.Sqrt(2);
            var e = (float)((Math.Sqrt(2) - 1) * 150);

            result.ShouldBe(
                v => v.Starting(),                 // 1.

                // 2.
                v => v.Started()
                .At(50, 125)
                .WithCumulative(),

                // 3.
                v => v.Delta()
                .At(125, 125)
                .WithDelta(tX: 75, tY: 0, angle: 315, scale: s, exp: e)
                .WithCumulative(tX: 75, tY: 0, angle: 315, scale: s, exp: e),

                // 4.
                v => v.Delta()
                .At(125, 200)
                .WithDelta(tX: 0, tY: 75, angle: 315, scale: 1 / s, exp: -e)
                .WithCumulative(tX: 75, tY: 75, angle: 270, scale: 1, exp: 0),

                // 5.
                v => v.Delta()
                .At(125, 125)
                .WithDelta(tX: 0, tY: -75, angle: 315, scale: s, exp: e)
                .WithCumulative(tX: 75, tY: 0, angle: 225, scale: s, exp: e),

                // 6.
                v => v.Delta()
                .At(200, 125)
                .WithDelta(tX: 75, tY: 0, angle: 315, scale: 1 / s, exp: -e)
                .WithCumulative(tX: 150, tY: 0, angle: 180, scale: 1, exp: 0),

                // 7.
                v => v.Delta()
                .At(125, 125)
                .WithDelta(tX: -75, tY: 0, angle: 315, scale: s, exp: e)
                .WithCumulative(tX: 75, tY: 0, angle: 135, scale: s, exp: e),

                // 8.
                v => v.Delta()
                .At(125, 50)
                .WithDelta(tX: 0, tY: -75, angle: 315, scale: 1 / s, exp: -e)
                .WithCumulative(tX: 75, tY: -75, angle: 90, scale: 1, exp: 0),

                // 9.
                v => v.Delta()
                .At(125, 125)
                .WithDelta(tX: 0, tY: 75, angle: 315, scale: s, exp: e)
                .WithCumulative(tX: 75, tY: 0, angle: 45, scale: s, exp: e),

                // 10.
                v => v.Delta()
                .At(50, 125)
                .WithDelta(tX: -75, tY: 0, angle: 315, scale: 1 / s, exp: -e)
                .WithCumulative(tX: 0, tY: 0, angle: 0, scale: 1, exp: 0),

                // 11.
                v => v.Delta()
                .At(50, 50)
                .WithDelta(tX: 0, tY: -75, angle: 90 /* ??? */, scale: 0, exp: -150F)
                .WithCumulative(tX: 0, tY: -75, angle: 90 /* ??? */, scale: 0, exp: -150F)
                );
        }