Browse Source

Fix broken tests, update dependencies

Former-commit-id: eb4a57b4048f1f5eb04dfdb03bb3171c944634d1
Former-commit-id: 65a5bc657b616b0d66861ad3fa54de6eb5a0fd2d
Former-commit-id: 73e8ae25740bd9742744f5ffe7ff45e6ddbf0a0b
af/merge-core
James Jackson-South 11 years ago
parent
commit
4efbe87e73
  1. 4
      .gitignore
  2. 7
      global.json
  3. 3
      src/ImageProcessor/Formats/Gif/Quantizer/QuantizedImage.cs
  4. 2
      src/ImageProcessor/project.lock.json.REMOVED.git-id
  5. 18
      tests/ImageProcessor.Tests/Colors/ColorConversionTests.cs
  6. 8
      tests/ImageProcessor.Tests/Processors/Formats/EncoderDecoderTests.cs
  7. 32
      tests/ImageProcessor.Tests/Processors/ProcessorTestBase.cs
  8. 12
      tests/ImageProcessor.Tests/Processors/Samplers/SamplerTests.cs
  9. 4
      tests/ImageProcessor.Tests/project.json
  10. 2
      tests/ImageProcessor.Tests/project.lock.json.REMOVED.git-id

4
.gitignore

@ -176,5 +176,5 @@ _site/
**/node_modules **/node_modules
**/node_modules/* **/node_modules/*
project.lock.json **/TestOutput
src/ImageProcessor/project.lock.json project.lock.json

7
global.json

@ -1,3 +1,8 @@
{ {
"projects": [ "src" ] "projects": [ "src" ],
"sdk": {
"version": "1.0.0-beta8",
"runtime": "coreclr",
"architecture": "x86"
}
} }

3
src/ImageProcessor/Formats/Gif/Quantizer/QuantizedImage.cs

@ -69,12 +69,13 @@ namespace ImageProcessor.Formats
Image image = new Image(); Image image = new Image();
int pixelCount = this.Pixels.Length; int pixelCount = this.Pixels.Length;
int palletCount = this.Palette.Length - 1;
float[] bgraPixels = new float[pixelCount * 4]; float[] bgraPixels = new float[pixelCount * 4];
for (int i = 0; i < pixelCount; i++) for (int i = 0; i < pixelCount; i++)
{ {
int offset = i * 4; int offset = i * 4;
Bgra32 color = this.Palette[this.Pixels[i]]; Bgra32 color = this.Palette[Math.Min(palletCount, this.Pixels[i])];
bgraPixels[offset + 0] = color.B; bgraPixels[offset + 0] = color.B;
bgraPixels[offset + 1] = color.G; bgraPixels[offset + 1] = color.G;
bgraPixels[offset + 2] = color.R; bgraPixels[offset + 2] = color.R;

2
src/ImageProcessor/project.lock.json.REMOVED.git-id

@ -1 +1 @@
b4afca3213a5d2714e409729a1ef2622b62a5bca 869b4da8e5d4467a9e8fe7af0413a80080cd8f15

18
tests/ImageProcessor.Tests/Colors/ColorConversionTests.cs

@ -36,23 +36,23 @@ namespace ImageProcessor.Tests
Color color = new Color(1, 1, 1); Color color = new Color(1, 1, 1);
YCbCr yCbCr = color; YCbCr yCbCr = color;
Assert.Equal(255, yCbCr.Y); Assert.Equal(255, yCbCr.Y, 0);
Assert.Equal(128, yCbCr.Cb); Assert.Equal(128, yCbCr.Cb, 0);
Assert.Equal(128, yCbCr.Cr); Assert.Equal(128, yCbCr.Cr, 0);
// Black // Black
Color color2 = new Color(0, 0, 0); Color color2 = new Color(0, 0, 0);
YCbCr yCbCr2 = color2; YCbCr yCbCr2 = color2;
Assert.Equal(0, yCbCr2.Y); Assert.Equal(0, yCbCr2.Y, 0);
Assert.Equal(128, yCbCr2.Cb); Assert.Equal(128, yCbCr2.Cb, 0);
Assert.Equal(128, yCbCr2.Cr); Assert.Equal(128, yCbCr2.Cr, 0);
// Grey // Grey
Color color3 = new Color(.5f, .5f, .5f); Color color3 = new Color(.5f, .5f, .5f);
YCbCr yCbCr3 = color3; YCbCr yCbCr3 = color3;
Assert.Equal(128, yCbCr3.Y); Assert.Equal(128, yCbCr3.Y, 0);
Assert.Equal(128, yCbCr3.Cb); Assert.Equal(128, yCbCr3.Cb, 0);
Assert.Equal(128, yCbCr3.Cr); Assert.Equal(128, yCbCr3.Cr, 0);
} }
/// <summary> /// <summary>

