Ejemplo n.º 1
1
        public void StoryboardTargetTest()
        {
            XamlNamespaces namespaces = new XamlNamespaces("http://schemas.microsoft.com/winfx/2006/xaml/presentation");

            ColorAnimation colorAnimation = new ColorAnimation { From = Colors.Green, To = Colors.Blue };
            Storyboard.SetTargetProperty(colorAnimation, PropertyPath.Parse("(Control.Background).(SolidColorBrush.Color)", namespaces));

            Storyboard storyboard = new Storyboard();
            storyboard.Children.Add(colorAnimation);

            TestRootClock rootClock = new TestRootClock();

            Control control = new Control();
            control.SetAnimatableRootClock(new AnimatableRootClock(rootClock, true));
            control.Background = new SolidColorBrush(Colors.Red);

            storyboard.Begin(control);

            rootClock.Tick(TimeSpan.FromSeconds(0));
            Assert.AreEqual(Colors.Green, ((SolidColorBrush)control.Background).Color);

            rootClock.Tick(TimeSpan.FromSeconds(0.5));
            Assert.IsTrue(Color.FromArgb(255, 0, (byte)(Colors.Green.G / 2), (byte)(Colors.Blue.B / 2)).IsClose(((SolidColorBrush)control.Background).Color));

            rootClock.Tick(TimeSpan.FromSeconds(1));
            Assert.AreEqual(Colors.Blue, ((SolidColorBrush)control.Background).Color);
        }
Ejemplo n.º 2
0
        public void ColorAnimationKeyFrameRepeatTest()
        {
            ColorAnimationUsingKeyFrames animation;

            animation = new ColorAnimationUsingKeyFrames();
            animation.KeyFrames.Add(new LinearColorKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = Color.FromUInt32(0) });
            animation.KeyFrames.Add(new LinearColorKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1)), Value = Color.FromUInt32(100) });
            animation.Duration = new Duration(TimeSpan.FromSeconds(2));
            animation.RepeatBehavior = RepeatBehavior.Forever;

            TestRootClock rootClock = new TestRootClock();
            AnimationTimelineClock clock = (AnimationTimelineClock)animation.CreateClock();
            clock.Begin(rootClock);

            rootClock.Tick(TimeSpan.FromSeconds(0.1));
            Assert.AreEqual(Color.FromUInt32(10), (Color)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(0.9));
            Assert.AreEqual(Color.FromUInt32(90), (Color)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(1));
            Assert.AreEqual(Color.FromUInt32(100), (Color)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(1.9));
            Assert.AreEqual(Color.FromUInt32(100), (Color)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(2.1));
            Assert.AreEqual(Color.FromUInt32(10), (Color)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(2.9));
            Assert.AreEqual(Color.FromUInt32(90), (Color)animation.GetCurrentValue(0.0, 0.0, clock));
        }
Ejemplo n.º 3
0
        public void DoubleAnimationKeyFrameRepeatTest()
        {
            DoubleAnimationUsingKeyFrames animation;

            animation = new DoubleAnimationUsingKeyFrames();
            animation.KeyFrames.Add(new LinearDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 0 });
            animation.KeyFrames.Add(new LinearDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1)), Value = 1 });
            animation.Duration = new Duration(TimeSpan.FromSeconds(2));
            animation.RepeatBehavior = RepeatBehavior.Forever;

            TestRootClock rootClock = new TestRootClock();
            AnimationTimelineClock clock = (AnimationTimelineClock)animation.CreateClock();
            clock.Begin(rootClock);

            rootClock.Tick(TimeSpan.FromSeconds(0.1));
            Assert.AreEqual(0.1, (double)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(0.9));
            Assert.AreEqual(0.9, (double)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(1));
            Assert.AreEqual(1, (double)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(1.9));
            Assert.AreEqual(1, (double)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(2.1));
            Assert.AreEqual(0.1, (double)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(2.9));
            Assert.AreEqual(0.9, (double)animation.GetCurrentValue(0.0, 0.0, clock));
        }
