예제 #1
0
        public unsafe void TestLoopWithoutStartValue()
        {
            QAnimationGroup parent = new QSequentialAnimationGroup();
            var             o      = new QObject();

            o.SetProperty("ole", new QVariant(0));
            Assert.AreEqual(0, o.Property("ole").ToInt());

            var anim1 = new QPropertyAnimation(o, new QByteArray("ole"));

            anim1.EndValue = new QVariant(-50);
            anim1.SetDuration(100);

            var anim2 = new QPropertyAnimation(o, new QByteArray("ole"));

            anim2.EndValue = new QVariant(50);
            anim2.SetDuration(100);

            parent.AddAnimation(anim1);
            parent.AddAnimation(anim2);

            parent.LoopCount = -1;
            parent.Start();

            Assert.IsTrue(anim1.StartValue.IsNull);
            Assert.AreEqual(0, anim1.CurrentValue.ToInt());
            Assert.AreEqual(0, parent.CurrentLoop);

            parent.CurrentTime = 200;
            Assert.AreEqual(1, parent.CurrentLoop);
            Assert.AreEqual(50, anim1.CurrentValue.ToInt());
            parent.Stop();
        }
예제 #2
0
        public void TestAddChildTwice()
        {
            QAnimationGroup    parent   = new QSequentialAnimationGroup();
            QAbstractAnimation subGroup = new QPropertyAnimation();

            subGroup.Parent = parent;
            parent.AddAnimation(subGroup);
            Assert.AreEqual(1, parent.AnimationCount);

            parent.Clear();

            Assert.AreEqual(0, parent.AnimationCount);

            // adding the same item twice to a group will remove the item from its current position
            // and append it to the end
            subGroup = new QPropertyAnimation(parent);
            QAbstractAnimation subGroup2 = new QPropertyAnimation(parent);

            Assert.AreEqual(2, parent.AnimationCount);
            Assert.AreSame(subGroup, parent.AnimationAt(0));
            Assert.AreSame(subGroup2, parent.AnimationAt(1));

            parent.AddAnimation(subGroup);

            Assert.AreEqual(2, parent.AnimationCount);
            Assert.AreSame(subGroup2, parent.AnimationAt(0));
            Assert.AreSame(subGroup, parent.AnimationAt(1));
        }
예제 #3
0
        public void TestSetParentAutoAdd()
        {
            var group     = new QParallelAnimationGroup();
            var animation = new QPropertyAnimation(group);

            Assert.AreEqual(animation.Group, (QAnimationGroup)group);
        }
예제 #4
0
        public void TestAddChildTwice()
        {
            QAnimationGroup parent = new QSequentialAnimationGroup();
            QAbstractAnimation subGroup = new QPropertyAnimation();

            subGroup.Parent = parent;
            parent.AddAnimation(subGroup);
            Assert.AreEqual(1, parent.AnimationCount);

            parent.Clear();

            Assert.AreEqual(0, parent.AnimationCount);

            // adding the same item twice to a group will remove the item from its current position
            // and append it to the end
            subGroup = new QPropertyAnimation(parent);
            QAbstractAnimation subGroup2 = new QPropertyAnimation(parent);

            Assert.AreEqual(2, parent.AnimationCount);
            Assert.AreSame(subGroup, parent.AnimationAt(0));
            Assert.AreSame(subGroup2, parent.AnimationAt(1));

            parent.AddAnimation(subGroup);

            Assert.AreEqual(2, parent.AnimationCount);
            Assert.AreSame(subGroup2, parent.AnimationAt(0));
            Assert.AreSame(subGroup, parent.AnimationAt(1));
        }
