LayoutTests.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using Xunit.Abstractions;
  2. namespace Terminal.Gui.LayoutTests;
  3. public class LayoutTests (ITestOutputHelper _output) : TestsAllViews
  4. {
  5. [Theory]
  6. [MemberData (nameof (AllViewTypes))]
  7. public void AllViews_Layout_Does_Not_Draw (Type viewType)
  8. {
  9. var view = (View)CreateInstanceIfNotGeneric (viewType);
  10. if (view == null)
  11. {
  12. _output.WriteLine ($"Ignoring {viewType} - It's a Generic");
  13. return;
  14. }
  15. if (view is IDesignable designable)
  16. {
  17. designable.EnableForDesign ();
  18. }
  19. var drawContentCount = 0;
  20. view.DrawContent += (s, e) => drawContentCount++;
  21. var layoutStartedCount = 0;
  22. view.LayoutStarted += (s, e) => layoutStartedCount++;
  23. var layoutCompleteCount = 0;
  24. view.LayoutComplete += (s, e) => layoutCompleteCount++;
  25. view.SetLayoutNeeded ();
  26. view.SetNeedsDisplay();
  27. view.Layout ();
  28. Assert.Equal (0, drawContentCount);
  29. Assert.Equal (1, layoutStartedCount);
  30. Assert.Equal (1, layoutCompleteCount);
  31. }
  32. }