LayerTests.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using PixiEditor.Models.DataHolders;
  2. using PixiEditor.Models.Layers;
  3. using PixiEditor.Models.Position;
  4. using SkiaSharp;
  5. using Xunit;
  6. namespace PixiEditorTests.ModelsTests.LayersTests
  7. {
  8. public class LayerTests
  9. {
  10. //[Fact]
  11. //public void TestThatEmptyLayerGeneratesCorrectly()
  12. //{
  13. // Layer layer = new Layer("layer");
  14. // Assert.Equal("layer", layer.Name);
  15. // Assert.Equal(1, layer.Width);
  16. // Assert.Equal(1, layer.Height);
  17. // Assert.Equal(1, layer.LayerBitmap.Width);
  18. // Assert.Equal(1, layer.LayerBitmap.Height);
  19. //}
  20. //[Fact]
  21. //public void TestThatEmptyLayerWithSizeGeneratesCorrectly()
  22. //{
  23. // Layer layer = new Layer("layer", 10, 10);
  24. // Assert.Equal("layer", layer.Name);
  25. // Assert.Equal(10, layer.Width);
  26. // Assert.Equal(10, layer.Height);
  27. // Assert.Equal(10, layer.LayerBitmap.Width);
  28. // Assert.Equal(10, layer.LayerBitmap.Height);
  29. //}
  30. //[Fact]
  31. //public void TestThatLayerFromBitmapGeneratesCorrectly()
  32. //{
  33. // using Surface bmp = new Surface(10, 10);
  34. // Layer layer = new Layer("layer", bmp);
  35. // Assert.Equal("layer", layer.Name);
  36. // Assert.Equal(10, layer.Width);
  37. // Assert.Equal(10, layer.Height);
  38. // Assert.Equal(10, layer.LayerBitmap.Width);
  39. // Assert.Equal(10, layer.LayerBitmap.Height);
  40. //}
  41. //[Fact]
  42. //public void TestThatCloneClonesCorrectly()
  43. //{
  44. // Layer layer = new Layer("test", 5, 2);
  45. // Layer clone = layer.Clone();
  46. // LayersTestHelper.LayersAreEqual(layer, clone);
  47. //}
  48. //[Fact]
  49. //public void TestThatCloneIsMakingDeepCopyOfBitmap()
  50. //{
  51. // Layer layer = new Layer("test", 5, 2);
  52. // Layer clone = layer.Clone();
  53. // clone.LayerBitmap.SetSRGBPixel(0, 0, SKColors.Lime); // Actually we are checking if modifying clone bitmap does not affect original
  54. // Assert.NotEqual(SKColors.Lime, layer.GetPixel(0, 0));
  55. //}
  56. //[Fact]
  57. //public void TestThatResizeResizesBitmap()
  58. //{
  59. // Layer layer = new Layer("layer", 1, 1);
  60. // layer.SetPixel(new Coordinates(0, 0), SKColors.Black);
  61. // layer.Resize(2, 2, 2, 2);
  62. // Assert.Equal(2, layer.Width);
  63. // Assert.Equal(2, layer.Height);
  64. // Assert.Equal(2, layer.MaxWidth);
  65. // Assert.Equal(2, layer.MaxHeight);
  66. // // 4 is new area of bitmap
  67. // for (int y = 0; y < layer.Height; y++)
  68. // {
  69. // for (int x = 0; x < layer.Width; x++)
  70. // {
  71. // Assert.Equal(SKColors.Black, layer.GetPixel(x, y));
  72. // }
  73. // }
  74. //}
  75. //[Fact]
  76. //public void TestThatGetPixelReturnsTransparentIfOutOfBounds()
  77. //{
  78. // Layer layer = new Layer("layer");
  79. // Assert.Equal(0, layer.GetPixel(-1, 999).Alpha);
  80. //}
  81. //[Fact]
  82. //public void TestThatSetPixelsSetsPixels() // This also tests if Dynamic Resize works
  83. //{
  84. // Coordinates[] pixels = { new Coordinates(4, 2), new Coordinates(0, 0), new Coordinates(15, 2) };
  85. // Layer layer = new Layer("layer");
  86. // layer.SetPixels(BitmapPixelChanges.FromSingleColoredArray(pixels, SKColors.Lime));
  87. // for (int i = 0; i < pixels.Length; i++)
  88. // {
  89. // Assert.Equal(SKColors.Lime, layer.GetPixelWithOffset(pixels[i].X, pixels[i].Y));
  90. // }
  91. //}
  92. //[Fact]
  93. //public void TestThatClipCanvasResizesBitmapCorrectly()
  94. //{
  95. // Layer layer = new Layer("layer", 10, 10);
  96. // layer.SetPixel(new Coordinates(4, 4), SKColors.Blue);
  97. // layer.ClipCanvas();
  98. // Assert.Equal(1, layer.Width);
  99. // Assert.Equal(1, layer.Height);
  100. // Assert.Equal(SKColors.Blue, layer.GetPixel(0, 0));
  101. //}
  102. }
  103. }