-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Update Shape.Fill when LinearGradientBrush gradient stops change
Change GradientStopCollection to inherit from DependencyObjectCollection, to invalidate parent view when collection is changed.
- Loading branch information
1 parent
4348caf
commit 947d2dd
Showing
7 changed files
with
141 additions
and
3 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
.../SamplesApp.UITests/Windows_UI_Xaml_Media/GradientBrushTests/LinearGradientBrush_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,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
using SamplesApp.UITests.TestFramework; | ||
using Uno.UITest.Helpers; | ||
|
||
namespace SamplesApp.UITests.Windows_UI_Xaml_Media.GradientBrushTests | ||
{ | ||
[TestFixture] | ||
public class LinearGradientBrush_Tests : SampleControlUITestBase | ||
{ | ||
[Test] | ||
[AutoRetry] | ||
public void When_GradientStops_Changed() | ||
{ | ||
Run("UITests.Windows_UI_Xaml_Media.GradientBrushTests.LinearGradientBrush_Change_Stops"); | ||
|
||
var rectangle = _app.Marked("GradientBrushRectangle"); | ||
|
||
_app.WaitForElement(rectangle); | ||
|
||
var screenRect = _app.GetRect(rectangle); | ||
|
||
var before = TakeScreenshot("Before"); | ||
|
||
_app.FastTap("ChangeBrushButton"); | ||
|
||
_app.WaitForText("StatusTextBlock", "Changed"); | ||
|
||
var after = TakeScreenshot("After"); | ||
|
||
ImageAssert.AreNotEqual(before, after, screenRect); | ||
} | ||
} | ||
} |
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
49 changes: 49 additions & 0 deletions
49
...sts.Shared/Windows_UI_Xaml_Media/GradientBrushTests/LinearGradientBrush_Change_Stops.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,49 @@ | ||
<UserControl | ||
x:Class="UITests.Windows_UI_Xaml_Media.GradientBrushTests.LinearGradientBrush_Change_Stops" | ||
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.GradientBrushTests" | ||
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> | ||
<Color x:Key="UnoBlueColor">#FF229DFC</Color> | ||
<Color x:Key="UnoPurpleColor">#FF7A69F5</Color> | ||
<Color x:Key="UnoGreenColor">#FF6CE5AE</Color> | ||
<Color x:Key="UnoRedColor">#FFF65678</Color> | ||
</UserControl.Resources> | ||
|
||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
<Rectangle x:Name="GradientBrushRectangle" | ||
Height="100" | ||
Width="150" | ||
HorizontalAlignment="Left"> | ||
<Rectangle.Fill> | ||
<LinearGradientBrush x:Name="UnoGradientBrush" | ||
StartPoint="0,0" | ||
EndPoint="1,1"> | ||
<GradientStop Color="{StaticResource UnoGreenColor}" | ||
Offset="0.0" /> | ||
<GradientStop Color="{StaticResource UnoGreenColor}" | ||
Offset="0.1" /> | ||
<GradientStop Color="{StaticResource UnoBlueColor}" | ||
Offset="0.40" /> | ||
<GradientStop Color="{StaticResource UnoPurpleColor}" | ||
Offset="0.60" /> | ||
<GradientStop Color="{StaticResource UnoRedColor}" | ||
Offset="0.9" /> | ||
<GradientStop Color="{StaticResource UnoRedColor}" | ||
Offset="1" /> | ||
</LinearGradientBrush> | ||
</Rectangle.Fill> | ||
</Rectangle> | ||
<Button x:Name="ChangeBrushButton" | ||
Content="Change gradient stops" | ||
Click="ChangeBrushButton_Click" /> | ||
<TextBlock x:Name="StatusTextBlock" | ||
Text="Not started" /> | ||
</StackPanel> | ||
</UserControl> |
36 changes: 36 additions & 0 deletions
36
....Shared/Windows_UI_Xaml_Media/GradientBrushTests/LinearGradientBrush_Change_Stops.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,36 @@ | ||
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.GradientBrushTests | ||
{ | ||
[Sample("GradientBrush")] | ||
public sealed partial class LinearGradientBrush_Change_Stops : UserControl | ||
{ | ||
public LinearGradientBrush_Change_Stops() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
private void ChangeBrushButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
UnoGradientBrush.GradientStops.RemoveAt(2); | ||
UnoGradientBrush.GradientStops.RemoveAt(2); | ||
StatusTextBlock.Text = "Changed"; | ||
} | ||
} | ||
} |
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