mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Trying fixing #518. Almost functions work on both Windows and Unix with the NetDriver.
This commit is contained in:
@@ -28,7 +28,7 @@ namespace Terminal.Gui {
|
||||
Assert.Null (Application.MainLoop);
|
||||
Assert.Null (Application.Driver);
|
||||
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Assert.NotNull (Application.Current);
|
||||
Assert.NotNull (Application.CurrentView);
|
||||
Assert.NotNull (Application.Top);
|
||||
@@ -66,7 +66,7 @@ namespace Terminal.Gui {
|
||||
|
||||
void Init ()
|
||||
{
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey(true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Assert.NotNull (Application.Driver);
|
||||
Assert.NotNull (Application.MainLoop);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Terminal.Gui {
|
||||
public void Init_Inits ()
|
||||
{
|
||||
var driver = new FakeDriver ();
|
||||
Application.Init (driver, new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (driver, new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
driver.Init (() => { });
|
||||
|
||||
Assert.Equal (80, Console.BufferWidth);
|
||||
@@ -27,7 +27,7 @@ namespace Terminal.Gui {
|
||||
public void End_Cleans_Up ()
|
||||
{
|
||||
var driver = new FakeDriver ();
|
||||
Application.Init (driver, new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (driver, new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
driver.Init (() => { });
|
||||
|
||||
FakeConsole.ForegroundColor = ConsoleColor.Red;
|
||||
@@ -50,7 +50,7 @@ namespace Terminal.Gui {
|
||||
public void SetColors_Changes_Colors ()
|
||||
{
|
||||
var driver = new FakeDriver ();
|
||||
Application.Init (driver, new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (driver, new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
driver.Init (() => { });
|
||||
Assert.Equal (ConsoleColor.Gray, Console.ForegroundColor);
|
||||
Assert.Equal (ConsoleColor.Black, Console.BackgroundColor);
|
||||
|
||||
@@ -247,7 +247,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void Dim_Validation_Throws_If_NewValue_Is_DimAbsolute_And_OldValue_Is_Another_Type ()
|
||||
{
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var t = Application.Top;
|
||||
|
||||
@@ -279,7 +279,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void Dim_Validation_Do_Not_Throws_If_NewValue_Is_DimAbsolute_And_OldValue_Is_Null ()
|
||||
{
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var t = Application.Top;
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void Dim_Validation_Do_Not_Throws_If_NewValue_Is_DimAbsolute_And_OldValue_Is_Another_Type_After_Sets_To_LayoutStyle_Absolute ()
|
||||
{
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var t = Application.Top;
|
||||
|
||||
@@ -333,7 +333,7 @@ namespace Terminal.Gui {
|
||||
{
|
||||
// Testing with the Button because it properly handles the Dim class.
|
||||
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var t = Application.Top;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void Constructor_Setups_Driver ()
|
||||
{
|
||||
var ml = new MainLoop (new NetMainLoop(() => FakeConsole.ReadKey (true)));
|
||||
var ml = new MainLoop (new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Assert.NotNull (ml.Driver);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void AddIdle_Adds_And_Removes ()
|
||||
{
|
||||
var ml = new MainLoop (new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ml = new MainLoop (new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
Func<bool> fnTrue = () => { return true; };
|
||||
Func<bool> fnFalse = () => { return false; };
|
||||
@@ -60,7 +60,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void AddIdle_Function_GetsCalled_OnIteration ()
|
||||
{
|
||||
var ml = new MainLoop (new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ml = new MainLoop (new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var functionCalled = 0;
|
||||
Func<bool> fn = () => {
|
||||
@@ -76,7 +76,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void RemoveIdle_Function_NotCalled ()
|
||||
{
|
||||
var ml = new MainLoop (new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ml = new MainLoop (new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var functionCalled = 0;
|
||||
Func<bool> fn = () => {
|
||||
@@ -93,7 +93,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void AddThenRemoveIdle_Function_NotCalled ()
|
||||
{
|
||||
var ml = new MainLoop (new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ml = new MainLoop (new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var functionCalled = 0;
|
||||
Func<bool> fn = () => {
|
||||
@@ -111,7 +111,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void AddTwice_Function_CalledTwice ()
|
||||
{
|
||||
var ml = new MainLoop (new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ml = new MainLoop (new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var functionCalled = 0;
|
||||
Func<bool> fn = () => {
|
||||
@@ -139,7 +139,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void False_Idle_Stops_It_Being_Called_Again ()
|
||||
{
|
||||
var ml = new MainLoop (new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ml = new MainLoop (new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var functionCalled = 0;
|
||||
Func<bool> fn1 = () => {
|
||||
@@ -172,7 +172,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void AddIdle_Twice_Returns_False_Called_Twice ()
|
||||
{
|
||||
var ml = new MainLoop (new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ml = new MainLoop (new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var functionCalled = 0;
|
||||
Func<bool> fn1 = () => {
|
||||
@@ -204,7 +204,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void Run_Runs_Idle_Stop_Stops_Idle ()
|
||||
{
|
||||
var ml = new MainLoop (new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ml = new MainLoop (new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var functionCalled = 0;
|
||||
Func<bool> fn = () => {
|
||||
@@ -226,7 +226,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void AddTimer_Adds_Removes_NoFaults ()
|
||||
{
|
||||
var ml = new MainLoop (new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ml = new MainLoop (new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ms = 100;
|
||||
|
||||
var callbackCount = 0;
|
||||
@@ -246,7 +246,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void AddTimer_Run_Called ()
|
||||
{
|
||||
var ml = new MainLoop (new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ml = new MainLoop (new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ms = 100;
|
||||
|
||||
var callbackCount = 0;
|
||||
@@ -274,7 +274,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void AddTimer_Run_CalledAtApproximatelyRightTime ()
|
||||
{
|
||||
var ml = new MainLoop (new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ml = new MainLoop (new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ms = TimeSpan.FromMilliseconds (50);
|
||||
var watch = new System.Diagnostics.Stopwatch ();
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void AddTimer_Run_CalledTwiceApproximatelyRightTime ()
|
||||
{
|
||||
var ml = new MainLoop (new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ml = new MainLoop (new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ms = TimeSpan.FromMilliseconds (50);
|
||||
var watch = new System.Diagnostics.Stopwatch ();
|
||||
|
||||
@@ -328,7 +328,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void AddTimer_Remove_NotCalled ()
|
||||
{
|
||||
var ml = new MainLoop (new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ml = new MainLoop (new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ms = TimeSpan.FromMilliseconds (50);
|
||||
|
||||
// Force stop if 10 iterations
|
||||
@@ -357,7 +357,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void AddTimer_ReturnFalse_StopsBeingCalled ()
|
||||
{
|
||||
var ml = new MainLoop (new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ml = new MainLoop (new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ms = TimeSpan.FromMilliseconds (50);
|
||||
|
||||
// Force stop if 10 iterations
|
||||
@@ -390,7 +390,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void Invoke_Adds_Idle ()
|
||||
{
|
||||
var ml = new MainLoop (new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
var ml = new MainLoop (new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var actionCalled = 0;
|
||||
ml.Invoke (() => { actionCalled++; });
|
||||
|
||||
@@ -262,7 +262,7 @@ namespace Terminal.Gui {
|
||||
// Setup Fake driver
|
||||
(Window win, Button button) setup ()
|
||||
{
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Iteration = () => {
|
||||
Application.RequestStop ();
|
||||
};
|
||||
@@ -374,7 +374,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void Pos_Validation_Throws_If_NewValue_Is_PosAbsolute_And_OldValue_Is_Another_Type ()
|
||||
{
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var t = Application.Top;
|
||||
|
||||
@@ -406,7 +406,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void Pos_Validation_Do_Not_Throws_If_NewValue_Is_PosAbsolute_And_OldValue_Is_Null ()
|
||||
{
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var t = Application.Top;
|
||||
|
||||
@@ -428,7 +428,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void Pos_Validation_Do_Not_Throws_If_NewValue_Is_PosAbsolute_And_OldValue_Is_Another_Type_After_Sets_To_LayoutStyle_Absolute ()
|
||||
{
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var t = Application.Top;
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Terminal.Gui {
|
||||
Application.RequestStop ();
|
||||
}
|
||||
};
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var ms = 1000;
|
||||
var abortCount = 0;
|
||||
@@ -107,7 +107,7 @@ namespace Terminal.Gui {
|
||||
Application.RequestStop ();
|
||||
}
|
||||
};
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var ms = 1000;
|
||||
var abortCount = 0;
|
||||
|
||||
@@ -544,7 +544,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void Initialized_Event_Comparing_With_Added_Event ()
|
||||
{
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var t = new Toplevel () { Id = "0", };
|
||||
|
||||
@@ -643,7 +643,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void Initialized_Event_Will_Be_Invoked_When_Added_Dynamically ()
|
||||
{
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var t = new Toplevel () { Id = "0", };
|
||||
|
||||
@@ -751,7 +751,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void CanFocus_Faced_With_Container_Before_Run ()
|
||||
{
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var t = Application.Top;
|
||||
|
||||
@@ -788,7 +788,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void CanFocus_Faced_With_Container_After_Run ()
|
||||
{
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var t = Application.Top;
|
||||
|
||||
@@ -831,7 +831,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void CanFocus_Container_ToFalse_Turns_All_Subviews_ToFalse_Too ()
|
||||
{
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var t = Application.Top;
|
||||
|
||||
@@ -866,7 +866,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void CanFocus_Container_Toggling_All_Subviews_To_Old_Value_When_Is_True ()
|
||||
{
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var t = Application.Top;
|
||||
|
||||
@@ -910,7 +910,7 @@ namespace Terminal.Gui {
|
||||
{
|
||||
// Non-regression test for #882 (NullReferenceException during keyboard navigation when Focused is null)
|
||||
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
Application.Top.Ready += () => {
|
||||
Assert.Null (Application.Top.Focused);
|
||||
@@ -928,7 +928,7 @@ namespace Terminal.Gui {
|
||||
[Fact]
|
||||
public void Multi_Thread_Toplevels ()
|
||||
{
|
||||
Application.Init (new FakeDriver (), new NetMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
Application.Init (new FakeDriver (), new FakeMainLoop (() => FakeConsole.ReadKey (true)));
|
||||
|
||||
var t = Application.Top;
|
||||
var w = new Window ();
|
||||
|
||||
Reference in New Issue
Block a user