Fixed issue creating Paths with segments without points on iOS (#13161)
Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
This commit is contained in:
Родитель
430754ba0b
Коммит
dad72d381f
|
@ -0,0 +1,126 @@
|
|||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
using Xamarin.Forms.Shapes;
|
||||
|
||||
#if UITEST
|
||||
using Xamarin.UITest;
|
||||
using NUnit.Framework;
|
||||
using Xamarin.Forms.Core.UITests;
|
||||
#endif
|
||||
|
||||
namespace Xamarin.Forms.Controls.Issues
|
||||
{
|
||||
[Preserve(AllMembers = true)]
|
||||
[Issue(IssueTracker.Github, 13159, "[Bug] +Fix. Path.Data crashing when geometry has a PolyLineSegment with 0 point",
|
||||
PlatformAffected.iOS)]
|
||||
#if UITEST
|
||||
[Category(UITestCategories.Shape)]
|
||||
#endif
|
||||
public class Issue13159 : TestContentPage
|
||||
{
|
||||
const string TestReady = "TestReadyId";
|
||||
|
||||
public Issue13159()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
var layout = new StackLayout();
|
||||
|
||||
var instructions = new Label
|
||||
{
|
||||
AutomationId = TestReady,
|
||||
Padding = 12,
|
||||
BackgroundColor = Color.Black,
|
||||
TextColor = Color.White,
|
||||
Text = "Without exceptions, the test has passed."
|
||||
};
|
||||
|
||||
layout.Children.Add(instructions);
|
||||
layout.Children.Add(CreateNoPointsPolyLineSegmentPath());
|
||||
layout.Children.Add(CreateNoPointsPolyBezierSegmentPath());
|
||||
layout.Children.Add(CreateNoPointsPolyQuadraticBezierSegmentPath());
|
||||
layout.Children.Add(CreateNoPointsArcSegmentPath());
|
||||
|
||||
Content = layout;
|
||||
}
|
||||
|
||||
Path CreateNoPointsPolyLineSegmentPath()
|
||||
{
|
||||
var path = new Path();
|
||||
|
||||
PathFigure pathFigure = new PathFigure();
|
||||
|
||||
pathFigure.Segments.Add(new PolyLineSegment());
|
||||
|
||||
PathGeometry geometry = new PathGeometry();
|
||||
|
||||
geometry.Figures.Add(pathFigure);
|
||||
|
||||
path.Data = geometry;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
Path CreateNoPointsPolyBezierSegmentPath()
|
||||
{
|
||||
var path = new Path();
|
||||
|
||||
PathFigure pathFigure = new PathFigure();
|
||||
|
||||
pathFigure.Segments.Add(new PolyBezierSegment());
|
||||
|
||||
PathGeometry geometry = new PathGeometry();
|
||||
|
||||
geometry.Figures.Add(pathFigure);
|
||||
|
||||
path.Data = geometry;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
Path CreateNoPointsPolyQuadraticBezierSegmentPath()
|
||||
{
|
||||
var path = new Path();
|
||||
|
||||
PathFigure pathFigure = new PathFigure();
|
||||
|
||||
pathFigure.Segments.Add(new PolyQuadraticBezierSegment());
|
||||
|
||||
PathGeometry geometry = new PathGeometry();
|
||||
|
||||
geometry.Figures.Add(pathFigure);
|
||||
|
||||
path.Data = geometry;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
Path CreateNoPointsArcSegmentPath()
|
||||
{
|
||||
var path = new Path();
|
||||
|
||||
PathFigure pathFigure = new PathFigure();
|
||||
|
||||
pathFigure.Segments.Add(new ArcSegment());
|
||||
|
||||
PathGeometry geometry = new PathGeometry();
|
||||
|
||||
geometry.Figures.Add(pathFigure);
|
||||
|
||||
path.Data = geometry;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
#if UITEST && __IOS__
|
||||
[Test]
|
||||
public void Issue13159NoPointsPathTest()
|
||||
{
|
||||
RunningApp.WaitForElement(TestReady);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -1794,6 +1794,7 @@
|
|||
<Compile Include="$(MSBuildThisFileDirectory)Issue8833.xaml.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue10086.xaml.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue13136.xaml.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue13159.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue11980.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue13173.xaml.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue8282.xaml.cs" />
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace Xamarin.Forms.Platform.MacOS
|
|||
for (int i = 0; i < points.Count; i++)
|
||||
pathData.Data.AddLineToPoint(transform, points[i].ToPointF());
|
||||
|
||||
lastPoint = points[points.Count - 1];
|
||||
lastPoint = points.Count > 0 ? points[points.Count - 1] : Point.Zero;
|
||||
}
|
||||
// BezierSegment
|
||||
else if (pathSegment is BezierSegment)
|
||||
|
@ -123,7 +123,7 @@ namespace Xamarin.Forms.Platform.MacOS
|
|||
}
|
||||
}
|
||||
|
||||
lastPoint = points[points.Count - 1];
|
||||
lastPoint = points.Count > 0 ? points[points.Count - 1] : Point.Zero;
|
||||
}
|
||||
// QuadraticBezierSegment
|
||||
else if (pathSegment is QuadraticBezierSegment)
|
||||
|
@ -158,7 +158,7 @@ namespace Xamarin.Forms.Platform.MacOS
|
|||
}
|
||||
}
|
||||
|
||||
lastPoint = points[points.Count - 1];
|
||||
lastPoint = points.Count > 0 ? points[points.Count - 1] : Point.Zero;
|
||||
}
|
||||
// ArcSegment
|
||||
else if (pathSegment is ArcSegment)
|
||||
|
|
Загрузка…
Ссылка в новой задаче