Browse Source

Merge pull request #453 from PixiEditor/fix-tests

Fix tests
Krzysztof Krysiński 2 years ago
parent
commit
f4ffbe67f4

+ 1 - 0
src/ChunkyImageLibTest/ChunkyImageLibTest.csproj

@@ -22,6 +22,7 @@
 
   <ItemGroup>
     <ProjectReference Include="..\ChunkyImageLib\ChunkyImageLib.csproj" />
+    <ProjectReference Include="..\PixiEditor.DrawingApi.Skia\PixiEditor.DrawingApi.Skia.csproj" />
   </ItemGroup>
 
 </Project>

+ 6 - 14
src/ChunkyImageLibTest/ChunkyImageTests.cs

@@ -1,30 +1,22 @@
 using ChunkyImageLib;
 using ChunkyImageLib.DataHolders;
+using PixiEditor.DrawingApi.Core.Bridge;
 using PixiEditor.DrawingApi.Core.ColorsImpl;
 using PixiEditor.DrawingApi.Core.Numerics;
 using PixiEditor.DrawingApi.Core.Surface;
+using PixiEditor.DrawingApi.Skia;
 using Xunit;
 
 namespace ChunkyImageLibTest;
 public class ChunkyImageTests
 {
-    public static Surface ImportImage(string path, VecI size)
+    public ChunkyImageTests()
     {
-        Surface original = Surface.Load(path);
-        if (original.Size != size)
+        try
         {
-            Surface resized = original.ResizeNearestNeighbor(size);
-            original.Dispose();
-            return resized;
+            DrawingBackendApi.SetupBackend(new SkiaDrawingBackend());
         }
-        return original;
-    }
-
-    [Fact]
-    public void LoadDemo()
-    {
-        var path = @"C:\Users\egor0\Desktop\SpazzS1.png";
-        ImportImage(path, new VecI(5, 5));
+        catch { }
     }
 
     [Fact]

+ 11 - 0
src/ChunkyImageLibTest/ImageOperationTests.cs

@@ -2,12 +2,23 @@
 using ChunkyImageLib;
 using ChunkyImageLib.DataHolders;
 using ChunkyImageLib.Operations;
+using PixiEditor.DrawingApi.Core.Bridge;
 using PixiEditor.DrawingApi.Core.Numerics;
+using PixiEditor.DrawingApi.Skia;
 using Xunit;
 
 namespace ChunkyImageLibTest;
 public class ImageOperationTests
 {
+    public ImageOperationTests()
+    {
+        try
+        {
+            DrawingBackendApi.SetupBackend(new SkiaDrawingBackend());
+        }
+        catch { }
+    }
+
     [Fact]
     public void FindAffectedChunks_SingleChunk_ReturnsSingleChunk()
     {

+ 1 - 1
src/PixiEditor.DrawingApi.Core/Numerics/RectI.cs

@@ -245,7 +245,7 @@ public struct RectI : IEquatable<RectI>
     {
         RectD rectD = (RectD)rect;
         RectD thisD = (RectD)this;
-        RectD aspect = rectD.AspectFit(thisD);
+        RectD aspect = thisD.AspectFit(rectD);
         return new RectI((int)aspect.Left, (int)aspect.Top, (int)aspect.Width, (int)aspect.Height);
     }