Browse Source

moved CreateOutputDirectory() into TestEnvironment

af/merge-core
Anton Firszov 9 years ago
parent
commit
3d26beb3da
  1. 4
      tests/ImageSharp.Tests/Drawing/BeziersTests.cs
  2. 6
      tests/ImageSharp.Tests/Drawing/DrawPathTests.cs
  3. 2
      tests/ImageSharp.Tests/Drawing/FillPatternTests.cs
  4. 6
      tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs
  5. 10
      tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs
  6. 16
      tests/ImageSharp.Tests/Drawing/LineTests.cs
  7. 6
      tests/ImageSharp.Tests/Drawing/PolygonTests.cs
  8. 4
      tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs
  9. 4
      tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs
  10. 6
      tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs
  11. 20
      tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs
  12. 2
      tests/ImageSharp.Tests/Drawing/Text/OutputText.cs
  13. 2
      tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs
  14. 10
      tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs
  15. 5
      tests/ImageSharp.Tests/Formats/Jpg/LibJpegTools.cs
  16. 43
      tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs
  17. 6
      tests/ImageSharp.Tests/Image/ImageTests.cs
  18. 24
      tests/ImageSharp.Tests/TestBase.cs
  19. 2
      tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs
  20. 53
      tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs

4
tests/ImageSharp.Tests/Drawing/BeziersTests.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByBezierLine()
{
string path = this.CreateOutputDirectory("Drawing", "BezierLine");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "BezierLine");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x.BackgroundColor(Rgba32.Blue)
@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedBezierLineWithOpacity()
{
string path = this.CreateOutputDirectory("Drawing", "BezierLine");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "BezierLine");
Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);

6
tests/ImageSharp.Tests/Drawing/DrawPathTests.cs

