Browse Source

Add some failing tests. Remove tiny bugs from MarkupExtensionTokenizer.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3303 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Ivan Shumilin 17 years ago
parent
commit
17b3167cf8
  1. 11
      samples/XamlDesigner/TestFiles/3.xaml
  2. 4
      samples/XamlDesigner/XamlDesigner.csproj
  3. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelProperty.cs
  4. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj
  5. 91
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/MarkupExtensionTests.cs
  6. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionParser.cs

11
samples/XamlDesigner/TestFiles/3.xaml

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
<Window xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Name="root"
Title="Hydralisk">
<Window.Resources>
<sys:String x:Key="r1">Title</sys:String>
<sys:String x:Key="r2">Width</sys:String>
</Window.Resources>
<TextBlock Text="{Binding Path={StaticResource r1}, ElementName=root}" />
</Window>

4
samples/XamlDesigner/XamlDesigner.csproj

@ -166,6 +166,10 @@ @@ -166,6 +166,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="TestFiles\3.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Generic.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelProperty.cs

@ -96,9 +96,12 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -96,9 +96,12 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
if (IsCollection)
throw new DesignerException("Cannot access Value for collection properties.");
//TODO
if (ValueOnInstance == null) return null;
return _designItem.ComponentService.GetDesignItem(ValueOnInstance);
var xamlObject = _property.PropertyValue as XamlObject;
if (xamlObject != null) {
return _designItem.ComponentService.GetDesignItem(xamlObject.Instance);
}
return null;
}
}

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj

@ -60,6 +60,7 @@ @@ -60,6 +60,7 @@
<Compile Include="XamlDom\ExampleClass.cs" />
<Compile Include="XamlDom\ExampleClassContainer.cs" />
<Compile Include="XamlDom\ExampleService.cs" />
<Compile Include="XamlDom\MarkupExtensionTests.cs" />
<Compile Include="XamlDom\SamplesTests.cs" />
<Compile Include="XamlDom\SimpleLoadTests.cs" />
<Compile Include="XamlDom\SystemTypesLoadTest.cs" />
@ -81,7 +82,5 @@ @@ -81,7 +82,5 @@
<Project>{78CC29AC-CC79-4355-B1F2-97936DF198AC}</Project>
<Name>WpfDesign.Designer</Name>
</ProjectReference>
<Folder Include="Designer" />
<Folder Include="XamlDom" />
</ItemGroup>
</Project>

91
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/MarkupExtensionTests.cs

@ -0,0 +1,91 @@ @@ -0,0 +1,91 @@
using System;
using NUnit.Framework;
using System.Windows.Markup;
namespace ICSharpCode.WpfDesign.Tests.XamlDom
{
[TestFixture]
public class MarkupExtensionTests : TestHelper
{
[Test]
public void Test1()
{
TestMarkupExtension("Title=\"{Binding}\"");
}
[Test]
public void Test2()
{
TestMarkupExtension("Title=\"{Binding Some}\"");
}
[Test]
public void Test3()
{
TestMarkupExtension("Title=\"{ Binding Some , ElementName = Some , Mode = TwoWay }\"");
}
[Test]
public void Test4()
{
TestMarkupExtension("Content=\"{x:Type Button}\"");
}
[Test]
public void Test5()
{
TestMarkupExtension("Content=\"{t:MyExtension 1, 2}\"");
}
[Test]
public void Test6()
{
TestMarkupExtension("Background=\"{x:Static SystemColors.ControlBrush}\"");
}
[Test]
public void Test7()
{
TestMarkupExtension("Background=\"{DynamicResource {x:Static SystemColors.ControlBrushKey}}\"");
}
[Test]
public void Test8()
{
TestMarkupExtension("Content=\"{Binding Some, RelativeSource={RelativeSource Self}}\"");
}
[Test]
[ExpectedException] // Must differ from official XamlReader result
public void Test9()
{
TestMarkupExtension("Content=\"{x:Static t:MyStaticClass.StaticString}\"");
}
static void TestMarkupExtension(string s)
{
TestLoading(@"<Window
xmlns=""http://schemas.microsoft.com/netfx/2007/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
xmlns:t=""" + XamlTypeFinderTests.XamlDomTestsNamespace + @"""
" + s + @"/>");
}
}
public static class MyStaticClass
{
public static string StaticString = "a";
}
public class MyExtension : MarkupExtension
{
public MyExtension(object p1, object p2)
{
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
return null;
}
}
}

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionParser.cs

@ -58,7 +58,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -58,7 +58,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
while (pos < text.Length) {
switch (text[pos]) {
case '}':
AddToken(MarkupExtensionTokenKind.CloseBrace, "{");
AddToken(MarkupExtensionTokenKind.CloseBrace, "}");
pos++;
break;
case '=':
@ -70,7 +70,9 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -70,7 +70,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
pos++;
break;
case '{':
throw new XamlMarkupExtensionParseException("'{' is invalid at this location");
AddToken(MarkupExtensionTokenKind.OpenBrace, "{");
pos++;
break;
default:
MembernameOrString();
break;

Loading…
Cancel
Save