Updated dotnet core 3.0 version, which solves some weird test issues. Fixed some small issues with tests, not all are fixed.

This commit is contained in:
Robin 2019-05-24 08:50:42 +02:00
commit 8bc684a1c4
No known key found for this signature in database
GPG key ID: CBBB6557491B1140
13 changed files with 83 additions and 41 deletions

View file

@ -15,7 +15,7 @@ steps:
- task: DotNetCoreInstaller@0
displayName: 'Install .NET Core SDK 3.0'
inputs:
version: '3.0.100-preview6-011809'
version: '3.0.100-preview6-012067'
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 5.0.0'

View file

@ -54,7 +54,7 @@
</PropertyGroup>
<ItemGroup Condition="!$(MSBuildProjectName.Contains('Tests')) And $(MSBuildProjectName.StartsWith('Greenshot'))">
<PackageReference Include="Nerdbank.GitVersioning" Version="2.3.138">
<PackageReference Include="Nerdbank.GitVersioning" Version="2.3.151">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>

View file

@ -24,7 +24,7 @@
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.26" />
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.26" />
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.28" />
<PackageReference Include="CliWrap" Version="2.2.1" />
<PackageReference Include="CliWrap" Version="2.2.2" />
<PackageReference Include="Fody" Version="4.2.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>

View file

@ -105,7 +105,7 @@ namespace Greenshot.Addons
.AutoActivate()
.OnActivated(args =>
{
BitmapHelper.StreamConverters["greenshot"] = args.Instance;
BitmapHelper.RegisterFormatReader(args.Instance);
});
base.Load(builder);

View file

@ -160,7 +160,7 @@ namespace Greenshot.Core.Extensions
// Calculate the location of the temp form
var windowRectangle = interopWindow.GetInfo().Bounds;
var formLocation = windowRectangle.Location;
var borderSize = new Size();
var borderSize = Size.Empty;
var doesCaptureFit = false;
if (!interopWindow.IsMaximized())
{

View file

@ -50,11 +50,33 @@ namespace Greenshot.Gfx
/// </summary>
public static IDictionary<string, IImageFormatReader> StreamConverters { get; } = new Dictionary<string, IImageFormatReader>(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Make sure the image is orientated correctly
/// </summary>
/// <param name="image">Image</param>
public static void Orientate(this Image image)
/// <summary>
/// Register a IImageFormatReader by type
/// </summary>
/// <typeparam name="TFormatReader">Type which extends IImageFormatReader</typeparam>
public static void RegisterFormatReader<TFormatReader>() where TFormatReader : IImageFormatReader, new()
{
RegisterFormatReader(new TFormatReader());
}
/// <summary>
/// Register an instance of an IImageFormatReader
/// </summary>
/// <typeparam name="TFormatReader">Type which extends IImageFormatReader</typeparam>
/// <param name="formatReader">IImageFormatReader</param>
public static void RegisterFormatReader<TFormatReader>(TFormatReader formatReader) where TFormatReader : IImageFormatReader
{
foreach (var extension in formatReader.SupportedFormats)
{
StreamConverters[extension] = formatReader;
}
}
/// <summary>
/// Make sure the image is orientated correctly
/// </summary>
/// <param name="image">Image</param>
public static void Orientate(this Image image)
{
try
{

View file

@ -27,14 +27,6 @@ namespace Greenshot.Gfx
/// <inheritdoc />
public class GfxModule : AddonModule
{
private void Register(IImageFormatReader reader)
{
foreach(var extension in reader.SupportedFormats)
{
BitmapHelper.StreamConverters[extension] = reader;
}
}
/// <inheritdoc/>
protected override void Load(ContainerBuilder builder)
{
@ -46,7 +38,7 @@ namespace Greenshot.Gfx
.AutoActivate()
.OnActivated(args =>
{
Register(args.Instance);
BitmapHelper.RegisterFormatReader(args.Instance);
});
builder
@ -56,7 +48,7 @@ namespace Greenshot.Gfx
.AutoActivate()
.OnActivated(args =>
{
Register(args.Instance);
BitmapHelper.RegisterFormatReader(args.Instance);
});
builder
@ -66,7 +58,7 @@ namespace Greenshot.Gfx
.AutoActivate()
.OnActivated(args =>
{
Register(args.Instance);
BitmapHelper.RegisterFormatReader(args.Instance);
});
base.Load(builder);

View file

@ -15,7 +15,7 @@
<Version>2.4.3</Version>
</PackageReference>
<PackageReference Include="System.Memory">
<Version>4.5.2</Version>
<Version>4.5.3</Version>
</PackageReference>
</ItemGroup>
</Project>

View file

@ -1,4 +1,23 @@
using System.Drawing;
// Greenshot - a free and open source screenshot tool
// Copyright (C) 2007-2019 Thomas Braun, Jens Klingen, Robin Krom
//
// For more information see: http://getgreenshot.org/
// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 1 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System.Drawing;
using System.Drawing.Imaging;
using BenchmarkDotNet.Attributes;
using Greenshot.Gfx;
@ -35,7 +54,7 @@ namespace Greenshot.PerformanceTests
}
//[Benchmark]
[Benchmark]
[Arguments(PixelFormat.Format24bppRgb)]
[Arguments(PixelFormat.Format32bppRgb)]
[Arguments(PixelFormat.Format32bppArgb)]
@ -57,9 +76,12 @@ namespace Greenshot.PerformanceTests
}
[Benchmark]
public void Blur_FastBitmap()
[Arguments(PixelFormat.Format24bppRgb)]
[Arguments(PixelFormat.Format32bppRgb)]
[Arguments(PixelFormat.Format32bppArgb)]
public void Blur_FastBitmap(PixelFormat pixelFormat)
{
using (var bitmap = BitmapFactory.CreateEmpty(400, 400, PixelFormat.Format32bppRgb, Color.White))
using (var bitmap = BitmapFactory.CreateEmpty(400, 400, pixelFormat, Color.White))
{
using (var graphics = Graphics.FromImage(bitmap.NativeBitmap))
using (var pen = new SolidBrush(Color.Blue))
@ -101,37 +123,37 @@ namespace Greenshot.PerformanceTests
}
}
//[Benchmark]
[Benchmark]
public void Scale2x_FastBitmap()
{
ScaleX.Scale2X(_unmanagedTestBitmap).Dispose();
}
//[Benchmark]
[Benchmark]
public void Scale2x_Unmanaged()
{
_unmanagedTestBitmap.Scale2X().Dispose();
}
//[Benchmark]
[Benchmark]
public void Scale2x_Unmanaged_Reference()
{
_unmanagedTestBitmap.Scale2XReference().Dispose();
}
//[Benchmark]
[Benchmark]
public void Scale3x_FastBitmap()
{
ScaleX.Scale3X(_unmanagedTestBitmap).Dispose();
}
//[Benchmark]
[Benchmark]
public void Scale3x_Unmanaged()
{
_unmanagedTestBitmap.Scale3X().Dispose();
}
//[Benchmark]
[Benchmark]
public void Scale3x_Unmanaged_Reference()
{
_unmanagedTestBitmap.Scale3XReference().Dispose();

View file

@ -33,7 +33,7 @@
<PackageReference Include="CommandLineParser" Version="2.5.0" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="2.1.0" />
<PackageReference Include="SharpAvi" Version="2.1.1" />
<PackageReference Include="System.Memory" Version="4.5.2" />
<PackageReference Include="System.Memory" Version="4.5.3" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.2" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
</ItemGroup>

View file

@ -121,13 +121,13 @@ namespace Greenshot.Tests
var template = new SimpleTemplate();
var bitmapSource = template.Apply(capture).ToBitmapSource();
Assert.Equal(bounds.Size, bitmapSource.Size());
using (var outputStream = bitmapSource.ToStream(OutputFormats.png))
using (var fileStream = File.Create("Test_CaptureFlow_DwmWindowSource.png"))
{
outputStream.Seek(0, SeekOrigin.Begin);
await outputStream.CopyToAsync(fileStream);
}
Assert.Equal(bounds.Size, bitmapSource.Size());
}

View file

@ -20,19 +20,19 @@
<ItemGroup>
<None Include="TestFiles\scroll0.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="TestFiles\scroll105.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="TestFiles\scroll124.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="TestFiles\scroll35.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="TestFiles\scroll70.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="TestFiles\project-feed.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

View file

@ -19,6 +19,7 @@
using System.Drawing.Imaging;
using Greenshot.Gfx;
using Greenshot.Gfx.Formats;
using Greenshot.Gfx.Stitching;
using Xunit;
@ -26,6 +27,11 @@ namespace Greenshot.Tests
{
public class StitchTests
{
public StitchTests()
{
BitmapHelper.RegisterFormatReader<GenericGdiFormatReader>();
}
[Fact]
public void BitmapStitcher_Default()
{