Fixes #3930 - Splits tests to Tests/UnitTests, Tests/IntegrationTests, Tests/StressTests (#3954)

* Tons of API doc updates

* Removed stale test

* Removed stale tests

* Fixed Skipped Shadow test 1

* Fixed Skipped Shadow test 2

* Fixed Skipped Shadow test 3

* Removed stale test

* Removed stale test2

* Explicit unregister of event handler on Application.Driver!.ClearedContents

* Added Toplevels to dict

* code cleanup

* spelling error

* Removed stale test3

* Removed stale test4

* Removed stale test5

* added script

* tweaked script

* tweaked script

* Created StressTests project; moved some tests

* Created IntegrationTests project; moved some tests

* New yml

* made old yml just unit tests

* Tweaked Button_IsDefault_Raises_Accepted_Correctly

* tweaked script

* cleaned up ymls

* tweakled up ymls

* stress tests...

* stress tests on ubuntu only

* Fixed WindowsDriver in InvokeLeakTest

* Fixed WindowsDriver in InvokeLeakTest2

* Added Directory.Packages.props.
Added Directory.Build.props

* Shortened StressTest time

* Removed dupe file.

* DemoFiles

* Moved all tests to ./Tests dir.

* Fixed release build issue

* Fixed .sln file

* Fixed .sl* files

* Fixing ymls

* Fixing interation tests

* Create link to the file TestHelpers.

* Created Tests/UnitTestsParallelizable.
Moved all obviously parallelizable tests.
Updated yml.

* fixing logs

* fixing logs2

* fixing logs3

* don't require stress to pass for PRs

* Fix a failure?

* tweaked script

* Coudl this be it?

* Moved tons of tests to parallelizable

* Fixed some stuff

* Script to find duplicate tests

* Testing workflows

* Updated to v4

* Fix RelativeBasePath issue

* Replace powershell to pwsh

* Add ignore projects.

* Removed dupe unit tests

* Code cleanup of tests

* Cleaned up test warnings

* yml tweak

* Moved setter

* tweak ymls

* just randomly throwing spaghetti at a wall

* Enable runing 5 test runners in par

* Turned off DEBUG_DISPOSABLE for par tests

* RunningUnitTests=true

* code cleanup (forcing more Action runs)

* DISABLE_DEBUG_IDISPOSABLE

* Added View.DebugIDisposable. False by default.

* Remobed bogus tareet

* Remobed bogus tareet2

* fixed warning

* added api doc

* fixed warning

* fixed warning

* fixed warning2

* fixed warning3

* fixed warning4

---------

Co-authored-by: BDisp <bd.bdisp@gmail.com>
This commit is contained in:
Tig
2025-03-05 23:44:27 -07:00
committed by GitHub
parent 64b216b1e8
commit b0f32811eb
303 changed files with 11531 additions and 11883 deletions

View File

