|
@@ -1,83 +1,15 @@
|
|
-using System.Reflection;
|
|
|
|
|
|
+using Avalonia;
|
|
using Avalonia.Headless;
|
|
using Avalonia.Headless;
|
|
-using Avalonia.Platform;
|
|
|
|
-using Avalonia.Threading;
|
|
|
|
-using Drawie.Backend.Core.Bridge;
|
|
|
|
-using Drawie.Skia;
|
|
|
|
-using DrawiEngine;
|
|
|
|
-using PixiEditor.Desktop;
|
|
|
|
-using Xunit.Abstractions;
|
|
|
|
-using Xunit.Sdk;
|
|
|
|
|
|
+using PixiEditor.Tests;
|
|
|
|
|
|
[assembly:TestFramework("PixiEditor.Tests.AvaloniaTestRunner", "PixiEditor.Tests")]
|
|
[assembly:TestFramework("PixiEditor.Tests.AvaloniaTestRunner", "PixiEditor.Tests")]
|
|
[assembly:CollectionBehavior(CollectionBehavior.CollectionPerAssembly, DisableTestParallelization = false, MaxParallelThreads = 1)]
|
|
[assembly:CollectionBehavior(CollectionBehavior.CollectionPerAssembly, DisableTestParallelization = false, MaxParallelThreads = 1)]
|
|
|
|
+[assembly: AvaloniaTestApplication(typeof(AvaloniaTestRunner))]
|
|
namespace PixiEditor.Tests
|
|
namespace PixiEditor.Tests
|
|
{
|
|
{
|
|
- public class AvaloniaTestRunner : XunitTestFramework
|
|
|
|
|
|
+ public class AvaloniaTestRunner
|
|
{
|
|
{
|
|
- public AvaloniaTestRunner(IMessageSink messageSink) : base(messageSink)
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- protected override ITestFrameworkExecutor CreateExecutor(AssemblyName assemblyName)
|
|
|
|
- => new Executor(assemblyName, SourceInformationProvider, DiagnosticMessageSink);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- class Executor : XunitTestFrameworkExecutor
|
|
|
|
- {
|
|
|
|
- public Executor(AssemblyName assemblyName, ISourceInformationProvider sourceInformationProvider,
|
|
|
|
- IMessageSink diagnosticMessageSink) : base(assemblyName, sourceInformationProvider,
|
|
|
|
- diagnosticMessageSink)
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- protected override async void RunTestCases(IEnumerable<IXunitTestCase> testCases,
|
|
|
|
- IMessageSink executionMessageSink,
|
|
|
|
- ITestFrameworkExecutionOptions executionOptions)
|
|
|
|
- {
|
|
|
|
- executionOptions.SetValue("xunit.execution.DisableParallelization", false);
|
|
|
|
- using (var assemblyRunner = new Runner(
|
|
|
|
- TestAssembly, testCases, DiagnosticMessageSink, executionMessageSink,
|
|
|
|
- executionOptions)) await assemblyRunner.RunAsync();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- class Runner : XunitTestAssemblyRunner
|
|
|
|
- {
|
|
|
|
- public Runner(ITestAssembly testAssembly, IEnumerable<IXunitTestCase> testCases,
|
|
|
|
- IMessageSink diagnosticMessageSink, IMessageSink executionMessageSink,
|
|
|
|
- ITestFrameworkExecutionOptions executionOptions) : base(testAssembly, testCases, diagnosticMessageSink,
|
|
|
|
- executionMessageSink, executionOptions)
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- protected override void SetupSyncContext(int maxParallelThreads)
|
|
|
|
- {
|
|
|
|
- var tcs = new TaskCompletionSource<SynchronizationContext>();
|
|
|
|
- new Thread(() =>
|
|
|
|
- {
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- Program.BuildAvaloniaApp()
|
|
|
|
- .UseHeadless(new AvaloniaHeadlessPlatformOptions { FrameBufferFormat = PixelFormat.Bgra8888, UseHeadlessDrawing = false })
|
|
|
|
- .SetupWithoutStarting();
|
|
|
|
- tcs.SetResult(SynchronizationContext.Current);
|
|
|
|
- }
|
|
|
|
- catch (Exception e)
|
|
|
|
- {
|
|
|
|
- tcs.SetException(e);
|
|
|
|
- }
|
|
|
|
- Dispatcher.UIThread.MainLoop(CancellationToken.None);
|
|
|
|
- })
|
|
|
|
- {
|
|
|
|
- IsBackground = true
|
|
|
|
- }.Start();
|
|
|
|
-
|
|
|
|
- SynchronizationContext.SetSynchronizationContext(tcs.Task.Result);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure<App>()
|
|
|
|
+ .UseHeadless(new AvaloniaHeadlessPlatformOptions());
|
|
}
|
|
}
|
|
}
|
|
}
|