Ejemplo n.º 4
0
        public void AnimationExpressionFillBehaviorStopTest()
        {
            DoubleAnimation animation = new DoubleAnimation {
                From = 10, To = 20, FillBehavior = FillBehavior.Stop
            };

            TestRootClock rootClock = new TestRootClock();

            rootClock.Tick(TimeSpan.FromSeconds(1));

            FrameworkElement element = new FrameworkElement();

            Assert.AreEqual(Double.NaN, element.Width);

            AnimationTimelineClock animationClock = (AnimationTimelineClock)animation.CreateClock();

            element.ApplyAnimationClock(FrameworkElement.WidthProperty, animationClock);
            animationClock.Begin(rootClock);

            rootClock.Tick(TimeSpan.FromSeconds(1));
            Assert.AreEqual(10, element.Width);

            rootClock.Tick(TimeSpan.FromSeconds(2));
            Assert.AreEqual(Double.NaN, element.Width);
        }
Ejemplo n.º 5
0
        private void ApplyAnimationClockTest(DoubleAnimation animation)
        {
            FrameworkElement element = new FrameworkElement();

            TestRootClock rootClock = new TestRootClock();

            rootClock.Tick(TimeSpan.FromSeconds(0));

            AnimationTimelineClock clock = (AnimationTimelineClock)animation.CreateClock();

            clock.Begin(rootClock);

            element.Width = 10;
            Assert.AreEqual(10, element.Width);

            element.ApplyAnimationClock(FrameworkElement.WidthProperty, clock);
            Assert.AreEqual(10, element.Width);

            rootClock.Tick(TimeSpan.FromSeconds(0.5));
            Assert.AreEqual(15, element.Width);

            rootClock.Tick(TimeSpan.FromSeconds(1));
            Assert.AreEqual(20, element.Width);

            clock.Stop();

            element.Width = 30;
            Assert.AreEqual(30, element.Width);
        }
Ejemplo n.º 6
0
        private void ApplyAnimationClockTest(DoubleAnimation animation)
        {
            FrameworkElement element = new FrameworkElement();

            TestRootClock rootClock = new TestRootClock();
            rootClock.Tick(TimeSpan.FromSeconds(0));

            AnimationTimelineClock clock = (AnimationTimelineClock)animation.CreateClock();
            clock.Begin(rootClock);

            element.Width = 10;
            Assert.AreEqual(10, element.Width);

            element.ApplyAnimationClock(FrameworkElement.WidthProperty, clock);
            Assert.AreEqual(10, element.Width);

            rootClock.Tick(TimeSpan.FromSeconds(0.5));
            Assert.AreEqual(15, element.Width);

            rootClock.Tick(TimeSpan.FromSeconds(1));
            Assert.AreEqual(20, element.Width);

            clock.Stop();

            element.Width = 30;
            Assert.AreEqual(30, element.Width);
        }
Ejemplo n.º 7
0
        public void SequentialTimelineClockStoryboardTest()
        {
            DoubleAnimation animation1 = new DoubleAnimation { To = 100, Duration = Duration.FromTimeSpan(TimeSpan.FromSeconds(1)) };
            DoubleAnimation animation2 = new DoubleAnimation { To = 200, Duration = Duration.FromTimeSpan(TimeSpan.FromSeconds(0)) };
            DoubleAnimation animation3 = new DoubleAnimation { To = 300, Duration = Duration.FromTimeSpan(TimeSpan.FromSeconds(1)) };

            SequentialTimeline sequentialTimeline = new SequentialTimeline();
            sequentialTimeline.Children.Add(animation1);
            sequentialTimeline.Children.Add(animation2);
            sequentialTimeline.Children.Add(animation3);

            Storyboard storyboard = new Storyboard();
            storyboard.Children.Add(sequentialTimeline);

            FrameworkElement element = new FrameworkElement { Width = 0, Height = 0 };

            Storyboard.SetTarget(animation1, element);
            Storyboard.SetTargetProperty(animation1, PropertyPath.FromDependencyProperty(FrameworkElement.WidthProperty));

            Storyboard.SetTarget(animation2, element);
            Storyboard.SetTargetProperty(animation2, PropertyPath.FromDependencyProperty(FrameworkElement.WidthProperty));

            Storyboard.SetTarget(animation3, element);
            Storyboard.SetTargetProperty(animation3, PropertyPath.FromDependencyProperty(FrameworkElement.WidthProperty));

            TestRootClock rootClock = new TestRootClock();
            element.SetAnimatableRootClock(new AnimatableRootClock(rootClock, true));
            storyboard.Begin(element);

            rootClock.Tick(TimeSpan.FromSeconds(0));
            Assert.AreEqual(0, element.Width);

            rootClock.Tick(TimeSpan.FromSeconds(0.9));
            Assert.AreEqual(90, element.Width);

            rootClock.Tick(TimeSpan.FromSeconds(1));
            Assert.AreEqual(200, element.Width);

            rootClock.Tick(TimeSpan.FromSeconds(1.5));
            Assert.AreEqual(250, element.Width);

            rootClock.Tick(TimeSpan.FromSeconds(2));
            Assert.AreEqual(300, element.Width);
        }
