Skip to content

Commit

Permalink
Ignore Shortcut, Bar and MenuBarv2 for now as they are unstable
Browse files Browse the repository at this point in the history
  • Loading branch information
tznind committed Aug 17, 2024
1 parent a6593e8 commit 9930ec4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/ViewFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,15 @@ public static class ViewFactory

// TODO: Requires tests and comprehensive testing, also its generic so that's more complicated
typeof(NumericUpDown),
typeof(NumericUpDown<>)
typeof(NumericUpDown<>),

// Ignore menu bar v2 for now
typeof(MenuBarv2),

// This is unstable when added directly as a view see https://github.com/gui-cs/Terminal.Gui/issues/3664
typeof(Shortcut),
typeof(Bar)

];

/// <summary>
Expand Down
28 changes: 27 additions & 1 deletion tests/ViewFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ public void Create_And_CreateT_ReturnEquivalentInstancesForSameInputs<T>( T dumm
{
foreach ( PropertyInfo property in publicPropertiesOfType )
{
// The purpose of this test is to confirm that generic and typeof(x) ViewFactory create methods create identical Views (in terms of properties).
// The following properties do not support equality well and are safe to assume get the same values regardless of which ViewFactory route creates them
if (property.PropertyType == typeof(KeyBindings))
{
continue;
}
if (property.PropertyType == typeof(SliderStyle))
{
continue;
}
switch ( dummyInvalidObject, property )
{
case (ComboBox, { Name: "Subviews" }):
Expand Down Expand Up @@ -128,6 +139,11 @@ public void Create_And_CreateT_ReturnEquivalentInstancesForSameInputs<T>( T dumm
continue;
}
if (nonGenericPropertyValue is KeyBindings)
{
continue;
}
Assert.That( (Dim)nonGenericPropertyValue!, Is.EqualTo( (Dim)genericPropertyValue! ) );
continue;
case (_, not null) when property.PropertyType.IsAssignableTo( typeof( TextFormatter ) ):
Expand All @@ -146,6 +162,9 @@ public void Create_And_CreateT_ReturnEquivalentInstancesForSameInputs<T>( T dumm
case (_, not null) when property.PropertyType.IsAssignableTo(typeof(Adornment)):
Assert.That(((Adornment)nonGenericPropertyValue!).ToString(), Is.EqualTo(((Adornment)genericPropertyValue!).ToString()));
continue;
case (_, not null) when property.PropertyType.IsAssignableTo(typeof(Shortcut)):
Assert.That(((Shortcut)nonGenericPropertyValue!).Key, Is.EqualTo(((Shortcut)genericPropertyValue!).Key));
continue;
}
Assert.That(
Expand Down Expand Up @@ -286,7 +305,14 @@ private static Type[] KnownUnsupportedTypes_ExpectedTypes( )
typeof( OpenDialog ),
typeof( ScrollBarView ),
typeof( Wizard ),
typeof( WizardStep )
typeof( WizardStep ),


typeof(NumericUpDown),
typeof(NumericUpDown<>),
typeof( MenuBarv2 ),
typeof( Bar ),
typeof( Shortcut )
};
}
}

0 comments on commit 9930ec4

Please sign in to comment.