diff --git a/tests/Avalonia.Svg.Skia.UnitTests/App.axaml b/tests/Avalonia.Svg.Skia.UnitTests/App.axaml deleted file mode 100644 index 96409ddc..00000000 --- a/tests/Avalonia.Svg.Skia.UnitTests/App.axaml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/tests/Avalonia.Svg.Skia.UnitTests/App.axaml.cs b/tests/Avalonia.Svg.Skia.UnitTests/App.axaml.cs deleted file mode 100644 index 9ce4152b..00000000 --- a/tests/Avalonia.Svg.Skia.UnitTests/App.axaml.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Avalonia; -using Avalonia.Controls; -using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Controls.Primitives; -using Avalonia.Markup.Xaml; - -namespace UITests -{ - public partial class App : Application - { - public override void Initialize() - { - AvaloniaXamlLoader.Load(this); - } - - public override void OnFrameworkInitializationCompleted() - { - if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) - { - desktop.MainWindow = new Window(); - } - base.OnFrameworkInitializationCompleted(); - } - } -} \ No newline at end of file diff --git a/tests/Avalonia.Svg.Skia.UnitTests/Assets/__tiger.svg b/tests/Avalonia.Svg.Skia.UnitTests/Assets/__tiger.svg deleted file mode 100644 index 11abcd06..00000000 --- a/tests/Avalonia.Svg.Skia.UnitTests/Assets/__tiger.svg +++ /dev/null @@ -1,1978 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/Avalonia.Svg.Skia.UnitTests/Avalonia.Svg.Skia.UnitTests.csproj b/tests/Avalonia.Svg.Skia.UnitTests/Avalonia.Svg.Skia.UnitTests.csproj index 8c97e40f..f5eaccb3 100644 --- a/tests/Avalonia.Svg.Skia.UnitTests/Avalonia.Svg.Skia.UnitTests.csproj +++ b/tests/Avalonia.Svg.Skia.UnitTests/Avalonia.Svg.Skia.UnitTests.csproj @@ -14,9 +14,7 @@ - - diff --git a/tests/Avalonia.Svg.Skia.UnitTests/AvaloniaApp.cs b/tests/Avalonia.Svg.Skia.UnitTests/AvaloniaApp.cs deleted file mode 100644 index c6cd1da4..00000000 --- a/tests/Avalonia.Svg.Skia.UnitTests/AvaloniaApp.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using Avalonia; -using Avalonia.Controls; -using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Threading; - -namespace UITests -{ - public static class AvaloniaApp - { - public static void Stop() - { - var app = GetApp(); - if (app is IDisposable disposable) - { - Dispatcher.UIThread.Post(disposable.Dispose); - } - - if (app != null) - Dispatcher.UIThread.Post(() => app.Shutdown()); - } - - public static Window? GetMainWindow() => GetApp()?.MainWindow; - - public static IClassicDesktopStyleApplicationLifetime? GetApp() => - (IClassicDesktopStyleApplicationLifetime?)Application.Current?.ApplicationLifetime; - - public static AppBuilder BuildAvaloniaApp() => - AppBuilder - .Configure() - .UsePlatformDetect(); - } -} diff --git a/tests/Avalonia.Svg.Skia.UnitTests/AvaloniaUiTestFramework.cs b/tests/Avalonia.Svg.Skia.UnitTests/AvaloniaUiTestFramework.cs deleted file mode 100644 index 54ca14ef..00000000 --- a/tests/Avalonia.Svg.Skia.UnitTests/AvaloniaUiTestFramework.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Threading; -using System.Threading.Tasks; - -using Avalonia; - -using Xunit; -using Xunit.Abstractions; -using Xunit.Sdk; - -[assembly: TestFramework("UITests.AvaloniaUiTestFramework", "Avalonia.Svg.Skia.UnitTests")] -[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly, DisableTestParallelization = true, MaxParallelThreads = 1)] -namespace UITests -{ - - public class AvaloniaUiTestFramework : XunitTestFramework - { - public AvaloniaUiTestFramework(IMessageSink messageSink) - : base(messageSink) - { - } - - protected override ITestFrameworkExecutor CreateExecutor(AssemblyName assemblyName) - => new Executor(assemblyName, SourceInformationProvider, DiagnosticMessageSink); - - private class Executor : XunitTestFrameworkExecutor - { - public Executor( - AssemblyName assemblyName, - ISourceInformationProvider sourceInformationProvider, - IMessageSink diagnosticMessageSink) - : base( - assemblyName, - sourceInformationProvider, - diagnosticMessageSink) - { - - } - - protected override async void RunTestCases(IEnumerable testCases, - IMessageSink executionMessageSink, - ITestFrameworkExecutionOptions executionOptions) - { - executionOptions.SetValue("xunit.execution.DisableParallelization", false); - using var assemblyRunner = new Runner( - TestAssembly, testCases, DiagnosticMessageSink, executionMessageSink, - executionOptions); - - await assemblyRunner.RunAsync(); - } - } - - private class Runner : XunitTestAssemblyRunner - { - public Runner( - ITestAssembly testAssembly, - IEnumerable testCases, - IMessageSink diagnosticMessageSink, - IMessageSink executionMessageSink, - ITestFrameworkExecutionOptions executionOptions) - : base( - testAssembly, - testCases, - diagnosticMessageSink, - executionMessageSink, - executionOptions) - { - - } - - public override void Dispose() - { - AvaloniaApp.Stop(); - - base.Dispose(); - } - - protected override void SetupSyncContext(int maxParallelThreads) - { - var tcs = new TaskCompletionSource(); - var thread = new Thread(() => - { - try - { - //AvaloniaApp.RegisterDependencies(); - - AvaloniaApp - .BuildAvaloniaApp() - .AfterSetup(_ => - { - tcs.SetResult(SynchronizationContext.Current!); - }) - .StartWithClassicDesktopLifetime(new string[0]); - } - catch (Exception e) - { - tcs.SetException(e); - } - }) - { - IsBackground = true - }; - - thread.Start(); - - SynchronizationContext.SetSynchronizationContext(tcs.Task.Result); - } - } - } -} diff --git a/tests/Avalonia.Svg.Skia.UnitTests/SvgImageReloadTests.cs b/tests/Avalonia.Svg.Skia.UnitTests/SvgImageReloadTests.cs deleted file mode 100644 index dd73f379..00000000 --- a/tests/Avalonia.Svg.Skia.UnitTests/SvgImageReloadTests.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using Avalonia.Controls; -using Avalonia.Media; -using Avalonia.Media.Imaging; -using Avalonia.Platform; -using Avalonia.Threading; -using Svg.Skia; -using Xunit; - -namespace Avalonia.Svg.Skia.UnitTests; - -public class SvgImageReloadTests -{ - Image test; - private string css = ".Black { fill: #FF0000; }"; - Window window; - [Fact] - public async void SvgImage_ReLoad() - { - SKSvg.CacheOriginalStream = true; - var uri = new Uri($"avares://Avalonia.Svg.Skia.UnitTests/Assets/__tiger.svg"); - var assetLoader = new StandardAssetLoader(); // AvaloniaLocator.Current.GetService() - - var svgFile = assetLoader.Open(uri); - - var svgSource = SvgSource.LoadFromStream(svgFile); - var svgImage = new SvgImage() { Source = svgSource }; - - test = new Image(); - test.Source = svgImage; - - window = new Window(); - window.Content = test; - window.Show(); - - var timer = new DispatcherTimer(); - timer.Interval = TimeSpan.FromMilliseconds(10); - timer.Tick += Timer_Tick; - timer.Start(); - - await Task.Delay(10000); - - timer?.Stop(); - window?.Close(); - SKSvg.CacheOriginalStream = false; - } - - - - private void Timer_Tick(object sender, EventArgs e) - { - var image = (SvgImage)test.Source; - (image.CurrentCss, css) = (css, image.CurrentCss); - test.InvalidateVisual(); - } -}