Ejemplo n.º 8
0
        public void AnimatableRootClockConnectionTest()
        {
            TestRootClock rootClock = new TestRootClock();

            FrameworkElement element = new FrameworkElement();

            element.SetAnimatableRootClock(new AnimatableRootClock(rootClock, false));

            Assert.AreEqual(0, rootClock.Clocks.Count());
            Assert.IsFalse(element.IsVisible);

            element.IsRootElement = true;
            Assert.IsTrue(element.IsVisible);

            DoubleAnimation animation = new DoubleAnimation {
                From = 0, To = 1
            };

            element.BeginAnimation(FrameworkElement.WidthProperty, animation);
            Assert.AreEqual(1, rootClock.Clocks.Count());

            rootClock.Tick(TimeSpan.FromSeconds(0.1));
            Assert.AreEqual(0.1, element.Width);

            element.IsRootElement = false;
            Assert.IsFalse(element.IsVisible);
            Assert.AreEqual(0, rootClock.Clocks.Count());

            rootClock.Tick(TimeSpan.FromSeconds(0.2));
            Assert.AreEqual(0.1, element.Width);

            element.IsRootElement = true;
            Assert.IsTrue(element.IsVisible);
            Assert.AreEqual(1, rootClock.Clocks.Count());
            Assert.AreEqual(0.2, element.Width);

            rootClock.Tick(TimeSpan.FromSeconds(2));
            Assert.AreEqual(0, rootClock.Clocks.Count());

            element.IsRootElement = false;
            element.IsRootElement = true;
            Assert.AreEqual(0, rootClock.Clocks.Count());
        }
Ejemplo n.º 9
0
        public void StoryboardBasicTest()
        {
            DoubleAnimation widthAnimation = new DoubleAnimation { To = 100 };
            DoubleAnimation heightAnimation = new DoubleAnimation { From = 100 };

            Storyboard storyboard = new Storyboard();
            storyboard.Children.Add(widthAnimation);
            storyboard.Children.Add(heightAnimation);

            FrameworkElement element = new FrameworkElement { Width = 0, Height = 0 };

            Storyboard.SetTarget(widthAnimation, element);
            Storyboard.SetTargetProperty(widthAnimation, PropertyPath.FromDependencyProperty(FrameworkElement.WidthProperty));

            Storyboard.SetTarget(heightAnimation, element);
            Storyboard.SetTargetProperty(heightAnimation, PropertyPath.FromDependencyProperty(FrameworkElement.HeightProperty));

            TestRootClock rootClock = new TestRootClock();
            element.SetAnimatableRootClock(new AnimatableRootClock(rootClock, true));
            storyboard.Begin(element);

            rootClock.Tick(TimeSpan.FromSeconds(0));
            Assert.AreEqual(0, element.Width);
            Assert.AreEqual(100, element.Height);

            rootClock.Tick(TimeSpan.FromSeconds(0.1));
            Assert.AreEqual(10, element.Width);
            Assert.AreEqual(90, element.Height);

            rootClock.Tick(TimeSpan.FromSeconds(1));
            Assert.AreEqual(100, element.Width);
            Assert.AreEqual(0, element.Height);

            storyboard.Seek(element, TimeSpan.FromSeconds(0.5));
            rootClock.Tick(TimeSpan.FromSeconds(1));
            Assert.AreEqual(50, element.Width);
            Assert.AreEqual(50, element.Height);

            storyboard.Remove(element);
            rootClock.Tick(TimeSpan.FromSeconds(1));
            Assert.AreEqual(0, element.Width);
            Assert.AreEqual(0, element.Height);
        }
