Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2921 from unoplatform/dev/djo/coloranimation
Implement ColorAnimation
- Loading branch information
Showing
42 changed files
with
1,862 additions
and
1,081 deletions.
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
68 changes: 68 additions & 0 deletions
68
src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Media_Animation/ColorAnimation_Tests.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,68 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
using SamplesApp.UITests.TestFramework; | ||
using Uno.UITest.Helpers.Queries; | ||
|
||
namespace SamplesApp.UITests.Windows_UI_Xaml_Media_Animation | ||
{ | ||
[TestFixture] | ||
public class ColorAnimation_Tests : SampleControlUITestBase | ||
{ | ||
[Test] | ||
[AutoRetry] | ||
[ActivePlatforms(Platform.Android, Platform.Browser)] // Disabled for iOS because HasColor() behaves strangely: https://github.com/unoplatform/uno/issues/1955 | ||
public void When_Border_Background_Animated() | ||
{ | ||
Run("UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background"); | ||
|
||
_app.WaitForElement("PlayColorAnimation"); | ||
|
||
_app.FastTap("BrushEqualityButton"); | ||
|
||
_app.WaitForText("BrushEqualityText", "true"); | ||
|
||
_app.FastTap("PlayColorAnimation"); | ||
|
||
_app.WaitForText("StatusText", "Completed"); | ||
|
||
_app.FastTap("BrushEqualityButton"); | ||
|
||
_app.WaitForText("BrushEqualityText", "false"); | ||
|
||
var targetRect = _app.GetRect("TargetBorder"); | ||
|
||
var indepRect = _app.GetRect("IndependentBorder"); | ||
|
||
var bmp = _app.Screenshot("Completed"); | ||
|
||
ImageAssert.HasColorAt(bmp, targetRect.CenterX, targetRect.CenterY, Color.Red); | ||
|
||
ImageAssert.HasColorAt(bmp, indepRect.CenterX, indepRect.CenterY, Color.Blue); //Shared resource shouldn't be modified | ||
} | ||
|
||
[Test] | ||
[AutoRetry] | ||
[ActivePlatforms(Platform.Android, Platform.Browser)] // Disabled for iOS because HasColor() behaves strangely: https://github.com/unoplatform/uno/issues/1955 | ||
public void When_Rectangle_Fill_Animated() | ||
{ | ||
Run("UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Fill"); | ||
|
||
_app.WaitForElement("PlayColorAnimation"); | ||
|
||
_app.FastTap("PlayColorAnimation"); | ||
|
||
_app.WaitForText("StatusText", "Completed"); | ||
|
||
var targetRect = _app.GetRect("TargetRectangle"); | ||
|
||
var bmp = _app.Screenshot("Completed"); | ||
|
||
ImageAssert.HasColorAt(bmp, targetRect.CenterX, targetRect.CenterY, Color.Brown); | ||
} | ||
} | ||
} |
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
48 changes: 48 additions & 0 deletions
48
src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media_Animation/ColorAnimation_Background.xaml
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,48 @@ | ||
<UserControl x:Class="UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:UITests.Windows_UI_Xaml_Media_Animation" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
d:DesignHeight="300" | ||
d:DesignWidth="400"> | ||
<UserControl.Resources> | ||
<SolidColorBrush x:Key="ColorAnimation_Background_Brush" | ||
Color="Blue" /> | ||
<Storyboard x:Name="colorStoryboard"> | ||
<ColorAnimation Duration="0:00:0.1" | ||
Storyboard.TargetName="TargetBorder" | ||
Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" | ||
To="Red" /> | ||
</Storyboard> | ||
</UserControl.Resources> | ||
|
||
<StackPanel> | ||
<Button x:Name="PlayColorAnimation" | ||
Content="Play ColorAnimation" | ||
Click="PlayColorAnimation_Click" /> | ||
<Button x:Name="BrushEqualityButton" | ||
Content="Are brushes ref-equal?" | ||
Click="CheckBrushEquality_Click" /> | ||
<TextBlock x:Name="BrushEqualityText" | ||
Text="-" /> | ||
<TextBlock Text="Status" /> | ||
<TextBlock x:Name="StatusText" /> | ||
<Border Width="300" | ||
Height="100" | ||
Margin="5" | ||
x:Name="TargetBorder" | ||
Background="{StaticResource ColorAnimation_Background_Brush}"> | ||
<Border.RenderTransform> | ||
<TranslateTransform /> | ||
</Border.RenderTransform> | ||
</Border> | ||
<Border Width="300" | ||
Height="100" | ||
Margin="5" | ||
x:Name="IndependentBorder" | ||
Background="{StaticResource ColorAnimation_Background_Brush}"> | ||
</Border> | ||
</StackPanel> | ||
</UserControl> |
45 changes: 45 additions & 0 deletions
45
...mplesApp/UITests.Shared/Windows_UI_Xaml_Media_Animation/ColorAnimation_Background.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,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Uno.UI.Samples.Controls; | ||
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; | ||
|
||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 | ||
|
||
namespace UITests.Windows_UI_Xaml_Media_Animation | ||
{ | ||
[Sample("Animations")] | ||
public sealed partial class ColorAnimation_Background : UserControl | ||
{ | ||
public ColorAnimation_Background() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
private void PlayColorAnimation_Click(object sender, RoutedEventArgs args) | ||
{ | ||
colorStoryboard.Completed += (o, e) => | ||
{ | ||
StatusText.Text = "Completed"; | ||
}; | ||
colorStoryboard.Begin(); | ||
} | ||
|
||
private void CheckBrushEquality_Click(object sender, RoutedEventArgs args) | ||
{ | ||
// Assert non-null | ||
var areEqual = ReferenceEquals(TargetBorder.Background, IndependentBorder.Background); | ||
BrushEqualityText.Text = areEqual.ToString().ToLowerInvariant(); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media_Animation/ColorAnimation_Fill.xaml
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,34 @@ | ||
<UserControl x:Class="UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Fill" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:UITests.Windows_UI_Xaml_Media_Animation" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
d:DesignHeight="300" | ||
d:DesignWidth="400"> | ||
<UserControl.Resources> | ||
<Storyboard x:Name="colorStoryboard"> | ||
<ColorAnimation Duration="0" | ||
Storyboard.TargetName="TargetRectangle" | ||
Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" | ||
From="Orange" | ||
To="Brown" /> | ||
</Storyboard> | ||
</UserControl.Resources> | ||
|
||
|
||
<StackPanel> | ||
<Button x:Name="PlayColorAnimation" | ||
Content="Play ColorAnimation" | ||
Click="PlayColorAnimation_Click" /> | ||
<TextBlock Text="Status" /> | ||
<TextBlock x:Name="StatusText" /> | ||
<Rectangle Width="300" | ||
Height="100" | ||
Margin="5" | ||
x:Name="TargetRectangle" | ||
Fill="Orange"> | ||
</Rectangle> | ||
</StackPanel> | ||
</UserControl> |
38 changes: 38 additions & 0 deletions
38
src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media_Animation/ColorAnimation_Fill.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,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Uno.UI.Samples.Controls; | ||
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; | ||
|
||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 | ||
|
||
namespace UITests.Windows_UI_Xaml_Media_Animation | ||
{ | ||
[Sample("Animations")] | ||
public sealed partial class ColorAnimation_Fill : UserControl | ||
{ | ||
public ColorAnimation_Fill() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
private void PlayColorAnimation_Click(object sender, RoutedEventArgs args) | ||
{ | ||
colorStoryboard.Completed += (o, e) => | ||
{ | ||
StatusText.Text = "Completed"; | ||
}; | ||
colorStoryboard.Begin(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.