コード例 #1
0
        public void TestPauseResume()
        {
            var group = new QParallelAnimationGroup();
            var anim  = new TestAnimation2(250, group);     // 0, duration = 250;

            var stateChangedSpy1 = 0;

            anim.StateChanged += (arg1, arg2) => { stateChangedSpy1++; };

            Assert.AreEqual(250, group.Duration);

            group.Start();

            System.Threading.Thread.Sleep(100);

            Assert.AreEqual(QAbstractAnimation.State.Running, group.state);
            Assert.AreEqual(QAbstractAnimation.State.Running, anim.state);
            Assert.AreEqual(1, stateChangedSpy1);
            stateChangedSpy1 = 0;

            var currentTime = group.CurrentLoopTime;

            Assert.AreEqual(currentTime, anim.CurrentLoopTime);

            group.Pause();

            Assert.AreEqual(QAbstractAnimation.State.Paused, group.state);
            Assert.AreEqual(currentTime, group.CurrentLoopTime);
            Assert.AreEqual(QAbstractAnimation.State.Paused, anim.state);
            Assert.AreEqual(currentTime, anim.CurrentLoopTime);
            Assert.AreEqual(1, stateChangedSpy1);
            stateChangedSpy1 = 0;

            group.Resume();

            Assert.AreEqual(QAbstractAnimation.State.Running, group.state);
            Assert.AreEqual(currentTime, group.CurrentLoopTime);

            Assert.AreEqual(QAbstractAnimation.State.Running, anim.state);
            Assert.AreEqual(currentTime, anim.CurrentLoopTime);
            Assert.AreEqual(1, stateChangedSpy1);

            group.Stop();
            stateChangedSpy1 = 0;

            new TestAnimation2(500, group);
            group.Start();
            Assert.AreEqual(1, stateChangedSpy1); //the animation should have been started
            Assert.AreEqual(QAbstractAnimation.State.Running, anim.state);
            group.CurrentTime = 250;              //end of first animation

            Assert.AreEqual(2, stateChangedSpy1); //the animation should have been stopped
            Assert.AreEqual(QAbstractAnimation.State.Stopped, anim.state);

            group.Pause();
            Assert.AreEqual(2, stateChangedSpy1); //this shouldn't have changed

            group.Resume();
            Assert.AreEqual(2, stateChangedSpy1); //this shouldn't have changed
        }
コード例 #2
0
        public void TestPauseResume()
        {
            var group = new QParallelAnimationGroup();
            var anim = new TestAnimation2(250, group);      // 0, duration = 250;

            var stateChangedSpy1 = 0;
            anim.StateChanged += (arg1, arg2) => { stateChangedSpy1++; };

            Assert.AreEqual(250, group.Duration);

            group.Start();

            System.Threading.Thread.Sleep(100);

            Assert.AreEqual(QAbstractAnimation.State.Running, group.state);
            Assert.AreEqual(QAbstractAnimation.State.Running, anim.state);
            Assert.AreEqual(1, stateChangedSpy1);
            stateChangedSpy1 = 0;

            var currentTime = group.CurrentLoopTime;
            Assert.AreEqual(currentTime, anim.CurrentLoopTime);

            group.Pause();

            Assert.AreEqual(QAbstractAnimation.State.Paused, group.state);
            Assert.AreEqual(currentTime, group.CurrentLoopTime);
            Assert.AreEqual(QAbstractAnimation.State.Paused, anim.state);
            Assert.AreEqual(currentTime, anim.CurrentLoopTime);
            Assert.AreEqual(1, stateChangedSpy1);
            stateChangedSpy1 = 0;

            group.Resume();

            Assert.AreEqual(QAbstractAnimation.State.Running, group.state);
            Assert.AreEqual(currentTime, group.CurrentLoopTime);

            Assert.AreEqual(QAbstractAnimation.State.Running, anim.state);
            Assert.AreEqual(currentTime, anim.CurrentLoopTime);
            Assert.AreEqual(1, stateChangedSpy1);

            group.Stop();
            stateChangedSpy1 = 0;

            new TestAnimation2(500, group);
            group.Start();
            Assert.AreEqual(1, stateChangedSpy1); //the animation should have been started
            Assert.AreEqual(QAbstractAnimation.State.Running, anim.state);
            group.CurrentTime = 250; //end of first animation

            Assert.AreEqual(2, stateChangedSpy1); //the animation should have been stopped
            Assert.AreEqual(QAbstractAnimation.State.Stopped, anim.state);

            group.Pause();
            Assert.AreEqual(2, stateChangedSpy1); //this shouldn't have changed

            group.Resume();
            Assert.AreEqual(2, stateChangedSpy1); //this shouldn't have changed
        }