mirror of https://github.com/SixLabors/ImageSharp
3 changed files with 95 additions and 19 deletions
@ -1,20 +1,30 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
using System; |
using SixLabors.ImageSharp.Processing; |
||||
using SixLabors.ImageSharp.PixelFormats; |
using SixLabors.ImageSharp.Processing.Processors; |
||||
|
|
||||
using Xunit; |
using Xunit; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Tests.Processing.Transforms |
namespace SixLabors.ImageSharp.Tests.Processing.Transforms |
||||
{ |
{ |
||||
|
|
||||
|
|
||||
public class PadTest : BaseImageOperationsExtensionTest |
public class PadTest : BaseImageOperationsExtensionTest |
||||
{ |
{ |
||||
#pragma warning disable xUnit1004 // Test methods should not be skipped
|
[Fact] |
||||
[Fact(Skip = "Skip this is a helper around resize, skip until resize can be refactord")] |
public void PadWidthHeightResizeProcessorWithCorrectOptionsSet() |
||||
#pragma warning restore xUnit1004 // Test methods should not be skipped
|
|
||||
public void Pad_width_height_ResizeProcessorWithCorrectOPtionsSet() |
|
||||
{ |
{ |
||||
throw new NotImplementedException("Write test here"); |
int width = 500; |
||||
|
int height = 565; |
||||
|
IResampler sampler = KnownResamplers.NearestNeighbor; |
||||
|
|
||||
|
this.operations.Pad(width, height); |
||||
|
ResizeProcessor<Rgba32> resizeProcessor = this.Verify<ResizeProcessor<Rgba32>>(); |
||||
|
|
||||
|
Assert.Equal(width, resizeProcessor.Width); |
||||
|
Assert.Equal(height, resizeProcessor.Height); |
||||
|
Assert.Equal(sampler, resizeProcessor.Sampler); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -1,23 +1,91 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
using System; |
|
||||
using SixLabors.ImageSharp.PixelFormats; |
|
||||
using SixLabors.ImageSharp.Processing; |
using SixLabors.ImageSharp.Processing; |
||||
using SixLabors.Primitives; |
using SixLabors.Primitives; |
||||
using Xunit; |
using Xunit; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Tests.Processing.Transforms |
namespace SixLabors.ImageSharp.Tests.Processing.Transforms |
||||
{ |
{ |
||||
|
using SixLabors.ImageSharp.Processing.Processors; |
||||
|
|
||||
public class ResizeTests : BaseImageOperationsExtensionTest |
public class ResizeTests : BaseImageOperationsExtensionTest |
||||
{ |
{ |
||||
#pragma warning disable xUnit1004 // Test methods should not be skipped
|
[Fact] |
||||
[Fact(Skip = "Skip resize tests as they need refactoring to be simpler and just pass data into the resize processor.")] |
public void ResizeWidthAndHeight() |
||||
#pragma warning restore xUnit1004 // Test methods should not be skipped
|
{ |
||||
public void TestMissing() |
int width = 50; |
||||
|
int height = 100; |
||||
|
this.operations.Resize(width, height); |
||||
|
ResizeProcessor<Rgba32> resizeProcessor = this.Verify<ResizeProcessor<Rgba32>>(); |
||||
|
|
||||
|
Assert.Equal(width, resizeProcessor.Width); |
||||
|
Assert.Equal(height, resizeProcessor.Height); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void ResizeWidthAndHeightAndSampler() |
||||
|
{ |
||||
|
int width = 50; |
||||
|
int height = 100; |
||||
|
IResampler sampler = KnownResamplers.Lanczos3; |
||||
|
this.operations.Resize(width, height, sampler); |
||||
|
ResizeProcessor<Rgba32> resizeProcessor = this.Verify<ResizeProcessor<Rgba32>>(); |
||||
|
|
||||
|
Assert.Equal(width, resizeProcessor.Width); |
||||
|
Assert.Equal(height, resizeProcessor.Height); |
||||
|
Assert.Equal(sampler, resizeProcessor.Sampler); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void ResizeWidthAndHeightAndSamplerAndCompand() |
||||
{ |
{ |
||||
//
|
int width = 50; |
||||
throw new NotImplementedException("Write test here"); |
int height = 100; |
||||
|
IResampler sampler = KnownResamplers.Lanczos3; |
||||
|
bool compand = true; |
||||
|
|
||||
|
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||
|
this.operations.Resize(width, height, sampler, compand); |
||||
|
ResizeProcessor<Rgba32> resizeProcessor = this.Verify<ResizeProcessor<Rgba32>>(); |
||||
|
|
||||
|
Assert.Equal(width, resizeProcessor.Width); |
||||
|
Assert.Equal(height, resizeProcessor.Height); |
||||
|
Assert.Equal(sampler, resizeProcessor.Sampler); |
||||
|
Assert.Equal(compand, resizeProcessor.Compand); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void ResizeWithOptions() |
||||
|
{ |
||||
|
int width = 50; |
||||
|
int height = 100; |
||||
|
IResampler sampler = KnownResamplers.Lanczos3; |
||||
|
bool compand = true; |
||||
|
ResizeMode mode = ResizeMode.Stretch; |
||||
|
|
||||
|
var resizeOptions = new ResizeOptions |
||||
|
{ |
||||
|
Size = new Size(width, height), |
||||
|
Sampler = sampler, |
||||
|
Compand = compand, |
||||
|
Mode = mode |
||||
|
}; |
||||
|
|
||||
|
this.operations.Resize(resizeOptions); |
||||
|
ResizeProcessor<Rgba32> resizeProcessor = this.Verify<ResizeProcessor<Rgba32>>(); |
||||
|
|
||||
|
Assert.Equal(width, resizeProcessor.Width); |
||||
|
Assert.Equal(height, resizeProcessor.Height); |
||||
|
Assert.Equal(sampler, resizeProcessor.Sampler); |
||||
|
Assert.Equal(compand, resizeProcessor.Compand); |
||||
|
|
||||
|
// Ensure options are not altered.
|
||||
|
Assert.Equal(width, resizeOptions.Size.Width); |
||||
|
Assert.Equal(height, resizeOptions.Size.Height); |
||||
|
Assert.Equal(sampler, resizeOptions.Sampler); |
||||
|
Assert.Equal(compand, resizeOptions.Compand); |
||||
|
Assert.Equal(mode, resizeOptions.Mode); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
Loading…
Reference in new issue