Browse Source

Added failing test.

StyleResources cannot currently be found in other style resources
because the style resource binding is evaluated before  the style is
attached to the parent. Described in #492.
pull/496/head
Steven Kirk 11 years ago
parent
commit
1c3b1672b8
  1. 10
      tests/Perspex.Markup.Xaml.UnitTests/Perspex.Markup.Xaml.UnitTests.csproj
  2. 8
      tests/Perspex.Markup.Xaml.UnitTests/Xaml/Style1.xaml
  3. 9
      tests/Perspex.Markup.Xaml.UnitTests/Xaml/Style2.xaml
  4. 26
      tests/Perspex.Markup.Xaml.UnitTests/Xaml/StyleTests.cs

10
tests/Perspex.Markup.Xaml.UnitTests/Perspex.Markup.Xaml.UnitTests.csproj

@ -174,6 +174,16 @@
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Xaml\Style1.xaml">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Xaml\Style2.xaml">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>

8
tests/Perspex.Markup.Xaml.UnitTests/Xaml/Style1.xaml

@ -0,0 +1,8 @@
<Style xmlns="https://github.com/perspex"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style.Resources>
<Color x:Key="Red">Red</Color>
<Color x:Key="Green">Green</Color>
<Color x:Key="Blue">Blue</Color>
</Style.Resources>
</Style>

9
tests/Perspex.Markup.Xaml.UnitTests/Xaml/Style2.xaml

@ -0,0 +1,9 @@
<Style xmlns="https://github.com/perspex"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mut="https://github.com/perspex/mutable">
<Style.Resources>
<mut:SolidColorBrush x:Key="RedBrush" Color="{StyleResource Red}"/>
<mut:SolidColorBrush x:Key="GreenBrush" Color="{StyleResource Green}"/>
<mut:SolidColorBrush x:Key="BlueBrush" Color="{StyleResource Blue}"/>
</Style.Resources>
</Style>

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

@ -198,5 +198,31 @@ namespace Perspex.Markup.Xaml.UnitTests.Xaml
Assert.Equal(0xff506070, brush.Color.ToUint32());
}
[Fact(Skip = "TODO: Issue #492")]
public void StyleResource_Can_Be_Found_Across_Xaml_Files()
{
using (UnitTestApplication.Start(TestServices.StyledWindow))
{
var xaml = @"
<Window xmlns='https://github.com/perspex'
xmlns:mut='https://github.com/perspex/mutable'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
<Window.Styles>
<StyleInclude Source='resm:Perspex.Markup.Xaml.UnitTests.Xaml.Style1.xaml?assembly=Perspex.Markup.Xaml.UnitTests'/>
<StyleInclude Source='resm:Perspex.Markup.Xaml.UnitTests.Xaml.Style2.xaml?assembly=Perspex.Markup.Xaml.UnitTests'/>
</Window.Styles>
<Border Name='border' Background='{StyleResource RedBrush}'/>
</Window>";
var loader = new PerspexXamlLoader();
var window = (Window)loader.Load(xaml);
var border = window.FindControl<Border>("border");
var borderBrush = (Perspex.Media.Mutable.SolidColorBrush)border.Background;
Assert.NotNull(borderBrush);
Assert.Equal(0xffff0000, borderBrush.Color.ToUint32());
}
}
}
}

Loading…
Cancel
Save