Browse Source
* Add Points binding observability support for Polygon and Polyline
* Add simple tests for Polygon and Polyline Points updating
* Revert "Add Points binding observability support for Polygon and Polyline"
This reverts commit e16d987945.
* Move Geometry.Changed handler to Shape class to make it available to all inheritors
* Fixes the event subscriptions
* Fix tests
* Add memory leak tests
pull/15190/head
committed by
GitHub
8 changed files with 149 additions and 57 deletions
@ -0,0 +1,28 @@ |
|||||
|
using System.Collections.ObjectModel; |
||||
|
using Avalonia.Controls.Shapes; |
||||
|
using Avalonia.UnitTests; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Avalonia.Controls.UnitTests.Shapes; |
||||
|
|
||||
|
public class PolygonTests |
||||
|
{ |
||||
|
[Fact] |
||||
|
public void Polygon_Will_Update_Geometry_On_Shapes_Collection_Content_Change() |
||||
|
{ |
||||
|
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface); |
||||
|
var points = new ObservableCollection<Point>(); |
||||
|
|
||||
|
var target = new Polygon() { Points = points }; |
||||
|
target.Measure(new Size()); |
||||
|
Assert.True(target.IsMeasureValid); |
||||
|
|
||||
|
var root = new TestRoot(target); |
||||
|
|
||||
|
points.Add(new Point()); |
||||
|
|
||||
|
Assert.False(target.IsMeasureValid); |
||||
|
|
||||
|
root.Child = null; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
using System.Collections.ObjectModel; |
||||
|
using Avalonia.Controls.Shapes; |
||||
|
using Avalonia.UnitTests; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Avalonia.Controls.UnitTests.Shapes; |
||||
|
|
||||
|
public class PolylineTests |
||||
|
{ |
||||
|
[Fact] |
||||
|
public void Polyline_Will_Update_Geometry_On_Shapes_Collection_Content_Change() |
||||
|
{ |
||||
|
using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface); |
||||
|
var points = new ObservableCollection<Point>(); |
||||
|
|
||||
|
var target = new Polyline { Points = points }; |
||||
|
target.Measure(new Size()); |
||||
|
Assert.True(target.IsMeasureValid); |
||||
|
|
||||
|
var root = new TestRoot(target); |
||||
|
|
||||
|
points.Add(new Point()); |
||||
|
|
||||
|
Assert.False(target.IsMeasureValid); |
||||
|
|
||||
|
root.Child = null; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue