瀏覽代碼

Fix more tests, fix flabbet's fixes

Equbuxu 3 年之前
父節點
當前提交
ec6231bc11

+ 1 - 1
PixiEditor/Models/IO/Exporter.cs

@@ -100,7 +100,7 @@ namespace PixiEditor.Models.IO
         /// <param name="exportWidth">File width.</param>
         /// <param name="exportHeight">File height.</param>
         /// <param name="bitmap">Bitmap to save.</param>
-        private static void SaveAsPng(string savePath, int exportWidth, int exportHeight, WriteableBitmap bitmap)
+        public static void SaveAsPng(string savePath, int exportWidth, int exportHeight, WriteableBitmap bitmap)
         {
             try
             {

+ 7 - 17
PixiEditorTests/ModelsTests/ColorsTests/ExtendedColorTests.cs

@@ -1,36 +1,26 @@
-using System;
-using System.Windows.Media;
-using PixiEditor.Models.Colors;
+using PixiEditor.Models.Colors;
 using SkiaSharp;
+using System;
 using Xunit;
 
 namespace PixiEditorTests.ModelsTests.ColorsTests
 {
     public class ExtendedColorTests
     {
-
-        public static readonly SKColor white = new SKColor(255, 255, 255);
-        public static readonly SKColor black = new SKColor(0, 0, 0);
-        public static readonly SKColor transparent = new SKColor(0, 0, 0, 0);
-        public static readonly SKColor red = new SKColor(255, 0, 0);
-        public static readonly SKColor green = new SKColor(0, 255, 0);
-        public static readonly SKColor blue = new SKColor(0, 0, 255);
-
         private const int AcceptableMaringOfError = 1;
 
-
         [Fact]
         public void ChangeColorBrightnessIsNotTheSameTest()
         {
-            SKColor newColor = ExColor.ChangeColorBrightness(white, -1);
-            Assert.NotEqual(white, newColor);
+            SKColor newColor = ExColor.ChangeColorBrightness(SKColors.White, -1);
+            Assert.NotEqual(SKColors.White, newColor);
         }
 
         [Fact]
         public void ChangeColorBrightnessNewValueTest()
         {
-            SKColor newColor = ExColor.ChangeColorBrightness(white, -100);
-            Assert.Equal(black, newColor);
+            SKColor newColor = ExColor.ChangeColorBrightness(SKColors.White, -100);
+            Assert.Equal(SKColors.Black, newColor);
         }
 
         // Acceptable margin of error is 1
@@ -68,4 +58,4 @@ namespace PixiEditorTests.ModelsTests.ColorsTests
             Assert.True(marginOfErrorB <= AcceptableMaringOfError);
         }
     }
-}
+}

+ 5 - 8
PixiEditorTests/ModelsTests/ControllersTests/BitmapManagerTests.cs

@@ -1,10 +1,7 @@
-using System.Windows.Media;
-using PixiEditor.Models.Controllers;
+using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Position;
-using PixiEditor.Models.Tools;
-using PixiEditor.Models.Undo;
-using PixiEditorTests.ModelsTests.ColorsTests;
+using SkiaSharp;
 using Xunit;
 
 namespace PixiEditorTests.ModelsTests.ControllersTests
@@ -84,7 +81,7 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
 
             bitmapManager.ActiveDocument.AddNewLayer("Layer");
             bitmapManager.SetActiveTool(new MockedSinglePixelPenTool());
-            bitmapManager.PrimaryColor = ExtendedColorTests.black;
+            bitmapManager.PrimaryColor = SKColors.Black;
 
             bitmapManager.MouseController.StartRecordingMouseMovementChanges(true);
             bitmapManager.MouseController.RecordMouseMovementChange(new Coordinates(1, 1));
@@ -92,7 +89,7 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
 
             bitmapManager.ExecuteTool(new Coordinates(1, 1), true);
 
-            Assert.Equal(ExtendedColorTests.black, bitmapManager.ActiveLayer.GetPixelWithOffset(1, 1));
+            Assert.Equal(SKColors.Black, bitmapManager.ActiveLayer.GetPixelWithOffset(1, 1));
         }
     }
-}
+}

+ 7 - 8
PixiEditorTests/ModelsTests/ControllersTests/BitmapOperationsUtilityTests.cs

@@ -1,10 +1,9 @@
-using System.Collections.Generic;
-using System.Windows.Media;
-using PixiEditor.Models.Controllers;
+using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
-using PixiEditorTests.ModelsTests.ColorsTests;
+using SkiaSharp;
+using System.Collections.Generic;
 using Xunit;
 
 namespace PixiEditorTests.ModelsTests.ControllersTests
