LayoutManagerTests.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (c) The Avalonia Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using Avalonia.Controls;
  4. using Xunit;
  5. namespace Avalonia.Layout.UnitTests
  6. {
  7. public class LayoutManagerTests
  8. {
  9. [Fact]
  10. public void Invalidating_Child_Should_Remeasure_Parent()
  11. {
  12. var layoutManager = new LayoutManager();
  13. using (AvaloniaLocator.EnterScope())
  14. {
  15. AvaloniaLocator.CurrentMutable.Bind<ILayoutManager>().ToConstant(layoutManager);
  16. Border border;
  17. StackPanel panel;
  18. var root = new TestLayoutRoot
  19. {
  20. Child = panel = new StackPanel
  21. {
  22. Children = new Controls.Controls
  23. {
  24. (border = new Border())
  25. }
  26. }
  27. };
  28. layoutManager.ExecuteInitialLayoutPass(root);
  29. Assert.Equal(new Size(0, 0), root.DesiredSize);
  30. border.Width = 100;
  31. border.Height = 100;
  32. layoutManager.ExecuteLayoutPass();
  33. Assert.Equal(new Size(100, 100), panel.DesiredSize);
  34. }
  35. }
  36. }
  37. }