Ejemplo n.º 10
0
        public void AnimationExpressionFillBehaviorStopTest()
        {
            DoubleAnimation animation = new DoubleAnimation { From = 10, To = 20, FillBehavior = FillBehavior.Stop };

            TestRootClock rootClock = new TestRootClock();
            rootClock.Tick(TimeSpan.FromSeconds(1));

            FrameworkElement element = new FrameworkElement();
            Assert.AreEqual(Double.NaN, element.Width);

            AnimationTimelineClock animationClock = (AnimationTimelineClock)animation.CreateClock();
            element.ApplyAnimationClock(FrameworkElement.WidthProperty, animationClock);
            animationClock.Begin(rootClock);

            rootClock.Tick(TimeSpan.FromSeconds(1));
            Assert.AreEqual(10, element.Width);

            rootClock.Tick(TimeSpan.FromSeconds(2));
            Assert.AreEqual(Double.NaN, element.Width);
        }
Ejemplo n.º 11
0
        public void TimelineClockControlBasicTest()
        {
            TestRootClock rootClock = new TestRootClock();
            TestTimeline timeline = new TestTimeline();
            TimelineClock clock = (TimelineClock)timeline.CreateClock();

            rootClock.Tick(TimeSpan.FromSeconds(10));

            Assert.AreEqual(ClockProgressState.BeforeStarted, clock.CurrentState.ProgressState);
            Assert.AreEqual(0, clock.CurrentState.Progress);
            Assert.AreEqual(0, clock.CurrentState.Iteration);

            clock.Begin(rootClock);

            Assert.AreEqual(ClockProgressState.Active, clock.CurrentState.ProgressState);
            Assert.AreEqual(0, clock.CurrentState.Progress);

            rootClock.Tick(TimeSpan.FromSeconds(10.1));

            Assert.AreEqual(ClockProgressState.Active, clock.CurrentState.ProgressState);
            Assert.AreEqual(0.1, clock.CurrentState.Progress);

            clock.Pause();
            rootClock.Tick(TimeSpan.FromSeconds(10.2));

            Assert.AreEqual(ClockProgressState.Active, clock.CurrentState.ProgressState);
            Assert.AreEqual(0.1, clock.CurrentState.Progress);

            clock.Resume();
            rootClock.Tick(TimeSpan.FromSeconds(10.3));

            Assert.AreEqual(ClockProgressState.Active, clock.CurrentState.ProgressState);
            Assert.AreEqual(0.2, clock.CurrentState.Progress);

            clock.Stop();
            rootClock.Tick(TimeSpan.FromSeconds(10.4));

            Assert.AreEqual(ClockProgressState.AfterEnded, clock.CurrentState.ProgressState);
            Assert.AreEqual(1, clock.CurrentState.Progress);
        }
Ejemplo n.º 12
0
        public void AnimatableRootClockConnectionTest()
        {
            TestRootClock rootClock = new TestRootClock();

            FrameworkElement element = new FrameworkElement();
            element.SetAnimatableRootClock(new AnimatableRootClock(rootClock, false));

            Assert.AreEqual(0, rootClock.Clocks.Count());
            Assert.IsFalse(element.IsVisible);

            element.IsRootElement = true;
            Assert.IsTrue(element.IsVisible);

            DoubleAnimation animation = new DoubleAnimation { From = 0, To = 1 };

            element.BeginAnimation(FrameworkElement.WidthProperty, animation);
            Assert.AreEqual(1, rootClock.Clocks.Count());

            rootClock.Tick(TimeSpan.FromSeconds(0.1));
            Assert.AreEqual(0.1, element.Width);

            element.IsRootElement = false;
            Assert.IsFalse(element.IsVisible);
            Assert.AreEqual(0, rootClock.Clocks.Count());

            rootClock.Tick(TimeSpan.FromSeconds(0.2));
            Assert.AreEqual(0.1, element.Width);

            element.IsRootElement = true;
            Assert.IsTrue(element.IsVisible);
            Assert.AreEqual(1, rootClock.Clocks.Count());
            Assert.AreEqual(0.2, element.Width);

            rootClock.Tick(TimeSpan.FromSeconds(2));
            Assert.AreEqual(0, rootClock.Clocks.Count());

            element.IsRootElement = false;
            element.IsRootElement = true;
            Assert.AreEqual(0, rootClock.Clocks.Count());
        }
