Browse Source

Updated OmniXAML and added checks for initialization order.

OmniXAML issue #84 is now fixed. Added tests to confirm this and to check that setting the Name property now fails because of this fix.

The fix for Name will come next.
pull/464/head
Steven Kirk 10 years ago
parent
commit
f7cd106937
  1. 2
      src/Markup/Perspex.Markup.Xaml/OmniXAML
  2. 6
      src/Markup/Perspex.Markup.Xaml/Perspex.Markup.Xaml.csproj
  3. 54
      tests/Perspex.Markup.Xaml.UnitTests/Xaml/BasicTests.cs
  4. 26
      tests/Perspex.Markup.Xaml.UnitTests/Xaml/InitializationOrderTracker.cs

2
src/Markup/Perspex.Markup.Xaml/OmniXAML

@ -1 +1 @@
Subproject commit 307361d65a187d404da1d4e15a553d918c3ed79c
Subproject commit c2b86b9d1ae638c788f44bc63d17911986d766fb

6
src/Markup/Perspex.Markup.Xaml/Perspex.Markup.Xaml.csproj

@ -87,11 +87,6 @@
<Compile Include="MarkupExtensions\TemplateBindingExtension.cs" />
<Compile Include="MarkupExtensions\TypeExtension.cs" />
<Compile Include="OmniXAML\Source\Glass\AutoKeyDictionary.cs" />
<Compile Include="OmniXAML\Source\Glass\ChangeTracking\ObservableProperty.cs" />
<Compile Include="OmniXAML\Source\Glass\ChangeTracking\ObservablePropertyChain.cs" />
<Compile Include="OmniXAML\Source\Glass\ChangeTracking\Property.cs" />
<Compile Include="OmniXAML\Source\Glass\ChangeTracking\PropertyChain.cs" />
<Compile Include="OmniXAML\Source\Glass\ChangeTracking\ValueTypePropertyChain.cs" />
<Compile Include="OmniXAML\Source\Glass\DependencySorter.cs" />
<Compile Include="OmniXAML\Source\Glass\EnumExtensions.cs" />
<Compile Include="OmniXAML\Source\Glass\Extensions.cs" />
@ -279,7 +274,6 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="OmniXAML\Source\Glass\ChangeTracking\packages.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>

54
tests/Perspex.Markup.Xaml.UnitTests/Xaml/BasicTests.cs

@ -0,0 +1,54 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using Perspex.Controls;
using Perspex.UnitTests;
using Xunit;
namespace Perspex.Markup.Xaml.UnitTests.Xaml
{
public class BasicTests
{
[Fact]
public void Named_Control_Is_Added_To_NameScope()
{
using (UnitTestApplication.Start(TestServices.StyledWindow))
{
var xaml = @"
<Window xmlns='https://github.com/perspex'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
<Button Name='button'>Foo</Button>
</Window>";
var loader = new PerspexXamlLoader();
var window = (Window)loader.Load(xaml);
var button = window.FindControl<Button>("button");
Assert.Equal("Foo", button.Content);
}
}
[Fact]
public void Control_Is_Added_To_Parent_Before_Properties_Are_Set()
{
using (UnitTestApplication.Start(TestServices.StyledWindow))
{
var xaml = @"
<Window xmlns='https://github.com/perspex'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
xmlns:local='clr-namespace:Perspex.Markup.Xaml.UnitTests.Xaml;assembly=Perspex.Markup.Xaml.UnitTests'>
<local:InitializationOrderTracker Width='100'/>
</Window>";
var loader = new PerspexXamlLoader();
var window = (Window)loader.Load(xaml);
var tracker = (InitializationOrderTracker)window.Content;
var attached = tracker.Order.IndexOf("AttachedToLogicalTree");
var widthChanged = tracker.Order.IndexOf("Property Width Changed");
Assert.NotEqual(-1, attached);
Assert.NotEqual(-1, widthChanged);
Assert.True(attached < widthChanged);
}
}
}
}

26
tests/Perspex.Markup.Xaml.UnitTests/Xaml/InitializationOrderTracker.cs

@ -0,0 +1,26 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Collections.Generic;
using Perspex.Controls;
using Perspex.LogicalTree;
namespace Perspex.Markup.Xaml.UnitTests.Xaml
{
public class InitializationOrderTracker : Control
{
public IList<string> Order { get; } = new List<string>();
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
{
Order.Add("AttachedToLogicalTree");
base.OnAttachedToLogicalTree(e);
}
protected override void OnPropertyChanged(PerspexPropertyChangedEventArgs e)
{
Order.Add($"Property {e.Property.Name} Changed");
base.OnPropertyChanged(e);
}
}
}
Loading…
Cancel
Save