public void TestSetCurrentTime()
        {
            var p_o1 = new AnimationObject();
            var p_o2 = new AnimationObject();
            var p_o3 = new AnimationObject();
            var t_o1 = new AnimationObject();
            var t_o2 = new AnimationObject();

            // parallel operating on different object/properties
            QAnimationGroup parallel = new QParallelAnimationGroup();
            var a1_p_o1 = new QPropertyAnimation(p_o1, new QByteArray("value"));
            var a1_p_o2 = new QPropertyAnimation(p_o2, new QByteArray("value"));
            var a1_p_o3 = new QPropertyAnimation(p_o3, new QByteArray("value"));
            a1_p_o2.LoopCount = 3;
            parallel.AddAnimation(a1_p_o1);
            parallel.AddAnimation(a1_p_o2);
            parallel.AddAnimation(a1_p_o3);

            var notTimeDriven = new UncontrolledAnimation(t_o1, new QByteArray("value"));
            Assert.AreEqual(-1, notTimeDriven.TotalDuration);

            QVariantAnimation loopsForever = new QPropertyAnimation(t_o2, new QByteArray("value"));
            loopsForever.LoopCount = -1;
            Assert.AreEqual(-1, loopsForever.TotalDuration);

            var group = new QParallelAnimationGroup();
            group.AddAnimation(parallel);
            group.AddAnimation(notTimeDriven);
            group.AddAnimation(loopsForever);

            // Current time = 1
            group.CurrentTime = 1;
            Assert.AreEqual(QAnimationGroup.State.Stopped, group.state);
            Assert.AreEqual(QAnimationGroup.State.Stopped, parallel.state);
            Assert.AreEqual(QAnimationGroup.State.Stopped, a1_p_o1.state);
            Assert.AreEqual(QAnimationGroup.State.Stopped, a1_p_o2.state);
            Assert.AreEqual(QAnimationGroup.State.Stopped, a1_p_o3.state);
            Assert.AreEqual(QAnimationGroup.State.Stopped, notTimeDriven.state);
            Assert.AreEqual(QAnimationGroup.State.Stopped, loopsForever.state);

            Assert.AreEqual(1, group.CurrentLoopTime);
            Assert.AreEqual(1, a1_p_o1.CurrentLoopTime);
            Assert.AreEqual(1, a1_p_o2.CurrentLoopTime);
            Assert.AreEqual(1, a1_p_o3.CurrentLoopTime);
            Assert.AreEqual(1, notTimeDriven.CurrentLoopTime);
            Assert.AreEqual(1, loopsForever.CurrentLoopTime);

            // Current time = 250
            group.CurrentTime = 250;
            Assert.AreEqual(250, group.CurrentLoopTime);
            Assert.AreEqual(250, a1_p_o1.CurrentLoopTime);
            Assert.AreEqual(0, a1_p_o2.CurrentLoopTime);
            Assert.AreEqual(1, a1_p_o2.CurrentLoop);
            Assert.AreEqual(250, a1_p_o3.CurrentLoopTime);
            Assert.AreEqual(250, notTimeDriven.CurrentLoopTime);
            Assert.AreEqual(0, loopsForever.CurrentLoopTime);
            Assert.AreEqual(1, loopsForever.CurrentLoop);

            // Current time = 251
            group.CurrentTime = 251;
            Assert.AreEqual(251, group.CurrentLoopTime);

            Assert.AreEqual(250, a1_p_o1.CurrentLoopTime);
            Assert.AreEqual(1, a1_p_o2.CurrentLoopTime);
            Assert.AreEqual(1, a1_p_o2.CurrentLoop);

            Assert.AreEqual(250, a1_p_o3.CurrentLoopTime);

            Assert.AreEqual(251, notTimeDriven.CurrentLoopTime);
            Assert.AreEqual(1, loopsForever.CurrentLoopTime);
        }
