diff --git a/components/Animations/tests/Animations.Tests.projitems b/components/Animations/tests/Animations.Tests.projitems index 32acc124..1fb5e1f4 100644 --- a/components/Animations/tests/Animations.Tests.projitems +++ b/components/Animations/tests/Animations.Tests.projitems @@ -10,5 +10,6 @@ + \ No newline at end of file diff --git a/components/Animations/tests/Test_AnimationBuilderStart.cs b/components/Animations/tests/Test_AnimationBuilderStart.cs index a25dfa6e..7cea9d73 100644 --- a/components/Animations/tests/Test_AnimationBuilderStart.cs +++ b/components/Animations/tests/Test_AnimationBuilderStart.cs @@ -9,7 +9,7 @@ namespace AnimationsExperiment.Tests; [TestClass] -[TestCategory("Test_AnimationBuilderStart")] +[TestCategory(nameof(Test_AnimationBuilderStart))] public class Test_AnimationBuilderStart : VisualUITestBase { [TestMethod] diff --git a/components/Animations/tests/Test_ExpressionFunctions.cs b/components/Animations/tests/Test_ExpressionFunctions.cs new file mode 100644 index 00000000..d2856b34 --- /dev/null +++ b/components/Animations/tests/Test_ExpressionFunctions.cs @@ -0,0 +1,59 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#if WINUI2 +using Windows.UI.Composition; +using Windows.UI.Xaml.Hosting; +#elif WINUI3 +using Microsoft.UI.Composition; +using Microsoft.UI.Xaml.Hosting; +#endif + +using System.Numerics; +using CommunityToolkit.Tests; +using CommunityToolkit.Tooling.TestGen; +using CommunityToolkit.WinUI.Animations.Expressions; + +namespace AnimationsExperiment.Tests; + +[TestClass] +[TestCategory(nameof(Test_ExpressionFunctions))] +public partial class Test_ExpressionFunctions : VisualUITestBase +{ + [UIThreadTestMethod] + public void ColorLerpRgb(Grid rootGrid) + { + // See https://github.com/CommunityToolkit/Windows/issues/303 + var compositor = ElementCompositionPreview.GetElementVisual(rootGrid).Compositor; + var brush = compositor.CreateColorBrush(); + var temp = ExpressionFunctions.ColorRgb(255f, 255f, 0f, 0f); + var color = ExpressionFunctions.ColorLerpRgb(temp, temp, 0.5f); + + brush.StartAnimation("Color", color); + + var visual = compositor.CreateSpriteVisual(); + visual.Brush = brush; + visual.RelativeSizeAdjustment = Vector2.One; + + ElementCompositionPreview.SetElementChildVisual(rootGrid, visual); + } + + [UIThreadTestMethod] + public void ColorLerpHsl(Grid rootGrid) + { + // See https://github.com/CommunityToolkit/Windows/issues/303 + var compositor = ElementCompositionPreview.GetElementVisual(rootGrid).Compositor; + var brush = compositor.CreateColorBrush(); + var temp = ExpressionFunctions.ColorHsl(255f, 255f, 0f); + var color = ExpressionFunctions.ColorLerpHsl(temp, temp, 0.5f); + + brush.StartAnimation("Color", color); + + var visual = compositor.CreateSpriteVisual(); + visual.Brush = brush; + visual.RelativeSizeAdjustment = Vector2.One; + + ElementCompositionPreview.SetElementChildVisual(rootGrid, visual); + } +}