@@ -19,7 +18,7 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
 
             Layer testLayer = new Layer("test layer", 10, 10);
             Coordinates[] cords = { new Coordinates(0, 0), new Coordinates(1, 1) };
-            BitmapPixelChanges pixels = BitmapPixelChanges.FromSingleColoredArray(cords, ExtendedColorTests.black);
+            BitmapPixelChanges pixels = BitmapPixelChanges.FromSingleColoredArray(cords, SKColors.Black);
             testLayer.SetPixels(pixels);
 
             util.DeletePixels(new[] { testLayer }, cords);
@@ -34,7 +33,7 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
             BitmapManager manager = new BitmapManager
             {
                 ActiveDocument = new Document(10, 10),
-                PrimaryColor = ExtendedColorTests.black
+                PrimaryColor = SKColors.Black
             };
             manager.ActiveDocument.AddNewLayer("Test layer", 10, 10);
 
@@ -43,7 +42,7 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
             List<Coordinates> mouseMove = new List<Coordinates>(new[] { new Coordinates(0, 0) });
 
             util.ExecuteTool(new Coordinates(0, 0), mouseMove, new MockedSinglePixelPenTool());
-            Assert.Equal(manager.ActiveLayer.GetPixel(0, 0), ExtendedColorTests.black);
+            Assert.Equal(manager.ActiveLayer.GetPixel(0, 0), SKColors.Black);
         }
     }
-}
+}

+ 10 - 11
PixiEditorTests/ModelsTests/ControllersTests/PixelChangesControllerTests.cs

@@ -1,9 +1,8 @@
-using System;
-using System.Windows.Media;
-using PixiEditor.Models.Controllers;
+using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Position;
-using PixiEditorTests.ModelsTests.ColorsTests;
+using SkiaSharp;
+using System;
 using Xunit;
 
 namespace PixiEditorTests.ModelsTests.ControllersTests
@@ -30,8 +29,8 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
 
             controller.AddChanges(
                 new LayerChange(
-                    BitmapPixelChanges.FromSingleColoredArray(cords, ExtendedColorTests.black), guid),
-                new LayerChange(BitmapPixelChanges.FromSingleColoredArray(cords, ExtendedColorTests.transparent), guid));
+                    BitmapPixelChanges.FromSingleColoredArray(cords, SKColors.Black), guid),
+                new LayerChange(BitmapPixelChanges.FromSingleColoredArray(cords, SKColors.Transparent), guid));
 
             System.Tuple<LayerChange, LayerChange>[] changes = controller.PopChanges();
             Assert.Equal(2, changes.Length);
@@ -46,8 +45,8 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
 
             controller.AddChanges(
                 new LayerChange(
-                    BitmapPixelChanges.FromSingleColoredArray(cords2, ExtendedColorTests.black), data.Item1),
-                new LayerChange(BitmapPixelChanges.FromSingleColoredArray(cords2, ExtendedColorTests.transparent), data.Item1));
+                    BitmapPixelChanges.FromSingleColoredArray(cords2, SKColors.Black), data.Item1),
+                new LayerChange(BitmapPixelChanges.FromSingleColoredArray(cords2, SKColors.Transparent), data.Item1));
 
             Tuple<LayerChange, LayerChange>[] changes = controller.PopChanges();
             Assert.Single(changes);
@@ -64,9 +63,9 @@ namespace PixiEditorTests.ModelsTests.ControllersTests
 
             controller.AddChanges(
                 new LayerChange(
-                    BitmapPixelChanges.FromSingleColoredArray(cords, ExtendedColorTests.black), guid),
-                new LayerChange(BitmapPixelChanges.FromSingleColoredArray(cords, ExtendedColorTests.transparent), guid));
+                    BitmapPixelChanges.FromSingleColoredArray(cords, SKColors.Black), guid),
+                new LayerChange(BitmapPixelChanges.FromSingleColoredArray(cords, SKColors.Transparent), guid));
             return new Tuple<Guid, PixelChangesController>(guid, controller);
         }
     }
-}
+}

+ 11 - 13
PixiEditorTests/ModelsTests/DataHoldersTests/BitmapPixelChangesTests.cs

@@ -1,8 +1,6 @@
-using System.Windows.Media;
-using PixiEditor.Exceptions;
+using PixiEditor.Exceptions;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Position;
-using PixiEditorTests.ModelsTests.ColorsTests;
 using SkiaSharp;
 using Xunit;
 
@@ -14,9 +12,9 @@ namespace PixiEditorTests.ModelsTests.DataHoldersTests
         public void TestThatFromSingleColoredArrayCreatesCorrectArray()
         {
             Coordinates[] cords = { new Coordinates(0, 0), new Coordinates(1, 0), new Coordinates(3, 2) };
-            BitmapPixelChanges bmpChanges = BitmapPixelChanges.FromSingleColoredArray(cords, ExtendedColorTests.green);
+            BitmapPixelChanges bmpChanges = BitmapPixelChanges.FromSingleColoredArray(cords, SKColors.Lime);
 
-            Assert.All(bmpChanges.ChangedPixels.Values, changeColor => Assert.Equal(ExtendedColorTests.green, changeColor));
+            Assert.All(bmpChanges.ChangedPixels.Values, changeColor => Assert.Equal(SKColors.Lime, changeColor));
             Assert.True(bmpChanges.WasBuiltAsSingleColored);
         }
 
@@ -25,28 +23,28 @@ namespace PixiEditorTests.ModelsTests.DataHoldersTests
         {
             Coordinates[] cords1 = { new Coordinates(0, 0), new Coordinates(1, 0), new Coordinates(3, 2) };
             Coordinates[] cords2 = { new Coordinates(3, 2), new Coordinates(0, 0), new Coordinates(5, 5) };
-            BitmapPixelChanges changes = BitmapPixelChanges.FromSingleColoredArray(cords1, ExtendedColorTests.green);
-            BitmapPixelChanges changes2 = BitmapPixelChanges.FromSingleColoredArray(cords2, ExtendedColorTests.red);
+            BitmapPixelChanges changes = BitmapPixelChanges.FromSingleColoredArray(cords1, SKColors.Lime);
+            BitmapPixelChanges changes2 = BitmapPixelChanges.FromSingleColoredArray(cords2, SKColors.Red);
 
             BitmapPixelChanges output = BitmapPixelChanges.CombineOverride(new[] { changes, changes2 });
             Assert.Equal(4, output.ChangedPixels.Count);
-            Assert.Equal(ExtendedColorTests.red, output.ChangedPixels[new Coordinates(3, 2)]);
-            Assert.Equal(ExtendedColorTests.black, output.ChangedPixels[new Coordinates(0, 0)]);
-            Assert.Equal(ExtendedColorTests.green, output.ChangedPixels[new Coordinates(1, 0)]);
+            Assert.Equal(SKColors.Red, output.ChangedPixels[new Coordinates(3, 2)]);
+            Assert.Equal(SKColors.Black, output.ChangedPixels[new Coordinates(0, 0)]);
+            Assert.Equal(SKColors.Lime, output.ChangedPixels[new Coordinates(1, 0)]);
         }
 
         [Fact]
         public void TestThatFromArraysThrowsError()
         {
             Assert.Throws<ArrayLengthMismatchException>(
-                () => BitmapPixelChanges.FromArrays(new[] { new Coordinates(0, 0) }, new[] { ExtendedColorTests.red, ExtendedColorTests.green }));
+                () => BitmapPixelChanges.FromArrays(new[] { new Coordinates(0, 0) }, new[] { SKColors.Red, SKColors.Lime }));
         }
 
         [Fact]
         public void TestThatFormArraysWorks()
         {
             Coordinates[] coordinatesArray = { new Coordinates(0, 0), new Coordinates(2, 3), new Coordinates(5, 5) };
-            SKColor[] colorsArray = { ExtendedColorTests.red, ExtendedColorTests.green, ExtendedColorTests.blue };
+            SKColor[] colorsArray = { SKColors.Red, SKColors.Lime, SKColors.Blue };
             BitmapPixelChanges result = BitmapPixelChanges.FromArrays(coordinatesArray, colorsArray);
             for (int i = 0; i < coordinatesArray.Length; i++)
             {
@@ -57,4 +55,4 @@ namespace PixiEditorTests.ModelsTests.DataHoldersTests
             Assert.False(result.WasBuiltAsSingleColored);
         }
     }
-}
+}

+ 13 - 14
PixiEditorTests/ModelsTests/DataHoldersTests/DocumentTests.cs

@@ -1,13 +1,12 @@
-using System;
-using System.Windows.Media;
-using PixiEditor.Models.Controllers;
+using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.ViewModels;
 using PixiEditorTests.HelpersTests;
-using PixiEditorTests.ModelsTests.ColorsTests;
+using SkiaSharp;
+using System;
 using Xunit;
 
 namespace PixiEditorTests.ModelsTests.DataHoldersTests
@@ -55,9 +54,9 @@ namespace PixiEditorTests.ModelsTests.DataHoldersTests
             manager.ActiveLayer.SetPixel(
                 new Coordinates(
                 (int)Math.Ceiling(initialWidth / 2f),
-                (int)Math.Ceiling(initialHeight / 2f)), ExtendedColorTests.black);
+                (int)Math.Ceiling(initialHeight / 2f)), SKColors.Black);
 
-            manager.ActiveLayer.SetPixel(new Coordinates(additionalPixelX, additionalPixelY), ExtendedColorTests.black);
+            manager.ActiveLayer.SetPixel(new Coordinates(additionalPixelX, additionalPixelY), SKColors.Black);
 
             document.ClipCanvas();
 
@@ -81,11 +80,11 @@ namespace PixiEditorTests.ModelsTests.DataHoldersTests
             manager.ActiveLayer.SetPixel(
                 new Coordinates(
                 (int)Math.Ceiling(initialWidth / 2f),
-                (int)Math.Ceiling(initialHeight / 2f)), ExtendedColorTests.black); // Set pixel in center
+                (int)Math.Ceiling(initialHeight / 2f)), SKColors.Black); // Set pixel in center
 
             manager.ActiveDocument.AddNewLayer("test2");
 
-            manager.ActiveLayer.SetPixel(new Coordinates(secondLayerPixelX, secondLayerPixelY), ExtendedColorTests.black);
+            manager.ActiveLayer.SetPixel(new Coordinates(secondLayerPixelX, secondLayerPixelY), SKColors.Black);
 
             document.ClipCanvas();
 
@@ -114,7 +113,7 @@ namespace PixiEditorTests.ModelsTests.DataHoldersTests
             };
             manager.ActiveDocument.AddNewLayer("test");
 
-            manager.ActiveLayer.SetPixel(new Coordinates(0, 0), ExtendedColorTests.green);
+            manager.ActiveLayer.SetPixel(new Coordinates(0, 0), SKColors.Lime);
 
             doc.CenterContent();
 
@@ -134,10 +133,10 @@ namespace PixiEditorTests.ModelsTests.DataHoldersTests
                 ActiveDocument = doc
             };
             manager.ActiveDocument.AddNewLayer("test");
-            manager.ActiveLayer.SetPixel(new Coordinates(0, 0), ExtendedColorTests.green);
+            manager.ActiveLayer.SetPixel(new Coordinates(0, 0), SKColors.Lime);
 
             manager.ActiveDocument.AddNewLayer("test2");
-            manager.ActiveLayer.SetPixel(new Coordinates(1, 1), ExtendedColorTests.green);
+            manager.ActiveLayer.SetPixel(new Coordinates(1, 1), SKColors.Lime);
 
             foreach (var layer in manager.ActiveDocument.Layers)
             {
@@ -322,7 +321,7 @@ namespace PixiEditorTests.ModelsTests.DataHoldersTests
         {
             const string layerName = "New Layer";
 
-            Document document = new (10, 10);
+            Document document = new(10, 10);
 
             document.AddNewLayer(layerName);
             Layer duplicate = document.DuplicateLayer(0);
@@ -337,7 +336,7 @@ namespace PixiEditorTests.ModelsTests.DataHoldersTests
         {
             const string layerName = "New Layer";
 
-            Document document = new (10, 10);
+            Document document = new(10, 10);
 
             document.AddNewLayer(layerName);
             document.AddNewLayer(layerName);
@@ -353,4 +352,4 @@ namespace PixiEditorTests.ModelsTests.DataHoldersTests
             Assert.Equal(layerName + " (16)", document.Layers[4].Name);
         }
     }
-}
+}

+ 3 - 3
PixiEditorTests/ModelsTests/DataHoldersTests/SurfaceTests.cs

@@ -27,7 +27,7 @@ namespace PixiEditorSkiaRewrite
         public void TestSurfaceSRGBPixelManipulation()
         {
             using Surface surface = new Surface(128, 200);
-            surface.SkiaSurface.Canvas.Clear(SKExtendedColorTests.red);
+            surface.SkiaSurface.Canvas.Clear(SKColors.Red);
             surface.SkiaSurface.Canvas.DrawRect(new SKRect(10, 10, 70, 70), redPaint);
             surface.SetSRGBPixel(73, 21, greenColor);
             Assert.Equal(redColor, surface.GetSRGBPixel(14, 14));
@@ -79,12 +79,12 @@ namespace PixiEditorSkiaRewrite
         }
 
         [Fact]
-        public void TestSurfaceToSurface()
+        public void TestSurfaceToWriteableBitmap()
         {
             using Surface original = new Surface(30, 40);
             original.SkiaSurface.Canvas.Clear(redColor);
             original.SkiaSurface.Canvas.DrawRect(5, 5, 20, 20, greenPaint);
-            var bitmap = original.ToSurface();
+            var bitmap = original.ToWriteableBitmap();
             byte[] pixels = new byte[30 * 40 * 4];
             bitmap.CopyPixels(pixels, 30 * 4, 0);
             Assert.Equal(redColor, new SKColor(pixels[2], pixels[1], pixels[0], pixels[3]));

+ 7 - 8
PixiEditorTests/ModelsTests/IO/ExporterTests.cs

@@ -1,11 +1,10 @@
-using System.IO;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using PixiEditor.Models.DataHolders;
+using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.IO;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
-using PixiEditorTests.ModelsTests.ColorsTests;
+using SkiaSharp;
+using System.IO;
+using System.Windows.Media.Imaging;
 using Xunit;
 
 namespace PixiEditorTests.ModelsTests.IO
@@ -31,9 +30,9 @@ namespace PixiEditorTests.ModelsTests.IO
             string filePath = "testFile.pixi";
 
             document.Layers.Add(new Layer("layer1"));
-            document.Layers[0].SetPixel(new Coordinates(1, 1), ExtendedColorTests.white);
+            document.Layers[0].SetPixel(new Coordinates(1, 1), SKColors.White);
 
-            document.Swatches.Add(ExtendedColorTests.white);
+            document.Swatches.Add(SKColors.White);
 
             Exporter.SaveAsEditableFile(document, filePath);
 
@@ -42,4 +41,4 @@ namespace PixiEditorTests.ModelsTests.IO
             File.Delete(filePath);
         }
     }
-}
+}

+ 1 - 4
PixiEditorTests/ModelsTests/IO/ImporterTests.cs

@@ -1,12 +1,9 @@
 using PixiEditor.Exceptions;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.IO;
-using PixiEditorTests.ModelsTests.ColorsTests;
 using SkiaSharp;
 using System;
 using System.IO;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
 using Xunit;
 
 namespace PixiEditorTests.ModelsTests.IO
@@ -79,7 +76,7 @@ namespace PixiEditorTests.ModelsTests.IO
         public void TestSaveAndLoadGZippedBytes()
         {
             using Surface original = new Surface(123, 456);
-            original.SkiaSurface.Canvas.Clear(ExtendedColorTests.red);
+            original.SkiaSurface.Canvas.Clear(SKColors.Red);
             using SKPaint paint = new SKPaint();
             paint.BlendMode = SKBlendMode.Src;
             paint.Color = new SKColor(128, 64, 32, 16);

+ 22 - 45
PixiEditorTests/ModelsTests/ImageManipulationTests/BitmapUtilsTests.cs

@@ -1,40 +1,17 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using PixiEditor.Models.DataHolders;
+using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.ImageManipulation;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
-using PixiEditorTests.ModelsTests.ColorsTests;
+using SkiaSharp;
+using System;
+using System.Collections.Generic;
+using System.Linq;
 using Xunit;
 
 namespace PixiEditorTests.ModelsTests.ImageManipulationTests
 {
     public class BitmapUtilsTests
     {
-        [Fact]
-        public void TestBytesToSurface()
-        {
-            int width = 10;
-            int height = 10;
-            Coordinates[] coloredPoints = { new Coordinates(0, 0), new Coordinates(3, 6), new Coordinates(9, 9) };
-            Surface bmp = BitmapFactory.New(width, height);
-            for (int i = 0; i < coloredPoints.Length; i++)
-            {
-                bmp.SetPixel(coloredPoints[i].X, coloredPoints[i].Y, ExtendedColorTests.green);
-            }
-
-            byte[] byteArray = bmp.ToByteArray();
-
-            Surface convertedBitmap = BitmapUtils.BytesToSurface(width, height, byteArray);
-
-            for (int i = 0; i < coloredPoints.Length; i++)
-            {
-                Assert.Equal(ExtendedColorTests.green, convertedBitmap.GetPixel(coloredPoints[i].X, coloredPoints[i].Y));
-            }
-        }
 
         [Fact]
         public void TestThatCombineLayersReturnsCorrectBitmap()
@@ -42,14 +19,14 @@ namespace PixiEditorTests.ModelsTests.ImageManipulationTests
             Coordinates[] cords = { new Coordinates(0, 0), new Coordinates(1, 1) };
             Layer[] layers = { new Layer("test", 2, 2), new Layer("test2", 2, 2) };
 
-            layers[0].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[0] }, ExtendedColorTests.green));
+            layers[0].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[0] }, SKColors.Lime));
 
-            layers[1].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[1] }, ExtendedColorTests.red));
+            layers[1].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[1] }, SKColors.Red));
 
             Surface outputBitmap = BitmapUtils.CombineLayers(2, 2, layers);
 
-            Assert.Equal(ExtendedColorTests.green, outputBitmap.GetPixel(0, 0));
-            Assert.Equal(ExtendedColorTests.red, outputBitmap.GetPixel(1, 1));
+            Assert.Equal(SKColors.Lime, outputBitmap.GetSRGBPixel(0, 0));
+            Assert.Equal(SKColors.Red, outputBitmap.GetSRGBPixel(1, 1));
         }
 
         [Fact]
@@ -58,13 +35,13 @@ namespace PixiEditorTests.ModelsTests.ImageManipulationTests
             Coordinates[] cords = { new Coordinates(0, 0) };
             Layer[] layers = { new Layer("test", 2, 2), new Layer("test2", 2, 2) };
 
-            layers[0].SetPixels(BitmapPixelChanges.FromSingleColoredArray(cords, ExtendedColorTests.green));
+            layers[0].SetPixels(BitmapPixelChanges.FromSingleColoredArray(cords, SKColors.Lime));
 
-            layers[1].SetPixels(BitmapPixelChanges.FromSingleColoredArray(cords, ExtendedColorTests.red));
+            layers[1].SetPixels(BitmapPixelChanges.FromSingleColoredArray(cords, SKColors.Red));
 
             Surface outputBitmap = BitmapUtils.CombineLayers(2, 2, layers);
 
-            Assert.Equal(ExtendedColorTests.red, outputBitmap.GetSRGBPixel(0, 0));
+            Assert.Equal(SKColors.Red, outputBitmap.GetSRGBPixel(0, 0));
         }
 
         [Fact]
@@ -77,26 +54,26 @@ namespace PixiEditorTests.ModelsTests.ImageManipulationTests
             };
             Layer[] layers = { new Layer("test", 2, 2), new Layer("test2", 2, 2) };
 
-            layers[0].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[0] }, ExtendedColorTests.green));
-            layers[1].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[1] }, ExtendedColorTests.red));
+            layers[0].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[0] }, SKColors.Lime));
+            layers[1].SetPixels(BitmapPixelChanges.FromSingleColoredArray(new[] { cords[1] }, SKColors.Red));
 
-            Dictionary<Guid, Color[]> output = BitmapUtils.GetPixelsForSelection(layers, cords);
+            Dictionary<Guid, SKColor[]> output = BitmapUtils.GetPixelsForSelection(layers, cords);
 
-            List<Color> colors = new List<Color>();
+            List<SKColor> colors = new List<SKColor>();
 
-            foreach (KeyValuePair<Guid, Color[]> layerColor in output.ToArray())
+            foreach (KeyValuePair<Guid, SKColor[]> layerColor in output.ToArray())
             {
-                foreach (Color color in layerColor.Value)
+                foreach (SKColor color in layerColor.Value)
                 {
                     colors.Add(color);
                 }
             }
 
-            Assert.Single(colors.Where(x => x == ExtendedColorTests.green));
-            Assert.Single(colors.Where(x => x == ExtendedColorTests.red));
-            Assert.Equal(6, colors.Count(x => x.A == 0)); // 6 because layer is 4 pixels,
+            Assert.Single(colors.Where(x => x == SKColors.Lime));
+            Assert.Single(colors.Where(x => x == SKColors.Red));
+            Assert.Equal(6, colors.Count(x => x.Alpha == 0)); // 6 because layer is 4 pixels,
 
             // 2 * 4 = 8, 2 other color pixels, so 8 - 2 = 6
         }
     }
-}
+}

+ 11 - 13
PixiEditorTests/ModelsTests/LayersTests/LayerTests.cs

@@ -1,9 +1,7 @@
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using PixiEditor.Models.DataHolders;
+using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
-using PixiEditorTests.ModelsTests.ColorsTests;
+using SkiaSharp;
 using Xunit;
 
 namespace PixiEditorTests.ModelsTests.LayersTests
@@ -65,9 +63,9 @@ namespace PixiEditorTests.ModelsTests.LayersTests
 
             Layer clone = layer.Clone();
 
-            clone.LayerBitmap.SetSRGBPixel(0, 0, ExtendedColorTests.green); // Actually we are checking if modifying clone bitmap does not affect original
+            clone.LayerBitmap.SetSRGBPixel(0, 0, SKColors.Lime); // Actually we are checking if modifying clone bitmap does not affect original
 
-            Assert.NotEqual(ExtendedColorTests.green, layer.GetPixel(0, 0));
+            Assert.NotEqual(SKColors.Lime, layer.GetPixel(0, 0));
         }
 
         [Fact]
@@ -75,7 +73,7 @@ namespace PixiEditorTests.ModelsTests.LayersTests
         {
             Layer layer = new Layer("layer", 1, 1);
 
-            layer.SetPixel(new Coordinates(0, 0), ExtendedColorTests.black);
+            layer.SetPixel(new Coordinates(0, 0), SKColors.Black);
 
             layer.Resize(2, 2, 2, 2);
 
@@ -89,7 +87,7 @@ namespace PixiEditorTests.ModelsTests.LayersTests
             {
                 for (int x = 0; x < layer.Width; x++)
                 {
-                    Assert.Equal(ExtendedColorTests.black, layer.GetPixel(x, y));
+                    Assert.Equal(SKColors.Black, layer.GetPixel(x, y));
                 }
             }
         }
@@ -109,11 +107,11 @@ namespace PixiEditorTests.ModelsTests.LayersTests
 
             Layer layer = new Layer("layer");
 
-            layer.SetPixels(BitmapPixelChanges.FromSingleColoredArray(pixels, ExtendedColorTests.green));
+            layer.SetPixels(BitmapPixelChanges.FromSingleColoredArray(pixels, SKColors.Lime));
 
             for (int i = 0; i < pixels.Length; i++)
             {
-                Assert.Equal(ExtendedColorTests.green, layer.GetPixelWithOffset(pixels[i].X, pixels[i].Y));
+                Assert.Equal(SKColors.Lime, layer.GetPixelWithOffset(pixels[i].X, pixels[i].Y));
             }
         }
 
@@ -121,13 +119,13 @@ namespace PixiEditorTests.ModelsTests.LayersTests
         public void TestThatClipCanvasResizesBitmapCorrectly()
         {
             Layer layer = new Layer("layer", 10, 10);
-            layer.SetPixel(new Coordinates(4, 4), ExtendedColorTests.blue);
+            layer.SetPixel(new Coordinates(4, 4), SKColors.Blue);
 
             layer.ClipCanvas();
 
             Assert.Equal(1, layer.Width);
             Assert.Equal(1, layer.Height);
-            Assert.Equal(ExtendedColorTests.blue, layer.GetPixel(0, 0));
+            Assert.Equal(SKColors.Blue, layer.GetPixel(0, 0));
         }
     }
-}
+}

+ 5 - 6
PixiEditorTests/ModelsTests/ToolsTests/BrightnessToolTests.cs

@@ -1,8 +1,7 @@
-using System.Windows.Media;
-using PixiEditor.Models.Layers;
+using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools.Tools;
-using PixiEditorTests.ModelsTests.ColorsTests;
+using SkiaSharp;
 using Xunit;
 
 namespace PixiEditorTests.ModelsTests.ToolsTests
@@ -17,12 +16,12 @@ namespace PixiEditorTests.ModelsTests.ToolsTests
         // If correction factor is negative, testing color will be white, otherwise black
         public void TestThatBrightnessToolChangesPixelBrightness(float correctionFactor, byte expectedR, byte expectedG, byte expectedB)
         {
-            Color expectedColor = Color.FromRgb(expectedR, expectedG, expectedB);
+            SKColor expectedColor = new SKColor(expectedR, expectedG, expectedB);
 
             BrightnessTool tool = new BrightnessTool();
 
             Layer layer = new Layer("test", 1, 1);
-            layer.SetPixel(new Coordinates(0, 0), correctionFactor < 0 ? ExtendedColorTests.white : ExtendedColorTests.black);
+            layer.SetPixel(new Coordinates(0, 0), correctionFactor < 0 ? SKColors.White : SKColors.Black);
 
             PixiEditor.Models.DataHolders.BitmapPixelChanges changes = tool.ChangeBrightness(layer, new Coordinates(0, 0), 1, correctionFactor);
             layer.SetPixels(changes);
@@ -30,4 +29,4 @@ namespace PixiEditorTests.ModelsTests.ToolsTests
             Assert.Equal(expectedColor, layer.GetPixel(0, 0));
         }
     }
-}
+}

+ 5 - 5
PixiEditorTests/ModelsTests/ToolsTests/PenToolTests.cs

@@ -1,7 +1,7 @@
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools.Tools;
 using PixiEditorTests.HelpersTests;
-using PixiEditorTests.ModelsTests.ColorsTests;
+using SkiaSharp;
 using Xunit;
 
 namespace PixiEditorTests.ModelsTests.ToolsTests
@@ -19,11 +19,11 @@ namespace PixiEditorTests.ModelsTests.ToolsTests
             Coordinates end2 = new Coordinates(1, 0);
             Coordinates start2 = new Coordinates(1, 1);
 
-            pen.Draw(start, end, ExtendedColorTests.black, 1, true);
-            pen.Draw(end, end2, ExtendedColorTests.black, 1, true);
-            var points = pen.Draw(end2, start2, ExtendedColorTests.black, 1, true);
+            pen.Draw(start, end, SKColors.Black, 1, true);
+            pen.Draw(end, end2, SKColors.Black, 1, true);
+            var points = pen.Draw(end2, start2, SKColors.Black, 1, true);
 
             Assert.Contains(points.ChangedPixels, x => x.Value.Alpha == 0);
         }
     }
-}
+}

+ 8 - 14
PixiEditorTests/ModelsTests/UndoTests/StorageBasedChangeTests.cs

@@ -1,18 +1,12 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using PixiEditor.Models.Controllers;
+using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Undo;
-using PixiEditorTests.ModelsTests.ColorsTests;
 using PixiEditorTests.ModelsTests.LayersTests;
+using SkiaSharp;
+using System;
+using System.Collections.ObjectModel;
+using System.IO;
 using Xunit;
 
 namespace PixiEditorTests.ModelsTests.UndoTests
@@ -34,8 +28,8 @@ namespace PixiEditorTests.ModelsTests.UndoTests
             Document testDocument = new Document(10, 10);
             using Surface testBitmap = new Surface(10, 10);
             using Surface testBitmap2 = new Surface(5, 8);
-            testBitmap.SetSRGBPixel(0, 0, ExtendedColorTests.black);
-            testBitmap2.SetSRGBPixel(4, 4, ExtendedColorTests.blue);
+            testBitmap.SetSRGBPixel(0, 0, SKColors.Black);
+            testBitmap2.SetSRGBPixel(4, 4, SKColors.Blue);
             Random random = new Random();
             testDocument.Layers = new ObservableCollection<Layer>()
             {
@@ -167,4 +161,4 @@ namespace PixiEditorTests.ModelsTests.UndoTests
             Assert.True(redoInvoked);
         }
     }
-}
+}

+ 9 - 10
PixiEditorTests/ViewModelsTests/ViewModelMainTests.cs

@@ -3,10 +3,9 @@ using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools.Tools;
 using PixiEditor.ViewModels;
 using PixiEditorTests.HelpersTests;
-using PixiEditorTests.ModelsTests.ColorsTests;
+using SkiaSharp;
 using System.IO;
 using System.Windows.Input;
-using System.Windows.Media;
 using Xunit;
 
 namespace PixiEditorTests.ViewModelsTests
@@ -31,13 +30,13 @@ namespace PixiEditorTests.ViewModelsTests
         {
             ViewModelMain viewModel = ViewModelHelper.MockedViewModelMain();
 
-            viewModel.ColorsSubViewModel.PrimaryColor = ExtendedColorTests.black;
-            viewModel.ColorsSubViewModel.SecondaryColor = ExtendedColorTests.white;
+            viewModel.ColorsSubViewModel.PrimaryColor = SKColors.Black;
+            viewModel.ColorsSubViewModel.SecondaryColor = SKColors.White;
 
             viewModel.ColorsSubViewModel.SwapColorsCommand.Execute(null);
 
-            Assert.Equal(ExtendedColorTests.white, viewModel.ColorsSubViewModel.PrimaryColor);
-            Assert.Equal(ExtendedColorTests.black, viewModel.ColorsSubViewModel.SecondaryColor);
+            Assert.Equal(SKColors.White, viewModel.ColorsSubViewModel.PrimaryColor);
+            Assert.Equal(SKColors.Black, viewModel.ColorsSubViewModel.SecondaryColor);
         }
 
         [StaFact]
@@ -131,11 +130,11 @@ namespace PixiEditorTests.ViewModelsTests
             ViewModelMain viewModel = ViewModelHelper.MockedViewModelMain();
             viewModel.BitmapManager.ActiveDocument = new Document(1, 1);
 
-            viewModel.ColorsSubViewModel.AddSwatch(ExtendedColorTests.green);
-            viewModel.ColorsSubViewModel.AddSwatch(ExtendedColorTests.green);
+            viewModel.ColorsSubViewModel.AddSwatch(SKColors.Lime);
+            viewModel.ColorsSubViewModel.AddSwatch(SKColors.Lime);
 
             Assert.Single(viewModel.BitmapManager.ActiveDocument.Swatches);
-            Assert.Equal(ExtendedColorTests.green, viewModel.BitmapManager.ActiveDocument.Swatches[0]);
+            Assert.Equal(SKColors.Lime, viewModel.BitmapManager.ActiveDocument.Swatches[0]);
         }
 
         [StaTheory]
@@ -171,4 +170,4 @@ namespace PixiEditorTests.ViewModelsTests
             Assert.True(viewModel.DocumentIsNotNull(null));
         }
     }
-}
+}