Browse Source

Merge branch 'master' into fix-fwd-fillmode

pull/2197/head
Jumar Macato 7 years ago
committed by GitHub
parent
commit
ee836b1ce9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      azure-pipelines.yml
  2. 5
      build/NetFX.props
  3. 8
      build/UnitTests.NetFX.props
  4. 1
      build/xunit.runner.mono.json
  5. 58
      nukebuild/Build.cs
  6. 1
      src/Avalonia.Animation/AnimatorKeyFrame.cs
  7. 2
      src/Avalonia.Animation/IterationCount.cs
  8. 4
      src/Avalonia.Base/Collections/AvaloniaDictionary.cs
  9. 2
      src/Avalonia.Base/Collections/AvaloniaList.cs
  10. 1
      src/Avalonia.Base/Platform/IAssetLoader.cs
  11. 2
      src/Avalonia.Controls/Calendar/DatePicker.cs
  12. 4
      src/Avalonia.Controls/GridLength.cs
  13. 2
      src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs
  14. 2
      src/Avalonia.Styling/Styling/Setter.cs
  15. 1
      src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs
  16. 1
      src/Skia/Avalonia.Skia/WriteableBitmapImpl.cs
  17. 6
      tests/Avalonia.Animation.UnitTests/Avalonia.Animation.UnitTests.csproj
  18. 4
      tests/Avalonia.Base.UnitTests/Avalonia.Base.UnitTests.csproj
  19. 7
      tests/Avalonia.Base.UnitTests/Data/Core/ExpressionObserverTests_Property.cs
  20. 24
      tests/Avalonia.Base.UnitTests/Data/Core/Plugins/DataAnnotationsValidationPluginTests.cs
  21. 6
      tests/Avalonia.Controls.UnitTests/Avalonia.Controls.UnitTests.csproj
  22. 53
      tests/Avalonia.Controls.UnitTests/GridLayoutTests.cs
  23. 6
      tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj
  24. 5
      tests/Avalonia.Interactivity.UnitTests/Avalonia.Interactivity.UnitTests.csproj
  25. 6
      tests/Avalonia.Markup.UnitTests/Avalonia.Markup.UnitTests.csproj
  26. 6
      tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj
  27. 6
      tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj
  28. 7
      tests/Avalonia.Visuals.UnitTests/Avalonia.Visuals.UnitTests.csproj

7
azure-pipelines.yml

@ -38,6 +38,13 @@ jobs:
inputs: inputs:
version: '2.1.403' version: '2.1.403'
- task: CmdLine@2
displayName: 'Install Mono 5.18'
inputs:
script: |
curl -o ./mono.pkg https://download.mono-project.com/archive/5.18.0/macos-10-universal/MonoFramework-MDK-5.18.0.225.macos10.xamarin.universal.pkg
sudo installer -verbose -pkg ./mono.pkg -target /
- task: Xcode@5 - task: Xcode@5
inputs: inputs:
actions: 'build' actions: 'build'

5
build/NetFX.props

@ -3,4 +3,9 @@
<FrameworkPathOverride>/usr/lib/mono/4.6.1-api</FrameworkPathOverride> <FrameworkPathOverride>/usr/lib/mono/4.6.1-api</FrameworkPathOverride>
<FrameworkPathOverride Condition="$([MSBuild]::IsOsPlatform('OSX'))">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.6.1-api</FrameworkPathOverride> <FrameworkPathOverride Condition="$([MSBuild]::IsOsPlatform('OSX'))">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.6.1-api</FrameworkPathOverride>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net47' and '$(OS)' == 'Unix' ">
<FrameworkPathOverride>/usr/lib/mono/4.7-api/</FrameworkPathOverride>
<FrameworkPathOverride Condition="$([MSBuild]::IsOsPlatform('OSX'))">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.7-api</FrameworkPathOverride>
</PropertyGroup>
</Project> </Project>

8
build/UnitTests.NetFX.props

@ -0,0 +1,8 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)/NetFX.props" />
<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
<Content Include="$(MSBuildThisFileDirectory)/xunit.runner.mono.json" Link="xunit.runner.json" >
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

1
build/xunit.runner.mono.json

@ -0,0 +1 @@
{ "appDomain": "denied" }

58
nukebuild/Build.cs

@ -5,6 +5,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using System.Xml.Linq;
using Nuke.Common; using Nuke.Common;
using Nuke.Common.Git; using Nuke.Common.Git;
using Nuke.Common.ProjectModel; using Nuke.Common.ProjectModel;
@ -56,6 +57,17 @@ partial class Build : NukeBuild
Information("IsReleasable: " + Parameters.IsReleasable); Information("IsReleasable: " + Parameters.IsReleasable);
Information("IsMyGetRelease: " + Parameters.IsMyGetRelease); Information("IsMyGetRelease: " + Parameters.IsMyGetRelease);
Information("IsNuGetRelease: " + Parameters.IsNuGetRelease); Information("IsNuGetRelease: " + Parameters.IsNuGetRelease);
void ExecWait(string preamble, string command, string args)
{
Console.WriteLine(preamble);
Process.Start(new ProcessStartInfo(command, args) {UseShellExecute = false}).WaitForExit();
}
ExecWait("dotnet version:", "dotnet", "--version");
if (Parameters.IsRunningOnUnix)
ExecWait("Mono version:", "mono", "--version");
} }
Target Clean => _ => _.Executes(() => Target Clean => _ => _.Executes(() =>
@ -92,16 +104,24 @@ partial class Build : NukeBuild
); );
}); });
void RunCoreTest(string project, bool coreOnly = false) void RunCoreTest(string project)
{ {
if(!project.EndsWith(".csproj")) if(!project.EndsWith(".csproj"))
project = System.IO.Path.Combine(project, System.IO.Path.GetFileName(project)+".csproj"); project = System.IO.Path.Combine(project, System.IO.Path.GetFileName(project)+".csproj");
Information("Running tests from " + project); Information("Running tests from " + project);
var frameworks = new List<string>(){"netcoreapp2.0"}; XDocument xdoc;
using (var s = File.OpenRead(project))
xdoc = XDocument.Load(s);
List<string> frameworks = null;
var targets = xdoc.Root.Descendants("TargetFrameworks").FirstOrDefault();
if (targets != null)
frameworks = targets.Value.Split(';').Where(f => !string.IsNullOrWhiteSpace(f)).ToList();
else
frameworks = new List<string> {xdoc.Root.Descendants("TargetFramework").First().Value};
foreach(var fw in frameworks) foreach(var fw in frameworks)
{ {
if(!fw.StartsWith("netcoreapp") && coreOnly)
continue;
Information("Running for " + fw); Information("Running for " + fw);
DotNetTest(c => DotNetTest(c =>
{ {
@ -124,18 +144,18 @@ partial class Build : NukeBuild
.DependsOn(Compile) .DependsOn(Compile)
.Executes(() => .Executes(() =>
{ {
RunCoreTest("./tests/Avalonia.Animation.UnitTests", false); RunCoreTest("./tests/Avalonia.Animation.UnitTests");
RunCoreTest("./tests/Avalonia.Base.UnitTests", false); RunCoreTest("./tests/Avalonia.Base.UnitTests");
RunCoreTest("./tests/Avalonia.Controls.UnitTests", false); RunCoreTest("./tests/Avalonia.Controls.UnitTests");
RunCoreTest("./tests/Avalonia.Input.UnitTests", false); RunCoreTest("./tests/Avalonia.Input.UnitTests");
RunCoreTest("./tests/Avalonia.Interactivity.UnitTests", false); RunCoreTest("./tests/Avalonia.Interactivity.UnitTests");
RunCoreTest("./tests/Avalonia.Layout.UnitTests", false); RunCoreTest("./tests/Avalonia.Layout.UnitTests");
RunCoreTest("./tests/Avalonia.Markup.UnitTests", false); RunCoreTest("./tests/Avalonia.Markup.UnitTests");
RunCoreTest("./tests/Avalonia.Markup.Xaml.UnitTests", false); RunCoreTest("./tests/Avalonia.Markup.Xaml.UnitTests");
RunCoreTest("./tests/Avalonia.Styling.UnitTests", false); RunCoreTest("./tests/Avalonia.Styling.UnitTests");
RunCoreTest("./tests/Avalonia.Visuals.UnitTests", false); RunCoreTest("./tests/Avalonia.Visuals.UnitTests");
RunCoreTest("./tests/Avalonia.Skia.UnitTests", false); RunCoreTest("./tests/Avalonia.Skia.UnitTests");
RunCoreTest("./tests/Avalonia.ReactiveUI.UnitTests", false); RunCoreTest("./tests/Avalonia.ReactiveUI.UnitTests");
}); });
Target RunRenderTests => _ => _ Target RunRenderTests => _ => _
@ -143,9 +163,9 @@ partial class Build : NukeBuild
.DependsOn(Compile) .DependsOn(Compile)
.Executes(() => .Executes(() =>
{ {
RunCoreTest("./tests/Avalonia.Skia.RenderTests/Avalonia.Skia.RenderTests.csproj", true); RunCoreTest("./tests/Avalonia.Skia.RenderTests/Avalonia.Skia.RenderTests.csproj");
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
RunCoreTest("./tests/Avalonia.Direct2D1.RenderTests/Avalonia.Direct2D1.RenderTests.csproj", true); RunCoreTest("./tests/Avalonia.Direct2D1.RenderTests/Avalonia.Direct2D1.RenderTests.csproj");
}); });
Target RunDesignerTests => _ => _ Target RunDesignerTests => _ => _
@ -153,7 +173,7 @@ partial class Build : NukeBuild
.DependsOn(Compile) .DependsOn(Compile)
.Executes(() => .Executes(() =>
{ {
RunCoreTest("./tests/Avalonia.DesignerSupport.Tests", false); RunCoreTest("./tests/Avalonia.DesignerSupport.Tests");
}); });
[PackageExecutable("JetBrains.dotMemoryUnit", "dotMemoryUnit.exe")] readonly Tool DotMemoryUnit; [PackageExecutable("JetBrains.dotMemoryUnit", "dotMemoryUnit.exe")] readonly Tool DotMemoryUnit;

1
src/Avalonia.Animation/AnimatorKeyFrame.cs

@ -1,5 +1,6 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using Avalonia.Animation.Animators;
using Avalonia.Data; using Avalonia.Data;
using Avalonia.Reactive; using Avalonia.Reactive;

2
src/Avalonia.Animation/IterationCount.cs

@ -44,7 +44,7 @@ namespace Avalonia.Animation
{ {
if (type > IterationType.Infinite) if (type > IterationType.Infinite)
{ {
throw new ArgumentException("Invalid value", "type"); throw new ArgumentException("Invalid value", nameof(type));
} }
_type = type; _type = type;

4
src/Avalonia.Base/Collections/AvaloniaDictionary.cs

@ -148,7 +148,7 @@ namespace Avalonia.Collections
{ {
if (_inner.TryGetValue(key, out TValue value)) if (_inner.TryGetValue(key, out TValue value))
{ {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Count")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Count)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs($"Item[{key}]")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs($"Item[{key}]"));
if (CollectionChanged != null) if (CollectionChanged != null)
@ -209,7 +209,7 @@ namespace Avalonia.Collections
private void NotifyAdd(TKey key, TValue value) private void NotifyAdd(TKey key, TValue value)
{ {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Count")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Count)));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs($"Item[{key}]")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs($"Item[{key}]"));

2
src/Avalonia.Base/Collections/AvaloniaList.cs

@ -511,7 +511,7 @@ namespace Avalonia.Collections
/// </summary> /// </summary>
private void NotifyCountChanged() private void NotifyCountChanged()
{ {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Count")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Count)));
} }
/// <summary> /// <summary>

1
src/Avalonia.Base/Platform/IAssetLoader.cs

@ -65,6 +65,7 @@ namespace Avalonia.Platform
/// Gets all assets of a folder and subfolders that match specified uri. /// Gets all assets of a folder and subfolders that match specified uri.
/// </summary> /// </summary>
/// <param name="uri">The URI.</param> /// <param name="uri">The URI.</param>
/// <param name="baseUri">The base URI.</param>
/// <returns>All matching assets as a tuple of the absolute path to the asset and the assembly containing the asset</returns> /// <returns>All matching assets as a tuple of the absolute path to the asset and the assembly containing the asset</returns>
IEnumerable<Uri> GetAssets(Uri uri, Uri baseUri); IEnumerable<Uri> GetAssets(Uri uri, Uri baseUri);
} }

2
src/Avalonia.Controls/Calendar/DatePicker.cs

@ -954,7 +954,7 @@ namespace Avalonia.Controls
} }
else else
{ {
var dateValidationError = new DatePickerDateValidationErrorEventArgs(new ArgumentOutOfRangeException("text", "SelectedDate value is not valid."), text); var dateValidationError = new DatePickerDateValidationErrorEventArgs(new ArgumentOutOfRangeException(nameof(text), "SelectedDate value is not valid."), text);
OnDateValidationError(dateValidationError); OnDateValidationError(dateValidationError);
if (dateValidationError.ThrowException) if (dateValidationError.ThrowException)

4
src/Avalonia.Controls/GridLength.cs

@ -56,12 +56,12 @@ namespace Avalonia.Controls
{ {
if (value < 0 || double.IsNaN(value) || double.IsInfinity(value)) if (value < 0 || double.IsNaN(value) || double.IsInfinity(value))
{ {
throw new ArgumentException("Invalid value", "value"); throw new ArgumentException("Invalid value", nameof(value));
} }
if (type < GridUnitType.Auto || type > GridUnitType.Star) if (type < GridUnitType.Auto || type > GridUnitType.Star)
{ {
throw new ArgumentException("Invalid value", "type"); throw new ArgumentException("Invalid value", nameof(type));
} }
_type = type; _type = type;

2
src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs

@ -487,7 +487,7 @@ namespace Avalonia.Controls
{ {
if (e == null) if (e == null)
{ {
throw new ArgumentNullException("e"); throw new ArgumentNullException(nameof(e));
} }
var handler = Spinned; var handler = Spinned;

2
src/Avalonia.Styling/Styling/Setter.cs

@ -69,7 +69,7 @@ namespace Avalonia.Styling
{ {
throw new ArgumentException( throw new ArgumentException(
"Cannot assign a control to Setter.Value. Wrap the control in a <Template>.", "Cannot assign a control to Setter.Value. Wrap the control in a <Template>.",
"value"); nameof(value));
} }
_value = value; _value = value;

1
src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs

@ -45,6 +45,7 @@ namespace Avalonia.Skia
/// <summary> /// <summary>
/// Create backing Skia surface. /// Create backing Skia surface.
/// </summary> /// </summary>
/// <param name="gpu">GPU.</param>
/// <param name="width">Width.</param> /// <param name="width">Width.</param>
/// <param name="height">Height.</param> /// <param name="height">Height.</param>
/// <param name="format">Format.</param> /// <param name="format">Format.</param>

1
src/Skia/Avalonia.Skia/WriteableBitmapImpl.cs

@ -123,6 +123,7 @@ namespace Avalonia.Skia
/// <summary> /// <summary>
/// Create framebuffer from given bitmap. /// Create framebuffer from given bitmap.
/// </summary> /// </summary>
/// <param name="parent">Parent bitmap impl.</param>
/// <param name="bitmap">Bitmap.</param> /// <param name="bitmap">Bitmap.</param>
public BitmapFramebuffer(WriteableBitmapImpl parent, SKBitmap bitmap) public BitmapFramebuffer(WriteableBitmapImpl parent, SKBitmap bitmap)
{ {

6
tests/Avalonia.Animation.UnitTests/Avalonia.Animation.UnitTests.csproj

@ -1,9 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0"> <Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;net47</TargetFrameworks>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<IsTestProject>true</IsTestProject>
</PropertyGroup> </PropertyGroup>
<Import Project="..\..\build\UnitTests.NetCore.targets" /> <Import Project="..\..\build\UnitTests.NetCore.targets" />
<Import Project="..\..\build\UnitTests.NetFX.props" />
<Import Project="..\..\build\Moq.props" /> <Import Project="..\..\build\Moq.props" />
<Import Project="..\..\build\XUnit.props" /> <Import Project="..\..\build\XUnit.props" />
<Import Project="..\..\build\Rx.props" /> <Import Project="..\..\build\Rx.props" />
@ -22,4 +24,4 @@
<ItemGroup> <ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup> </ItemGroup>
</Project> </Project>

4
tests/Avalonia.Base.UnitTests/Avalonia.Base.UnitTests.csproj

@ -1,9 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0"> <Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;net47</TargetFrameworks>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<IsTestProject>true</IsTestProject>
</PropertyGroup> </PropertyGroup>
<Import Project="..\..\build\UnitTests.NetCore.targets" /> <Import Project="..\..\build\UnitTests.NetCore.targets" />
<Import Project="..\..\build\UnitTests.NetFX.props" />
<Import Project="..\..\build\Moq.props" /> <Import Project="..\..\build\Moq.props" />
<Import Project="..\..\build\XUnit.props" /> <Import Project="..\..\build\XUnit.props" />
<Import Project="..\..\build\Rx.props" /> <Import Project="..\..\build\Rx.props" />

7
tests/Avalonia.Base.UnitTests/Data/Core/ExpressionObserverTests_Property.cs

@ -558,7 +558,12 @@ namespace Avalonia.Base.UnitTests.Data.Core
var result = run(); var result = run();
result.Item1.Subscribe(x => { }); result.Item1.Subscribe(x => { });
GC.Collect(); // Mono trickery
GC.Collect(2);
GC.WaitForPendingFinalizers();
GC.WaitForPendingFinalizers();
GC.Collect(2);
Assert.Null(result.Item2.Target); Assert.Null(result.Item2.Target);
} }

24
tests/Avalonia.Base.UnitTests/Data/Core/Plugins/DataAnnotationsValidationPluginTests.cs

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq;
using Avalonia.Data; using Avalonia.Data;
using Avalonia.Data.Core.Plugins; using Avalonia.Data.Core.Plugins;
using Avalonia.UnitTests; using Avalonia.UnitTests;
@ -86,17 +87,18 @@ namespace Avalonia.Markup.UnitTests.Data.Plugins
validator.SetValue("123456", BindingPriority.LocalValue); validator.SetValue("123456", BindingPriority.LocalValue);
validator.SetValue("abcdefghijklm", BindingPriority.LocalValue); validator.SetValue("abcdefghijklm", BindingPriority.LocalValue);
Assert.Equal(new[] Assert.Equal(3, result.Count);
{ Assert.Equal(new BindingNotification(null), result[0]);
new BindingNotification(null), Assert.Equal(new BindingNotification("123456"), result[1]);
new BindingNotification("123456"), var errorResult = (BindingNotification)result[2];
new BindingNotification( Assert.Equal(BindingErrorType.DataValidationError, errorResult.ErrorType);
new AggregateException( Assert.Equal("abcdefghijklm", errorResult.Value);
new ValidationException("The PhoneNumber field is not a valid phone number."), var exceptions = ((AggregateException)(errorResult.Error)).InnerExceptions;
new ValidationException("The field PhoneNumber must be a string or array type with a maximum length of '10'.")), Assert.True(exceptions.Any(ex =>
BindingErrorType.DataValidationError, ex.Message.Contains("The PhoneNumber field is not a valid phone number.")));
"abcdefghijklm"), Assert.True(exceptions.Any(ex =>
}, result); ex.Message.Contains("The field PhoneNumber must be a string or array type with a maximum length of '10'.")));
} }
private class Data private class Data

6
tests/Avalonia.Controls.UnitTests/Avalonia.Controls.UnitTests.csproj

@ -1,10 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0"> <Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;net47</TargetFrameworks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<IsTestProject>true</IsTestProject>
</PropertyGroup> </PropertyGroup>
<Import Project="..\..\build\UnitTests.NetCore.targets" /> <Import Project="..\..\build\UnitTests.NetCore.targets" />
<Import Project="..\..\build\UnitTests.NetFX.props" />
<Import Project="..\..\build\Moq.props" /> <Import Project="..\..\build\Moq.props" />
<Import Project="..\..\build\XUnit.props" /> <Import Project="..\..\build\XUnit.props" />
<Import Project="..\..\build\Rx.props" /> <Import Project="..\..\build\Rx.props" />
@ -26,4 +28,4 @@
<ItemGroup> <ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup> </ItemGroup>
</Project> </Project>

53
tests/Avalonia.Controls.UnitTests/GridLayoutTests.cs

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using Avalonia.Controls.Utils; using Avalonia.Controls.Utils;
@ -16,7 +17,7 @@ namespace Avalonia.Controls.UnitTests
[InlineData("100, 200, 300", 600d, 600d, new[] { 100d, 200d, 300d })] [InlineData("100, 200, 300", 600d, 600d, new[] { 100d, 200d, 300d })]
[InlineData("100, 200, 300", 400d, 400d, new[] { 100d, 200d, 100d })] [InlineData("100, 200, 300", 400d, 400d, new[] { 100d, 200d, 100d })]
public void MeasureArrange_AllPixelLength_Correct(string length, double containerLength, public void MeasureArrange_AllPixelLength_Correct(string length, double containerLength,
double expectedDesiredLength, IList<double> expectedLengthList) double expectedDesiredLength, IList expectedLengthList)
{ {
TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList); TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList);
} }
@ -25,7 +26,7 @@ namespace Avalonia.Controls.UnitTests
[InlineData("*,2*,3*", 0d, 0d, new[] { 0d, 0d, 0d })] [InlineData("*,2*,3*", 0d, 0d, new[] { 0d, 0d, 0d })]
[InlineData("*,2*,3*", 600d, 0d, new[] { 100d, 200d, 300d })] [InlineData("*,2*,3*", 600d, 0d, new[] { 100d, 200d, 300d })]
public void MeasureArrange_AllStarLength_Correct(string length, double containerLength, public void MeasureArrange_AllStarLength_Correct(string length, double containerLength,
double expectedDesiredLength, IList<double> expectedLengthList) double expectedDesiredLength, IList expectedLengthList)
{ {
TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList); TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList);
} }
@ -36,7 +37,7 @@ namespace Avalonia.Controls.UnitTests
[InlineData("100,2*,3*", 100d, 100d, new[] { 100d, 0d, 0d })] [InlineData("100,2*,3*", 100d, 100d, new[] { 100d, 0d, 0d })]
[InlineData("100,2*,3*", 50d, 50d, new[] { 50d, 0d, 0d })] [InlineData("100,2*,3*", 50d, 50d, new[] { 50d, 0d, 0d })]
public void MeasureArrange_MixStarPixelLength_Correct(string length, double containerLength, public void MeasureArrange_MixStarPixelLength_Correct(string length, double containerLength,
double expectedDesiredLength, IList<double> expectedLengthList) double expectedDesiredLength, IList expectedLengthList)
{ {
TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList); TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList);
} }
@ -49,7 +50,7 @@ namespace Avalonia.Controls.UnitTests
[InlineData("100,200,Auto", 100d, 100d, new[] { 100d, 0d, 0d })] [InlineData("100,200,Auto", 100d, 100d, new[] { 100d, 0d, 0d })]
[InlineData("100,200,Auto", 50d, 50d, new[] { 50d, 0d, 0d })] [InlineData("100,200,Auto", 50d, 50d, new[] { 50d, 0d, 0d })]
public void MeasureArrange_MixAutoPixelLength_Correct(string length, double containerLength, public void MeasureArrange_MixAutoPixelLength_Correct(string length, double containerLength,
double expectedDesiredLength, IList<double> expectedLengthList) double expectedDesiredLength, IList expectedLengthList)
{ {
TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList); TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList);
} }
@ -58,7 +59,7 @@ namespace Avalonia.Controls.UnitTests
[InlineData("*,2*,Auto", 0d, 0d, new[] { 0d, 0d, 0d })] [InlineData("*,2*,Auto", 0d, 0d, new[] { 0d, 0d, 0d })]
[InlineData("*,2*,Auto", 600d, 0d, new[] { 200d, 400d, 0d })] [InlineData("*,2*,Auto", 600d, 0d, new[] { 200d, 400d, 0d })]
public void MeasureArrange_MixAutoStarLength_Correct(string length, double containerLength, public void MeasureArrange_MixAutoStarLength_Correct(string length, double containerLength,
double expectedDesiredLength, IList<double> expectedLengthList) double expectedDesiredLength, IList expectedLengthList)
{ {
TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList); TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList);
} }
@ -69,14 +70,24 @@ namespace Avalonia.Controls.UnitTests
[InlineData("*,200,Auto", 200d, 200d, new[] { 0d, 200d, 0d })] [InlineData("*,200,Auto", 200d, 200d, new[] { 0d, 200d, 0d })]
[InlineData("*,200,Auto", 100d, 100d, new[] { 0d, 100d, 0d })] [InlineData("*,200,Auto", 100d, 100d, new[] { 0d, 100d, 0d })]
public void MeasureArrange_MixAutoStarPixelLength_Correct(string length, double containerLength, public void MeasureArrange_MixAutoStarPixelLength_Correct(string length, double containerLength,
double expectedDesiredLength, IList<double> expectedLengthList) double expectedDesiredLength, IList expectedLengthList)
{ {
TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList); TestRowDefinitionsOnly(length, containerLength, expectedDesiredLength, expectedLengthList);
} }
/// <summary>
/// This is needed because Mono somehow converts double array to object array in attribute metadata
/// </summary>
static void AssertEqual(IList expected, IReadOnlyList<double> actual)
{
var conv = expected.Cast<double>().ToArray();
Assert.Equal(conv, actual);
}
[SuppressMessage("ReSharper", "ParameterOnlyUsedForPreconditionCheck.Local")] [SuppressMessage("ReSharper", "ParameterOnlyUsedForPreconditionCheck.Local")]
private static void TestRowDefinitionsOnly(string length, double containerLength, private static void TestRowDefinitionsOnly(string length, double containerLength,
double expectedDesiredLength, IList<double> expectedLengthList) double expectedDesiredLength, IList expectedLengthList)
{ {
// Arrange // Arrange
var layout = new GridLayout(new RowDefinitions(length)); var layout = new GridLayout(new RowDefinitions(length));
@ -84,11 +95,11 @@ namespace Avalonia.Controls.UnitTests
// Measure - Action & Assert // Measure - Action & Assert
var measure = layout.Measure(containerLength); var measure = layout.Measure(containerLength);
Assert.Equal(expectedDesiredLength, measure.DesiredLength); Assert.Equal(expectedDesiredLength, measure.DesiredLength);
Assert.Equal(expectedLengthList, measure.LengthList); AssertEqual(expectedLengthList, measure.LengthList);
// Arrange - Action & Assert // Arrange - Action & Assert
var arrange = layout.Arrange(containerLength, measure); var arrange = layout.Arrange(containerLength, measure);
Assert.Equal(expectedLengthList, arrange.LengthList); AssertEqual(expectedLengthList, arrange.LengthList);
} }
[Theory] [Theory]
@ -99,7 +110,7 @@ namespace Avalonia.Controls.UnitTests
[InlineData("*,2*,Auto", 0d, new[] { Inf, Inf, 0d }, new[] { 0d, 0d, 0d })] [InlineData("*,2*,Auto", 0d, new[] { Inf, Inf, 0d }, new[] { 0d, 0d, 0d })]
[InlineData("*,200,Auto", 200d, new[] { Inf, 200d, 0d }, new[] { 0d, 200d, 0d })] [InlineData("*,200,Auto", 200d, new[] { Inf, 200d, 0d }, new[] { 0d, 200d, 0d })]
public void MeasureArrange_InfiniteMeasure_Correct(string length, double expectedDesiredLength, public void MeasureArrange_InfiniteMeasure_Correct(string length, double expectedDesiredLength,
IList<double> expectedMeasureList, IList<double> expectedArrangeList) IList expectedMeasureList, IList expectedArrangeList)
{ {
// Arrange // Arrange
var layout = new GridLayout(new RowDefinitions(length)); var layout = new GridLayout(new RowDefinitions(length));
@ -107,34 +118,34 @@ namespace Avalonia.Controls.UnitTests
// Measure - Action & Assert // Measure - Action & Assert
var measure = layout.Measure(Inf); var measure = layout.Measure(Inf);
Assert.Equal(expectedDesiredLength, measure.DesiredLength); Assert.Equal(expectedDesiredLength, measure.DesiredLength);
Assert.Equal(expectedMeasureList, measure.LengthList); AssertEqual(expectedMeasureList, measure.LengthList);
// Arrange - Action & Assert // Arrange - Action & Assert
var arrange = layout.Arrange(measure.DesiredLength, measure); var arrange = layout.Arrange(measure.DesiredLength, measure);
Assert.Equal(expectedArrangeList, arrange.LengthList); AssertEqual(expectedArrangeList, arrange.LengthList);
} }
[Theory] [Theory]
[InlineData("Auto,*,*", new[] { 100d, 100d, 100d }, 600d, 300d, new[] { 100d, 250d, 250d })] [InlineData("Auto,*,*", new[] { 100d, 100d, 100d }, 600d, 300d, new[] { 100d, 250d, 250d })]
public void MeasureArrange_ChildHasSize_Correct(string length, public void MeasureArrange_ChildHasSize_Correct(string length,
IList<double> childLengthList, double containerLength, IList childLengthList, double containerLength,
double expectedDesiredLength, IList<double> expectedLengthList) double expectedDesiredLength, IList expectedLengthList)
{ {
// Arrange // Arrange
var lengthList = new ColumnDefinitions(length); var lengthList = new ColumnDefinitions(length);
var layout = new GridLayout(lengthList); var layout = new GridLayout(lengthList);
layout.AppendMeasureConventions( layout.AppendMeasureConventions(
Enumerable.Range(0, lengthList.Count).ToDictionary(x => x, x => (x, 1)), Enumerable.Range(0, lengthList.Count).ToDictionary(x => x, x => (x, 1)),
x => childLengthList[x]); x => (double)childLengthList[x]);
// Measure - Action & Assert // Measure - Action & Assert
var measure = layout.Measure(containerLength); var measure = layout.Measure(containerLength);
Assert.Equal(expectedDesiredLength, measure.DesiredLength); Assert.Equal(expectedDesiredLength, measure.DesiredLength);
Assert.Equal(expectedLengthList, measure.LengthList); AssertEqual(expectedLengthList, measure.LengthList);
// Arrange - Action & Assert // Arrange - Action & Assert
var arrange = layout.Arrange(containerLength, measure); var arrange = layout.Arrange(containerLength, measure);
Assert.Equal(expectedLengthList, arrange.LengthList); AssertEqual(expectedLengthList, arrange.LengthList);
} }
[Theory] [Theory]
@ -145,7 +156,7 @@ namespace Avalonia.Controls.UnitTests
[InlineData(160d, 160d, new[] { 100d, 20d, 40d }, new[] { 100d, 20d, 40d })] [InlineData(160d, 160d, new[] { 100d, 20d, 40d }, new[] { 100d, 20d, 40d })]
public void MeasureArrange_ChildHasSizeAndHasMultiSpan_Correct( public void MeasureArrange_ChildHasSizeAndHasMultiSpan_Correct(
double containerLength, double expectedDesiredLength, double containerLength, double expectedDesiredLength,
IList<double> expectedMeasureLengthList, IList<double> expectedArrangeLengthList) IList expectedMeasureLengthList, IList expectedArrangeLengthList)
{ {
var length = "100,*,2*"; var length = "100,*,2*";
var childLengthList = new[] { 150d, 150d, 150d }; var childLengthList = new[] { 150d, 150d, 150d };
@ -161,13 +172,13 @@ namespace Avalonia.Controls.UnitTests
// Measure - Action & Assert // Measure - Action & Assert
var measure = layout.Measure(containerLength); var measure = layout.Measure(containerLength);
Assert.Equal(expectedDesiredLength, measure.DesiredLength); Assert.Equal(expectedDesiredLength, measure.DesiredLength);
Assert.Equal(expectedMeasureLengthList, measure.LengthList); AssertEqual(expectedMeasureLengthList, measure.LengthList);
// Arrange - Action & Assert // Arrange - Action & Assert
var arrange = layout.Arrange( var arrange = layout.Arrange(
double.IsInfinity(containerLength) ? measure.DesiredLength : containerLength, double.IsInfinity(containerLength) ? measure.DesiredLength : containerLength,
measure); measure);
Assert.Equal(expectedArrangeLengthList, arrange.LengthList); AssertEqual(expectedArrangeLengthList, arrange.LengthList);
} }
} }
} }

6
tests/Avalonia.Input.UnitTests/Avalonia.Input.UnitTests.csproj

@ -1,9 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0"> <Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;net47</TargetFrameworks>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<IsTestProject>true</IsTestProject>
</PropertyGroup> </PropertyGroup>
<Import Project="..\..\build\UnitTests.NetCore.targets" /> <Import Project="..\..\build\UnitTests.NetCore.targets" />
<Import Project="..\..\build\UnitTests.NetFX.props" />
<Import Project="..\..\build\Moq.props" /> <Import Project="..\..\build\Moq.props" />
<Import Project="..\..\build\XUnit.props" /> <Import Project="..\..\build\XUnit.props" />
<Import Project="..\..\build\Rx.props" /> <Import Project="..\..\build\Rx.props" />
@ -22,4 +24,4 @@
<ItemGroup> <ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup> </ItemGroup>
</Project> </Project>

5
tests/Avalonia.Interactivity.UnitTests/Avalonia.Interactivity.UnitTests.csproj

@ -1,9 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0"> <Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks> <TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;net47</TargetFrameworks>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<IsTestProject>true</IsTestProject>
</PropertyGroup> </PropertyGroup>
<Import Project="..\..\build\UnitTests.NetCore.targets" /> <Import Project="..\..\build\UnitTests.NetCore.targets" />
<Import Project="..\..\build\UnitTests.NetFX.props" />
<Import Project="..\..\build\XUnit.props" /> <Import Project="..\..\build\XUnit.props" />
<Import Project="..\..\build\Rx.props" /> <Import Project="..\..\build\Rx.props" />
<Import Project="..\..\build\Microsoft.Reactive.Testing.props" /> <Import Project="..\..\build\Microsoft.Reactive.Testing.props" />
@ -20,4 +23,4 @@
<ItemGroup> <ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup> </ItemGroup>
</Project> </Project>

6
tests/Avalonia.Markup.UnitTests/Avalonia.Markup.UnitTests.csproj

@ -1,9 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0"> <Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;net47</TargetFrameworks>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<IsTestProject>true</IsTestProject>
</PropertyGroup> </PropertyGroup>
<Import Project="..\..\build\UnitTests.NetCore.targets" /> <Import Project="..\..\build\UnitTests.NetCore.targets" />
<Import Project="..\..\build\UnitTests.NetFX.props" />
<Import Project="..\..\build\Moq.props" /> <Import Project="..\..\build\Moq.props" />
<Import Project="..\..\build\XUnit.props" /> <Import Project="..\..\build\XUnit.props" />
<Import Project="..\..\build\Rx.props" /> <Import Project="..\..\build\Rx.props" />
@ -23,4 +25,4 @@
<ItemGroup> <ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup> </ItemGroup>
</Project> </Project>

6
tests/Avalonia.Markup.Xaml.UnitTests/Avalonia.Markup.Xaml.UnitTests.csproj

@ -1,9 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0"> <Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;net47</TargetFrameworks>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<IsTestProject>true</IsTestProject>
</PropertyGroup> </PropertyGroup>
<Import Project="..\..\build\UnitTests.NetCore.targets" /> <Import Project="..\..\build\UnitTests.NetCore.targets" />
<Import Project="..\..\build\UnitTests.NetFX.props" />
<Import Project="..\..\build\Moq.props" /> <Import Project="..\..\build\Moq.props" />
<Import Project="..\..\build\XUnit.props" /> <Import Project="..\..\build\XUnit.props" />
<Import Project="..\..\build\Rx.props" /> <Import Project="..\..\build\Rx.props" />
@ -36,4 +38,4 @@
<ItemGroup> <ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup> </ItemGroup>
</Project> </Project>

6
tests/Avalonia.Styling.UnitTests/Avalonia.Styling.UnitTests.csproj

@ -1,10 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0"> <Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;net47</TargetFrameworks>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<NoWarn>CS0067</NoWarn> <NoWarn>CS0067</NoWarn>
<IsTestProject>true</IsTestProject>
</PropertyGroup> </PropertyGroup>
<Import Project="..\..\build\UnitTests.NetCore.targets" /> <Import Project="..\..\build\UnitTests.NetCore.targets" />
<Import Project="..\..\build\UnitTests.NetFX.props" />
<Import Project="..\..\build\Moq.props" /> <Import Project="..\..\build\Moq.props" />
<Import Project="..\..\build\XUnit.props" /> <Import Project="..\..\build\XUnit.props" />
<Import Project="..\..\build\Rx.props" /> <Import Project="..\..\build\Rx.props" />
@ -23,4 +25,4 @@
<ItemGroup> <ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup> </ItemGroup>
</Project> </Project>

7
tests/Avalonia.Visuals.UnitTests/Avalonia.Visuals.UnitTests.csproj

@ -1,8 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0"> <Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks> <TargetFrameworks>netcoreapp2.0;net47</TargetFrameworks>
<OutputType>Library</OutputType>
<IsTestProject>true</IsTestProject>
</PropertyGroup> </PropertyGroup>
<Import Project="..\..\build\UnitTests.NetCore.targets" /> <Import Project="..\..\build\UnitTests.NetCore.targets" />
<Import Project="..\..\build\UnitTests.NetFX.props" />
<Import Project="..\..\build\Moq.props" /> <Import Project="..\..\build\Moq.props" />
<Import Project="..\..\build\XUnit.props" /> <Import Project="..\..\build\XUnit.props" />
<Import Project="..\..\build\Rx.props" /> <Import Project="..\..\build\Rx.props" />
@ -21,4 +24,4 @@
<ItemGroup> <ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup> </ItemGroup>
</Project> </Project>

Loading…
Cancel
Save