Browse Source

Merge branch 'master' into indexer-bindings

pull/691/head
Steven Kirk 10 years ago
parent
commit
7a53f46330
  1. 7
      .travis.yml
  2. 4
      src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs
  3. 5
      src/Avalonia.Styling/Styling/Setter.cs
  4. 4
      src/Skia/Avalonia.Skia/StreamGeometryImpl.cs
  5. 38
      tests/Avalonia.Controls.UnitTests/Presenters/ItemsPresenterTests_Virtualization_Simple.cs
  6. 31
      tests/Avalonia.Markup.Xaml.UnitTests/Xaml/StyleTests.cs

7
.travis.yml

@ -1,12 +1,15 @@
language: csharp
os:
- linux
- osx
mono:
- nightly
- latest
solution: Avalonia.mono.sln
before_install:
- mkdir -p .nuget
- wget -O .nuget/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
install:
- sudo apt-get install -y gtk-sharp2
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y gtk-sharp2 ; fi
- mono .nuget/nuget.exe restore Avalonia.mono.sln
- mono .nuget/nuget.exe install xunit.runner.console -Version 2.1.0 -OutputDirectory testrunner
script:

4
src/Avalonia.Controls/Presenters/ItemVirtualizerSimple.cs

@ -252,7 +252,7 @@ namespace Avalonia.Controls.Presenters
var index = NextIndex;
var step = 1;
while (!panel.IsFull)
while (!panel.IsFull && index >= 0)
{
if (index >= ItemCount)
{
@ -475,7 +475,7 @@ namespace Avalonia.Controls.Presenters
// is only partially visible due to differing item sizes. If the container is only
// partially visible, scroll again. Don't do this if there's no layout manager:
// it means we're running a unit test.
if (layoutManager != null)
if (container != null && layoutManager != null)
{
layoutManager.ExecuteLayoutPass();

5
src/Avalonia.Styling/Styling/Setter.cs

@ -4,6 +4,7 @@
using System;
using System.Reactive.Disposables;
using System.Reactive.Subjects;
using System.Reflection;
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Metadata;
@ -98,8 +99,10 @@ namespace Avalonia.Styling
if (binding == null)
{
var template = value as ITemplate;
bool isPropertyOfTypeITemplate = typeof(ITemplate).GetTypeInfo()
.IsAssignableFrom(Property.PropertyType.GetTypeInfo());
if (template != null)
if (template != null && !isPropertyOfTypeITemplate)
{
var materialized = template.Build();
NameScope.SetNameScope((Visual)materialized, new NameScope());

4
src/Skia/Avalonia.Skia/StreamGeometryImpl.cs

@ -141,10 +141,8 @@ namespace Avalonia.Skia
public void SetFillRule(FillRule fillRule)
{
_geometryImpl.FillRule = fillRule;
_path.FillType = fillRule == FillRule.EvenOdd ? SKPathFillType.EvenOdd : SKPathFillType.Winding;
}
}
public FillRule FillRule { get; set; }
}
}

38
tests/Avalonia.Controls.UnitTests/Presenters/ItemsPresenterTests_Virtualization_Simple.cs

@ -326,6 +326,27 @@ namespace Avalonia.Controls.UnitTests.Presenters
Assert.Equal(expected, actual);
}
[Fact]
public void Measuring_To_Infinity_When_Scrolled_To_End_Should_Not_Throw()
{
var target = CreateTarget(useAvaloniaList: true);
target.ApplyTemplate();
target.Measure(new Size(100, 100));
target.Arrange(new Rect(0, 0, 100, 100));
((ILogicalScrollable)target).Offset = new Vector(0, 10);
// Check for issue #589: this should not throw.
target.Measure(Size.Infinity);
var expected = Enumerable.Range(0, 20).Select(x => $"Item {x}").ToList();
var items = (AvaloniaList<string>)target.Items;
var actual = target.Panel.Children.Select(x => x.DataContext).ToList();
Assert.Equal(expected, actual);
}
[Fact]
public void Replacing_Items_Should_Update_Containers()
{
@ -484,6 +505,23 @@ namespace Avalonia.Controls.UnitTests.Presenters
Assert.Equal(0, ((IVirtualizingPanel)target.Panel).PixelOffset);
}
[Fact]
public void Scrolling_To_Item_In_Zero_Sized_Presenter_Doesnt_Throw()
{
using (UnitTestApplication.Start(TestServices.RealLayoutManager))
{
var target = CreateTarget(itemCount: 10);
var items = (IList<string>)target.Items;
target.ApplyTemplate();
target.Measure(Size.Empty);
target.Arrange(Rect.Empty);
// Check for issue #591: this should not throw.
target.ScrollIntoView(items[0]);
}
}
public class Vertical
{
[Fact]

31
tests/Avalonia.Markup.Xaml.UnitTests/Xaml/StyleTests.cs

@ -254,5 +254,36 @@ namespace Avalonia.Markup.Xaml.UnitTests.Xaml
Assert.Equal("Hello World!", ((TextBlock)target.Content).Text);
}
}
[Fact]
public void Setter_Value_Is_Bound_Directly_If_The_Target_Type_Derives_From_ITemplate()
{
using (UnitTestApplication.Start(TestServices.StyledWindow))
{
var xaml = @"
<Window xmlns='https://github.com/avaloniaui'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
<Window.Styles>
<Style Selector=':is(Control)'>
<Setter Property='FocusAdorner'>
<FocusAdornerTemplate>
<Rectangle Stroke='Black'
StrokeThickness='1'
StrokeDashArray='1,2'/>
</FocusAdornerTemplate>
</Setter>
</Style>
</Window.Styles>
<TextBlock Name='target'/>
</Window>";
var loader = new AvaloniaXamlLoader();
var window = (Window)loader.Load(xaml);
var target = window.Find<TextBlock>("target");
Assert.NotNull(target.FocusAdorner);
}
}
}
}

Loading…
Cancel
Save