From 3a250c86f3a0551a7d6dd122f9593d080c0eb914 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 4 May 2023 14:23:12 +0200 Subject: [PATCH] Added failing test for #7706. --- .../Layout/LayoutManagerTests.cs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/Avalonia.Base.UnitTests/Layout/LayoutManagerTests.cs b/tests/Avalonia.Base.UnitTests/Layout/LayoutManagerTests.cs index 45a6efdd4a5..cadf23c7540 100644 --- a/tests/Avalonia.Base.UnitTests/Layout/LayoutManagerTests.cs +++ b/tests/Avalonia.Base.UnitTests/Layout/LayoutManagerTests.cs @@ -547,5 +547,38 @@ public void Grandparent_Can_Invalidate_Root_Measure_During_Arrange() Assert.True(root.IsMeasureValid); Assert.True(root.IsArrangeValid); } + + [Fact] + public void GreatGrandparent_Can_Invalidate_Grandparent_Measure_During_Arrange() + { + // Issue #7706 (second part: scrollbar gets stuck) + var child = new LayoutTestControl(); + var parent = new LayoutTestControl { Child = child }; + var grandparent = new LayoutTestControl { Child = parent }; + var greatGrandparent = new LayoutTestControl { Child = grandparent }; + var root = new LayoutTestRoot { Child = greatGrandparent }; + + root.LayoutManager.ExecuteInitialLayoutPass(); + + greatGrandparent.DoArrangeOverride = (_, s) => + { + grandparent.InvalidateMeasure(); + return s; + }; + + child.InvalidateArrange(); + greatGrandparent.InvalidateArrange(); + + root.LayoutManager.ExecuteLayoutPass(); + + Assert.True(child.IsMeasureValid); + Assert.True(child.IsArrangeValid); + Assert.True(parent.IsMeasureValid); + Assert.True(parent.IsArrangeValid); + Assert.True(greatGrandparent.IsMeasureValid); + Assert.True(greatGrandparent.IsArrangeValid); + Assert.True(root.IsMeasureValid); + Assert.True(root.IsArrangeValid); + } } }