예제 #5
0
        public unsafe void TestPropagateGroupUpdateToChildren()
        {
            // this test verifies if group state changes are updating its children correctly
            var group = new QParallelAnimationGroup();
            var o     = new QObject();

            o.SetProperty("ole", new QVariant(42));
            Assert.AreEqual(42, o.Property("ole").ToInt());

            var anim1 = new QPropertyAnimation(o, new QByteArray("ole"));

            anim1.EndValue = new QVariant(42);
            anim1.SetDuration(100);
            Assert.IsFalse(anim1.CurrentValue.IsValid);
            Assert.AreEqual(0, anim1.CurrentValue.ToInt());
            Assert.AreEqual(42, o.Property("ole").ToInt());

            var anim2 = new TestAnimation();

            anim2.StartValue = new QVariant(0);
            anim2.EndValue   = new QVariant(100);
            anim2.SetDuration(200);

            Assert.IsTrue(anim2.CurrentValue.IsValid);
            Assert.AreEqual(0, anim2.CurrentValue.ToInt());

            Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state);
            Assert.AreEqual(QAbstractAnimation.State.Stopped, anim1.state);
            Assert.AreEqual(QAbstractAnimation.State.Stopped, anim2.state);

            group.AddAnimation(anim1);
            group.AddAnimation(anim2);

            group.Start();
            Assert.AreEqual(QAbstractAnimation.State.Running, group.state);
            Assert.AreEqual(QAbstractAnimation.State.Running, anim1.state);
            Assert.AreEqual(QAbstractAnimation.State.Running, anim2.state);

            group.Pause();
            Assert.AreEqual(QAbstractAnimation.State.Paused, group.state);
            Assert.AreEqual(QAbstractAnimation.State.Paused, anim1.state);
            Assert.AreEqual(QAbstractAnimation.State.Paused, anim2.state);

            group.Stop();
            Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state);
            Assert.AreEqual(QAbstractAnimation.State.Stopped, anim1.state);
            Assert.AreEqual(QAbstractAnimation.State.Stopped, anim2.state);
        }
예제 #6
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);
        }
예제 #7
0
        public unsafe void TestPropagateGroupUpdateToChildren()
        {
            // this test verifies if group state changes are updating its children correctly
            var group = new QParallelAnimationGroup();
            var o = new QObject();
            o.SetProperty("ole", new QVariant(42));
            Assert.AreEqual(42, o.Property("ole").ToInt());

            var anim1 = new QPropertyAnimation(o, new QByteArray("ole"));
            anim1.EndValue = new QVariant(42);
            anim1.SetDuration(100);
            Assert.IsFalse(anim1.CurrentValue.IsValid);
            Assert.AreEqual(0, anim1.CurrentValue.ToInt());
            Assert.AreEqual(42, o.Property("ole").ToInt());

            var anim2 = new TestAnimation();
            anim2.StartValue = new QVariant(0);
            anim2.EndValue = new QVariant(100);
            anim2.SetDuration(200);

            Assert.IsTrue(anim2.CurrentValue.IsValid);
            Assert.AreEqual(0, anim2.CurrentValue.ToInt());

            Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state);
            Assert.AreEqual(QAbstractAnimation.State.Stopped, anim1.state);
            Assert.AreEqual(QAbstractAnimation.State.Stopped, anim2.state);

            group.AddAnimation(anim1);
            group.AddAnimation(anim2);

            group.Start();
            Assert.AreEqual(QAbstractAnimation.State.Running, group.state);
            Assert.AreEqual(QAbstractAnimation.State.Running, anim1.state);
            Assert.AreEqual(QAbstractAnimation.State.Running, anim2.state);

            group.Pause();
            Assert.AreEqual(QAbstractAnimation.State.Paused, group.state);
            Assert.AreEqual(QAbstractAnimation.State.Paused, anim1.state);
            Assert.AreEqual(QAbstractAnimation.State.Paused, anim2.state);

            group.Stop();
            Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state);
            Assert.AreEqual(QAbstractAnimation.State.Stopped, anim1.state);
            Assert.AreEqual(QAbstractAnimation.State.Stopped, anim2.state);
        }
예제 #8
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);
        }
예제 #9
0
        public unsafe void TestLoopWithoutStartValue()
        {
            QAnimationGroup parent = new QSequentialAnimationGroup();
            var o = new QObject();
            o.SetProperty("ole", new QVariant(0));
            Assert.AreEqual(0, o.Property("ole").ToInt());

            var anim1 = new QPropertyAnimation(o, new QByteArray("ole"));
            anim1.EndValue = new QVariant(-50);
            anim1.SetDuration(100);

            var anim2 = new QPropertyAnimation(o, new QByteArray("ole"));
            anim2.EndValue = new QVariant(50);
            anim2.SetDuration(100);

            parent.AddAnimation(anim1);
            parent.AddAnimation(anim2);

            parent.LoopCount = -1;
            parent.Start();

            Assert.IsTrue(anim1.StartValue.IsNull);
            Assert.AreEqual(0, anim1.CurrentValue.ToInt());
            Assert.AreEqual(0, parent.CurrentLoop);

            parent.CurrentTime = 200;
            Assert.AreEqual(1, parent.CurrentLoop);
            Assert.AreEqual(50, anim1.CurrentValue.ToInt());
            parent.Stop();
        }
예제 #10
0
        public void TestSetParentAutoAdd()
        {
            var group = new QParallelAnimationGroup();
            var animation = new QPropertyAnimation(group);

            Assert.AreEqual(animation.Group, (QAnimationGroup)group);
        }