Synced with 2021.10
This commit is contained in:
Родитель
f3b75b43ac
Коммит
7980befb77
|
@ -8,6 +8,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
|
||||
<PackageReference Include="nunit" Version="3.13.2" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using NUnit.Framework;
|
||||
using QuestPDF.Drawing.SpacePlan;
|
||||
using QuestPDF.Drawing;
|
||||
using QuestPDF.Elements;
|
||||
using QuestPDF.Infrastructure;
|
||||
using QuestPDF.UnitTests.TestEngine;
|
||||
|
@ -21,7 +21,7 @@ namespace QuestPDF.UnitTests
|
|||
Child = x.CreateChild()
|
||||
})
|
||||
.DrawElement(new Size(400, 300))
|
||||
.ExpectChildMeasure(expectedInput: new Size(400, 300), returns: new Wrap())
|
||||
.ExpectChildMeasure(expectedInput: new Size(400, 300), returns: SpacePlan.Wrap())
|
||||
.CheckDrawResult();
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace QuestPDF.UnitTests
|
|||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(400, 300))
|
||||
.ExpectChildMeasure(expectedInput: new Size(400, 300), returns: new PartialRender(200, 100))
|
||||
.ExpectChildMeasure(expectedInput: new Size(400, 300), returns: SpacePlan.PartialRender(200, 100))
|
||||
.ExpectChildDraw(new Size(200, 100))
|
||||
.CheckDrawResult();
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ namespace QuestPDF.UnitTests
|
|||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(500, 400))
|
||||
.ExpectChildMeasure(expectedInput: new Size(500, 400), returns: new FullRender(300, 200))
|
||||
.ExpectChildMeasure(expectedInput: new Size(500, 400), returns: SpacePlan.FullRender(300, 200))
|
||||
.ExpectChildDraw(new Size(300, 200))
|
||||
.CheckDrawResult();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using QuestPDF.Drawing.SpacePlan;
|
||||
using QuestPDF.Drawing;
|
||||
using QuestPDF.Elements;
|
||||
using QuestPDF.Infrastructure;
|
||||
using QuestPDF.UnitTests.TestEngine;
|
||||
|
@ -45,8 +45,8 @@ namespace QuestPDF.UnitTests
|
|||
TestPlan
|
||||
.For(GetLayers)
|
||||
.MeasureElement(new Size(800, 600))
|
||||
.ExpectChildMeasure(MainLayer, new Size(800, 600), new Wrap())
|
||||
.CheckMeasureResult(new Wrap());
|
||||
.ExpectChildMeasure(MainLayer, new Size(800, 600), SpacePlan.Wrap())
|
||||
.CheckMeasureResult(SpacePlan.Wrap());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -55,8 +55,8 @@ namespace QuestPDF.UnitTests
|
|||
TestPlan
|
||||
.For(GetLayers)
|
||||
.MeasureElement(new Size(800, 600))
|
||||
.ExpectChildMeasure(MainLayer, new Size(800, 600), new PartialRender(700, 500))
|
||||
.CheckMeasureResult(new PartialRender(700, 500));
|
||||
.ExpectChildMeasure(MainLayer, new Size(800, 600), SpacePlan.PartialRender(700, 500))
|
||||
.CheckMeasureResult(SpacePlan.PartialRender(700, 500));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -65,8 +65,8 @@ namespace QuestPDF.UnitTests
|
|||
TestPlan
|
||||
.For(GetLayers)
|
||||
.MeasureElement(new Size(800, 600))
|
||||
.ExpectChildMeasure(MainLayer, new Size(800, 600), new FullRender(500, 400))
|
||||
.CheckMeasureResult(new FullRender(500, 400));
|
||||
.ExpectChildMeasure(MainLayer, new Size(800, 600), SpacePlan.FullRender(500, 400))
|
||||
.CheckMeasureResult(SpacePlan.FullRender(500, 400));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -80,9 +80,9 @@ namespace QuestPDF.UnitTests
|
|||
.For(GetLayers)
|
||||
.MeasureElement(new Size(800, 600))
|
||||
|
||||
.ExpectChildMeasure(BackgroundLayer, new Size(800, 600), new FullRender(100, 200))
|
||||
.ExpectChildMeasure(MainLayer, new Size(800, 600), new PartialRender(200, 300))
|
||||
.ExpectChildMeasure(ForegroundLayer, new Size(800, 600), new FullRender(300, 400))
|
||||
.ExpectChildMeasure(BackgroundLayer, new Size(800, 600), SpacePlan.FullRender(100, 200))
|
||||
.ExpectChildMeasure(MainLayer, new Size(800, 600), SpacePlan.PartialRender(200, 300))
|
||||
.ExpectChildMeasure(ForegroundLayer, new Size(800, 600), SpacePlan.FullRender(300, 400))
|
||||
|
||||
|
||||
.ExpectChildDraw(BackgroundLayer, new Size(800, 600))
|
||||
|
@ -99,9 +99,9 @@ namespace QuestPDF.UnitTests
|
|||
.For(GetLayers)
|
||||
.MeasureElement(new Size(800, 600))
|
||||
|
||||
.ExpectChildMeasure(BackgroundLayer, new Size(800, 600), new PartialRender(100, 200))
|
||||
.ExpectChildMeasure(MainLayer, new Size(800, 600), new PartialRender(200, 300))
|
||||
.ExpectChildMeasure(ForegroundLayer, new Size(800, 600), new Wrap())
|
||||
.ExpectChildMeasure(BackgroundLayer, new Size(800, 600), SpacePlan.PartialRender(100, 200))
|
||||
.ExpectChildMeasure(MainLayer, new Size(800, 600), SpacePlan.PartialRender(200, 300))
|
||||
.ExpectChildMeasure(ForegroundLayer, new Size(800, 600), SpacePlan.Wrap())
|
||||
|
||||
.ExpectChildDraw(BackgroundLayer, new Size(800, 600))
|
||||
.ExpectChildDraw(MainLayer, new Size(800, 600))
|
||||
|
@ -116,9 +116,9 @@ namespace QuestPDF.UnitTests
|
|||
.For(GetLayers)
|
||||
.MeasureElement(new Size(800, 600))
|
||||
|
||||
.ExpectChildMeasure(BackgroundLayer, new Size(800, 600), new Wrap())
|
||||
.ExpectChildMeasure(MainLayer, new Size(800, 600), new PartialRender(200, 300))
|
||||
.ExpectChildMeasure(ForegroundLayer, new Size(800, 600), new PartialRender(300, 400))
|
||||
.ExpectChildMeasure(BackgroundLayer, new Size(800, 600), SpacePlan.Wrap())
|
||||
.ExpectChildMeasure(MainLayer, new Size(800, 600), SpacePlan.PartialRender(200, 300))
|
||||
.ExpectChildMeasure(ForegroundLayer, new Size(800, 600), SpacePlan.PartialRender(300, 400))
|
||||
|
||||
.ExpectChildDraw(MainLayer, new Size(800, 600))
|
||||
.ExpectChildDraw(ForegroundLayer, new Size(800, 600))
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using NUnit.Framework;
|
||||
using QuestPDF.Drawing.SpacePlan;
|
||||
using QuestPDF.Elements;
|
||||
using QuestPDF.Infrastructure;
|
||||
using QuestPDF.UnitTests.TestEngine;
|
||||
|
|
|
@ -184,11 +184,11 @@ namespace QuestPDF.UnitTests
|
|||
});
|
||||
|
||||
// assert
|
||||
var expected = new SimpleRow
|
||||
var expected = new BinaryRow
|
||||
{
|
||||
Left = new SimpleRow
|
||||
Left = new BinaryRow
|
||||
{
|
||||
Left = new SimpleRow
|
||||
Left = new BinaryRow
|
||||
{
|
||||
Left = new Constrained
|
||||
{
|
||||
|
@ -202,7 +202,7 @@ namespace QuestPDF.UnitTests
|
|||
MaxWidth = 25
|
||||
}
|
||||
},
|
||||
Right = new SimpleRow
|
||||
Right = new BinaryRow
|
||||
{
|
||||
Left = new Constrained
|
||||
{
|
||||
|
@ -217,9 +217,9 @@ namespace QuestPDF.UnitTests
|
|||
}
|
||||
}
|
||||
},
|
||||
Right = new SimpleRow
|
||||
Right = new BinaryRow
|
||||
{
|
||||
Left = new SimpleRow
|
||||
Left = new BinaryRow
|
||||
{
|
||||
Left = new Constrained
|
||||
{
|
||||
|
@ -233,7 +233,7 @@ namespace QuestPDF.UnitTests
|
|||
MaxWidth = 25
|
||||
}
|
||||
},
|
||||
Right = new SimpleRow
|
||||
Right = new BinaryRow
|
||||
{
|
||||
Left = new Constrained
|
||||
{
|
||||
|
@ -241,7 +241,7 @@ namespace QuestPDF.UnitTests
|
|||
MaxWidth = 200,
|
||||
Child = childD
|
||||
},
|
||||
Right = new SimpleRow
|
||||
Right = new BinaryRow
|
||||
{
|
||||
Left = new Constrained
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using NUnit.Framework;
|
||||
using QuestPDF.Drawing.SpacePlan;
|
||||
using QuestPDF.Drawing;
|
||||
using QuestPDF.Elements;
|
||||
using QuestPDF.Infrastructure;
|
||||
using QuestPDF.UnitTests.TestEngine;
|
||||
|
@ -22,8 +22,8 @@ namespace QuestPDF.UnitTests
|
|||
ScaleY = 2
|
||||
})
|
||||
.MeasureElement(new Size(900, 800))
|
||||
.ExpectChildMeasure(new Size(300, 400), new Wrap())
|
||||
.CheckMeasureResult(new Wrap());
|
||||
.ExpectChildMeasure(new Size(300, 400), SpacePlan.Wrap())
|
||||
.CheckMeasureResult(SpacePlan.Wrap());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -37,8 +37,8 @@ namespace QuestPDF.UnitTests
|
|||
ScaleY = 2
|
||||
})
|
||||
.MeasureElement(new Size(900, 800))
|
||||
.ExpectChildMeasure(new Size(300, 400), new PartialRender(200, 350))
|
||||
.CheckMeasureResult(new PartialRender(600, 700));
|
||||
.ExpectChildMeasure(new Size(300, 400), SpacePlan.PartialRender(200, 350))
|
||||
.CheckMeasureResult(SpacePlan.PartialRender(600, 700));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -52,8 +52,8 @@ namespace QuestPDF.UnitTests
|
|||
ScaleY = 2
|
||||
})
|
||||
.MeasureElement(new Size(900, 800))
|
||||
.ExpectChildMeasure(new Size(300, 400), new FullRender(250, 300))
|
||||
.CheckMeasureResult(new FullRender(750, 600));
|
||||
.ExpectChildMeasure(new Size(300, 400), SpacePlan.FullRender(250, 300))
|
||||
.CheckMeasureResult(SpacePlan.FullRender(750, 600));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -67,8 +67,8 @@ namespace QuestPDF.UnitTests
|
|||
ScaleY = 1
|
||||
})
|
||||
.MeasureElement(new Size(800, 600))
|
||||
.ExpectChildMeasure(new Size(400, 600), new FullRender(300, 500))
|
||||
.CheckMeasureResult(new FullRender(600, 500));
|
||||
.ExpectChildMeasure(new Size(400, 600), SpacePlan.FullRender(300, 500))
|
||||
.CheckMeasureResult(SpacePlan.FullRender(600, 500));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -82,8 +82,8 @@ namespace QuestPDF.UnitTests
|
|||
ScaleY = -3
|
||||
})
|
||||
.MeasureElement(new Size(800, 600))
|
||||
.ExpectChildMeasure(new Size(800, 200), new FullRender(800, 100))
|
||||
.CheckMeasureResult(new FullRender(800, 300));
|
||||
.ExpectChildMeasure(new Size(800, 200), SpacePlan.FullRender(800, 100))
|
||||
.CheckMeasureResult(SpacePlan.FullRender(800, 300));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework;
|
||||
using QuestPDF.Drawing;
|
||||
using QuestPDF.Elements;
|
||||
using QuestPDF.Infrastructure;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using NUnit.Framework;
|
||||
using QuestPDF.Drawing.SpacePlan;
|
||||
using QuestPDF.Drawing;
|
||||
using QuestPDF.Elements;
|
||||
using QuestPDF.Infrastructure;
|
||||
using QuestPDF.UnitTests.TestEngine;
|
||||
|
@ -21,8 +21,8 @@ namespace QuestPDF.UnitTests
|
|||
TurnCount = 0
|
||||
})
|
||||
.MeasureElement(new Size(400, 300))
|
||||
.ExpectChildMeasure(new Size(400, 300), new Wrap())
|
||||
.CheckMeasureResult(new Wrap());
|
||||
.ExpectChildMeasure(new Size(400, 300), SpacePlan.Wrap())
|
||||
.CheckMeasureResult(SpacePlan.Wrap());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -35,8 +35,8 @@ namespace QuestPDF.UnitTests
|
|||
TurnCount = 0
|
||||
})
|
||||
.MeasureElement(new Size(400, 300))
|
||||
.ExpectChildMeasure(new Size(400, 300), new PartialRender(300, 200))
|
||||
.CheckMeasureResult(new PartialRender(300, 200));
|
||||
.ExpectChildMeasure(new Size(400, 300), SpacePlan.PartialRender(300, 200))
|
||||
.CheckMeasureResult(SpacePlan.PartialRender(300, 200));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -49,8 +49,8 @@ namespace QuestPDF.UnitTests
|
|||
TurnCount = 1
|
||||
})
|
||||
.MeasureElement(new Size(400, 300))
|
||||
.ExpectChildMeasure(new Size(300, 400), new FullRender(200, 300))
|
||||
.CheckMeasureResult(new FullRender(300, 200));
|
||||
.ExpectChildMeasure(new Size(300, 400), SpacePlan.FullRender(200, 300))
|
||||
.CheckMeasureResult(SpacePlan.FullRender(300, 200));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -63,8 +63,8 @@ namespace QuestPDF.UnitTests
|
|||
TurnCount = 2
|
||||
})
|
||||
.MeasureElement(new Size(400, 300))
|
||||
.ExpectChildMeasure(new Size(400, 300), new FullRender(200, 100))
|
||||
.CheckMeasureResult(new FullRender(200, 100));
|
||||
.ExpectChildMeasure(new Size(400, 300), SpacePlan.FullRender(200, 100))
|
||||
.CheckMeasureResult(SpacePlan.FullRender(200, 100));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -77,8 +77,8 @@ namespace QuestPDF.UnitTests
|
|||
TurnCount = 3 // or -1
|
||||
})
|
||||
.MeasureElement(new Size(500, 400))
|
||||
.ExpectChildMeasure(new Size(400, 500), new FullRender(300, 350))
|
||||
.CheckMeasureResult(new FullRender(350, 300));
|
||||
.ExpectChildMeasure(new Size(400, 500), SpacePlan.FullRender(300, 350))
|
||||
.CheckMeasureResult(SpacePlan.FullRender(350, 300));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using NUnit.Framework;
|
||||
using QuestPDF.Drawing;
|
||||
using QuestPDF.Elements;
|
||||
using QuestPDF.Fluent;
|
||||
using QuestPDF.Infrastructure;
|
||||
using QuestPDF.UnitTests.TestEngine;
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@ using QuestPDF.Infrastructure;
|
|||
|
||||
namespace QuestPDF.UnitTests.TestEngine.Operations
|
||||
{
|
||||
internal class ChildMeasureOperationBase : OperationBase
|
||||
internal class ChildMeasureOperation : OperationBase
|
||||
{
|
||||
public string ChildId { get; }
|
||||
public Size Input { get; }
|
||||
public SpacePlan Output { get; }
|
||||
|
||||
public ChildMeasureOperationBase(string childId, Size input, SpacePlan output)
|
||||
public ChildMeasureOperation(string childId, Size input, SpacePlan output)
|
||||
{
|
||||
ChildId = childId;
|
||||
Input = input;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using QuestPDF.Drawing.SpacePlan;
|
||||
using QuestPDF.Elements;
|
||||
using QuestPDF.Drawing;
|
||||
using QuestPDF.Infrastructure;
|
||||
|
||||
namespace QuestPDF.UnitTests.TestEngine
|
||||
|
@ -23,8 +22,8 @@ namespace QuestPDF.UnitTests.TestEngine
|
|||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(400, 300))
|
||||
.ExpectChildMeasure(new Size(400, 300), new Wrap())
|
||||
.CheckMeasureResult(new Wrap());
|
||||
.ExpectChildMeasure(new Size(400, 300), SpacePlan.Wrap())
|
||||
.CheckMeasureResult(SpacePlan.Wrap());
|
||||
}
|
||||
|
||||
private static void Measure_PartialRender<TElement>() where TElement : Element, IContainer, new()
|
||||
|
@ -35,8 +34,8 @@ namespace QuestPDF.UnitTests.TestEngine
|
|||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(400, 300))
|
||||
.ExpectChildMeasure(new Size(400, 300), new PartialRender(200, 100))
|
||||
.CheckMeasureResult(new PartialRender(200, 100));
|
||||
.ExpectChildMeasure(new Size(400, 300), SpacePlan.PartialRender(200, 100))
|
||||
.CheckMeasureResult(SpacePlan.PartialRender(200, 100));
|
||||
}
|
||||
|
||||
private static void Measure_FullRender<TElement>() where TElement : Element, IContainer, new()
|
||||
|
@ -47,8 +46,8 @@ namespace QuestPDF.UnitTests.TestEngine
|
|||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(400, 300))
|
||||
.ExpectChildMeasure(new Size(400, 300), new FullRender(250, 150))
|
||||
.CheckMeasureResult(new FullRender(250, 150));
|
||||
.ExpectChildMeasure(new Size(400, 300), SpacePlan.FullRender(250, 150))
|
||||
.CheckMeasureResult(SpacePlan.FullRender(250, 150));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -6,6 +6,8 @@ using NUnit.Framework;
|
|||
using QuestPDF.Drawing;
|
||||
using QuestPDF.Elements;
|
||||
using QuestPDF.Helpers;
|
||||
using QuestPDF.Infrastructure;
|
||||
using QuestPDF.UnitTests.TestEngine.Operations;
|
||||
|
||||
namespace QuestPDF.UnitTests.TestEngine
|
||||
{
|
||||
|
@ -270,10 +272,10 @@ namespace QuestPDF.UnitTests.TestEngine
|
|||
|
||||
var canvas = new FreeCanvas();
|
||||
value.HandleVisitor(x => x.Initialize(null, canvas));
|
||||
var valueMeasure = value.Measure(availableSpace);
|
||||
var valueMeasure = value.Measure(availableSpace.Value);
|
||||
|
||||
expected.HandleVisitor(x => x.Initialize(null, canvas));
|
||||
var expectedMeasure = expected.Measure(availableSpace);
|
||||
var expectedMeasure = expected.Measure(availableSpace.Value);
|
||||
|
||||
valueMeasure.Should().BeEquivalentTo(expectedMeasure);
|
||||
}
|
||||
|
@ -284,11 +286,11 @@ namespace QuestPDF.UnitTests.TestEngine
|
|||
|
||||
var valueCanvas = new OperationRecordingCanvas();
|
||||
value.HandleVisitor(x => x.Initialize(null, valueCanvas));
|
||||
value.Draw(availableSpace);
|
||||
value.Draw(availableSpace.Value);
|
||||
|
||||
var expectedCanvas = new OperationRecordingCanvas();
|
||||
expected.HandleVisitor(x => x.Initialize(null, expectedCanvas));
|
||||
expected.Draw(availableSpace);
|
||||
expected.Draw(availableSpace.Value);
|
||||
|
||||
valueCanvas.Operations.Should().BeEquivalentTo(expectedCanvas.Operations);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using NUnit.Framework;
|
||||
using QuestPDF.Drawing.SpacePlan;
|
||||
using QuestPDF.Elements;
|
||||
using QuestPDF.Infrastructure;
|
||||
using QuestPDF.UnitTests.TestEngine;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using NUnit.Framework;
|
||||
using QuestPDF.Drawing.SpacePlan;
|
||||
using QuestPDF.Drawing;
|
||||
using QuestPDF.Elements;
|
||||
using QuestPDF.Infrastructure;
|
||||
using QuestPDF.UnitTests.TestEngine;
|
||||
|
@ -20,8 +20,8 @@ namespace QuestPDF.UnitTests
|
|||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(900, 800))
|
||||
.ExpectChildMeasure(Size.Max, new Wrap())
|
||||
.CheckMeasureResult(new Wrap());
|
||||
.ExpectChildMeasure(Size.Max, SpacePlan.Wrap())
|
||||
.CheckMeasureResult(SpacePlan.Wrap());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -33,8 +33,8 @@ namespace QuestPDF.UnitTests
|
|||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(900, 800))
|
||||
.ExpectChildMeasure(Size.Max, new PartialRender(1200, 1600))
|
||||
.CheckMeasureResult(new PartialRender(Size.Zero));
|
||||
.ExpectChildMeasure(Size.Max, SpacePlan.PartialRender(1200, 1600))
|
||||
.CheckMeasureResult(SpacePlan.PartialRender(Size.Zero));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -46,8 +46,8 @@ namespace QuestPDF.UnitTests
|
|||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(900, 800))
|
||||
.ExpectChildMeasure(Size.Max, new FullRender(1200, 1600))
|
||||
.CheckMeasureResult(new FullRender(Size.Zero));
|
||||
.ExpectChildMeasure(Size.Max, SpacePlan.FullRender(1200, 1600))
|
||||
.CheckMeasureResult(SpacePlan.FullRender(Size.Zero));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -63,7 +63,7 @@ namespace QuestPDF.UnitTests
|
|||
Child = x.CreateChild()
|
||||
})
|
||||
.DrawElement(new Size(900, 800))
|
||||
.ExpectChildMeasure(Size.Max, new Wrap())
|
||||
.ExpectChildMeasure(Size.Max, SpacePlan.Wrap())
|
||||
.CheckDrawResult();
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ namespace QuestPDF.UnitTests
|
|||
Child = x.CreateChild()
|
||||
})
|
||||
.DrawElement(new Size(900, 800))
|
||||
.ExpectChildMeasure(Size.Max, new PartialRender(1200, 1600))
|
||||
.ExpectChildMeasure(Size.Max, SpacePlan.PartialRender(1200, 1600))
|
||||
.ExpectChildDraw(new Size(1200, 1600))
|
||||
.CheckDrawResult();
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ namespace QuestPDF.UnitTests
|
|||
Child = x.CreateChild()
|
||||
})
|
||||
.DrawElement(new Size(900, 800))
|
||||
.ExpectChildMeasure(Size.Max, new FullRender(1600, 1000))
|
||||
.ExpectChildMeasure(Size.Max, SpacePlan.FullRender(1600, 1000))
|
||||
.ExpectChildDraw(new Size(1600, 1000))
|
||||
.CheckDrawResult();
|
||||
}
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
namespace QuestPDF.Drawing.SpacePlan
|
||||
{
|
||||
internal class TextRender : FullRender
|
||||
{
|
||||
public float Ascent { get; set; }
|
||||
public float Descent { get; set; }
|
||||
|
||||
public TextRender(float width, float height) : base(width, height)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuestPDF.Drawing;
|
||||
using QuestPDF.Infrastructure;
|
||||
|
||||
namespace QuestPDF.Elements
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using QuestPDF.Drawing.SpacePlan;
|
||||
using QuestPDF.Drawing;
|
||||
using QuestPDF.Elements.Text.Calculation;
|
||||
using QuestPDF.Infrastructure;
|
||||
|
||||
|
@ -15,16 +15,14 @@ namespace QuestPDF.Elements.Text.Items
|
|||
|
||||
var measurement = Element.Measure(new Size(request.AvailableWidth, Size.Max.Height));
|
||||
|
||||
if (measurement is Wrap || measurement is PartialRender)
|
||||
if (measurement.Type != SpacePlanType.FullRender)
|
||||
return null;
|
||||
|
||||
var elementSize = measurement as Size;
|
||||
|
||||
return new TextMeasurementResult
|
||||
{
|
||||
Width = elementSize.Width,
|
||||
Width = measurement.Width,
|
||||
|
||||
Ascent = -elementSize.Height,
|
||||
Ascent = -measurement.Height,
|
||||
Descent = 0,
|
||||
|
||||
LineHeight = 1,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using QuestPDF.Drawing.SpacePlan;
|
||||
using QuestPDF.Drawing;
|
||||
using QuestPDF.Elements.Text.Calculation;
|
||||
using QuestPDF.Elements.Text.Items;
|
||||
using QuestPDF.Infrastructure;
|
||||
|
@ -22,21 +22,21 @@ namespace QuestPDF.Elements.Text
|
|||
CurrentElementIndex = 0;
|
||||
}
|
||||
|
||||
internal override ISpacePlan Measure(Size availableSpace)
|
||||
internal override SpacePlan Measure(Size availableSpace)
|
||||
{
|
||||
if (!RenderingQueue.Any())
|
||||
return new FullRender(Size.Zero);
|
||||
return SpacePlan.FullRender(Size.Zero);
|
||||
|
||||
var lines = DivideTextItemsIntoLines(availableSpace.Width, availableSpace.Height).ToList();
|
||||
|
||||
if (!lines.Any())
|
||||
return new PartialRender(Size.Zero);
|
||||
return SpacePlan.PartialRender(Size.Zero);
|
||||
|
||||
var width = lines.Max(x => x.Width);
|
||||
var height = lines.Sum(x => x.LineHeight);
|
||||
|
||||
if (width > availableSpace.Width + Size.Epsilon || height > availableSpace.Height + Size.Epsilon)
|
||||
return new Wrap();
|
||||
return SpacePlan.Wrap();
|
||||
|
||||
var fullyRenderedItemsCount = lines
|
||||
.SelectMany(x => x.Elements)
|
||||
|
@ -44,9 +44,9 @@ namespace QuestPDF.Elements.Text
|
|||
.Count(x => x.Any(y => y.Measurement.IsLast));
|
||||
|
||||
if (fullyRenderedItemsCount == RenderingQueue.Count)
|
||||
return new FullRender(width, height);
|
||||
return SpacePlan.FullRender(width, height);
|
||||
|
||||
return new PartialRender(width, height);
|
||||
return SpacePlan.PartialRender(width, height);
|
||||
}
|
||||
|
||||
internal override void Draw(Size availableSpace)
|
||||
|
|
Загрузка…
Ссылка в новой задаче