csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.5 KiB
46 lines
1.5 KiB
// Copyright (c) The Perspex Project. All rights reserved.
|
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|
|
|
using Perspex.Controls;
|
|
using Xunit;
|
|
|
|
namespace Perspex.Layout.UnitTests
|
|
{
|
|
public class ArrangeTests
|
|
{
|
|
[Fact]
|
|
public void Arrange_With_IsMeasureValid_False_Calls_Measure()
|
|
{
|
|
var target = new TestControl();
|
|
|
|
Assert.False(target.IsMeasureValid);
|
|
target.Arrange(new Rect(0, 0, 120, 120));
|
|
Assert.True(target.IsMeasureValid);
|
|
Assert.Equal(new Size(120, 120), target.MeasureConstraint);
|
|
}
|
|
|
|
[Fact]
|
|
public void Arrange_With_IsMeasureValid_False_Calls_Measure_With_Previous_Size_If_Available()
|
|
{
|
|
var target = new TestControl();
|
|
|
|
Assert.False(target.IsMeasureValid);
|
|
target.Arrange(new Rect(0, 0, 120, 120));
|
|
target.InvalidateMeasure();
|
|
target.Arrange(new Rect(0, 0, 100, 100));
|
|
Assert.True(target.IsMeasureValid);
|
|
Assert.Equal(new Size(120, 120), target.MeasureConstraint);
|
|
}
|
|
|
|
private class TestControl : Border
|
|
{
|
|
public Size MeasureConstraint { get; private set; }
|
|
|
|
protected override Size MeasureOverride(Size constraint)
|
|
{
|
|
MeasureConstraint = constraint;
|
|
return base.MeasureOverride(constraint);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|