| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- // Copyright (c) The Avalonia Project. All rights reserved.
- // Licensed under the MIT license. See licence.md file in the project root for full license information.
- using Avalonia.Media;
- using Avalonia.Platform;
- using Moq;
- using Xunit;
- namespace Avalonia.Visuals.UnitTests.Media
- {
- public class PathMarkupParserTests
- {
- [Fact]
- public void Parses_Move()
- {
- using (AvaloniaLocator.EnterScope())
- {
- var result = new Mock<IStreamGeometryContextImpl>();
- var parser = PrepareParser(result);
- parser.Parse("M10 10");
- result.Verify(x => x.BeginFigure(new Point(10, 10), true));
- }
- }
- [Fact]
- public void Parses_Line()
- {
- using (AvaloniaLocator.EnterScope())
- {
- var result = new Mock<IStreamGeometryContextImpl>();
- var parser = PrepareParser(result);
- parser.Parse("M0 0L10 10");
- result.Verify(x => x.LineTo(new Point(10, 10)));
- }
- }
- [Fact]
- public void Parses_Close()
- {
- using (AvaloniaLocator.EnterScope())
- {
- var result = new Mock<IStreamGeometryContextImpl>();
- var parser = PrepareParser(result);
- parser.Parse("M0 0L10 10z");
- result.Verify(x => x.EndFigure(true));
- }
- }
- [Theory]
- [InlineData("F1 M24,14 A2,2,0,1,1,20,14 A2,2,0,1,1,24,14 z")] // issue #1107
- [InlineData("M0 0L10 10z")]
- [InlineData("M50 50 L100 100 L150 50")]
- [InlineData("M50 50L100 100L150 50")]
- [InlineData("M50,50 L100,100 L150,50")]
- [InlineData("M50 50 L-10 -10 L10 50")]
- [InlineData("M50 50L-10-10L10 50")]
- [InlineData("M50 50 L100 100 L150 50zM50 50 L70 70 L120 50z")]
- [InlineData("M 50 50 L 100 100 L 150 50")]
- [InlineData("M50 50 L100 100 L150 50 H200 V100Z")]
- [InlineData("M 80 200 A 100 50 45 1 0 100 50")]
- [InlineData(
- "F1 M 16.6309 18.6563C 17.1309 8.15625 29.8809 14.1563 29.8809 14.1563C 30.8809 11.1563 34.1308 11.4063" +
- " 34.1308 11.4063C 33.5 12 34.6309 13.1563 34.6309 13.1563C 32.1309 13.1562 31.1309 14.9062 31.1309 14.9" +
- "062C 41.1309 23.9062 32.6309 27.9063 32.6309 27.9062C 24.6309 24.9063 21.1309 22.1562 16.6309 18.6563 Z" +
- " M 16.6309 19.9063C 21.6309 24.1563 25.1309 26.1562 31.6309 28.6562C 31.6309 28.6562 26.3809 39.1562 18" +
- ".3809 36.1563C 18.3809 36.1563 18 38 16.3809 36.9063C 15 36 16.3809 34.9063 16.3809 34.9063C 16.3809 34" +
- ".9063 10.1309 30.9062 16.6309 19.9063 Z ")]
- [InlineData(
- "F1M16,12C16,14.209 14.209,16 12,16 9.791,16 8,14.209 8,12 8,11.817 8.03,11.644 8.054,11.467L6.585,10 4,10 " +
- "4,6.414 2.5,7.914 0,5.414 0,3.586 3.586,0 4.414,0 7.414,3 7.586,3 9,1.586 11.914,4.5 10.414,6 " +
- "12.461,8.046C14.45,8.278,16,9.949,16,12")]
- public void Should_Parse(string pathData)
- {
- using (AvaloniaLocator.EnterScope())
- {
- var parser = PrepareParser();
- parser.Parse(pathData);
- Assert.True(true);
- }
- }
- private static PathMarkupParser PrepareParser(Mock<IStreamGeometryContextImpl> implMock = null)
- {
- AvaloniaLocator.CurrentMutable
- .Bind<IPlatformRenderInterface>()
- .ToConstant(Mock.Of<IPlatformRenderInterface>());
- return new PathMarkupParser(
- new StreamGeometryContext(implMock != null ? implMock.Object : Mock.Of<IStreamGeometryContextImpl>()));
- }
- }
- }
|