Browse Source

moving input test images into ./tests/TestImages/Input

af/merge-core
Anton Firszov 9 years ago
parent
commit
41794a6a7a
  1. 2
      tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs
  2. 19
      tests/ImageSharp.Tests/Image/ImageTests.cs
  3. 4
      tests/ImageSharp.Tests/TestBase.cs
  4. 14
      tests/ImageSharp.Tests/TestFile.cs
  5. 4
      tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs
  6. 42
      tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs
  7. 4
      tests/ImageSharp.Tests/TestUtilities/Tests/IntegrationTestUtilsTests.cs
  8. 37
      tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs
  9. 0
      tests/TestImages/Input/Bmp/Car.bmp
  10. 0
      tests/TestImages/Input/Bmp/F.bmp
  11. 0
      tests/TestImages/Input/Bmp/neg_height.bmp
  12. 0
      tests/TestImages/Input/Gif/cheers.gif
  13. 0
      tests/TestImages/Input/Gif/giphy.gif
  14. 0
      tests/TestImages/Input/Gif/rings.gif
  15. 0
      tests/TestImages/Input/Gif/trans.gif
  16. 0
      tests/TestImages/Input/Jpg/baseline/Calliphora.jpg
  17. 0
      tests/TestImages/Input/Jpg/baseline/ExifUndefType.jpg
  18. 0
      tests/TestImages/Input/Jpg/baseline/Floorplan.jpg
  19. 0
      tests/TestImages/Input/Jpg/baseline/Hiyamugi.jpg
  20. 0
      tests/TestImages/Input/Jpg/baseline/Lake.jpg
  21. 0
      tests/TestImages/Input/Jpg/baseline/Snake.jpg
  22. 0
      tests/TestImages/Input/Jpg/baseline/badeof.jpg
  23. 0
      tests/TestImages/Input/Jpg/baseline/cmyk.jpg
  24. 0
      tests/TestImages/Input/Jpg/baseline/exif.jpg
  25. 0
      tests/TestImages/Input/Jpg/baseline/gamma_dalai_lama_gray.jpg
  26. 0
      tests/TestImages/Input/Jpg/baseline/jpeg400jfif.jpg
  27. 0
      tests/TestImages/Input/Jpg/baseline/jpeg420exif.jpg
  28. 0
      tests/TestImages/Input/Jpg/baseline/jpeg444.jpg
  29. 0
      tests/TestImages/Input/Jpg/baseline/testimgint.jpg
  30. 0
      tests/TestImages/Input/Jpg/baseline/testorig.jpg
  31. 0
      tests/TestImages/Input/Jpg/baseline/turtle.jpg
  32. 0
      tests/TestImages/Input/Jpg/baseline/ycck.jpg
  33. 0
      tests/TestImages/Input/Jpg/progressive/BadEofProgressive.jpg
  34. 0
      tests/TestImages/Input/Jpg/progressive/Festzug.jpg
  35. 0
      tests/TestImages/Input/Jpg/progressive/fb.jpg
  36. 0
      tests/TestImages/Input/Jpg/progressive/progress.jpg
  37. 0
      tests/TestImages/Input/Png/CalliphoraPartial.png
  38. 0
      tests/TestImages/Input/Png/blur.png
  39. 0
      tests/TestImages/Input/Png/chunklength1.png
  40. 0
      tests/TestImages/Input/Png/chunklength2.png
  41. 0
      tests/TestImages/Input/Png/cross.png
  42. 0
      tests/TestImages/Input/Png/filter0.png
  43. 0
      tests/TestImages/Input/Png/filter1.png
  44. 0
      tests/TestImages/Input/Png/filter2.png
  45. 0
      tests/TestImages/Input/Png/filter3.png
  46. 0
      tests/TestImages/Input/Png/filter4.png
  47. 0
      tests/TestImages/Input/Png/filterVar.png
  48. 0
      tests/TestImages/Input/Png/indexed.png
  49. 0
      tests/TestImages/Input/Png/interlaced.png
  50. 0
      tests/TestImages/Input/Png/pd.png
  51. 0
      tests/TestImages/Input/Png/pl.png
  52. 0
      tests/TestImages/Input/Png/pp.png
  53. 0
      tests/TestImages/Input/Png/rgb-48bpp-interlaced.png
  54. 0
      tests/TestImages/Input/Png/rgb-48bpp.png
  55. 0
      tests/TestImages/Input/Png/splash-interlaced.png
  56. 0
      tests/TestImages/Input/Png/splash.png
  57. 0
      tests/TestImages/Input/Png/versioning-1_1.png
  58. 0
      tests/TestImages/Input/Png/versioning-1_2.png
  59. 0
      tests/TestImages/Input/Png/vim16x16_1.png
  60. 0
      tests/TestImages/Input/Png/vim16x16_2.png

