-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit tests for ExpressionFunctions.ColorLerpRgb and ColorLerpHsl
- Loading branch information
1 parent
0637901
commit e33f6dd
Showing
3 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |