|
|
|
@ -341,5 +341,38 @@ namespace Avalonia.Layout.UnitTests |
|
|
|
//layoutmanager should process properly other visuals
|
|
|
|
Assert.All(targets, c => Assert.True(c.Arranged)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void LayoutManager_Should_Recover_From_Infinite_Loop_On_Measure() |
|
|
|
{ |
|
|
|
// Test for issue #3041.
|
|
|
|
var control = new LayoutTestControl(); |
|
|
|
var root = new LayoutTestRoot { Child = control }; |
|
|
|
|
|
|
|
root.LayoutManager.ExecuteInitialLayoutPass(root); |
|
|
|
control.Measured = false; |
|
|
|
|
|
|
|
control.DoMeasureOverride = (l, s) => |
|
|
|
{ |
|
|
|
control.InvalidateMeasure(); |
|
|
|
return new Size(100, 100); |
|
|
|
}; |
|
|
|
|
|
|
|
control.InvalidateMeasure(); |
|
|
|
root.LayoutManager.ExecuteLayoutPass(); |
|
|
|
|
|
|
|
// This is the important part: running a second layout pass in which we exceed the maximum
|
|
|
|
// retries causes LayoutQueue<T>.Info.Count to exceed _maxEnqueueCountPerLoop.
|
|
|
|
root.LayoutManager.ExecuteLayoutPass(); |
|
|
|
|
|
|
|
control.Measured = false; |
|
|
|
control.DoMeasureOverride = null; |
|
|
|
|
|
|
|
root.LayoutManager.ExecuteLayoutPass(); |
|
|
|
|
|
|
|
Assert.True(control.Measured); |
|
|
|
Assert.True(control.IsMeasureValid); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|