Files
Terminal.Gui/UnitTests/Application/SynchronizatonContextTests.cs
Tig 85a0ad1654 Diagnosing xunit failures in github action on ubuntu/macos (#3593)
* Just ubuntu

* windows & ubuntu

* commented test out

* uncommented test

* back to ubuntu

* deleted all Views tests

* deleted all Views tests

* VSTEST_DUMP_PATH

* Revert "deleted all Views tests"

This reverts commit 985f6143e6.

* Deleted first half Views tests

* Revert "Deleted first half Views tests"

This reverts commit bff2484cd7.

* Deleted 2nd half Views tests

* VSTEST_DUMP_PATH 2

* VSTEST_DUMP_PATH 3

* Revert "Deleted 2nd half Views tests"

This reverts commit b1dbd79dc9.

* Reapply "Deleted first half Views tests"

This reverts commit 3e8e890b03.

* Revert "Reapply "Deleted first half Views tests""

This reverts commit 731b50f392.

* ubuntu/mac

* removed dupe test

* removed dupe test

* removed statusbar tests

* Revert "removed statusbar tests"

This reverts commit 889813143b.

* Fixed shortcut tests

* windows, mac, linux

* fail-fast: false temporarily

* fail-fast: false temporarily

* trying stuff

* fixed quote error

* fixed sed issue

* Skip WindowDispose_CanFocusProblem

* Skip SynchronizationContext_CreateCopy

* mac

* mac

* mac

* mac

* mac

* gsed

* gsed

* gsed

* gsed

* finally fixed! Hopefully.
2024-07-08 18:29:00 -06:00

94 lines
2.9 KiB
C#

// Alias Console to MockConsole so we don't accidentally use Console
namespace Terminal.Gui.ApplicationTests;
public class SyncrhonizationContextTests
{
[Fact(Skip = "Causes ubuntu to crash in github action.")]
public void SynchronizationContext_CreateCopy ()
{
Application.Init ();
SynchronizationContext context = SynchronizationContext.Current;
Assert.NotNull (context);
SynchronizationContext contextCopy = context.CreateCopy ();
Assert.NotNull (contextCopy);
Assert.NotEqual (context, contextCopy);
Application.Shutdown ();
}
[Theory]
[InlineData (typeof (FakeDriver))]
//[InlineData (typeof (NetDriver))]
[InlineData (typeof (WindowsDriver))]
//[InlineData (typeof (CursesDriver))]
public void SynchronizationContext_Post (Type driverType)
{
Application.Init (driverName: driverType.Name);
SynchronizationContext context = SynchronizationContext.Current;
var success = false;
Task.Run (
() =>
{
Thread.Sleep (1_000);
// non blocking
context.Post (
delegate
{
success = true;
// then tell the application to quit
Application.Invoke (() => Application.RequestStop ());
},
null
);
Assert.False (success);
}
);
// blocks here until the RequestStop is processed at the end of the test
Application.Run ().Dispose ();
Assert.True (success);
Application.Shutdown ();
}
[Fact]
[AutoInitShutdown]
public void SynchronizationContext_Send ()
{
Application.Init ();
SynchronizationContext context = SynchronizationContext.Current;
var success = false;
Task.Run (
() =>
{
Thread.Sleep (1_000);
// blocking
context.Send (
delegate
{
success = true;
// then tell the application to quit
Application.Invoke (() => Application.RequestStop ());
},
null
);
Assert.True (success);
}
);
// blocks here until the RequestStop is processed at the end of the test
Application.Run ().Dispose ();
Assert.True (success);
Application.Shutdown ();
}
}