public void TestUpdateChildrenWithRunningGroup() { var group = new QParallelAnimationGroup(); var anim = new TestAnimation(); anim.StartValue = new QVariant(0); anim.EndValue = new QVariant(100); anim.SetDuration(200); var groupStateChangedSpy = 0; group.StateChanged += (arg1, arg2) => { groupStateChangedSpy++; }; var childStateChangedSpy = 0; anim.StateChanged += (arg1, arg2) => { childStateChangedSpy++; }; Assert.AreEqual(0, groupStateChangedSpy); Assert.AreEqual(0, childStateChangedSpy); Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim.state); group.AddAnimation(anim); group.Start(); Assert.AreEqual(QAbstractAnimation.State.Running, group.state); Assert.AreEqual(QAbstractAnimation.State.Running, anim.state); Assert.AreEqual(1, groupStateChangedSpy); Assert.AreEqual(1, childStateChangedSpy); anim.Start(); Assert.AreEqual(1, groupStateChangedSpy); Assert.AreEqual(1, childStateChangedSpy); anim.Pause(); Assert.AreEqual(QAbstractAnimation.State.Running, group.state); Assert.AreEqual(QAbstractAnimation.State.Paused, anim.state); // in the animation stops directly, the group will still be running anim.Stop(); Assert.AreEqual(QAbstractAnimation.State.Running, group.state); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim.state); }
public void TestStopGroupWithRunningChild() { // test if children can be activated when their group is stopped var group = new QParallelAnimationGroup(); var anim1 = new TestAnimation(); anim1.StartValue = new QVariant(0); anim1.EndValue = new QVariant(100); anim1.SetDuration(200); var anim2 = new TestAnimation(); anim2.StartValue = new QVariant(0); anim2.EndValue = new QVariant(100); anim2.SetDuration(200); 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); anim1.Start(); anim2.Start(); anim2.Pause(); Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state); Assert.AreEqual(QAbstractAnimation.State.Running, anim1.state); Assert.AreEqual(QAbstractAnimation.State.Paused, anim2.state); group.Stop(); Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state); Assert.AreEqual(QAbstractAnimation.State.Running, anim1.state); Assert.AreEqual(QAbstractAnimation.State.Paused, anim2.state); anim1.Stop(); anim2.Stop(); Assert.AreEqual(QAbstractAnimation.State.Stopped, group.state); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim1.state); Assert.AreEqual(QAbstractAnimation.State.Stopped, anim2.state); }
public async void TestAnimationCreateFrames() { //Set DebugMode to debug with Fiddler //Bootstrapper.DebugMode = true; var tests = new ChromaInstanceTests(); var instance = await tests.Instance_ReturnValidInstance(); var testAnimation = new TestAnimation(instance); testAnimation.AnimationState += (devices, frame, result) => { Console.WriteLine($"Devices: {string.Join(",", devices)}, Frame: {frame} of {testAnimation.Frames.Count}, Effects: {string.Join(",", devices.Select(x=>x.EffectId))} Result: {string.Join(",", result)}"); }; testAnimation.CreateFrames(); var playTask = testAnimation.Play(); await Task.Delay(20000); await testAnimation.Stop(); }