Browse Source
Conflicts: src/Avalonia.Controls/Primitives/PopupRoot.cs src/Avalonia.Controls/TopLevel.cs tests/Avalonia.Controls.UnitTests/WindowTests.cs tests/Avalonia.UnitTests/TestServices.csscenegraph-after-breakage
100 changed files with 692 additions and 2132 deletions
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="JetBrains.Annotations" Version="10.3.0" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="JetBrains.dotMemoryUnit" Version="2.1.20150828.125449" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="7.0.0.0101" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,9 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="System.ComponentModel.Annotations" Version="4.3.0" /> |
|||
<PackageReference Include="System.Globalization" Version="4.3.0" /> |
|||
<PackageReference Include="System.Linq" Version="4.3.0" /> |
|||
<PackageReference Include="System.Runtime" Version="4.3.0" /> |
|||
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.0" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.Reactive.Testing" Version="3.0.0" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="Moq" Version="4.7.1" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,6 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" /> |
|||
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="1.1.0" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,11 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="System.Reactive" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Core" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Interfaces" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Linq" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.PlatformServices" Version="3.0.0" /> |
|||
<PackageReference Condition="'$(TargetFramework)' == 'net45'" Include="System.Reactive.Windows.Threading" Version="3.0.0" /> |
|||
<PackageReference Condition="'$(TargetFramework)' == 'net461'" Include="System.Reactive.Windows.Threading" Version="3.0.0" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="Serilog.Sinks.Trace" Version="2.1.0" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="Serilog" Version="2.4.0" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,8 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="SharpDX" Version="3.1.1" /> |
|||
<PackageReference Include="SharpDX.Direct2D1" Version="3.1.1" /> |
|||
<PackageReference Include="SharpDX.Direct3D11" Version="3.1.1" /> |
|||
<PackageReference Include="SharpDX.DXGI" Version="3.1.1" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="Avalonia.Skia.Linux.Natives" Version="1.56.1.3" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="SkiaSharp" Version="1.56.1-beta" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="Splat" Version="2.0.0" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="Sprache" Version="2.1.0" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,29 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> |
|||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<PackageReference Include="System.Threading.Thread" Version="4.3.0" /> |
|||
</ItemGroup> |
|||
<Import Condition="'$(TargetFramework)' == 'net461'" Project="$(MSBuildThisFileDirectory)..\src\Shared\nuget.workaround.targets" /> |
|||
</Project> |
|||
@ -0,0 +1,13 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="xunit" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.abstractions" Version="2.0.1" /> |
|||
<PackageReference Include="xunit.assert" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.core" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.extensibility.core" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.extensibility.execution" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.runner.console" Version="2.2.0" /> |
|||
<PackageReference Condition="'$(TargetFramework)' == 'net461'" Include="xunit.runner.visualstudio" Version="2.2.0" /> |
|||
<PackageReference Condition="'$(TargetFramework)' == 'netcoreapp1.1'" Include="Microsoft.NET.Test.Sdk" Version="15.0.0" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,27 @@ |
|||
### MSBuild Props |
|||
|
|||
```XML |
|||
<Import Project="..\..\build\JetBrains.Annotations.props" /> |
|||
<Import Project="..\..\build\JetBrains.dotMemoryUnit.props" /> |
|||
<Import Project="..\..\build\Magick.NET-Q16-AnyCPU.props" /> |
|||
<Import Project="..\..\build\Markup.props" /> |
|||
<Import Project="..\..\build\Microsoft.CSharp.props" /> |
|||
<Import Project="..\..\build\Microsoft.Reactive.Testing.props" /> |
|||
<Import Project="..\..\build\Moq.props" /> |
|||
<Import Project="..\..\build\NetCore.props" /> |
|||
<Import Project="..\..\build\Rx.props" /> |
|||
<Import Project="..\..\build\Serilog.props" /> |
|||
<Import Project="..\..\build\Serilog.Sinks.Trace.props" /> |
|||
<Import Project="..\..\build\SharpDX.props" /> |
|||
<Import Project="..\..\build\SkiaSharp.Desktop.props" /> |
|||
<Import Project="..\..\build\SkiaSharp.props" /> |
|||
<Import Project="..\..\build\Splat.props" /> |
|||
<Import Project="..\..\build\Sprache.props" /> |
|||
<Import Project="..\..\build\XUnit.props" /> |
|||
``` |
|||
|
|||
### MSBuild Targets |
|||
|
|||
```XML |
|||
<Import Project="..\..\build\UnitTests.NetCore.targets" /> |
|||
``` |
|||
@ -1,494 +0,0 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.Presenters; |
|||
using Avalonia.Layout; |
|||
using Avalonia.Media; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Rendering; |
|||
using Avalonia.UnitTests; |
|||
using Moq; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using Xunit; |
|||
|
|||
namespace Avalonia.Input.UnitTests |
|||
{ |
|||
public class InputElement_HitTesting |
|||
{ |
|||
[Fact] |
|||
public void InputHitTest_Should_Find_Control_At_Point() |
|||
{ |
|||
using (var application = UnitTestApplication.Start(new TestServices(renderInterface: new MockRenderInterface()))) |
|||
{ |
|||
var container = new Decorator |
|||
{ |
|||
Width = 200, |
|||
Height = 200, |
|||
Child = new Border |
|||
{ |
|||
Width = 100, |
|||
Height = 100, |
|||
HorizontalAlignment = HorizontalAlignment.Center, |
|||
VerticalAlignment = VerticalAlignment.Center |
|||
} |
|||
}; |
|||
|
|||
container.Measure(Size.Infinity); |
|||
container.Arrange(new Rect(container.DesiredSize)); |
|||
|
|||
var context = new DrawingContext(Mock.Of<IDrawingContextImpl>()); |
|||
context.Render(container); |
|||
|
|||
var result = container.InputHitTest(new Point(100, 100)); |
|||
|
|||
Assert.Equal(container.Child, result); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public void InputHitTest_Should_Not_Find_Control_Outside_Point() |
|||
{ |
|||
using (UnitTestApplication.Start(new TestServices(renderInterface: new MockRenderInterface()))) |
|||
{ |
|||
var container = new Decorator |
|||
{ |
|||
Width = 200, |
|||
Height = 200, |
|||
Child = new Border |
|||
{ |
|||
Width = 100, |
|||
Height = 100, |
|||
HorizontalAlignment = HorizontalAlignment.Center, |
|||
VerticalAlignment = VerticalAlignment.Center |
|||
} |
|||
}; |
|||
|
|||
container.Measure(Size.Infinity); |
|||
container.Arrange(new Rect(container.DesiredSize)); |
|||
|
|||
var context = new DrawingContext(Mock.Of<IDrawingContextImpl>()); |
|||
context.Render(container); |
|||
|
|||
var result = container.InputHitTest(new Point(10, 10)); |
|||
|
|||
Assert.Equal(container, result); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public void InputHitTest_Should_Find_Top_Control_At_Point() |
|||
{ |
|||
using (UnitTestApplication.Start(new TestServices(renderInterface: new MockRenderInterface()))) |
|||
{ |
|||
var container = new Panel |
|||
{ |
|||
Width = 200, |
|||
Height = 200, |
|||
Children = new Controls.Controls |
|||
{ |
|||
new Border |
|||
{ |
|||
Width = 100, |
|||
Height = 100, |
|||
HorizontalAlignment = HorizontalAlignment.Center, |
|||
VerticalAlignment = VerticalAlignment.Center |
|||
}, |
|||
new Border |
|||
{ |
|||
Width = 50, |
|||
Height = 50, |
|||
HorizontalAlignment = HorizontalAlignment.Center, |
|||
VerticalAlignment = VerticalAlignment.Center |
|||
} |
|||
} |
|||
}; |
|||
|
|||
container.Measure(Size.Infinity); |
|||
container.Arrange(new Rect(container.DesiredSize)); |
|||
|
|||
var context = new DrawingContext(Mock.Of<IDrawingContextImpl>()); |
|||
context.Render(container); |
|||
|
|||
var result = container.InputHitTest(new Point(100, 100)); |
|||
|
|||
Assert.Equal(container.Children[1], result); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public void InputHitTest_Should_Find_Top_Control_At_Point_With_ZOrder() |
|||
{ |
|||
using (UnitTestApplication.Start(new TestServices(renderInterface: new MockRenderInterface()))) |
|||
{ |
|||
var container = new Panel |
|||
{ |
|||
Width = 200, |
|||
Height = 200, |
|||
Children = new Controls.Controls |
|||
{ |
|||
new Border |
|||
{ |
|||
Width = 100, |
|||
Height = 100, |
|||
ZIndex = 1, |
|||
HorizontalAlignment = HorizontalAlignment.Center, |
|||
VerticalAlignment = VerticalAlignment.Center |
|||
}, |
|||
new Border |
|||
{ |
|||
Width = 50, |
|||
Height = 50, |
|||
HorizontalAlignment = HorizontalAlignment.Center, |
|||
VerticalAlignment = VerticalAlignment.Center |
|||
} |
|||
} |
|||
}; |
|||
|
|||
container.Measure(Size.Infinity); |
|||
container.Arrange(new Rect(container.DesiredSize)); |
|||
|
|||
var context = new DrawingContext(Mock.Of<IDrawingContextImpl>()); |
|||
context.Render(container); |
|||
|
|||
var result = container.InputHitTest(new Point(100, 100)); |
|||
|
|||
Assert.Equal(container.Children[0], result); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public void InputHitTest_Should_Find_Control_Translated_Outside_Parent_Bounds() |
|||
{ |
|||
using (UnitTestApplication.Start(new TestServices(renderInterface: new MockRenderInterface()))) |
|||
{ |
|||
Border target; |
|||
var container = new Panel |
|||
{ |
|||
Width = 200, |
|||
Height = 200, |
|||
ClipToBounds = false, |
|||
Children = new Controls.Controls |
|||
{ |
|||
new Border |
|||
{ |
|||
Width = 100, |
|||
Height = 100, |
|||
ZIndex = 1, |
|||
HorizontalAlignment = HorizontalAlignment.Left, |
|||
VerticalAlignment = VerticalAlignment.Top, |
|||
Child = target = new Border |
|||
{ |
|||
Width = 50, |
|||
Height = 50, |
|||
HorizontalAlignment = HorizontalAlignment.Left, |
|||
VerticalAlignment = VerticalAlignment.Top, |
|||
RenderTransform = new TranslateTransform(110, 110), |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
container.Measure(Size.Infinity); |
|||
container.Arrange(new Rect(container.DesiredSize)); |
|||
|
|||
var context = new DrawingContext(Mock.Of<IDrawingContextImpl>()); |
|||
context.Render(container); |
|||
|
|||
var result = container.InputHitTest(new Point(120, 120)); |
|||
|
|||
Assert.Equal(target, result); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public void InputHitTest_Should_Not_Find_Control_Outside_Parent_Bounds_When_Clipped() |
|||
{ |
|||
using (UnitTestApplication.Start(new TestServices(renderInterface: new MockRenderInterface()))) |
|||
{ |
|||
Border target; |
|||
|
|||
var container = new Panel |
|||
{ |
|||
Width = 100, |
|||
Height = 200, |
|||
Children = new Controls.Controls |
|||
{ |
|||
new Panel() |
|||
{ |
|||
Width = 100, |
|||
Height = 100, |
|||
Margin = new Thickness(0, 100, 0, 0), |
|||
ClipToBounds = true, |
|||
Children = new Controls.Controls |
|||
{ |
|||
(target = new Border() |
|||
{ |
|||
Width = 100, |
|||
Height = 100, |
|||
Margin = new Thickness(0, -100, 0, 0) |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
}; |
|||
|
|||
container.Measure(Size.Infinity); |
|||
container.Arrange(new Rect(container.DesiredSize)); |
|||
|
|||
var context = new DrawingContext(Mock.Of<IDrawingContextImpl>()); |
|||
context.Render(container); |
|||
|
|||
var result = container.InputHitTest(new Point(50, 50)); |
|||
|
|||
Assert.NotEqual(target, result); |
|||
Assert.Equal(container, result); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public void InputHitTest_Should_Not_Find_Control_Outside_Scroll_ViewPort() |
|||
{ |
|||
using (UnitTestApplication.Start(new TestServices(renderInterface: new MockRenderInterface()))) |
|||
{ |
|||
Border target; |
|||
Border item1; |
|||
Border item2; |
|||
ScrollContentPresenter scroll; |
|||
|
|||
var container = new Panel |
|||
{ |
|||
Width = 100, |
|||
Height = 200, |
|||
Children = new Controls.Controls |
|||
{ |
|||
(target = new Border() |
|||
{ |
|||
Width = 100, |
|||
Height = 100 |
|||
}), |
|||
new Border() |
|||
{ |
|||
Width = 100, |
|||
Height = 100, |
|||
Margin = new Thickness(0, 100, 0, 0), |
|||
Child = scroll = new ScrollContentPresenter() |
|||
{ |
|||
Content = new StackPanel() |
|||
{ |
|||
Children = new Controls.Controls |
|||
{ |
|||
(item1 = new Border() |
|||
{ |
|||
Width = 100, |
|||
Height = 100, |
|||
}), |
|||
(item2 = new Border() |
|||
{ |
|||
Width = 100, |
|||
Height = 100, |
|||
}), |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}; |
|||
|
|||
scroll.UpdateChild(); |
|||
|
|||
container.Measure(Size.Infinity); |
|||
container.Arrange(new Rect(container.DesiredSize)); |
|||
|
|||
var context = new DrawingContext(Mock.Of<IDrawingContextImpl>()); |
|||
context.Render(container); |
|||
|
|||
var result = container.InputHitTest(new Point(50, 150)); |
|||
|
|||
Assert.Equal(item1, result); |
|||
|
|||
result = container.InputHitTest(new Point(50, 50)); |
|||
|
|||
Assert.Equal(target, result); |
|||
|
|||
scroll.Offset = new Vector(0, 100); |
|||
|
|||
//we don't have setup LayoutManager so we will make it manually
|
|||
scroll.Parent.InvalidateArrange(); |
|||
container.InvalidateArrange(); |
|||
|
|||
container.Arrange(new Rect(container.DesiredSize)); |
|||
context.Render(container); |
|||
|
|||
result = container.InputHitTest(new Point(50, 150)); |
|||
|
|||
Assert.Equal(item2, result); |
|||
|
|||
result = container.InputHitTest(new Point(50, 50)); |
|||
|
|||
Assert.NotEqual(item1, result); |
|||
Assert.Equal(target, result); |
|||
} |
|||
} |
|||
|
|||
class MockRenderInterface : IPlatformRenderInterface |
|||
{ |
|||
public IFormattedTextImpl CreateFormattedText(string text, string fontFamilyName, double fontSize, FontStyle fontStyle, TextAlignment textAlignment, FontWeight fontWeight, TextWrapping wrapping) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public IRenderTarget CreateRenderTarget(IEnumerable<object> surfaces) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public IRenderTargetBitmapImpl CreateRenderTargetBitmap(int width, int height) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public IStreamGeometryImpl CreateStreamGeometry() |
|||
{ |
|||
return new MockStreamGeometry(); |
|||
} |
|||
|
|||
public IBitmapImpl LoadBitmap(Stream stream) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public IBitmapImpl LoadBitmap(string fileName) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public IBitmapImpl LoadBitmap(PixelFormat format, IntPtr data, int width, int height, int stride) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public IWritableBitmapImpl CreateWritableBitmap(int width, int height, PixelFormat? fmt) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
class MockStreamGeometry : Avalonia.Platform.IStreamGeometryImpl |
|||
{ |
|||
private MockStreamGeometryContext _impl = new MockStreamGeometryContext(); |
|||
public Rect Bounds |
|||
{ |
|||
get |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
|
|||
public Matrix Transform |
|||
{ |
|||
get |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
set |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
|
|||
public IStreamGeometryImpl Clone() |
|||
{ |
|||
return this; |
|||
} |
|||
|
|||
public bool FillContains(Point point) |
|||
{ |
|||
return _impl.FillContains(point); |
|||
} |
|||
|
|||
public Rect GetRenderBounds(double strokeThickness) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public IStreamGeometryContextImpl Open() |
|||
{ |
|||
return _impl; |
|||
} |
|||
|
|||
class MockStreamGeometryContext : IStreamGeometryContextImpl |
|||
{ |
|||
private List<Point> points = new List<Point>(); |
|||
public void ArcTo(Point point, Size size, double rotationAngle, bool isLargeArc, SweepDirection sweepDirection) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public void BeginFigure(Point startPoint, bool isFilled) |
|||
{ |
|||
points.Add(startPoint); |
|||
} |
|||
|
|||
public void CubicBezierTo(Point point1, Point point2, Point point3) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
} |
|||
|
|||
public void EndFigure(bool isClosed) |
|||
{ |
|||
} |
|||
|
|||
public void LineTo(Point point) |
|||
{ |
|||
points.Add(point); |
|||
} |
|||
|
|||
public void QuadraticBezierTo(Point control, Point endPoint) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public void SetFillRule(FillRule fillRule) |
|||
{ |
|||
} |
|||
|
|||
public bool FillContains(Point point) |
|||
{ |
|||
// Use the algorithm from http://www.blackpawn.com/texts/pointinpoly/default.html
|
|||
// to determine if the point is in the geometry (since it will always be convex in this situation)
|
|||
for (int i = 0; i < points.Count; i++) |
|||
{ |
|||
var a = points[i]; |
|||
var b = points[(i + 1) % points.Count]; |
|||
var c = points[(i + 2) % points.Count]; |
|||
|
|||
Vector v0 = c - a; |
|||
Vector v1 = b - a; |
|||
Vector v2 = point - a; |
|||
|
|||
var dot00 = v0 * v0; |
|||
var dot01 = v0 * v1; |
|||
var dot02 = v0 * v2; |
|||
var dot11 = v1 * v1; |
|||
var dot12 = v1 * v2; |
|||
|
|||
|
|||
var invDenom = 1 / (dot00 * dot11 - dot01 * dot01); |
|||
var u = (dot11 * dot02 - dot01 * dot12) * invDenom; |
|||
var v = (dot00 * dot12 - dot01 * dot02) * invDenom; |
|||
if ((u >= 0) && (v >= 0) && (u + v < 1)) return true; |
|||
} |
|||
return false; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,7 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<configuration> |
|||
<runtime> |
|||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|||
</assemblyBinding> |
|||
</runtime> |
|||
</configuration> |
|||
@ -1,112 +1,22 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> |
|||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0"> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|||
<ProjectGuid>{08478EF5-44E8-42E9-92D6-15E00EC038D8}</ProjectGuid> |
|||
<OutputType>Library</OutputType> |
|||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|||
<RootNamespace>Avalonia.Interactivity.UnitTests</RootNamespace> |
|||
<AssemblyName>Avalonia.Interactivity.UnitTests</AssemblyName> |
|||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> |
|||
<FileAlignment>512</FileAlignment> |
|||
<NuGetPackageImportStamp> |
|||
</NuGetPackageImportStamp> |
|||
<TargetFrameworks>net461;netcoreapp1.1</TargetFrameworks> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<DocumentationFile>bin\Debug\Avalonia.Interactivity.UnitTests.xml</DocumentationFile> |
|||
<NoWarn>CS1591</NoWarn> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Reference Include="System" /> |
|||
<Reference Include="System.Core" /> |
|||
<Reference Include="System.Xml.Linq" /> |
|||
<Reference Include="System.Data.DataSetExtensions" /> |
|||
<Reference Include="Microsoft.CSharp" /> |
|||
<Reference Include="System.Data" /> |
|||
<Reference Include="System.Xml" /> |
|||
<Reference Include="WindowsBase" /> |
|||
</ItemGroup> |
|||
<Import Project="..\..\build\UnitTests.NetCore.targets" /> |
|||
<Import Project="..\..\build\XUnit.props" /> |
|||
<Import Project="..\..\build\Rx.props" /> |
|||
<Import Project="..\..\build\Microsoft.Reactive.Testing.props" /> |
|||
<ItemGroup> |
|||
<Compile Include="GestureTests.cs" /> |
|||
<Compile Include="InteractiveTests.cs" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Avalonia.Animation\Avalonia.Animation.csproj"> |
|||
<Project>{D211E587-D8BC-45B9-95A4-F297C8FA5200}</Project> |
|||
<Name>Avalonia.Animation</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Base\Avalonia.Base.csproj"> |
|||
<Project>{B09B78D8-9B26-48B0-9149-D64A2F120F3F}</Project> |
|||
<Name>Avalonia.Base</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Controls\Avalonia.Controls.csproj"> |
|||
<Project>{d2221c82-4a25-4583-9b43-d791e3f6820c}</Project> |
|||
<Name>Avalonia.Controls</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Input\Avalonia.Input.csproj"> |
|||
<Project>{62024b2d-53eb-4638-b26b-85eeaa54866e}</Project> |
|||
<Name>Avalonia.Input</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Interactivity\Avalonia.Interactivity.csproj"> |
|||
<Project>{6B0ED19D-A08B-461C-A9D9-A9EE40B0C06B}</Project> |
|||
<Name>Avalonia.Interactivity</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Layout\Avalonia.Layout.csproj"> |
|||
<Project>{42472427-4774-4C81-8AFF-9F27B8E31721}</Project> |
|||
<Name>Avalonia.Layout</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Visuals\Avalonia.Visuals.csproj"> |
|||
<Project>{EB582467-6ABB-43A1-B052-E981BA910E3A}</Project> |
|||
<Name>Avalonia.Visuals</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Styling\Avalonia.Styling.csproj"> |
|||
<Project>{f1baa01a-f176-4c6a-b39d-5b40bb1b148f}</Project> |
|||
<Name>Avalonia.Styling</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Animation\Avalonia.Animation.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Base\Avalonia.Base.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Controls\Avalonia.Controls.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Input\Avalonia.Input.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Interactivity\Avalonia.Interactivity.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Layout\Avalonia.Layout.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Visuals\Avalonia.Visuals.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Styling\Avalonia.Styling.csproj" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
|||
Other similar extension points exist, see Microsoft.Common.targets. |
|||
<Target Name="BeforeBuild"> |
|||
</Target> |
|||
<Target Name="AfterBuild"> |
|||
</Target> |
|||
--> |
|||
<ItemGroup> |
|||
<PackageReference Include="System.Reactive" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Core" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Interfaces" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Linq" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.PlatformServices" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Windows.Threading" Version="3.0.0" /> |
|||
<PackageReference Include="xunit" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.abstractions" Version="2.0.1" /> |
|||
<PackageReference Include="xunit.assert" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.core" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.extensibility.core" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.extensibility.execution" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" /> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildThisFileDirectory)..\..\src\Shared\nuget.workaround.targets" /> |
|||
</Project> |
|||
@ -1,133 +1,26 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> |
|||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0"> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|||
<ProjectGuid>{8EF392D5-1416-45AA-9956-7CBBC3229E8A}</ProjectGuid> |
|||
<OutputType>Library</OutputType> |
|||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|||
<RootNamespace>Avalonia.Markup.UnitTests</RootNamespace> |
|||
<AssemblyName>Avalonia.Markup.UnitTests</AssemblyName> |
|||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> |
|||
<FileAlignment>512</FileAlignment> |
|||
<NuGetPackageImportStamp> |
|||
</NuGetPackageImportStamp> |
|||
<TargetFrameworkProfile /> |
|||
<TargetFrameworks>net461;netcoreapp1.1</TargetFrameworks> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Compile Include="ControlLocatorTests.cs" /> |
|||
<Compile Include="Data\IndeiBase.cs" /> |
|||
<Compile Include="Data\Plugins\DataAnnotationsValidationPluginTests.cs" /> |
|||
<Compile Include="Data\Plugins\IndeiValidationPluginTests.cs" /> |
|||
<Compile Include="Data\Plugins\ExceptionValidationPluginTests.cs" /> |
|||
<Compile Include="Data\ExpressionNodeBuilderTests.cs" /> |
|||
<Compile Include="Data\ExpressionNodeBuilderTests_Errors.cs" /> |
|||
<Compile Include="Data\ExpressionObserverTests_Lifetime.cs" /> |
|||
<Compile Include="Data\ExpressionObserverTests_Indexer.cs" /> |
|||
<Compile Include="Data\ExpressionObserverTests_Negation.cs" /> |
|||
<Compile Include="Data\ExpressionObserverTests_Observable.cs" /> |
|||
<Compile Include="Data\ExpressionObserverTests_AttachedProperty.cs" /> |
|||
<Compile Include="Data\ExpressionObserverTests_AvaloniaProperty.cs" /> |
|||
<Compile Include="Data\ExpressionObserverTests_Property.cs" /> |
|||
<Compile Include="Data\ExpressionObserverTests_SetValue.cs" /> |
|||
<Compile Include="Data\ExpressionObserverTests_Task.cs" /> |
|||
<Compile Include="Data\ExpressionObserverTests_DataValidation.cs" /> |
|||
<Compile Include="Data\BindingExpressionTests.cs" /> |
|||
<Compile Include="DefaultValueConverterTests.cs" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|||
<Compile Include="UnitTestSynchronizationContext.cs" /> |
|||
</ItemGroup> |
|||
<Import Project="..\..\build\UnitTests.NetCore.targets" /> |
|||
<Import Project="..\..\build\Moq.props" /> |
|||
<Import Project="..\..\build\XUnit.props" /> |
|||
<Import Project="..\..\build\Rx.props" /> |
|||
<Import Project="..\..\build\Microsoft.Reactive.Testing.props" /> |
|||
<Import Project="..\..\build\Markup.props" /> |
|||
<ItemGroup> |
|||
<None Include="app.config" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Markup\Avalonia.Markup\Avalonia.Markup.csproj"> |
|||
<Project>{6417e941-21bc-467b-a771-0de389353ce6}</Project> |
|||
<Name>Avalonia.Markup</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Animation\Avalonia.Animation.csproj"> |
|||
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project> |
|||
<Name>Avalonia.Animation</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Base\Avalonia.Base.csproj"> |
|||
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project> |
|||
<Name>Avalonia.Base</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Controls\Avalonia.Controls.csproj"> |
|||
<Project>{d2221c82-4a25-4583-9b43-d791e3f6820c}</Project> |
|||
<Name>Avalonia.Controls</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Input\Avalonia.Input.csproj"> |
|||
<Project>{62024b2d-53eb-4638-b26b-85eeaa54866e}</Project> |
|||
<Name>Avalonia.Input</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Interactivity\Avalonia.Interactivity.csproj"> |
|||
<Project>{6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b}</Project> |
|||
<Name>Avalonia.Interactivity</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Layout\Avalonia.Layout.csproj"> |
|||
<Project>{42472427-4774-4c81-8aff-9f27b8e31721}</Project> |
|||
<Name>Avalonia.Layout</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Visuals\Avalonia.Visuals.csproj"> |
|||
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project> |
|||
<Name>Avalonia.Visuals</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Styling\Avalonia.Styling.csproj"> |
|||
<Project>{f1baa01a-f176-4c6a-b39d-5b40bb1b148f}</Project> |
|||
<Name>Avalonia.Styling</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\Avalonia.UnitTests\Avalonia.UnitTests.csproj"> |
|||
<Project>{88060192-33d5-4932-b0f9-8bd2763e857d}</Project> |
|||
<Name>Avalonia.UnitTests</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Markup\Avalonia.Markup\Avalonia.Markup.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Animation\Avalonia.Animation.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Base\Avalonia.Base.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Controls\Avalonia.Controls.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Input\Avalonia.Input.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Interactivity\Avalonia.Interactivity.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Layout\Avalonia.Layout.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Visuals\Avalonia.Visuals.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Styling\Avalonia.Styling.csproj" /> |
|||
<ProjectReference Include="..\Avalonia.UnitTests\Avalonia.UnitTests.csproj" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
|||
Other similar extension points exist, see Microsoft.Common.targets. |
|||
<Target Name="BeforeBuild"> |
|||
</Target> |
|||
<Target Name="AfterBuild"> |
|||
</Target> |
|||
--> |
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.Reactive.Testing" Version="3.0.0" /> |
|||
<PackageReference Include="Moq" Version="4.7.1" /> |
|||
<PackageReference Include="System.ComponentModel.Annotations" Version="4.3.0" /> |
|||
<PackageReference Include="System.Reactive" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Core" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Interfaces" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Linq" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.PlatformServices" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Windows.Threading" Version="3.0.0" /> |
|||
<PackageReference Include="xunit" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.abstractions" Version="2.0.1" /> |
|||
<PackageReference Include="xunit.assert" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.core" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.extensibility.core" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.extensibility.execution" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" /> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildThisFileDirectory)..\..\src\Shared\nuget.workaround.targets" /> |
|||
</Project> |
|||
@ -1,11 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<configuration> |
|||
<runtime> |
|||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|||
<dependentAssembly> |
|||
<assemblyIdentity name="Moq" publicKeyToken="69f491c39445e920" culture="neutral"/> |
|||
<bindingRedirect oldVersion="0.0.0.0-4.2.1510.2205" newVersion="4.2.1510.2205"/> |
|||
</dependentAssembly> |
|||
</assemblyBinding> |
|||
</runtime> |
|||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration> |
|||
@ -1,126 +0,0 @@ |
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Data; |
|||
using Avalonia.Markup.Xaml.Data; |
|||
using Avalonia.UnitTests; |
|||
using Xunit; |
|||
|
|||
namespace Avalonia.Markup.Xaml.UnitTests.Data |
|||
{ |
|||
public class BindingTests_Validation |
|||
{ |
|||
[Fact] |
|||
public void Non_Validated_Property_Does_Not_Receive_BindingNotifications() |
|||
{ |
|||
var source = new ValidationTestModel { MustBePositive = 5 }; |
|||
var target = new TestControl |
|||
{ |
|||
DataContext = source, |
|||
[!TestControl.NonValidatedProperty] = new Binding(nameof(source.MustBePositive)), |
|||
}; |
|||
|
|||
Assert.Empty(target.Notifications); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Validated_Direct_Property_Receives_BindingNotifications() |
|||
{ |
|||
var source = new ValidationTestModel { MustBePositive = 5 }; |
|||
var target = new TestControl |
|||
{ |
|||
DataContext = source, |
|||
}; |
|||
|
|||
target.Bind( |
|||
TestControl.ValidatedDirectProperty, |
|||
new Binding(nameof(source.MustBePositive), BindingMode.TwoWay)); |
|||
|
|||
target.ValidatedDirect = 6; |
|||
target.ValidatedDirect = -1; |
|||
target.ValidatedDirect = 7; |
|||
|
|||
Assert.Equal( |
|||
new[] |
|||
{ |
|||
new BindingNotification(5), |
|||
new BindingNotification(6), |
|||
new BindingNotification(new ArgumentOutOfRangeException("value"), BindingErrorType.DataValidationError), |
|||
new BindingNotification(7), |
|||
}, |
|||
target.Notifications.AsEnumerable()); |
|||
} |
|||
|
|||
private class TestControl : Control |
|||
{ |
|||
public static readonly StyledProperty<int> NonValidatedProperty = |
|||
AvaloniaProperty.Register<TestControl, int>( |
|||
nameof(Validated), |
|||
enableDataValidation: false); |
|||
|
|||
public static readonly StyledProperty<int> ValidatedProperty = |
|||
AvaloniaProperty.Register<TestControl, int>( |
|||
nameof(Validated), |
|||
enableDataValidation: true); |
|||
|
|||
public static readonly DirectProperty<TestControl, int> ValidatedDirectProperty = |
|||
AvaloniaProperty.RegisterDirect<TestControl, int>( |
|||
nameof(Validated), |
|||
o => o.ValidatedDirect, |
|||
(o, v) => o.ValidatedDirect = v, |
|||
enableDataValidation: true); |
|||
|
|||
private int _direct; |
|||
|
|||
public int NonValidated |
|||
{ |
|||
get { return GetValue(NonValidatedProperty); } |
|||
set { SetValue(NonValidatedProperty, value); } |
|||
} |
|||
|
|||
public int Validated |
|||
{ |
|||
get { return GetValue(ValidatedProperty); } |
|||
set { SetValue(ValidatedProperty, value); } |
|||
} |
|||
|
|||
public int ValidatedDirect |
|||
{ |
|||
get { return _direct; } |
|||
set { SetAndRaise(ValidatedDirectProperty, ref _direct, value); } |
|||
} |
|||
|
|||
public IList<BindingNotification> Notifications { get; } = new List<BindingNotification>(); |
|||
|
|||
protected override void BindingNotificationReceived(AvaloniaProperty property, BindingNotification notification) |
|||
{ |
|||
Notifications.Add(notification); |
|||
} |
|||
} |
|||
|
|||
private class ValidationTestModel : NotifyingBase |
|||
{ |
|||
private int _mustBePositive; |
|||
|
|||
public int MustBePositive |
|||
{ |
|||
get { return _mustBePositive; } |
|||
set |
|||
{ |
|||
if (value <= 0) |
|||
{ |
|||
throw new ArgumentOutOfRangeException(nameof(value)); |
|||
} |
|||
|
|||
if (_mustBePositive != value) |
|||
{ |
|||
_mustBePositive = value; |
|||
RaisePropertyChanged(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,11 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<configuration> |
|||
<runtime> |
|||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|||
<dependentAssembly> |
|||
<assemblyIdentity name="Moq" publicKeyToken="69f491c39445e920" culture="neutral" /> |
|||
<bindingRedirect oldVersion="0.0.0.0-4.2.1510.2205" newVersion="4.2.1510.2205" /> |
|||
</dependentAssembly> |
|||
</assemblyBinding> |
|||
</runtime> |
|||
</configuration> |
|||
@ -1,157 +1,24 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0"> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|||
<ProjectGuid>{47ECDF59-DEF8-4C53-87B1-2098A3429059}</ProjectGuid> |
|||
<OutputType>Library</OutputType> |
|||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|||
<RootNamespace>Avalonia.Styling.UnitTests</RootNamespace> |
|||
<AssemblyName>Avalonia.Styling.UnitTests</AssemblyName> |
|||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> |
|||
<FileAlignment>512</FileAlignment> |
|||
<TargetFrameworkProfile /> |
|||
<TargetFrameworks>net461;netcoreapp1.1</TargetFrameworks> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<DocumentationFile>bin\Debug\Avalonia.Styling.UnitTests.XML</DocumentationFile> |
|||
<NoWarn>CS1591</NoWarn> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> |
|||
<Reference Include="System" /> |
|||
</ItemGroup> |
|||
<Choose> |
|||
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'"> |
|||
<ItemGroup> |
|||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> |
|||
</ItemGroup> |
|||
</When> |
|||
<Otherwise /> |
|||
</Choose> |
|||
<ItemGroup> |
|||
<Compile Include="ActivatedValueTests.cs" /> |
|||
<Compile Include="ActivatedSubjectTests.cs" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|||
<Compile Include="SelectorTests_Class.cs" /> |
|||
<Compile Include="SelectorTests_Child.cs" /> |
|||
<Compile Include="SelectorTests_Descendent.cs" /> |
|||
<Compile Include="SelectorTests_Name.cs" /> |
|||
<Compile Include="SelectorTests_Multiple.cs" /> |
|||
<Compile Include="SelectorTests_PropertyEquals.cs" /> |
|||
<Compile Include="SelectorTests_OfType.cs" /> |
|||
<Compile Include="SelectorTests_Template.cs" /> |
|||
<Compile Include="ResourceTests.cs" /> |
|||
<Compile Include="StyleActivatorTests.cs" /> |
|||
<Compile Include="ActivatedObservableTests.cs" /> |
|||
<Compile Include="SetterTests.cs" /> |
|||
<Compile Include="StyleTests.cs" /> |
|||
<Compile Include="TestControlBase.cs" /> |
|||
<Compile Include="TestObservable.cs" /> |
|||
<Compile Include="TestObserver.cs" /> |
|||
<Compile Include="TestSelectors.cs" /> |
|||
<Compile Include="TestSubject.cs" /> |
|||
<Compile Include="TestTemplatedControl.cs" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Avalonia.Animation\Avalonia.Animation.csproj"> |
|||
<Project>{D211E587-D8BC-45B9-95A4-F297C8FA5200}</Project> |
|||
<Name>Avalonia.Animation</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Base\Avalonia.Base.csproj"> |
|||
<Project>{B09B78D8-9B26-48B0-9149-D64A2F120F3F}</Project> |
|||
<Name>Avalonia.Base</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Controls\Avalonia.Controls.csproj"> |
|||
<Project>{D2221C82-4A25-4583-9B43-D791E3F6820C}</Project> |
|||
<Name>Avalonia.Controls</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Input\Avalonia.Input.csproj"> |
|||
<Project>{62024B2D-53EB-4638-B26B-85EEAA54866E}</Project> |
|||
<Name>Avalonia.Input</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Interactivity\Avalonia.Interactivity.csproj"> |
|||
<Project>{6B0ED19D-A08B-461C-A9D9-A9EE40B0C06B}</Project> |
|||
<Name>Avalonia.Interactivity</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Layout\Avalonia.Layout.csproj"> |
|||
<Project>{42472427-4774-4C81-8AFF-9F27B8E31721}</Project> |
|||
<Name>Avalonia.Layout</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Visuals\Avalonia.Visuals.csproj"> |
|||
<Project>{EB582467-6ABB-43A1-B052-E981BA910E3A}</Project> |
|||
<Name>Avalonia.Visuals</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Styling\Avalonia.Styling.csproj"> |
|||
<Project>{F1BAA01A-F176-4C6A-B39D-5B40BB1B148F}</Project> |
|||
<Name>Avalonia.Styling</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\Avalonia.UnitTests\Avalonia.UnitTests.csproj"> |
|||
<Project>{88060192-33d5-4932-b0f9-8bd2763e857d}</Project> |
|||
<Name>Avalonia.UnitTests</Name> |
|||
</ProjectReference> |
|||
</ItemGroup> |
|||
<Import Project="..\..\build\UnitTests.NetCore.targets" /> |
|||
<Import Project="..\..\build\Moq.props" /> |
|||
<Import Project="..\..\build\XUnit.props" /> |
|||
<Import Project="..\..\build\Rx.props" /> |
|||
<Import Project="..\..\build\Microsoft.Reactive.Testing.props" /> |
|||
<ItemGroup> |
|||
<None Include="app.config" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Animation\Avalonia.Animation.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Base\Avalonia.Base.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Controls\Avalonia.Controls.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Input\Avalonia.Input.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Interactivity\Avalonia.Interactivity.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Layout\Avalonia.Layout.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Visuals\Avalonia.Visuals.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Styling\Avalonia.Styling.csproj" /> |
|||
<ProjectReference Include="..\Avalonia.UnitTests\Avalonia.UnitTests.csproj" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> |
|||
</ItemGroup> |
|||
<Choose> |
|||
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'"> |
|||
<ItemGroup> |
|||
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> |
|||
<Private>False</Private> |
|||
</Reference> |
|||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> |
|||
<Private>False</Private> |
|||
</Reference> |
|||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> |
|||
<Private>False</Private> |
|||
</Reference> |
|||
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> |
|||
<Private>False</Private> |
|||
</Reference> |
|||
</ItemGroup> |
|||
</When> |
|||
</Choose> |
|||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" /> |
|||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
|||
Other similar extension points exist, see Microsoft.Common.targets. |
|||
<Target Name="BeforeBuild"> |
|||
</Target> |
|||
<Target Name="AfterBuild"> |
|||
</Target> |
|||
--> |
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.Reactive.Testing" Version="3.0.0" /> |
|||
<PackageReference Include="Moq" Version="4.7.1" /> |
|||
<PackageReference Include="System.Reactive.Core" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Interfaces" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Linq" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.PlatformServices" Version="3.0.0" /> |
|||
<PackageReference Include="xunit" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.abstractions" Version="2.0.1" /> |
|||
<PackageReference Include="xunit.assert" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.core" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.extensibility.core" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.extensibility.execution" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" /> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildThisFileDirectory)..\..\src\Shared\nuget.workaround.targets" /> |
|||
</Project> |
|||
@ -1,11 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<configuration> |
|||
<runtime> |
|||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|||
<dependentAssembly> |
|||
<assemblyIdentity name="Moq" publicKeyToken="69f491c39445e920" culture="neutral" /> |
|||
<bindingRedirect oldVersion="0.0.0.0-4.2.1510.2205" newVersion="4.2.1510.2205" /> |
|||
</dependentAssembly> |
|||
</assemblyBinding> |
|||
</runtime> |
|||
</configuration> |
|||
@ -1,41 +0,0 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> |
|||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.Reactive.Testing" Version="3.0.0" /> |
|||
<PackageReference Include="Moq" Version="4.7.1" /> |
|||
<PackageReference Include="System.Reactive.Core" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Interfaces" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Linq" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.PlatformServices" Version="3.0.0" /> |
|||
<PackageReference Include="xunit" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.abstractions" Version="2.0.1" /> |
|||
<PackageReference Include="xunit.assert" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.core" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.extensibility.core" Version="2.2.0" /> |
|||
<PackageReference Include="xunit.extensibility.execution" Version="2.2.0" /> |
|||
<PackageReference Condition="'$(TargetFramework)' == 'net461'" Include="xunit.runner.visualstudio" Version="2.2.0" /> |
|||
</ItemGroup> |
|||
<Import Condition="'$(TargetFramework)' == 'net461'" Project="$(MSBuildThisFileDirectory)..\src\Shared\nuget.workaround.targets" /> |
|||
</Project> |
|||
Loading…
Reference in new issue