@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByPath()
{
string path = this.CreateOutputDirectory("Drawing", "Path");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Path");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
{
LinearLineSegment linerSegemnt = new LinearLineSegment(
@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedPathWithOpacity()
{
string path = this.CreateOutputDirectory("Drawing", "Path");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Path");
Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);
@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void PathExtendingOffEdgeOfImageShouldNotBeCropped()
{
string path = this.CreateOutputDirectory("Drawing", "Path");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Path");
using (var image = new Image<Rgba32>(256, 256))
{
image.Mutate(x => x.Fill(Rgba32.Black));

2
tests/ImageSharp.Tests/Drawing/FillPatternTests.cs

@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{
private void Test(string name, Rgba32 background, IBrush<Rgba32> brush, Rgba32[,] expectedPattern)
{
string path = this.CreateOutputDirectory("Fill", "PatternBrush");
string path = TestEnvironment.CreateOutputDirectory("Fill", "PatternBrush");
using (Image<Rgba32> image = new Image<Rgba32>(20, 20))
{
image.Mutate(x => x

6
tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithColorOnDefaultBackground()
{
string path = this.CreateOutputDirectory("Fill", "SolidBrush");
string path = TestEnvironment.CreateOutputDirectory("Fill", "SolidBrush");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x
@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithColor()
{
string path = this.CreateOutputDirectory("Fill", "SolidBrush");
string path = TestEnvironment.CreateOutputDirectory("Fill", "SolidBrush");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x
@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeFloodFilledWithColorOpacity()
{
string path = this.CreateOutputDirectory("Fill", "SolidBrush");
string path = TestEnvironment.CreateOutputDirectory("Fill", "SolidBrush");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
{
Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);

10
tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByPolygonOutline()
{
string path = this.CreateOutputDirectory("Drawing", "LineComplexPolygon");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "LineComplexPolygon");
Polygon simplePath = new Polygon(new LinearLineSegment(
new Vector2(10, 10),
@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByPolygonOutlineNoOverlapping()
{
string path = this.CreateOutputDirectory("Drawing", "LineComplexPolygon");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "LineComplexPolygon");
Polygon simplePath = new Polygon(new LinearLineSegment(
new Vector2(10, 10),
new Vector2(200, 150),
@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByPolygonOutlineOverlapping()
{
string path = this.CreateOutputDirectory("Drawing", "LineComplexPolygon");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "LineComplexPolygon");
Polygon simplePath = new Polygon(new LinearLineSegment(
new Vector2(10, 10),
new Vector2(200, 150),
@ -156,7 +156,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByPolygonOutlineDashed()
{
string path = this.CreateOutputDirectory("Drawing", "LineComplexPolygon");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "LineComplexPolygon");
Polygon simplePath = new Polygon(new LinearLineSegment(
new Vector2(10, 10),
new Vector2(200, 150),
@ -180,7 +180,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedPolygonOutlineWithOpacity()
{
string path = this.CreateOutputDirectory("Drawing", "LineComplexPolygon");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "LineComplexPolygon");
Polygon simplePath = new Polygon(new LinearLineSegment(
new Vector2(10, 10),
new Vector2(200, 150),

16
tests/ImageSharp.Tests/Drawing/LineTests.cs

@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByPath()
{
string path = this.CreateOutputDirectory("Drawing", "Lines");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x
@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByPath_NoAntialias()
{
string path = this.CreateOutputDirectory("Drawing", "Lines");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x
@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByPathDashed()
{
string path = this.CreateOutputDirectory("Drawing", "Lines");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x
@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByPathDotted()
{
string path = this.CreateOutputDirectory("Drawing", "Lines");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x
@ -106,7 +106,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByPathDashDot()
{
string path = this.CreateOutputDirectory("Drawing", "Lines");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
{
image.Mutate(x => x
@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByPathDashDotDot()
{
string path = this.CreateOutputDirectory("Drawing", "Lines");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
Image<Rgba32> image = new Image<Rgba32>(500, 500);
image.Mutate(x => x
@ -140,7 +140,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedPathWithOpacity()
{
string path = this.CreateOutputDirectory("Drawing", "Lines");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);
@ -171,7 +171,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByPathOutline()
{
string path = this.CreateOutputDirectory("Drawing", "Lines");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
Image<Rgba32> image = new Image<Rgba32>(500, 500);

6
tests/ImageSharp.Tests/Drawing/PolygonTests.cs

@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByPolygonOutline()
{
string path = this.CreateOutputDirectory("Drawing", "Polygons");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Polygons");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
{
@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedPolygonOutlineWithOpacity()
{
string path = this.CreateOutputDirectory("Drawing", "Polygons");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Polygons");
SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] {
new Vector2(10, 10),
new Vector2(200, 150),
@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByRectangleOutline()
{
string path = this.CreateOutputDirectory("Drawing", "Polygons");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Polygons");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
{

4
tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs

@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void ImageShouldRecolorYellowToHotPink()
{
string path = this.CreateOutputDirectory("Drawing", "RecolorImage");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "RecolorImage");
RecolorBrush<Rgba32> brush = new RecolorBrush<Rgba32>(Rgba32.Yellow, Rgba32.HotPink, 0.2f);
@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void ImageShouldRecolorYellowToHotPinkInARectangle()
{
string path = this.CreateOutputDirectory("Drawing", "RecolorImage");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "RecolorImage");
RecolorBrush<Rgba32> brush = new RecolorBrush<Rgba32>(Rgba32.Yellow, Rgba32.HotPink, 0.2f);

4
tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs

@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByFilledPolygon()
{
string path = this.CreateOutputDirectory("Drawing", "FilledBezier");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledBezier");
SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] {
new Vector2(10, 400),
new Vector2(30, 10),
@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByFilledPolygonOpacity()
{
string path = this.CreateOutputDirectory("Drawing", "FilledBezier");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledBezier");
SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] {
new Vector2(10, 400),
new Vector2(30, 10),

6
tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs

@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByPolygonOutline()
{
string path = this.CreateOutputDirectory("Drawing", "ComplexPolygon");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "ComplexPolygon");
Polygon simplePath = new Polygon(new LinearLineSegment(
new Vector2(10, 10),
new Vector2(200, 150),
@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedPolygonOutlineWithOverlap()
{
string path = this.CreateOutputDirectory("Drawing", "ComplexPolygon");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "ComplexPolygon");
Polygon simplePath = new Polygon(new LinearLineSegment(
new Vector2(10, 10),
new Vector2(200, 150),
@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedPolygonOutlineWithOpacity()
{
string path = this.CreateOutputDirectory("Drawing", "ComplexPolygon");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "ComplexPolygon");
Polygon simplePath = new Polygon(new LinearLineSegment(
new Vector2(10, 10),
new Vector2(200, 150),

20
tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs

@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByFilledPolygon()
{
string path = this.CreateOutputDirectory("Drawing", "FilledPolygons");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons");
SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] {
new Vector2(10, 10),
new Vector2(200, 150),
@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByFilledPolygonWithPattern()
{
string path = this.CreateOutputDirectory("Drawing", "FilledPolygons");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons");
SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] {
new Vector2(10, 10),
new Vector2(200, 150),
@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByFilledPolygonNoAntialias()
{
string path = this.CreateOutputDirectory("Drawing", "FilledPolygons");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons");
SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] {
new Vector2(10, 10),
new Vector2(200, 150),
@ -95,7 +95,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByFilledPolygonImage()
{
string path = this.CreateOutputDirectory("Drawing", "FilledPolygons");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons");
SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] {
new Vector2(10, 10),
new Vector2(200, 150),
@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByFilledPolygonOpacity()
{
string path = this.CreateOutputDirectory("Drawing", "FilledPolygons");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons");
SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] {
new Vector2(10, 10),
new Vector2(200, 150),
@ -145,7 +145,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByFilledRectangle()
{
string path = this.CreateOutputDirectory("Drawing", "FilledPolygons");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons");
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
{
@ -172,7 +172,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByFilledTriangle()
{
string path = this.CreateOutputDirectory("Drawing", "FilledPolygons");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons");
using (Image<Rgba32> image = new Image<Rgba32>(100, 100))
{
@ -193,7 +193,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByFilledSeptagon()
{
string path = this.CreateOutputDirectory("Drawing", "FilledPolygons");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons");
Configuration config = Configuration.CreateDefaultInstance();
config.ParallelOptions.MaxDegreeOfParallelism = 1;
@ -209,7 +209,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedByFilledEllipse()
{
string path = this.CreateOutputDirectory("Drawing", "FilledPolygons");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons");
Configuration config = Configuration.CreateDefaultInstance();
config.ParallelOptions.MaxDegreeOfParallelism = 1;
@ -226,7 +226,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
[Fact]
public void ImageShouldBeOverlayedBySquareWithCornerClipped()
{
string path = this.CreateOutputDirectory("Drawing", "FilledPolygons");
string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons");
Configuration config = Configuration.CreateDefaultInstance();
config.ParallelOptions.MaxDegreeOfParallelism = 1;

2
tests/ImageSharp.Tests/Drawing/Text/OutputText.cs

@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
{
img.Mutate(x => x.Fill(Rgba32.DarkBlue)
.DrawText("AB\nAB", new Font(this.Font, 50), Rgba32.Red, new Vector2(0, 0)));
img.Save($"{this.CreateOutputDirectory("Drawing", "Text")}/AB.png");
img.Save($"{TestEnvironment.CreateOutputDirectory("Drawing", "Text")}/AB.png");
}
}
}

2
tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs

@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Tests
[MemberData(nameof(BitsPerPixel))]
public void BitmapCanEncodeDifferentBitRates(BmpBitsPerPixel bitsPerPixel)
{
string path = this.CreateOutputDirectory("Bmp");
string path = TestEnvironment.CreateOutputDirectory("Bmp");
foreach (TestFile file in Files)
{

10
tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs

@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void ImageCanEncodeToString()
{
string path = this.CreateOutputDirectory("ToString");
string path = TestEnvironment.CreateOutputDirectory("ToString");
foreach (TestFile file in Files)
{
@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void DecodeThenEncodeImageFromStreamShouldSucceed()
{
string path = this.CreateOutputDirectory("Encode");
string path = TestEnvironment.CreateOutputDirectory("Encode");
foreach (TestFile file in Files)
{
@ -55,7 +55,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void QuantizeImageShouldPreserveMaximumColorPrecision()
{
string path = this.CreateOutputDirectory("Quantize");
string path = TestEnvironment.CreateOutputDirectory("Quantize");
foreach (TestFile file in Files)
{
@ -95,7 +95,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void ImageCanConvertFormat()
{
string path = this.CreateOutputDirectory("Format");
string path = TestEnvironment.CreateOutputDirectory("Format");
foreach (TestFile file in Files)
{
@ -127,7 +127,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void ImageShouldPreservePixelByteOrderWhenSerialized()
{
string path = this.CreateOutputDirectory("Serialized");
string path = TestEnvironment.CreateOutputDirectory("Serialized");
foreach (TestFile file in Files)
{

5
tests/ImageSharp.Tests/Formats/Jpg/LibJpegTools.cs

@ -453,5 +453,10 @@ namespace SixLabors.ImageSharp.Tests
double result = (double)totalDiff;
return result / (count * Block8x8.Size);
}
public static void RunDumpJpegCoeffsTool(string sourceFile, string destFile)
{
throw new NotImplementedException();
}
}
}

43
tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs

@ -5,9 +5,11 @@ namespace SixLabors.ImageSharp.Tests
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Jpeg.Common;
using SixLabors.ImageSharp.Formats.Jpeg.GolangPort;
using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort;
using SixLabors.ImageSharp.PixelFormats;
@ -42,6 +44,13 @@ namespace SixLabors.ImageSharp.Tests
public static readonly string[] AllTestJpegs = BaselineTestJpegs.Concat(ProgressiveTestJpegs).ToArray();
[Fact]
public void RunDumpJpegCoeffsTool()
{
string inputFile = TestFile.GetInputFileFullPath(TestImages.Jpeg.Progressive.Progress);
}
[Theory]
[WithFileCollection(nameof(BaselineTestJpegs), PixelTypes.Rgba32)]
public void BuildLibJpegSpectralResult<TPixel>(TestImageProvider<TPixel> provider)
@ -59,6 +68,40 @@ namespace SixLabors.ImageSharp.Tests
}
}
[Theory]
//[WithFileCollection(nameof(BaselineTestJpegs), PixelTypes.Rgba32)]
[WithFile(TestImages.Jpeg.Progressive.Progress, PixelTypes.Rgba32)]
public void HelloSerializedSpectralData<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes;
using (var ms = new MemoryStream(sourceBytes))
{
//LibJpegTools.SpectralData data = LibJpegTools.SpectralData.Load(ms);
OldJpegDecoderCore dec = new OldJpegDecoderCore(Configuration.Default, new JpegDecoder());
dec.ParseStream(new MemoryStream(sourceBytes));
LibJpegTools.SpectralData data = LibJpegTools.SpectralData.LoadFromImageSharpDecoder(dec);
Assert.True(data.ComponentCount > 0);
this.Output.WriteLine($"ComponentCount: {data.ComponentCount}");
string comp0FileName = TestFile.GetInputFileFullPath(provider.SourceFileOrDescription + ".comp0");
if (!File.Exists(comp0FileName))
{
this.Output.WriteLine("Missing file: " + comp0FileName);
}
byte[] stuff = File.ReadAllBytes(comp0FileName);
ref Block8x8 actual = ref Unsafe.As<byte, Block8x8>(ref stuff[0]);
ref Block8x8 expected = ref data.Components[0].Blocks[0];
Assert.Equal(actual, expected);
//this.SaveSpectralImage(provider, data);
}
}
[Theory]
[WithFileCollection(nameof(AllTestJpegs), PixelTypes.Rgba32)]
public void PdfJsDecoder_ParseStream_SaveSpectralResult<TPixel>(TestImageProvider<TPixel> provider)

6
tests/ImageSharp.Tests/Image/ImageTests.cs

@ -64,7 +64,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void Save_DetecedEncoding()
{
string dir = this.CreateOutputDirectory(nameof(ImageTests));
string dir = TestEnvironment.CreateOutputDirectory(nameof(ImageTests));
string file = System.IO.Path.Combine(dir, "Save_DetecedEncoding.png");
using (Image<Rgba32> image = new Image<Rgba32>(10, 10))
@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void Save_WhenExtensionIsUnknown_Throws()
{
string dir = this.CreateOutputDirectory(nameof(ImageTests));
string dir = TestEnvironment.CreateOutputDirectory(nameof(ImageTests));
string file = System.IO.Path.Combine(dir, "Save_UnknownExtensionsEncoding_Throws.tmp");
NotSupportedException ex = Assert.Throws<NotSupportedException>(
@ -97,7 +97,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void Save_SetEncoding()
{
string dir = this.CreateOutputDirectory(nameof(ImageTests));
string dir = TestEnvironment.CreateOutputDirectory(nameof(ImageTests));
string file = System.IO.Path.Combine(dir, "Save_SetEncoding.dat");
using (Image<Rgba32> image = new Image<Rgba32>(10, 10))

24
tests/ImageSharp.Tests/TestBase.cs

@ -12,29 +12,5 @@ namespace SixLabors.ImageSharp.Tests
/// </summary>
public abstract class TestBase
{
/// <summary>
/// Creates the image output directory.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="pathParts">The path parts.</param>
/// <returns>
/// The <see cref="string"/>.
/// </returns>
protected string CreateOutputDirectory(string path, params string[] pathParts)
{
path = Path.Combine(TestEnvironment.ActualOutputDirectoryFullPath, path);
if (pathParts != null && pathParts.Length > 0)
{
path = Path.Combine(path, Path.Combine(pathParts));
}
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
return path;
}
}
}

2
tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs

@ -194,7 +194,7 @@ namespace SixLabors.ImageSharp.Tests
internal string GetTestOutputDir()
{
string testGroupName = Path.GetFileNameWithoutExtension(this.TestGroupName);
return this.CreateOutputDirectory(testGroupName);
return TestEnvironment.CreateOutputDirectory(testGroupName);
}
public static void ModifyPixel<TPixel>(ImageBase<TPixel> img, int x, int y, byte perChannelChange)

53
tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs

@ -27,13 +27,15 @@ namespace SixLabors.ImageSharp.Tests
private const string ReferenceOutputDirectoryRelativePath = @"tests\Images\External\ReferenceOutput";
private const string ToolsDirectoryRelativePath = @"tests\Images\External\tools";
private static Lazy<string> solutionDirectoryFullPath = new Lazy<string>(GetSolutionDirectoryFullPathImpl);
private static Lazy<bool> runsOnCi = new Lazy<bool>(
() =>
{
bool isCi;
return bool.TryParse(Environment.GetEnvironmentVariable("CI"), out isCi) && isCi;
return Boolean.TryParse(Environment.GetEnvironmentVariable("CI"), out isCi) && isCi;
});
private static Lazy<Configuration> configuration = new Lazy<Configuration>(CreateDefaultConfiguration);
@ -120,25 +122,26 @@ namespace SixLabors.ImageSharp.Tests
return directory.FullName;
}
private static string GetFullPath(string relativePath) =>
Path.Combine(SolutionDirectoryFullPath, relativePath)
.Replace('\\', Path.DirectorySeparatorChar);
/// <summary>
/// Gets the correct full path to the Input Images directory.
/// </summary>
internal static string InputImagesDirectoryFullPath =>
Path.Combine(SolutionDirectoryFullPath, InputImagesRelativePath).Replace('\\', Path.DirectorySeparatorChar);
internal static string InputImagesDirectoryFullPath => GetFullPath(InputImagesRelativePath);
/// <summary>
/// Gets the correct full path to the Actual Output directory. (To be written to by the test cases.)
/// </summary>
internal static string ActualOutputDirectoryFullPath => Path.Combine(
SolutionDirectoryFullPath,
ActualOutputDirectoryRelativePath).Replace('\\', Path.DirectorySeparatorChar);
internal static string ActualOutputDirectoryFullPath => GetFullPath(ActualOutputDirectoryRelativePath);
/// <summary>
/// Gets the correct full path to the Expected Output directory. (To compare the test results to.)
/// </summary>
internal static string ReferenceOutputDirectoryFullPath => Path.Combine(
SolutionDirectoryFullPath,
ReferenceOutputDirectoryRelativePath).Replace('\\', Path.DirectorySeparatorChar);
internal static string ReferenceOutputDirectoryFullPath => GetFullPath(ReferenceOutputDirectoryRelativePath);
internal static string ToolsDirectoryFullPath => GetFullPath(ToolsDirectoryRelativePath);
internal static string GetReferenceOutputFileName(string actualOutputFileName) =>
actualOutputFileName.Replace("ActualOutput", @"External\ReferenceOutput").Replace('\\', Path.DirectorySeparatorChar);
@ -163,7 +166,33 @@ namespace SixLabors.ImageSharp.Tests
return format;
}
internal static bool IsLinux =>
System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
internal static bool IsLinux => RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
internal static bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
/// <summary>
/// Creates the image output directory.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="pathParts">The path parts.</param>
/// <returns>
/// The <see cref="string"/>.
/// </returns>
internal static string CreateOutputDirectory(string path, params string[] pathParts)
{
path = Path.Combine(TestEnvironment.ActualOutputDirectoryFullPath, path);
if (pathParts != null && pathParts.Length > 0)
{
path = Path.Combine(path, Path.Combine(pathParts));
}
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
return path;
}
}
}
Loading…
Cancel
Save