Browse Source

Fix some tests

Equbuxu 3 years ago
parent
commit
501978aede

+ 6 - 6
src/ChunkyImageLibTest/ChunkyImageTests.cs

@@ -9,23 +9,23 @@ public class ChunkyImageTests
     public void ChunkyImage_Dispose_ReturnsAllChunks()
     {
         ChunkyImage image = new ChunkyImage(new(ChunkyImage.ChunkSize, ChunkyImage.ChunkSize));
-        image.EnqueueDrawRectangle(new(new(5, 5), new(80, 80), 2, SKColors.AliceBlue, SKColors.Snow));
+        image.EnqueueDrawRectangle(new(new(5, 5), new(80, 80), 0, 2, SKColors.AliceBlue, SKColors.Snow));
         using (Chunk target = Chunk.Create())
         {
             image.DrawMostUpToDateChunkOn(new(0, 0), ChunkyImageLib.DataHolders.ChunkResolution.Full, target.Surface.SkiaSurface, new(0, 0));
             image.CancelChanges();
             image.EnqueueResize(new(ChunkyImage.ChunkSize * 4, ChunkyImage.ChunkSize * 4));
-            image.EnqueueDrawRectangle(new(new(0, 0), image.CommittedSize, 2, SKColors.AliceBlue, SKColors.Snow, SKBlendMode.Multiply));
+            image.EnqueueDrawRectangle(new(new(0, 0), image.CommittedSize, 0, 2, SKColors.AliceBlue, SKColors.Snow, SKBlendMode.Multiply));
             image.CommitChanges();
             image.SetBlendMode(SKBlendMode.Overlay);
-            image.EnqueueDrawRectangle(new(new(0, 0), image.CommittedSize, 2, SKColors.AliceBlue, SKColors.Snow, SKBlendMode.Multiply));
-            image.EnqueueDrawRectangle(new(new(0, 0), image.CommittedSize, 2, SKColors.AliceBlue, SKColors.Snow));
+            image.EnqueueDrawRectangle(new(new(0, 0), image.CommittedSize, 0, 2, SKColors.AliceBlue, SKColors.Snow, SKBlendMode.Multiply));
+            image.EnqueueDrawRectangle(new(new(0, 0), image.CommittedSize, 0, 2, SKColors.AliceBlue, SKColors.Snow));
             image.CommitChanges();
             image.SetBlendMode(SKBlendMode.Screen);
-            image.EnqueueDrawRectangle(new(new(0, 0), image.CommittedSize, 2, SKColors.AliceBlue, SKColors.Snow));
+            image.EnqueueDrawRectangle(new(new(0, 0), image.CommittedSize, 0, 2, SKColors.AliceBlue, SKColors.Snow));
             image.CancelChanges();
             image.SetBlendMode(SKBlendMode.SrcOver);
-            image.EnqueueDrawRectangle(new(new(0, 0), image.CommittedSize, 2, SKColors.AliceBlue, SKColors.Snow));
+            image.EnqueueDrawRectangle(new(new(0, 0), image.CommittedSize, 0, 2, SKColors.AliceBlue, SKColors.Snow));
         }
         image.Dispose();
 

+ 16 - 16
src/ChunkyImageLibTest/RectangleOperationTests.cs

@@ -1,8 +1,8 @@
-using ChunkyImageLib;
+using System.Collections.Generic;
+using ChunkyImageLib;
 using ChunkyImageLib.DataHolders;
 using ChunkyImageLib.Operations;
 using SkiaSharp;
-using System.Collections.Generic;
 using Xunit;
 
 namespace ChunkyImageLibTest;
@@ -15,8 +15,8 @@ public class RectangleOperationTests
     [Fact]
     public void FindAffectedChunks_SmallStrokeOnly_FindsCorrectChunks()
     {
-        var (x, y, w, h) = (0, 0, chunkSize, chunkSize);
-        RectangleOperation operation = new(new(new(x, y), new(w, h), 1, SKColors.Black, SKColors.Transparent));
+        var (x, y, w, h) = (chunkSize / 2, chunkSize / 2, chunkSize, chunkSize);
+        RectangleOperation operation = new(new(new(x, y), new(w, h), 0, 1, SKColors.Black, SKColors.Transparent));
 
         HashSet<VecI> expected = new() { new(0, 0) };
         var actual = operation.FindAffectedChunks();
@@ -27,8 +27,8 @@ public class RectangleOperationTests
     [Fact]
     public void FindAffectedChunks_2by2StrokeOnly_FindsCorrectChunks()
     {
-        var (x, y, w, h) = (-chunkSize, -chunkSize, chunkSize * 2, chunkSize * 2);
-        RectangleOperation operation = new(new(new(x, y), new(w, h), 1, SKColors.Black, SKColors.Transparent));
+        var (x, y, w, h) = (0, 0, chunkSize * 2, chunkSize * 2);
+        RectangleOperation operation = new(new(new(x, y), new(w, h), 0, 1, SKColors.Black, SKColors.Transparent));
 
         HashSet<VecI> expected = new() { new(-1, -1), new(0, -1), new(-1, 0), new(0, 0) };
         var actual = operation.FindAffectedChunks();
@@ -39,8 +39,8 @@ public class RectangleOperationTests
     [Fact]
     public void FindAffectedChunks_3x3PositiveStrokeOnly_FindsCorrectChunks()
     {
-        var (x, y, w, h) = (chunkSize + chunkSize / 2, chunkSize + chunkSize / 2, chunkSize * 2, chunkSize * 2);
-        RectangleOperation operation = new(new(new(x, y), new(w, h), 1, SKColors.Black, SKColors.Transparent));
+        var (x, y, w, h) = (2 * chunkSize + chunkSize / 2, 2 * chunkSize + chunkSize / 2, chunkSize * 2, chunkSize * 2);
+        RectangleOperation operation = new(new(new(x, y), new(w, h), 0, 1, SKColors.Black, SKColors.Transparent));
 
         HashSet<VecI> expected = new()
         {
@@ -56,8 +56,8 @@ public class RectangleOperationTests
     [Fact]
     public void FindAffectedChunks_3x3NegativeStrokeOnly_FindsCorrectChunks()
     {
-        var (x, y, w, h) = (-chunkSize * 3 - chunkSize / 2, -chunkSize * 3 - chunkSize / 2, chunkSize * 2, chunkSize * 2);
-        RectangleOperation operation = new(new(new(x, y), new(w, h), 1, SKColors.Black, SKColors.Transparent));
+        var (x, y, w, h) = (-chunkSize * 2 - chunkSize / 2, -chunkSize * 2 - chunkSize / 2, chunkSize * 2, chunkSize * 2);
+        RectangleOperation operation = new(new(new(x, y), new(w, h), 0, 1, SKColors.Black, SKColors.Transparent));
 
         HashSet<VecI> expected = new()
         {
@@ -73,8 +73,8 @@ public class RectangleOperationTests
     [Fact]
     public void FindAffectedChunks_3x3PositiveFilled_FindsCorrectChunks()
     {
-        var (x, y, w, h) = (chunkSize + chunkSize / 2, chunkSize + chunkSize / 2, chunkSize * 2, chunkSize * 2);
-        RectangleOperation operation = new(new(new(x, y), new(w, h), 1, SKColors.Black, SKColors.White));
+        var (x, y, w, h) = (2 * chunkSize + chunkSize / 2, 2 * chunkSize + chunkSize / 2, chunkSize * 2, chunkSize * 2);
+        RectangleOperation operation = new(new(new(x, y), new(w, h), 0, 1, SKColors.Black, SKColors.White));
 
         HashSet<VecI> expected = new()
         {
@@ -90,8 +90,8 @@ public class RectangleOperationTests
     [Fact]
     public void FindAffectedChunks_ThickPositiveStroke_FindsCorrectChunks()
     {
-        var (x, y, w, h) = (chunkSize / 2, chunkSize / 2, chunkSize * 4, chunkSize * 4);
-        RectangleOperation operation = new(new(new(x, y), new(w, h), chunkSize, SKColors.Black, SKColors.Transparent));
+        var (x, y, w, h) = (2 * chunkSize + chunkSize / 2, 2 * chunkSize + chunkSize / 2, chunkSize * 4, chunkSize * 4);
+        RectangleOperation operation = new(new(new(x, y), new(w, h), 0, chunkSize, SKColors.Black, SKColors.Transparent));
 
         HashSet<VecI> expected = new()
         {
@@ -109,8 +109,8 @@ public class RectangleOperationTests
     [Fact]
     public void FindAffectedChunks_SmallButThick_FindsCorrectChunks()
     {
-        var (x, y, w, h) = (chunkSize / 2, chunkSize / 2, 1, 1);
-        RectangleOperation operation = new(new(new(x, y), new(w, h), 256, SKColors.Black, SKColors.White));
+        var (x, y, w, h) = (chunkSize / 2 - 0.5, chunkSize / 2 - 0.5, 1, 1);
+        RectangleOperation operation = new(new(new(x, y), new(w, h), 0, chunkSize, SKColors.Black, SKColors.White));
 
         HashSet<VecI> expected = new() { new(0, 0) };
         var actual = operation.FindAffectedChunks();

+ 1 - 7
src/PixiEditorPrototype.sln

@@ -15,14 +15,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChunkyImageLibVis", "Chunky
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PixiEditor.Zoombox", "PixiEditor.Zoombox\PixiEditor.Zoombox.csproj", "{232E58B6-8080-4725-8541-98BFCFE23A1C}"
 EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChunkyImageLibBenchmark", "ChunkyImageLibBenchmark\ChunkyImageLibBenchmark.csproj", "{3998B3EB-F11F-4637-A135-FBC3CCA24299}"
-EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2AF84829-B00E-4B10-B010-C9306C6DF278}"
 	ProjectSection(SolutionItems) = preProject
 		.editorconfig = .editorconfig
 	EndProjectSection
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PixiEditor.ChangeableDocument.Gen", "PixiEditor.ChangeableDocument.Gen\PixiEditor.ChangeableDocument.Gen.csproj", "{07EE9CD1-5B4B-454D-A362-F7B42C49412F}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PixiEditor.ChangeableDocument.Gen", "PixiEditor.ChangeableDocument.Gen\PixiEditor.ChangeableDocument.Gen.csproj", "{07EE9CD1-5B4B-454D-A362-F7B42C49412F}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -54,10 +52,6 @@ Global
 		{232E58B6-8080-4725-8541-98BFCFE23A1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{232E58B6-8080-4725-8541-98BFCFE23A1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{232E58B6-8080-4725-8541-98BFCFE23A1C}.Release|Any CPU.Build.0 = Release|Any CPU
-		{3998B3EB-F11F-4637-A135-FBC3CCA24299}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{3998B3EB-F11F-4637-A135-FBC3CCA24299}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{3998B3EB-F11F-4637-A135-FBC3CCA24299}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{3998B3EB-F11F-4637-A135-FBC3CCA24299}.Release|Any CPU.Build.0 = Release|Any CPU
 		{07EE9CD1-5B4B-454D-A362-F7B42C49412F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{07EE9CD1-5B4B-454D-A362-F7B42C49412F}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{07EE9CD1-5B4B-454D-A362-F7B42C49412F}.Release|Any CPU.ActiveCfg = Release|Any CPU