Browse Source
Merge pull request #10552 from AvaloniaUI/repro-test-issue
Fix Flaky Tests: Ensure that the dispatcher jobs queues are emptied after each test
pull/10555/head
Dan Walmsley
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
20 additions and
1 deletions
-
tests/Avalonia.RenderTests/TestBase.cs
-
tests/Avalonia.UnitTests/TestWithServicesBase.cs
-
tests/Avalonia.UnitTests/UnitTestApplication.cs
|
|
|
@ -31,7 +31,7 @@ namespace Avalonia.Skia.RenderTests |
|
|
|
namespace Avalonia.Direct2D1.RenderTests |
|
|
|
#endif
|
|
|
|
{ |
|
|
|
public class TestBase |
|
|
|
public class TestBase : IDisposable |
|
|
|
{ |
|
|
|
#if AVALONIA_SKIA
|
|
|
|
private static string s_fontUri = "resm:Avalonia.Skia.RenderTests.Assets?assembly=Avalonia.Skia.RenderTests#Noto Mono"; |
|
|
|
@ -282,5 +282,13 @@ namespace Avalonia.Direct2D1.RenderTests |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void Dispose() |
|
|
|
{ |
|
|
|
if (Dispatcher.UIThread.CheckAccess()) |
|
|
|
{ |
|
|
|
Dispatcher.UIThread.RunJobs(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Avalonia.Threading; |
|
|
|
|
|
|
|
namespace Avalonia.UnitTests |
|
|
|
{ |
|
|
|
@ -17,6 +18,11 @@ namespace Avalonia.UnitTests |
|
|
|
|
|
|
|
public void Dispose() |
|
|
|
{ |
|
|
|
if (Dispatcher.UIThread.CheckAccess()) |
|
|
|
{ |
|
|
|
Dispatcher.UIThread.RunJobs(); |
|
|
|
} |
|
|
|
|
|
|
|
_scope.Dispose(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -46,6 +46,11 @@ namespace Avalonia.UnitTests |
|
|
|
Dispatcher.UIThread.UpdateServices(); |
|
|
|
return Disposable.Create(() => |
|
|
|
{ |
|
|
|
if (Dispatcher.UIThread.CheckAccess()) |
|
|
|
{ |
|
|
|
Dispatcher.UIThread.RunJobs(); |
|
|
|
} |
|
|
|
|
|
|
|
scope.Dispose(); |
|
|
|
Dispatcher.UIThread.UpdateServices(); |
|
|
|
}); |
|
|
|
|