Esempio n. 2
0
        public void TestSetCurrentTime()
        {
            var p_o1 = new AnimationObject();
            var p_o2 = new AnimationObject();
            var p_o3 = new AnimationObject();
            var t_o1 = new AnimationObject();
            var t_o2 = new AnimationObject();

            // parallel operating on different object/properties
            QAnimationGroup parallel = new QParallelAnimationGroup();
            var             a1_p_o1  = new QPropertyAnimation(p_o1, new QByteArray("value"));
            var             a1_p_o2  = new QPropertyAnimation(p_o2, new QByteArray("value"));
            var             a1_p_o3  = new QPropertyAnimation(p_o3, new QByteArray("value"));

            a1_p_o2.LoopCount = 3;
            parallel.AddAnimation(a1_p_o1);
            parallel.AddAnimation(a1_p_o2);
            parallel.AddAnimation(a1_p_o3);

            var notTimeDriven = new UncontrolledAnimation(t_o1, new QByteArray("value"));

            Assert.AreEqual(-1, notTimeDriven.TotalDuration);

            QVariantAnimation loopsForever = new QPropertyAnimation(t_o2, new QByteArray("value"));

            loopsForever.LoopCount = -1;
            Assert.AreEqual(-1, loopsForever.TotalDuration);

            var group = new QParallelAnimationGroup();

            group.AddAnimation(parallel);
            group.AddAnimation(notTimeDriven);
            group.AddAnimation(loopsForever);

            // Current time = 1
            group.CurrentTime = 1;
            Assert.AreEqual(QAnimationGroup.State.Stopped, group.state);
            Assert.AreEqual(QAnimationGroup.State.Stopped, parallel.state);
            Assert.AreEqual(QAnimationGroup.State.Stopped, a1_p_o1.state);
            Assert.AreEqual(QAnimationGroup.State.Stopped, a1_p_o2.state);
            Assert.AreEqual(QAnimationGroup.State.Stopped, a1_p_o3.state);
            Assert.AreEqual(QAnimationGroup.State.Stopped, notTimeDriven.state);
            Assert.AreEqual(QAnimationGroup.State.Stopped, loopsForever.state);

            Assert.AreEqual(1, group.CurrentLoopTime);
            Assert.AreEqual(1, a1_p_o1.CurrentLoopTime);
            Assert.AreEqual(1, a1_p_o2.CurrentLoopTime);
            Assert.AreEqual(1, a1_p_o3.CurrentLoopTime);
            Assert.AreEqual(1, notTimeDriven.CurrentLoopTime);
            Assert.AreEqual(1, loopsForever.CurrentLoopTime);

            // Current time = 250
            group.CurrentTime = 250;
            Assert.AreEqual(250, group.CurrentLoopTime);
            Assert.AreEqual(250, a1_p_o1.CurrentLoopTime);
            Assert.AreEqual(0, a1_p_o2.CurrentLoopTime);
            Assert.AreEqual(1, a1_p_o2.CurrentLoop);
            Assert.AreEqual(250, a1_p_o3.CurrentLoopTime);
            Assert.AreEqual(250, notTimeDriven.CurrentLoopTime);
            Assert.AreEqual(0, loopsForever.CurrentLoopTime);
            Assert.AreEqual(1, loopsForever.CurrentLoop);

            // Current time = 251
            group.CurrentTime = 251;
            Assert.AreEqual(251, group.CurrentLoopTime);

            Assert.AreEqual(250, a1_p_o1.CurrentLoopTime);
            Assert.AreEqual(1, a1_p_o2.CurrentLoopTime);
            Assert.AreEqual(1, a1_p_o2.CurrentLoop);

            Assert.AreEqual(250, a1_p_o3.CurrentLoopTime);

            Assert.AreEqual(251, notTimeDriven.CurrentLoopTime);
            Assert.AreEqual(1, loopsForever.CurrentLoopTime);
        }