@@ -0,0 +1,195 @@
using UnitTests;
using Xunit.Abstractions;
namespace Terminal.Gui.ViewsTests;
public class StatusBarTests
{
[Fact]
public void AddItemAt_RemoveItem_Replacing ()
{
var sb = new StatusBar ([
new (Key.O.WithCtrl, "Open", null),
new (Key.S.WithCtrl, "Save", null),
new (Key.Q.WithCtrl, "Quit", null)
]
);
sb.AddShortcutAt (2, new (Key.C.WithCtrl, "Close", null));
Assert.Equal ("Open", sb.Subviews [0].Title);
Assert.Equal ("Save", sb.Subviews [1].Title);
Assert.Equal ("Close", sb.Subviews [2].Title);
Assert.Equal ("Quit", sb.Subviews [^1].Title);
Assert.Equal ("Save", sb.RemoveShortcut (1).Title);
Assert.Equal ("Open", sb.Subviews [0].Title);
Assert.Equal ("Close", sb.Subviews [1].Title);
Assert.Equal ("Quit", sb.Subviews [^1].Title);
sb.AddShortcutAt (1, new Shortcut (Key.A.WithCtrl, "Save As", null));
Assert.Equal ("Open", sb.Subviews [0].Title);
Assert.Equal ("Save As", sb.Subviews [1].Title);
Assert.Equal ("Quit", sb.Subviews [^1].Title);
}
//[Fact]
//[AutoInitShutdown]
//public void CanExecute_ProcessHotKey ()
//{
// Window win = null;
// var statusBar = new StatusBar (
// new Shortcut []
// {
// new (
// KeyCode.CtrlMask | KeyCode.N,
// "~^N~ New",
// New,
// CanExecuteNew
// ),
// new (
// KeyCode.CtrlMask | KeyCode.C,
// "~^C~ Close",
// Close,
// CanExecuteClose
// )
// }
// );
// Toplevel top = new ();
// top.Add (statusBar);
// bool CanExecuteNew () { return win == null; }
// void New () { win = new (); }
// bool CanExecuteClose () { return win != null; }
// void Close () { win = null; }
// Application.Begin (top);
// Assert.Null (win);
// Assert.True (CanExecuteNew ());
// Assert.False (CanExecuteClose ());
// Assert.True (top.NewKeyDownEvent (Key.N.WithCtrl));
// Application.MainLoop.RunIteration ();
// Assert.NotNull (win);
// Assert.False (CanExecuteNew ());
// Assert.True (CanExecuteClose ());
// top.Dispose ();
//}
[Fact]
[AutoInitShutdown]
public void Run_Action_With_Key_And_Mouse ()
{
var msg = "";
var sb = new StatusBar (
new Shortcut []
{
new (
Application.QuitKey,
$"Quit",
() => msg = "Quiting..."
)
}
);
var iteration = 0;
Application.Iteration += (s, a) =>
{
if (iteration == 0)
{
Assert.Equal ("", msg);
Application.RaiseKeyDownEvent (Application.QuitKey);
}
else if (iteration == 1)
{
Assert.Equal ("Quiting...", msg);
msg = "";
sb.NewMouseEvent (new () { Position = new (0, 0), Flags = MouseFlags.Button1Clicked });
}
else
{
Assert.Equal ("Quiting...", msg);
Application.RequestStop ();
}
iteration++;
};
Application.Run ().Dispose ();
}
[Fact]
public void StatusBar_Constructor_Default ()
{
var sb = new StatusBar ();
Assert.Empty (sb.Subviews);
Assert.True (sb.CanFocus);
Assert.Equal (Colors.ColorSchemes ["Menu"], sb.ColorScheme);
Assert.Equal (0, sb.X);
Assert.Equal ("AnchorEnd", sb.Y.ToString ());
Assert.Equal (Dim.Fill (), sb.Width);
sb.Layout ();
Assert.Equal (1, sb.Frame.Height);
}
//[Fact]
//public void RemoveAndThenAddStatusBar_ShouldNotChangeWidth ()
//{
// StatusBar statusBar;
// StatusBar statusBar2;
// var w = new Window ();
// statusBar2 = new StatusBar () { Id = "statusBar2" };
// statusBar = new StatusBar () { Id = "statusBar" };
// w.Width = Dim.Fill (0);
// w.Height = Dim.Fill (0);
// w.X = 0;
// w.Y = 0;
// w.Visible = true;
// w.Modal = false;
// w.Title = "";
// statusBar.Width = Dim.Fill (0);
// statusBar.Height = 1;
// statusBar.X = 0;
// statusBar.Y = 0;
// statusBar.Visible = true;
// w.Add (statusBar);
// Assert.Equal (w.StatusBar, statusBar);
// statusBar2.Width = Dim.Fill (0);
// statusBar2.Height = 1;
// statusBar2.X = 0;
// statusBar2.Y = 4;
// statusBar2.Visible = true;
// w.Add (statusBar2);
// Assert.Equal (w.StatusBar, statusBar2);
// var menuBars = w.Subviews.OfType<StatusBar> ().ToArray ();
// Assert.Equal (2, menuBars.Length);
// Assert.Equal (Dim.Fill (0), menuBars [0].Width);
// Assert.Equal (Dim.Fill (0), menuBars [1].Width);
// // Goes wrong here
// w.Remove (statusBar);
// w.Remove (statusBar2);
// w.Add (statusBar);
// w.Add (statusBar2);
// // These assertions fail
// Assert.Equal (Dim.Fill (0), menuBars [0].Width);
// Assert.Equal (Dim.Fill (0), menuBars [1].Width);
//}
}