8
tests/ImageProcessor.Tests/Processors/Formats/EncoderDecoderTests.cs

@ -12,12 +12,12 @@
[Fact] [Fact]
public void DecodeThenEncodeImageFromStreamShouldSucceed() public void DecodeThenEncodeImageFromStreamShouldSucceed()
{ {
if (!Directory.Exists("Encoded")) if (!Directory.Exists("TestOutput/Encoded"))
{ {
Directory.CreateDirectory("Encoded"); Directory.CreateDirectory("TestOutput/Encoded");
} }
foreach (FileInfo file in new DirectoryInfo("Encoded").GetFiles()) foreach (FileInfo file in new DirectoryInfo("TestOutput/Encoded").GetFiles())
{ {
file.Delete(); file.Delete();
} }
@ -29,7 +29,7 @@
Stopwatch watch = Stopwatch.StartNew(); Stopwatch watch = Stopwatch.StartNew();
Image image = new Image(stream); Image image = new Image(stream);
string encodedFilename = "Encoded/" + Path.GetFileName(file); string encodedFilename = "TestOutput/Encoded/" + Path.GetFileName(file);
using (FileStream output = File.OpenWrite(encodedFilename)) using (FileStream output = File.OpenWrite(encodedFilename))
{ {

32
tests/ImageProcessor.Tests/Processors/ProcessorTestBase.cs

@ -19,25 +19,25 @@ namespace ImageProcessor.Tests
/// </summary> /// </summary>
public static readonly List<string> Files = new List<string> public static readonly List<string> Files = new List<string>
{ {
//"../../TestImages/Formats/Jpg/Backdrop.jpg", //"TestImages/Formats/Jpg/Backdrop.jpg",
//"../../TestImages/Formats/Jpg/Calliphora.jpg", //"TestImages/Formats/Jpg/Calliphora.jpg",
"TestImages/Formats/Jpg/china.jpg", "TestImages/Formats/Jpg/china.jpg",
//"../../TestImages/Formats/Jpg/ant.jpg", //"TestImages/Formats/Jpg/ant.jpg",
//"../../TestImages/Formats/Jpg/parachute.jpg", //"TestImages/Formats/Jpg/parachute.jpg",
//"../../TestImages/Formats/Jpg/lomo.jpg", //"TestImages/Formats/Jpg/lomo.jpg",
//"../../TestImages/Formats/Jpg/shaftesbury.jpg", //"TestImages/Formats/Jpg/shaftesbury.jpg",
//"../../TestImages/Formats/Jpg/gamma_dalai_lama_gray.jpg", //"TestImages/Formats/Jpg/gamma_dalai_lama_gray.jpg",
//"../../TestImages/Formats/Jpg/greyscale.jpg", //"TestImages/Formats/Jpg/greyscale.jpg",
//"../../TestImages/Formats/Bmp/Car.bmp", //"TestImages/Formats/Bmp/Car.bmp",
"TestImages/Formats/Png/cballs.png", "TestImages/Formats/Png/cballs.png",
//"../../TestImages/Formats/Png/cmyk.png", //"TestImages/Formats/Png/cmyk.png",
//"../../TestImages/Formats/Png/gamma-1.0-or-2.2.png", //"TestImages/Formats/Png/gamma-1.0-or-2.2.png",
"TestImages/Formats/Png/splash.png", "TestImages/Formats/Png/splash.png",
//"../../TestImages/Formats/Gif/leaf.gif", "TestImages/Formats/Gif/leaf.gif",
//"../../TestImages/Formats/Gif/ben2.gif", //"TestImages/Formats/Gif/ben2.gif",
//"../../TestImages/Formats/Gif/rings.gif", //"TestImages/Formats/Gif/rings.gif",
//"../../TestImages/Formats/Gif/ani2.gif", //"TestImages/Formats/Gif/ani2.gif",
//"../../TestImages/Formats/Gif/giphy.gif" //"TestImages/Formats/Gif/giphy.gif"
}; };
} }
} }

12
tests/ImageProcessor.Tests/Processors/Samplers/SamplerTests.cs

@ -32,9 +32,9 @@ namespace ImageProcessor.Tests
[MemberData("Samplers")] [MemberData("Samplers")]
public void ImageShouldResize(string name, IResampler sampler) public void ImageShouldResize(string name, IResampler sampler)
{ {
if (!Directory.Exists("Resized")) if (!Directory.Exists("TestOutput/Resized"))
{ {
Directory.CreateDirectory("Resized"); Directory.CreateDirectory("TestOutput/Resized");
} }
foreach (string file in Files) foreach (string file in Files)
@ -44,7 +44,7 @@ namespace ImageProcessor.Tests
Stopwatch watch = Stopwatch.StartNew(); Stopwatch watch = Stopwatch.StartNew();
Image image = new Image(stream); Image image = new Image(stream);
string filename = Path.GetFileNameWithoutExtension(file) + "-" + name + Path.GetExtension(file); string filename = Path.GetFileNameWithoutExtension(file) + "-" + name + Path.GetExtension(file);
using (FileStream output = File.OpenWrite($"Resized/{filename}")) using (FileStream output = File.OpenWrite($"TestOutput/Resized/{filename}"))
{ {
image.Resize(image.Width / 2, image.Height / 2, sampler).Save(output); image.Resize(image.Width / 2, image.Height / 2, sampler).Save(output);
} }
@ -57,9 +57,9 @@ namespace ImageProcessor.Tests
[Fact] [Fact]
public void ImageShouldCrop() public void ImageShouldCrop()
{ {
if (!Directory.Exists("Cropped")) if (!Directory.Exists("TestOutput/Cropped"))
{ {
Directory.CreateDirectory("Cropped"); Directory.CreateDirectory("TestOutput/Cropped");
} }
foreach (string file in Files) foreach (string file in Files)
@ -68,7 +68,7 @@ namespace ImageProcessor.Tests
{ {
Image image = new Image(stream); Image image = new Image(stream);
string filename = Path.GetFileNameWithoutExtension(file) + "-Cropped" + Path.GetExtension(file); string filename = Path.GetFileNameWithoutExtension(file) + "-Cropped" + Path.GetExtension(file);
using (FileStream output = File.OpenWrite($"Cropped/{filename}")) using (FileStream output = File.OpenWrite($"TestOutput/Cropped/{filename}"))
{ {
image.Crop(image.Width / 2, image.Height / 2).Save(output); image.Crop(image.Width / 2, image.Height / 2).Save(output);
} }

4
tests/ImageProcessor.Tests/project.json

@ -20,8 +20,8 @@
"ImageProcessor": "3.0.0-*", "ImageProcessor": "3.0.0-*",
"Microsoft.NETCore": "5.0.1-beta-23409", "Microsoft.NETCore": "5.0.1-beta-23409",
"Microsoft.NETCore.Platforms": "1.0.1-beta-23409", "Microsoft.NETCore.Platforms": "1.0.1-beta-23409",
"xunit": "2.1.0", "xunit": "2.1.0-*",
"xunit.runner.dnx": "2.1.0-beta6-build191" "xunit.runner.dnx": "2.1.0-*"
}, },
"commands": { "commands": {
"test": "xunit.runner.dnx" "test": "xunit.runner.dnx"

2
tests/ImageProcessor.Tests/project.lock.json.REMOVED.git-id

@ -1 +1 @@
986564cced9c1356c73f345d4f605395896bf156 e6a19da5fae2d14f8371b848e58732e830f6e7d7
Loading…
Cancel
Save