mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
* Remove continous press code from Application * WIP prototype code to handle continuous press as subcomponent of View * Prototype with Button * Implement CWP * Move to seperate classes and prevent double entry to Start * Fix repeat clicking when moving mouse by removing phantom click code (old implementation of WantContinuousButtonPressed) * Remove initial tick because it results in double activation e.g. button firing twice immediately as mouse is pressed down. * Refactor DatePicker lamdas * WIP investigate subcomponents instead of statics * Add IMouseGrabHandler to IApplication * Make mouse grabbing non static activity * Make MouseHeldDown suppress when null fields e.g. app not initialized in tests * Update test and remove dependency on Application * Fix other mouse click and hold tests * Code cleanup * Update class diagram * Fix bad xml doc references * Fix timed events not getting passed through in v2 applications * Make timed events nullable for tests that dont create an Application * Remove strange blocking test * WIP remove all idles and replace with zero timeouts * Fix build of tests * Fix unit tests * Add wakeup call back in * Comment out incredibly complicated test and fix others * Fix test * test fix * Make Post execute immediately if already on UI thread * Re enable test and simplify Invoke to just execute if in UI thread (up front) * Remove xml doc references to idles * Remove more references to idles * Make Screen initialization threadsafe * Add more exciting timeouts * WIP add tests * fix log * fix test * make continuous key press use smoth acceleration * Rename _lock to _lockScreen * Remove section on idles, they are not a thing anymore - and they kinda never were. * Add nullable enable * Add xml comment * Fix namings and cleanup code * xmldoc fix * Rename LockAndRunTimers to just RunTimers * Rename AddTimeout and RemoveTimeout (and event) to just Add/Remove * Update description of MainLoop * Commented out Run_T_Call_Init_ForceDriver_Should_Pick_Correct_Driver * Again? Commented out Run_T_Call_Init_ForceDriver_Should_Pick_Correct_Driver * Revert Commented out Run_T_Call_Init_ForceDriver_Should_Pick_Correct_Driver * When mouse is released from MouseHeldDown reset host MouseState * Fix namespaces in class diagram * Apply @BDisp suggested fix * Fix class diagrams * Add lock * Make TimeSpan.Zero definetly run * Fix duplicate entry in package props --------- Co-authored-by: Tig <tig@users.noreply.github.com>
This commit is contained in:
@@ -15,7 +15,7 @@ public class MainLoopDriverTests
|
||||
[InlineData (typeof (WindowsDriver), typeof (WindowsMainLoop))]
|
||||
|
||||
//[InlineData (typeof (ANSIDriver), typeof (AnsiMainLoopDriver))]
|
||||
public void MainLoop_AddIdle_ValidIdleHandler_ReturnsToken (Type driverType, Type mainLoopDriverType)
|
||||
public void MainLoop_AddTimeout_ValidIdleHandler_ReturnsToken (Type driverType, Type mainLoopDriverType)
|
||||
{
|
||||
var driver = (IConsoleDriver)Activator.CreateInstance (driverType);
|
||||
var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
|
||||
@@ -29,7 +29,7 @@ public class MainLoopDriverTests
|
||||
return false;
|
||||
}
|
||||
|
||||
Func<bool> token = mainLoop.AddIdle (IdleHandler);
|
||||
var token = mainLoop.TimedEvents.Add(TimeSpan.Zero, IdleHandler);
|
||||
|
||||
Assert.NotNull (token);
|
||||
Assert.False (idleHandlerInvoked); // Idle handler should not be invoked immediately
|
||||
@@ -52,7 +52,7 @@ public class MainLoopDriverTests
|
||||
var mainLoop = new MainLoop (mainLoopDriver);
|
||||
var callbackInvoked = false;
|
||||
|
||||
object token = mainLoop.TimedEvents.AddTimeout (
|
||||
object token = mainLoop.TimedEvents.Add (
|
||||
TimeSpan.FromMilliseconds (100),
|
||||
() =>
|
||||
{
|
||||
@@ -87,11 +87,11 @@ public class MainLoopDriverTests
|
||||
var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
|
||||
var mainLoop = new MainLoop (mainLoopDriver);
|
||||
|
||||
mainLoop.AddIdle (() => false);
|
||||
bool result = mainLoop.TimedEvents.CheckTimersAndIdleHandlers (out int waitTimeout);
|
||||
mainLoop.TimedEvents.Add (TimeSpan.Zero, () => false);
|
||||
bool result = mainLoop.TimedEvents.CheckTimers (out int waitTimeout);
|
||||
|
||||
Assert.True (result);
|
||||
Assert.Equal (-1, waitTimeout);
|
||||
Assert.Equal (0, waitTimeout);
|
||||
mainLoop.Dispose ();
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class MainLoopDriverTests
|
||||
[InlineData (typeof (WindowsDriver), typeof (WindowsMainLoop))]
|
||||
|
||||
//[InlineData (typeof (ANSIDriver), typeof (AnsiMainLoopDriver))]
|
||||
public void MainLoop_CheckTimersAndIdleHandlers_NoTimersOrIdleHandlers_ReturnsFalse (
|
||||
public void MainLoop_CheckTimers_NoTimersOrIdleHandlers_ReturnsFalse (
|
||||
Type driverType,
|
||||
Type mainLoopDriverType
|
||||
)
|
||||
@@ -111,7 +111,7 @@ public class MainLoopDriverTests
|
||||
var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
|
||||
var mainLoop = new MainLoop (mainLoopDriver);
|
||||
|
||||
bool result = mainLoop.TimedEvents.CheckTimersAndIdleHandlers (out int waitTimeout);
|
||||
bool result = mainLoop.TimedEvents.CheckTimers (out int waitTimeout);
|
||||
|
||||
Assert.False (result);
|
||||
Assert.Equal (-1, waitTimeout);
|
||||
@@ -134,8 +134,8 @@ public class MainLoopDriverTests
|
||||
var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
|
||||
var mainLoop = new MainLoop (mainLoopDriver);
|
||||
|
||||
mainLoop.TimedEvents.AddTimeout (TimeSpan.FromMilliseconds (100), () => false);
|
||||
bool result = mainLoop.TimedEvents.CheckTimersAndIdleHandlers (out int waitTimeout);
|
||||
mainLoop.TimedEvents.Add (TimeSpan.FromMilliseconds (100), () => false);
|
||||
bool result = mainLoop.TimedEvents.CheckTimers(out int waitTimeout);
|
||||
|
||||
Assert.True (result);
|
||||
Assert.True (waitTimeout >= 0);
|
||||
@@ -158,7 +158,6 @@ public class MainLoopDriverTests
|
||||
// Check default values
|
||||
Assert.NotNull (mainLoop);
|
||||
Assert.Equal (mainLoopDriver, mainLoop.MainLoopDriver);
|
||||
Assert.Empty (mainLoop.TimedEvents.IdleHandlers);
|
||||
Assert.Empty (mainLoop.TimedEvents.Timeouts);
|
||||
Assert.False (mainLoop.Running);
|
||||
|
||||
@@ -168,7 +167,6 @@ public class MainLoopDriverTests
|
||||
// TODO: It'd be nice if we could really verify IMainLoopDriver.TearDown was called
|
||||
// and that it was actually cleaned up.
|
||||
Assert.Null (mainLoop.MainLoopDriver);
|
||||
Assert.Empty (mainLoop.TimedEvents.IdleHandlers);
|
||||
Assert.Empty (mainLoop.TimedEvents.Timeouts);
|
||||
Assert.False (mainLoop.Running);
|
||||
}
|
||||
@@ -186,7 +184,7 @@ public class MainLoopDriverTests
|
||||
var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
|
||||
var mainLoop = new MainLoop (mainLoopDriver);
|
||||
|
||||
bool result = mainLoop.TimedEvents.RemoveIdle (() => false);
|
||||
bool result = mainLoop.TimedEvents.Remove("flibble");
|
||||
|
||||
Assert.False (result);
|
||||
mainLoop.Dispose ();
|
||||
@@ -207,8 +205,9 @@ public class MainLoopDriverTests
|
||||
|
||||
bool IdleHandler () { return false; }
|
||||
|
||||
Func<bool> token = mainLoop.AddIdle (IdleHandler);
|
||||
bool result = mainLoop.TimedEvents.RemoveIdle (token);
|
||||
|
||||
var token = mainLoop.TimedEvents.Add (TimeSpan.Zero, IdleHandler);
|
||||
bool result = mainLoop.TimedEvents.Remove (token);
|
||||
|
||||
Assert.True (result);
|
||||
mainLoop.Dispose ();
|
||||
@@ -227,7 +226,7 @@ public class MainLoopDriverTests
|
||||
var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
|
||||
var mainLoop = new MainLoop (mainLoopDriver);
|
||||
|
||||
bool result = mainLoop.TimedEvents.RemoveTimeout (new object ());
|
||||
bool result = mainLoop.TimedEvents.Remove (new object ());
|
||||
|
||||
Assert.False (result);
|
||||
}
|
||||
@@ -245,8 +244,8 @@ public class MainLoopDriverTests
|
||||
var mainLoopDriver = (IMainLoopDriver)Activator.CreateInstance (mainLoopDriverType, driver);
|
||||
var mainLoop = new MainLoop (mainLoopDriver);
|
||||
|
||||
object token = mainLoop.TimedEvents.AddTimeout (TimeSpan.FromMilliseconds (100), () => false);
|
||||
bool result = mainLoop.TimedEvents.RemoveTimeout (token);
|
||||
object token = mainLoop.TimedEvents.Add (TimeSpan.FromMilliseconds (100), () => false);
|
||||
bool result = mainLoop.TimedEvents.Remove (token);
|
||||
|
||||
Assert.True (result);
|
||||
mainLoop.Dispose ();
|
||||
@@ -273,7 +272,7 @@ public class MainLoopDriverTests
|
||||
return false;
|
||||
};
|
||||
|
||||
mainLoop.AddIdle (idleHandler);
|
||||
mainLoop.TimedEvents.Add (TimeSpan.Zero, idleHandler);
|
||||
mainLoop.RunIteration (); // Run an iteration to process the idle handler
|
||||
|
||||
Assert.True (idleHandlerInvoked);
|
||||
|
||||
@@ -401,7 +401,7 @@ public class ApplicationV2Tests
|
||||
|
||||
v2.Init ();
|
||||
|
||||
v2.AddIdle (IdleExit);
|
||||
v2.AddTimeout (TimeSpan.Zero, IdleExit);
|
||||
Assert.Null (Application.Top);
|
||||
|
||||
// Blocks until the timeout call is hit
|
||||
@@ -448,7 +448,7 @@ public class ApplicationV2Tests
|
||||
Assert.Same (t, a.Toplevel);
|
||||
};
|
||||
|
||||
v2.AddIdle (IdleExit);
|
||||
v2.AddTimeout(TimeSpan.Zero, IdleExit);
|
||||
|
||||
// Blocks until the timeout call is hit
|
||||
|
||||
|
||||
Reference in New Issue
Block a user