2
tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs

@ -44,7 +44,7 @@ namespace ImageSharp.Tests
throw new Exception("Vector.IsHardwareAccelerated == false! ('prefer32 bit' enabled?)");
}
string path = TestFile.GetPath(fileName);
string path = TestFile.GetInputFileFullPath(fileName);
byte[] bytes = File.ReadAllBytes(path);
this.Measure(

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

@ -3,6 +3,7 @@
// Licensed under the Apache License, Version 2.0.
// </copyright>
// ReSharper disable InconsistentNaming
namespace ImageSharp.Tests
{
using System;
@ -15,7 +16,7 @@ namespace ImageSharp.Tests
/// <summary>
/// Tests the <see cref="Image"/> class.
/// </summary>
public class ImageTests
public class ImageTests : FileTestBase
{
[Fact]
public void ConstructorByteArray()
@ -67,8 +68,9 @@ namespace ImageSharp.Tests
[Fact]
public void Save_DetecedEncoding()
{
string file = TestFile.GetPath("../../TestOutput/Save_DetecedEncoding.png");
System.IO.DirectoryInfo dir = System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(file));
string dir = this.CreateOutputDirectory(nameof(ImageTests));
string file = System.IO.Path.Combine(dir, "Save_DetecedEncoding.png");
using (Image<Rgba32> image = new Image<Rgba32>(10, 10))
{
image.Save(file);
@ -81,9 +83,11 @@ namespace ImageSharp.Tests
}
[Fact]
public void Save_UnknownExtensionsEncoding()
public void Save_WhenExtensionIsUnknown_Throws()
{
string file = TestFile.GetPath("../../TestOutput/Save_DetecedEncoding.tmp");
string dir = this.CreateOutputDirectory(nameof(ImageTests));
string file = System.IO.Path.Combine(dir, "Save_UnknownExtensionsEncoding_Throws.tmp");
NotSupportedException ex = Assert.Throws<NotSupportedException>(
() =>
{
@ -97,8 +101,9 @@ namespace ImageSharp.Tests
[Fact]
public void Save_SetEncoding()
{
string file = TestFile.GetPath("../../TestOutput/Save_SetEncoding.dat");
System.IO.DirectoryInfo dir = System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(file));
string dir = this.CreateOutputDirectory(nameof(ImageTests));
string file = System.IO.Path.Combine(dir, "Save_SetEncoding.dat");
using (Image<Rgba32> image = new Image<Rgba32>(10, 10))
{
image.Save(file, new PngEncoder());

4
tests/ImageSharp.Tests/TestBase.cs

@ -25,9 +25,7 @@ namespace ImageSharp.Tests
/// </returns>
protected string CreateOutputDirectory(string path, params string[] pathParts)
{
string assemblyLocation = typeof(TestFile).GetTypeInfo().Assembly.Location;
assemblyLocation = Path.GetDirectoryName(assemblyLocation);
path = Path.GetFullPath(Path.Combine(assemblyLocation, "../../../TestOutput", path));
path = Path.Combine(TestEnvironment.ActualOutputDirectoryFullPath, path);
if (pathParts != null && pathParts.Length > 0)
{

14
tests/ImageSharp.Tests/TestFile.cs

@ -28,7 +28,7 @@ namespace ImageSharp.Tests
/// The formats directory, as lazy value
/// </summary>
// ReSharper disable once InconsistentNaming
private static readonly Lazy<string> formatsDirectory = new Lazy<string>(TestEnvironment.GetInputImagesDirectoryFullPath);
private static readonly Lazy<string> inputImagesDirectory = new Lazy<string>(() => TestEnvironment.InputImagesDirectoryFullPath);
/// <summary>
/// The image.
@ -73,12 +73,12 @@ namespace ImageSharp.Tests
public string FileNameWithoutExtension => Path.GetFileNameWithoutExtension(this.file);
/// <summary>
/// Gets the "Formats" test file directory.
/// Gets the Input Images directory.
/// </summary>
private static string FormatsDirectory => formatsDirectory.Value;
private static string InputImagesDirectory => inputImagesDirectory.Value;
/// <summary>
/// Gets the full qualified path to the file.
/// Gets the full qualified path to the input test file.
/// </summary>
/// <param name="file">
/// The file path.
@ -86,9 +86,9 @@ namespace ImageSharp.Tests
/// <returns>
/// The <see cref="string"/>.
/// </returns>
public static string GetPath(string file)
public static string GetInputFileFullPath(string file)
{
return Path.Combine(FormatsDirectory, file);
return Path.Combine(InputImagesDirectory, file);
}
/// <summary>
@ -100,7 +100,7 @@ namespace ImageSharp.Tests
/// </returns>
public static TestFile Create(string file)
{
return Cache.GetOrAdd(file, (string fileName) => new TestFile(GetPath(file)));
return Cache.GetOrAdd(file, (string fileName) => new TestFile(GetInputFileFullPath(file)));
}
/// <summary>

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

@ -144,8 +144,8 @@ namespace ImageSharp.Tests
}
}
internal string GetReferenceOutputFileName(string extension = null, object settings = null)
=> this.GetTestOutputFileName(extension, settings).Replace("TestOutput", "ReferenceOutput");
internal string GetReferenceOutputFileName(string extension = null, object settings = null) =>
TestEnvironment.GetReferenceOutputFileName(this.GetTestOutputFileName(extension, settings));
internal void Init(string typeName, string methodName)
{

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

@ -11,8 +11,14 @@ namespace ImageSharp.Tests
{
public const string ImageSharpSolution = "ImageSharp.sln";
public const string InputImagesRelativePath = @"tests\ImageSharp.Tests\TestImages\Formats";
private const string InputImagesRelativePath = @"tests\TestImages\Input";
private const string ActualOutputDirectoryRelativePath = @"tests\TestImages\ActualOutput";
private const string ReferenceOutputDirectoryRelativePath = @"tests\TestImages\ReferenceOutput";
private static Lazy<string> solutionDirectoryFullPath = new Lazy<string>(GetSolutionDirectoryFullPathImpl);
private static Lazy<bool> runsOnCi = new Lazy<bool>(
() =>
{
@ -25,8 +31,10 @@ namespace ImageSharp.Tests
/// Gets a value indicating whether test execution runs on CI.
/// </summary>
internal static bool RunsOnCI => runsOnCi.Value;
internal static string GetSolutionDirectoryFullPath()
internal static string SolutionDirectoryFullPath => solutionDirectoryFullPath.Value;
private static string GetSolutionDirectoryFullPathImpl()
{
string assemblyLocation = typeof(TestFile).GetTypeInfo().Assembly.Location;
@ -51,22 +59,26 @@ namespace ImageSharp.Tests
throw new Exception($"Unable to find ImageSharp solution directory from {assemblyLocation}!");
}
}
return directory.FullName;
}
/// <summary>
/// Gets the correct full path to the Input Images directory.
/// </summary>
internal static string InputImagesDirectoryFullPath => Path.Combine(SolutionDirectoryFullPath, InputImagesRelativePath);
/// <summary>
/// Gets the correct path to the InputImages directory.
/// Gets the correct full path to the Actual Output directory. (To be written to by the test cases.)
/// </summary>
/// <returns>
/// The <see cref="string"/>.
/// </returns>
internal static string GetInputImagesDirectoryFullPath()
{
string soulitionDir = GetSolutionDirectoryFullPath();
internal static string ActualOutputDirectoryFullPath => Path.Combine(SolutionDirectoryFullPath, ActualOutputDirectoryRelativePath);
return Path.Combine(soulitionDir, InputImagesRelativePath);
}
/// <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);
internal static string GetReferenceOutputFileName(string actualOutputFileName) =>
actualOutputFileName.Replace("ActualOutput", "ExpectedOutput");
}
}

4
tests/ImageSharp.Tests/TestUtilities/Tests/IntegrationTestUtilsTests.cs

@ -35,7 +35,7 @@ namespace ImageSharp.Tests
public void FromSystemDrawingBitmap<TPixel>(TestImageProvider<TPixel> dummyProvider)
where TPixel : struct, IPixel<TPixel>
{
string path = TestFile.GetPath(TestImages.Png.Splash);
string path = TestFile.GetInputFileFullPath(TestImages.Png.Splash);
using (var sdBitmap = new System.Drawing.Bitmap(path))
{
@ -51,7 +51,7 @@ namespace ImageSharp.Tests
public void OpenWithReferenceDecoder<TPixel>(TestImageProvider<TPixel> dummyProvider)
where TPixel : struct, IPixel<TPixel>
{
string path = TestFile.GetPath(TestImages.Png.Splash);
string path = TestFile.GetInputFileFullPath(TestImages.Png.Splash);
using (Image<TPixel> image = Image.Load<TPixel>(path, ReferenceDecoder.Instance))
{
image.DebugSave(dummyProvider);

37
tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs

@ -19,24 +19,45 @@ namespace ImageSharp.Tests
}
private ITestOutputHelper Output { get; }
private void CheckPath(string path)
{
this.Output.WriteLine(path);
Assert.True(Directory.Exists(path));
}
[Fact]
public void SolutionDirectoryFullPath()
{
this.CheckPath(TestEnvironment.SolutionDirectoryFullPath);
}
[Fact]
public void GetSolutionDirectoryFullPath()
public void InputImagesDirectoryFullPath()
{
string path = TestEnvironment.GetSolutionDirectoryFullPath();
this.Output.WriteLine(path);
this.CheckPath(TestEnvironment.InputImagesDirectoryFullPath);
}
Assert.True(Directory.Exists(path));
[Fact]
public void ActualOutputDirectoryFullPath()
{
this.CheckPath(TestEnvironment.ActualOutputDirectoryFullPath);
}
[Fact]
public void GetInputImagesDirectoryFullPath()
public void ExpectedOutputDirectoryFullPath()
{
string path = TestEnvironment.GetInputImagesDirectoryFullPath();
this.Output.WriteLine(path);
this.CheckPath(TestEnvironment.ReferenceOutputDirectoryFullPath);
}
Assert.True(Directory.Exists(path));
[Fact]
public void GetReferenceOutputFileName()
{
string actual = Path.Combine(TestEnvironment.ActualOutputDirectoryFullPath, @"foo\bar\lol.jpeg");
string expected = TestEnvironment.GetReferenceOutputFileName(actual);
this.Output.WriteLine(expected);
Assert.Contains(TestEnvironment.ReferenceOutputDirectoryFullPath, expected);
}
}
}

0
tests/ImageSharp.Tests/TestImages/Formats/Bmp/Car.bmp → tests/TestImages/Input/Bmp/Car.bmp

0
tests/ImageSharp.Tests/TestImages/Formats/Bmp/F.bmp → tests/TestImages/Input/Bmp/F.bmp

0
tests/ImageSharp.Tests/TestImages/Formats/Bmp/neg_height.bmp → tests/TestImages/Input/Bmp/neg_height.bmp

0
tests/ImageSharp.Tests/TestImages/Formats/Gif/cheers.gif → tests/TestImages/Input/Gif/cheers.gif

0
tests/ImageSharp.Tests/TestImages/Formats/Gif/giphy.gif → tests/TestImages/Input/Gif/giphy.gif

0
tests/ImageSharp.Tests/TestImages/Formats/Gif/rings.gif → tests/TestImages/Input/Gif/rings.gif

0
tests/ImageSharp.Tests/TestImages/Formats/Gif/trans.gif → tests/TestImages/Input/Gif/trans.gif

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/baseline/Calliphora.jpg → tests/TestImages/Input/Jpg/baseline/Calliphora.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/baseline/ExifUndefType.jpg → tests/TestImages/Input/Jpg/baseline/ExifUndefType.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/baseline/Floorplan.jpg → tests/TestImages/Input/Jpg/baseline/Floorplan.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/baseline/Hiyamugi.jpg → tests/TestImages/Input/Jpg/baseline/Hiyamugi.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/baseline/Lake.jpg → tests/TestImages/Input/Jpg/baseline/Lake.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/baseline/Snake.jpg → tests/TestImages/Input/Jpg/baseline/Snake.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/baseline/badeof.jpg → tests/TestImages/Input/Jpg/baseline/badeof.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/baseline/cmyk.jpg → tests/TestImages/Input/Jpg/baseline/cmyk.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/baseline/exif.jpg → tests/TestImages/Input/Jpg/baseline/exif.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/baseline/gamma_dalai_lama_gray.jpg → tests/TestImages/Input/Jpg/baseline/gamma_dalai_lama_gray.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/baseline/jpeg400jfif.jpg → tests/TestImages/Input/Jpg/baseline/jpeg400jfif.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/baseline/jpeg420exif.jpg → tests/TestImages/Input/Jpg/baseline/jpeg420exif.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/baseline/jpeg444.jpg → tests/TestImages/Input/Jpg/baseline/jpeg444.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/baseline/testimgint.jpg → tests/TestImages/Input/Jpg/baseline/testimgint.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/baseline/testorig.jpg → tests/TestImages/Input/Jpg/baseline/testorig.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/baseline/turtle.jpg → tests/TestImages/Input/Jpg/baseline/turtle.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/baseline/ycck.jpg → tests/TestImages/Input/Jpg/baseline/ycck.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/progressive/BadEofProgressive.jpg → tests/TestImages/Input/Jpg/progressive/BadEofProgressive.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/progressive/Festzug.jpg → tests/TestImages/Input/Jpg/progressive/Festzug.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/progressive/fb.jpg → tests/TestImages/Input/Jpg/progressive/fb.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Jpg/progressive/progress.jpg → tests/TestImages/Input/Jpg/progressive/progress.jpg

0
tests/ImageSharp.Tests/TestImages/Formats/Png/CalliphoraPartial.png → tests/TestImages/Input/Png/CalliphoraPartial.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/blur.png → tests/TestImages/Input/Png/blur.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/chunklength1.png → tests/TestImages/Input/Png/chunklength1.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/chunklength2.png → tests/TestImages/Input/Png/chunklength2.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/cross.png → tests/TestImages/Input/Png/cross.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/filter0.png → tests/TestImages/Input/Png/filter0.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/filter1.png → tests/TestImages/Input/Png/filter1.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/filter2.png → tests/TestImages/Input/Png/filter2.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/filter3.png → tests/TestImages/Input/Png/filter3.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/filter4.png → tests/TestImages/Input/Png/filter4.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/filterVar.png → tests/TestImages/Input/Png/filterVar.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/indexed.png → tests/TestImages/Input/Png/indexed.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/interlaced.png → tests/TestImages/Input/Png/interlaced.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/pd.png → tests/TestImages/Input/Png/pd.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/pl.png → tests/TestImages/Input/Png/pl.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/pp.png → tests/TestImages/Input/Png/pp.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/rgb-48bpp-interlaced.png → tests/TestImages/Input/Png/rgb-48bpp-interlaced.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/rgb-48bpp.png → tests/TestImages/Input/Png/rgb-48bpp.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/splash-interlaced.png → tests/TestImages/Input/Png/splash-interlaced.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/splash.png → tests/TestImages/Input/Png/splash.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/versioning-1_1.png → tests/TestImages/Input/Png/versioning-1_1.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/versioning-1_2.png → tests/TestImages/Input/Png/versioning-1_2.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/vim16x16_1.png → tests/TestImages/Input/Png/vim16x16_1.png

0
tests/ImageSharp.Tests/TestImages/Formats/Png/vim16x16_2.png → tests/TestImages/Input/Png/vim16x16_2.png

Loading…
Cancel
Save