AllViewsDrawTests.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using Xunit.Abstractions;
  2. namespace Terminal.Gui.LayoutTests;
  3. public class AllViewsDrawTests (ITestOutputHelper _output) : TestsAllViews
  4. {
  5. [Theory]
  6. [MemberData (nameof (AllViewTypes))]
  7. public void AllViews_Draw_Does_Not_Layout (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. _output.WriteLine ($"Testing {viewType}");
  16. if (view is IDesignable designable)
  17. {
  18. designable.EnableForDesign ();
  19. }
  20. var drawCompleteCount = 0;
  21. view.DrawComplete += (s, e) => drawCompleteCount++;
  22. var layoutStartedCount = 0;
  23. view.SubviewLayout += (s, e) => layoutStartedCount++;
  24. var layoutCompleteCount = 0;
  25. view.SubviewsLaidOut += (s, e) => layoutCompleteCount++;
  26. view.SetNeedsLayout ();
  27. view.Layout ();
  28. Assert.Equal (0, drawCompleteCount);
  29. Assert.Equal (1, layoutStartedCount);
  30. Assert.Equal (1, layoutCompleteCount);
  31. view.SetNeedsDraw ();
  32. view.Draw ();
  33. Assert.Equal (1, drawCompleteCount);
  34. Assert.Equal (1, layoutStartedCount);
  35. Assert.Equal (1, layoutCompleteCount);
  36. }
  37. }