-
Notifications
You must be signed in to change notification settings - Fork 718
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(animation): anomalies when quickly transitioning between multiple…
… VisualStates of same VSGroup
- Loading branch information
Showing
7 changed files
with
619 additions
and
10 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...RuntimeTests/Tests/Windows_UI_Xaml_Media_Animation/Given_DoubleAnimationUsingKeyFrames.cs
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,53 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Uno.UI.RuntimeTests.Helpers; | ||
using Windows.UI; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Shapes; | ||
using static Private.Infrastructure.TestServices; | ||
|
||
namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Media_Animation; | ||
|
||
[TestClass] | ||
[RunsOnUIThread] | ||
public class Given_DoubleAnimationUsingKeyFrames | ||
{ | ||
[TestMethod] | ||
public async Task When_Quickly_Transitions() | ||
{ | ||
// We are mimicking Fluent-style ToggleSwitch's ToggleStates here. | ||
var sut = new TestPages.QuickMultiTransitionsPage(); | ||
WindowHelper.WindowContent = sut; | ||
await WindowHelper.WaitForLoaded(sut); | ||
await Task.Delay(1000); | ||
|
||
// Quickly play through multiple visual-states to simulate what happens when tapping(*1) on a ToggleSwitch. | ||
/* *1: The full tapping experience is: [InitialState: Off]->Dragging->Off->On or [InitialState: A]->B->A->C | ||
* where A=Off, B=Dragging, C=Off | ||
* SwitchKnobOn.Opacity ToggleStates\AOff->COn 1 @[ControlFasterAnimationDuration] f=Linear | ||
* SwitchKnobOn.Opacity ToggleStates\BDragging->AOff 0 @[ControlFasterAnimationDuration] f=Linear | ||
* SwitchKnobOn.Opacity ToggleStates\BDragging->COn 1 @[ControlFasterAnimationDuration] f=Linear | ||
* SwitchKnobOn.Opacity ToggleStates\COn->AOff 0 @[ControlFasterAnimationDuration] f=Linear | ||
* SwitchKnobOn.Opacity ToggleStates\COn->BDragging 1 @0 f=Linear | ||
* SwitchKnobOn.Opacity ToggleStates\COn 1 @[ControlFasterAnimationDuration] f=Linear | ||
*/ | ||
VisualStateManager.GoToState(sut, TestPages.QuickMultiTransitionsPage.TestStateNames.PhaseB, useTransitions: true); | ||
VisualStateManager.GoToState(sut, TestPages.QuickMultiTransitionsPage.TestStateNames.PhaseA, useTransitions: true); | ||
VisualStateManager.GoToState(sut, TestPages.QuickMultiTransitionsPage.TestStateNames.PhaseC, useTransitions: true); | ||
await WindowHelper.WaitForIdle(); | ||
await Task.Delay(1000); | ||
|
||
// Given that it involves a race condition, we use a matrix of 4x4 to boost the failure rate. | ||
// If everything went smoothly, the end result should be an opacity of 1 for all the borders. | ||
var total = sut.RootGrid.Children.OfType<Border>().Count(); | ||
var passed = sut.RootGrid.Children.OfType<Border>() | ||
.Count(x => x.Opacity == 1.0); | ||
Assert.AreEqual(total, passed, $"Only {passed} of {total} Border.Opacity is at expected value of 1.0"); | ||
} | ||
} |
502 changes: 502 additions & 0 deletions
502
...ntimeTests/Tests/Windows_UI_Xaml_Media_Animation/TestPages/QuickMultiTransitionsPage.xaml
Large diffs are not rendered by default.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
...meTests/Tests/Windows_UI_Xaml_Media_Animation/TestPages/QuickMultiTransitionsPage.xaml.cs
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,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
using Windows.UI.Xaml.Data; | ||
using Windows.UI.Xaml.Input; | ||
using Windows.UI.Xaml.Media; | ||
using Windows.UI.Xaml.Navigation; | ||
|
||
namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Media_Animation.TestPages; | ||
|
||
public sealed partial class QuickMultiTransitionsPage : Page | ||
{ | ||
public static class TestStateNames | ||
{ | ||
public const string PhaseA = nameof(PhaseA); | ||
public const string PhaseB = nameof(PhaseB); | ||
public const string PhaseC = nameof(PhaseC); | ||
} | ||
|
||
public QuickMultiTransitionsPage() | ||
{ | ||
this.InitializeComponent(); | ||
this.Loaded += (s, e) => VisualStateManager.GoToState(this, TestStateNames.PhaseA, useTransitions: true); | ||
} | ||
} |
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
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