From 237d129afcf96b1e9876f079cc3d99a199450658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=88=B0=E9=98=9F=E7=9A=84=E5=81=B6=E5=83=8F-=E5=B2=9B?= =?UTF-8?q?=E9=A3=8E=E9=85=B1!?= Date: Tue, 18 Jun 2024 21:45:45 +0800 Subject: [PATCH] Update Tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 舰队的偶像-岛风酱! --- .../Formats/Icon/Cur/CurDecoderTests.cs | 12 +++ .../Formats/Icon/Cur/CurEncoderTests.cs | 9 -- .../Formats/Icon/Ico/IcoDecoderTests.cs | 101 +++++++++++++++++- tests/ImageSharp.Tests/TestImages.cs | 2 +- 4 files changed, 110 insertions(+), 14 deletions(-) diff --git a/tests/ImageSharp.Tests/Formats/Icon/Cur/CurDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Icon/Cur/CurDecoderTests.cs index d1587d35b..e6efda4b6 100644 --- a/tests/ImageSharp.Tests/Formats/Icon/Cur/CurDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Icon/Cur/CurDecoderTests.cs @@ -21,4 +21,16 @@ public class CurDecoderTests // TODO: Assert metadata, frame count, etc } + + [Theory] + [WithFile(CurFake, PixelTypes.Rgba32)] + [WithFile(CurReal, PixelTypes.Rgba32)] + public void CurDecoder_Decode2(TestImageProvider provider) + { + using Image image = provider.GetImage(CurDecoder.Instance); + + image.DebugSaveMultiFrame(provider, extension: "png"); + + // TODO: Assert metadata, frame count, etc + } } diff --git a/tests/ImageSharp.Tests/Formats/Icon/Cur/CurEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Icon/Cur/CurEncoderTests.cs index 58213397c..9908786f1 100644 --- a/tests/ImageSharp.Tests/Formats/Icon/Cur/CurEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Icon/Cur/CurEncoderTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using System.Diagnostics; using SixLabors.ImageSharp.Formats.Cur; using SixLabors.ImageSharp.PixelFormats; using static SixLabors.ImageSharp.Tests.TestImages.Cur; @@ -30,12 +29,4 @@ public class CurEncoderTests memStream.Seek(0, SeekOrigin.Begin); CurDecoder.Instance.Decode(new(), memStream); } - - [Theory] - [WithFile(CurFake, PixelTypes.Rgba32)] - [WithFile(CurReal, PixelTypes.Rgba32)] - public void CurDecoder_Decode2(TestImageProvider provider) - { - Debug.Assert(false); - } } diff --git a/tests/ImageSharp.Tests/Formats/Icon/Ico/IcoDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Icon/Ico/IcoDecoderTests.cs index 8ea7cf6d4..981a1031d 100644 --- a/tests/ImageSharp.Tests/Formats/Icon/Ico/IcoDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Icon/Ico/IcoDecoderTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. -using System.Diagnostics; using SixLabors.ImageSharp.Formats.Ico; using SixLabors.ImageSharp.PixelFormats; using static SixLabors.ImageSharp.Tests.TestImages.Ico; @@ -42,6 +41,16 @@ public class IcoDecoderTests [WithFile(Bpp1Size9x9, PixelTypes.Rgba32)] [WithFile(Bpp1TranspNotSquare, PixelTypes.Rgba32)] [WithFile(Bpp1TranspPartial, PixelTypes.Rgba32)] + public void Bpp1Test(TestImageProvider provider) + { + using Image image = provider.GetImage(IcoDecoder.Instance); + + image.DebugSaveMultiFrame(provider, extension: "png"); + + // TODO: Assert metadata, frame count, etc + } + + [Theory] [WithFile(Bpp24Size15x15, PixelTypes.Rgba32)] [WithFile(Bpp24Size16x16, PixelTypes.Rgba32)] [WithFile(Bpp24Size17x17, PixelTypes.Rgba32)] @@ -61,6 +70,16 @@ public class IcoDecoderTests [WithFile(Bpp24TranspNotSquare, PixelTypes.Rgba32)] [WithFile(Bpp24TranspPartial, PixelTypes.Rgba32)] [WithFile(Bpp24Transp, PixelTypes.Rgba32)] + public void Bpp24Test(TestImageProvider provider) + { + using Image image = provider.GetImage(IcoDecoder.Instance); + + image.DebugSaveMultiFrame(provider, extension: "png"); + + // TODO: Assert metadata, frame count, etc + } + + [Theory] [WithFile(Bpp32Size15x15, PixelTypes.Rgba32)] [WithFile(Bpp32Size16x16, PixelTypes.Rgba32)] [WithFile(Bpp32Size17x17, PixelTypes.Rgba32)] @@ -80,6 +99,16 @@ public class IcoDecoderTests [WithFile(Bpp32TranspNotSquare, PixelTypes.Rgba32)] [WithFile(Bpp32TranspPartial, PixelTypes.Rgba32)] [WithFile(Bpp32Transp, PixelTypes.Rgba32)] + public void Bpp32Test(TestImageProvider provider) + { + using Image image = provider.GetImage(IcoDecoder.Instance); + + image.DebugSaveMultiFrame(provider, extension: "png"); + + // TODO: Assert metadata, frame count, etc + } + + [Theory] [WithFile(Bpp4Size15x15, PixelTypes.Rgba32)] [WithFile(Bpp4Size16x16, PixelTypes.Rgba32)] [WithFile(Bpp4Size17x17, PixelTypes.Rgba32)] @@ -98,6 +127,16 @@ public class IcoDecoderTests [WithFile(Bpp4Size9x9, PixelTypes.Rgba32)] [WithFile(Bpp4TranspNotSquare, PixelTypes.Rgba32)] [WithFile(Bpp4TranspPartial, PixelTypes.Rgba32)] + public void Bpp4Test(TestImageProvider provider) + { + using Image image = provider.GetImage(IcoDecoder.Instance); + + image.DebugSaveMultiFrame(provider, extension: "png"); + + // TODO: Assert metadata, frame count, etc + } + + [Theory] [WithFile(Bpp8Size15x15, PixelTypes.Rgba32)] [WithFile(Bpp8Size16x16, PixelTypes.Rgba32)] [WithFile(Bpp8Size17x17, PixelTypes.Rgba32)] @@ -116,28 +155,82 @@ public class IcoDecoderTests [WithFile(Bpp8Size9x9, PixelTypes.Rgba32)] [WithFile(Bpp8TranspNotSquare, PixelTypes.Rgba32)] [WithFile(Bpp8TranspPartial, PixelTypes.Rgba32)] + public void Bpp8Test(TestImageProvider provider) + { + using Image image = provider.GetImage(IcoDecoder.Instance); + + image.DebugSaveMultiFrame(provider, extension: "png"); + + // TODO: Assert metadata, frame count, etc + } + + [Theory] [WithFile(InvalidAll, PixelTypes.Rgba32)] - [WithFile(IcoFake, PixelTypes.Rgba32)] [WithFile(InvalidBpp, PixelTypes.Rgba32)] [WithFile(InvalidCompression, PixelTypes.Rgba32)] [WithFile(InvalidPng, PixelTypes.Rgba32)] [WithFile(InvalidRLE4, PixelTypes.Rgba32)] [WithFile(InvalidRLE8, PixelTypes.Rgba32)] + public void InvalidTest(TestImageProvider provider) + { + using Image image = provider.GetImage(IcoDecoder.Instance); + + image.DebugSaveMultiFrame(provider, extension: "png"); + + // TODO: Assert metadata, frame count, etc + } + + [Theory] [WithFile(MixedBmpPngA, PixelTypes.Rgba32)] [WithFile(MixedBmpPngB, PixelTypes.Rgba32)] [WithFile(MixedBmpPngC, PixelTypes.Rgba32)] + public void MixedBmpPngTest(TestImageProvider provider) + { + using Image image = provider.GetImage(IcoDecoder.Instance); + + image.DebugSaveMultiFrame(provider, extension: "png"); + + // TODO: Assert metadata, frame count, etc + } + + [Theory] [WithFile(MultiSizeA, PixelTypes.Rgba32)] [WithFile(MultiSizeB, PixelTypes.Rgba32)] [WithFile(MultiSizeC, PixelTypes.Rgba32)] [WithFile(MultiSizeD, PixelTypes.Rgba32)] [WithFile(MultiSizeE, PixelTypes.Rgba32)] [WithFile(MultiSizeF, PixelTypes.Rgba32)] + public void MultiSizeTest(TestImageProvider provider) + { + using Image image = provider.GetImage(IcoDecoder.Instance); + + image.DebugSaveMultiFrame(provider, extension: "png"); + + // TODO: Assert metadata, frame count, etc + } + + [Theory] [WithFile(MultiSizeMultiBitsA, PixelTypes.Rgba32)] [WithFile(MultiSizeMultiBitsB, PixelTypes.Rgba32)] [WithFile(MultiSizeMultiBitsC, PixelTypes.Rgba32)] [WithFile(MultiSizeMultiBitsD, PixelTypes.Rgba32)] - public void IcoDecoder_Decode2(TestImageProvider provider) + public void MultiSizeMultiBitsTest(TestImageProvider provider) + { + using Image image = provider.GetImage(IcoDecoder.Instance); + + image.DebugSaveMultiFrame(provider, extension: "png"); + + // TODO: Assert metadata, frame count, etc + } + + [Theory] + [WithFile(IcoFake, PixelTypes.Rgba32)] + public void IcoFakeTest(TestImageProvider provider) { - Debug.Assert(false); + using Image image = provider.GetImage(IcoDecoder.Instance); + + image.DebugSaveMultiFrame(provider, extension: "png"); + + // TODO: Assert metadata, frame count, etc } } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index fcb32eae6..8937799e1 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -1219,7 +1219,6 @@ public static class TestImages public const string Bpp8TranspNotSquare = "Icon/8bpp_transp_not_square.ico"; public const string Bpp8TranspPartial = "Icon/8bpp_transp_partial.ico"; public const string InvalidAll = "Icon/invalid_all.ico"; - public const string IcoFake = "Icon/ico_fake.cur"; public const string InvalidBpp = "Icon/invalid_bpp.ico"; public const string InvalidCompression = "Icon/invalid_compression.ico"; public const string InvalidPng = "Icon/invalid_png.ico"; @@ -1238,6 +1237,7 @@ public static class TestImages public const string MultiSizeMultiBitsB = "Icon/multi_size_multi_bits_b.ico"; public const string MultiSizeMultiBitsC = "Icon/multi_size_multi_bits_c.ico"; public const string MultiSizeMultiBitsD = "Icon/multi_size_multi_bits_d.ico"; + public const string IcoFake = "Icon/ico_fake.cur"; } public static class Cur