Ejemplo n.º 13
0
        private void ColorAnimationBasicTest(AnimationTimeline animation, Color defaultOriginValue, Color defaultDestinationValue, Color expectedStartValue, Color expectedMiddleValue, Color expectedEndValue)
        {
            AnimationTimelineClock clock = (AnimationTimelineClock)animation.CreateClock();

            TestRootClock rootClock = new TestRootClock();

            clock.Begin(rootClock);

            rootClock.Tick(TimeSpan.Zero);
            Assert.AreEqual(expectedStartValue, (Color)animation.GetCurrentValue(defaultOriginValue, defaultDestinationValue, clock));

            rootClock.Tick(animation.Duration.TimeSpan.Scale(0.5));
            Assert.AreEqual(expectedMiddleValue, (Color)animation.GetCurrentValue(defaultOriginValue, defaultDestinationValue, clock));

            rootClock.Tick(animation.Duration.TimeSpan);
            Assert.AreEqual(expectedEndValue, (Color)animation.GetCurrentValue(defaultOriginValue, defaultDestinationValue, clock));
        }
Ejemplo n.º 14
0
        public void TimelineClockControlSeekTest()
        {
            TestRootClock rootClock = new TestRootClock();
            TestTimeline timeline = new TestTimeline();
            TimelineClock clock = (TimelineClock)timeline.CreateClock();

            clock.Begin(rootClock);
            rootClock.Tick(TimeSpan.FromSeconds(0.1));
            Assert.AreEqual(ClockProgressState.Active, clock.CurrentState.ProgressState);
            Assert.AreEqual(0.1, clock.CurrentState.Progress);

            clock.SeekOffset(TimeSpan.FromSeconds(0.1));
            rootClock.Tick(TimeSpan.FromSeconds(0.2));
            Assert.AreEqual(0.1, clock.CurrentState.Progress);

            clock.Seek(TimeSpan.FromSeconds(0.9));
            rootClock.Tick(TimeSpan.FromSeconds(0.3));
            Assert.AreEqual(1, clock.CurrentState.Progress);
        }
Ejemplo n.º 15
0
        public void VisualStateStoryboardTest()
        {
            string text = @"
            <Control xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' Width='0'>
                <Control.TemplateChild>
                    <FrameworkElement>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name='StateGroup1'>
                                <VisualStateGroup.Transitions>

                                    <VisualTransition To='State1'>
                                        <VisualTransition.Storyboard>
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetProperty='Width' To='100'/>
                                            </Storyboard>
                                        </VisualTransition.Storyboard>
                                    </VisualTransition>

                                    <VisualTransition To='State2'>
                                        <VisualTransition.Storyboard>
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetProperty='Width' To='200'/>
                                            </Storyboard>
                                        </VisualTransition.Storyboard>
                                    </VisualTransition>

                                </VisualStateGroup.Transitions>

                                <VisualState x:Name='State1'>
                                    <VisualState.Storyboard>
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetProperty='Width' From='100' To='200'/>
                                        </Storyboard>
                                    </VisualState.Storyboard>
                                </VisualState>

                                <VisualState x:Name='State2'>
                                    <VisualState.Storyboard>
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetProperty='Width' From='200' To='300'/>
                                        </Storyboard>
                                    </VisualState.Storyboard>
                                </VisualState>

                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </FrameworkElement>
                </Control.TemplateChild>
            </Control>";

            Control control = XamlLoader.Load(XamlParser.Parse(text)) as Control;

            VisualStateGroup group1 = VisualStateManager.GetVisualStateGroups(control.TemplateChild).FirstOrDefault();

            Assert.IsTrue(group1 != null);

            TestRootClock rootClock = new TestRootClock();

            control.SetAnimatableRootClock(new AnimatableRootClock(rootClock, true));

            VisualStateManager.GoToState(control, "State1", true);

            rootClock.Tick(TimeSpan.FromSeconds(0));
            Assert.AreEqual(0, control.Width);

            rootClock.Tick(TimeSpan.FromSeconds(0.5));
            Assert.AreEqual(50, control.Width);

            rootClock.Tick(TimeSpan.FromSeconds(1));
            Assert.AreEqual(100, control.Width);

            rootClock.Tick(TimeSpan.FromSeconds(1.5));
            Assert.AreEqual(150, control.Width);

            VisualStateManager.GoToState(control, "State2", true);

            rootClock.Tick(TimeSpan.FromSeconds(2));
            Assert.AreEqual(175, control.Width);

            rootClock.Tick(TimeSpan.FromSeconds(2.5));
            Assert.AreEqual(200, control.Width);

            rootClock.Tick(TimeSpan.FromSeconds(3));
            Assert.AreEqual(250, control.Width);

            rootClock.Tick(TimeSpan.FromSeconds(4));
            Assert.AreEqual(300, control.Width);

            VisualStateManager.GoToState(control, "State1", false);

            rootClock.Tick(TimeSpan.FromSeconds(4));
            Assert.AreEqual(100, control.Width);

            rootClock.Tick(TimeSpan.FromSeconds(5));
            Assert.AreEqual(200, control.Width);
        }
Ejemplo n.º 16
0
        public void VisualStateEmptyStoryboardTest()
        {
            string text = @"
            <Control xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' Width='100'>
                <Control.TemplateChild>
                    <FrameworkElement>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name='StateGroup1'>
                                <VisualStateGroup.Transitions>

                                    <VisualTransition To='State2'>
                                        <VisualTransition.Storyboard>
                                            <Storyboard>
                                                <DoubleAnimation Storyboard.TargetProperty='Width' To='200'/>
                                            </Storyboard>
                                        </VisualTransition.Storyboard>
                                    </VisualTransition>

                                </VisualStateGroup.Transitions>

                                <VisualState x:Name='State1'/>

                                <VisualState x:Name='State2'>
                                    <VisualState.Storyboard>
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetProperty='Width' From='200' To='300'/>
                                        </Storyboard>
                                    </VisualState.Storyboard>
                                </VisualState>

                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </FrameworkElement>
                </Control.TemplateChild>
            </Control>";

            Control control = XamlLoader.Load(XamlParser.Parse(text)) as Control;

            TestRootClock rootClock = new TestRootClock();
            control.SetAnimatableRootClock(new AnimatableRootClock(rootClock, true));

            Assert.AreEqual(100, control.Width);

            VisualStateManager.GoToState(control, "State2", true);

            rootClock.Tick(TimeSpan.FromSeconds(0));
            Assert.AreEqual(100, control.Width);

            rootClock.Tick(TimeSpan.FromSeconds(0.5));
            Assert.AreEqual(150, control.Width);

            VisualStateManager.GoToState(control, "State1", true);
            Assert.AreEqual(100, control.Width);

            rootClock.Tick(TimeSpan.FromSeconds(1));

            VisualStateManager.GoToState(control, "State2", true);

            rootClock.Tick(TimeSpan.FromSeconds(1));
            Assert.AreEqual(100, control.Width);

            rootClock.Tick(TimeSpan.FromSeconds(1.5));
            Assert.AreEqual(150, control.Width);

            rootClock.Tick(TimeSpan.FromSeconds(2));
            Assert.AreEqual(200, control.Width);

            rootClock.Tick(TimeSpan.FromSeconds(2.5));
            Assert.AreEqual(250, control.Width);

            VisualStateManager.GoToState(control, "State1", true);
            Assert.AreEqual(100, control.Width);

            rootClock.Tick(TimeSpan.FromSeconds(3));

            VisualStateManager.GoToState(control, "State2", false);

            rootClock.Tick(TimeSpan.FromSeconds(3));
            Assert.AreEqual(200, control.Width);

            rootClock.Tick(TimeSpan.FromSeconds(3.5));
            Assert.AreEqual(250, control.Width);

            VisualStateManager.GoToState(control, "State1", true);
            Assert.AreEqual(100, control.Width);
        }