diff --git a/Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs b/Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs index b824663c4..b08958bd6 100644 --- a/Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs @@ -353,7 +353,7 @@ public class FakeDriver : ConsoleDriver { _keyUpHandler = keyUpHandler; // Note: Net doesn't support keydown/up events and thus any passed keyDown/UpHandlers will never be called - (mainLoop.MainLoopDriver as FakeMainLoop).KeyPressed += (consoleKey) => ProcessInput (consoleKey); + (mainLoop.MainLoopDriver as FakeMainLoop).KeyPressed = (consoleKey) => ProcessInput (consoleKey); } void ProcessInput (ConsoleKeyInfo consoleKey) diff --git a/UnitTests/UICatalog/ScenarioTests.cs b/UnitTests/UICatalog/ScenarioTests.cs index 0569a2757..1edd6ece5 100644 --- a/UnitTests/UICatalog/ScenarioTests.cs +++ b/UnitTests/UICatalog/ScenarioTests.cs @@ -74,16 +74,17 @@ namespace UICatalog.Tests { // BUGBUG: (#2474) For some reason ReadKey is not returning the QuitKey for some Scenarios // by adding this Space it seems to work. // See #2474 for why this is commented out - //Assert.Equal (Application.QuitKey, args.KeyEvent.Key); - args.Handled = false; + Assert.Equal (Application.QuitKey, args.KeyEvent.Key); }; uint abortTime = 500; // If the scenario doesn't close within 500ms, this will force it to quit Func forceCloseCallback = (MainLoop loop) => { - Application.RequestStop (); - // See #2474 for why this is commented out - //Assert.Fail ($"'{scenario.GetName ()}' failed to Quit with {Application.QuitKey} after {abortTime}ms. Force quit."); + if (Application.Top.Running && FakeConsole.MockKeyPresses.Count == 0) { + Application.RequestStop (); + // See #2474 for why this is commented out + Assert.Fail ($"'{scenario.GetName ()}' failed to Quit with {Application.QuitKey} after {abortTime}ms. Force quit."); + } return false; }; //output.WriteLine ($" Add timeout to force quit after {abortTime}ms"); @@ -91,9 +92,9 @@ namespace UICatalog.Tests { Application.Iteration += () => { //output.WriteLine ($" iteration {++iterations}"); - if (FakeConsole.MockKeyPresses.Count == 0) { + if (Application.Top.Running && FakeConsole.MockKeyPresses.Count == 0) { Application.RequestStop (); - //Assert.Fail ($"'{scenario.GetName ()}' failed to Quit with {Application.QuitKey}. Force quit."); + Assert.Fail ($"'{scenario.GetName ()}' failed to Quit with {Application.QuitKey}. Force quit."); } };