Example #1
0
        public void Kinetic()
        {
            var view       = AnimationReadyHandler.Prepare(new View());
            var resultList = new List <Tuple <double, double> >();

            view.AnimateKinetic(
                name: "Kinetics",
                callback: (distance, velocity) =>
            {
                resultList.Add(new Tuple <double, double>(distance, velocity));
                return(true);
            },
                velocity: 100,
                drag: 1);

            Assert.That(resultList, Is.Not.Empty);
            int checkVelo = 100;
            int dragStep  = 16;

            foreach (var item in resultList)
            {
                checkVelo -= dragStep;
                Assert.AreEqual(checkVelo, item.Item2);
                Assert.AreEqual(checkVelo * dragStep, item.Item1);
            }
        }
Example #2
0
        //https://bugzilla.xamarin.com/show_bug.cgi?id=51424
        public async Task AnimationRepeats()
        {
            var box = AnimationReadyHandler.Prepare(new BoxView());

            Assume.That(box.Rotation, Is.EqualTo(0d));
            var sb        = new Animation();
            var animcount = 0;
            var rot45     = new Animation(d =>
            {
                box.Rotation = d;
                if (d > 44)
                {
                    animcount++;
                }
            }, box.Rotation, box.Rotation + 45);

            sb.Add(0, .5, rot45);
            Assume.That(box.Rotation, Is.EqualTo(0d));

            var i = 0;

            sb.Commit(box, "foo", length: 100, repeat: () => ++ i < 2);

            await Task.Delay(1000);

            Assert.That(animcount, Is.EqualTo(2));
        }
Example #3
0
        public async Task TestRotateXTo()
        {
            var view = AnimationReadyHandler.Prepare(new View());

            await view.RotateXTo(25);

            Assert.That(view.RotationX, Is.EqualTo(25).Within(0.001));
        }
Example #4
0
        public async Task ScaleTo()
        {
            var view = AnimationReadyHandler.Prepare(new View());

            await view.ScaleTo(2);

            Assert.AreEqual(2, view.Scale);
        }
Example #5
0
        public async Task TestFadeTo()
        {
            var view = AnimationReadyHandler.Prepare(new View());

            await view.FadeTo(0.1);

            Assert.True(Math.Abs(0.1 - view.Opacity) < 0.001);
        }
Example #6
0
        public void TestProgressTo()
        {
            var bar = AnimationReadyHandler.Prepare(new ProgressBar());

            bar.ProgressTo(0.8, 250, Easing.Linear);

            Assert.That(bar.Progress, Is.EqualTo(0.8).Within(0.001));
        }
Example #7
0
        public async Task TestTranslateTo()
        {
            var view = AnimationReadyHandler.Prepare(new View());

            await view.TranslateTo(100, 50);

            Assert.AreEqual(100, view.TranslationX);
            Assert.AreEqual(50, view.TranslationY);
        }
Example #8
0
        public async Task TestRelScaleTo()
        {
            var view = AnimationReadyHandler.Prepare(new View {
                Scale = 1
            });

            await view.RelScaleTo(1);

            Assert.That(view.Scale, Is.EqualTo(2).Within(0.001));
        }
Example #9
0
        public async Task TestRelRotateTo()
        {
            var view = AnimationReadyHandler.Prepare(new View {
                Rotation = 30
            });

            await view.RelRotateTo(20);

            Assert.That(view.Rotation, Is.EqualTo(50).Within(0.001));
        }
Example #10
0
        public void KineticFinished()
        {
            var  view     = AnimationReadyHandler.Prepare(new View());
            bool finished = false;

            view.AnimateKinetic(
                name: "Kinetics",
                callback: (distance, velocity) => true,
                velocity: 100,
                drag: 1,
                finished: () => finished = true);

            Assert.True(finished);
        }