Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtsushi Eno <atsushi@ximian.com>2012-03-09 13:59:46 +0400
committerAtsushi Eno <atsushi@ximian.com>2012-03-09 13:59:46 +0400
commitd7d2e98d941ab5c10daa7a4e791a5f351fee6a88 (patch)
tree4d74d9a40e1d9c3d435a50c4e958df4cfeb55e58 /mcs/class/System.Xaml
parentf717ddb496d58e4f3c23f6918f814848a3421224 (diff)
Added test case for #3003.
Diffstat (limited to 'mcs/class/System.Xaml')
-rwxr-xr-xmcs/class/System.Xaml/Test/System.Xaml/TestedTypes.cs138
-rwxr-xr-xmcs/class/System.Xaml/Test/System.Xaml/XamlObjectWriterTest.cs39
-rw-r--r--mcs/class/System.Xaml/Test/System.Xaml/XamlSchemaContextTest.cs4
3 files changed, 179 insertions, 2 deletions
diff --git a/mcs/class/System.Xaml/Test/System.Xaml/TestedTypes.cs b/mcs/class/System.Xaml/Test/System.Xaml/TestedTypes.cs
index 88fcce250dd..5795722a2d8 100755
--- a/mcs/class/System.Xaml/Test/System.Xaml/TestedTypes.cs
+++ b/mcs/class/System.Xaml/Test/System.Xaml/TestedTypes.cs
@@ -23,6 +23,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
@@ -39,6 +40,9 @@ using System.Xml.Serialization;
[assembly: XmlnsDefinition ("http://www.domain.com/path", "XamlTest")] // bug #680385
[assembly: XmlnsDefinition ("http://www.domain.com/path", "SecondTest")] // bug #681045, same xmlns key for different clrns.
+[assembly: XmlnsDefinition ("http://schemas.example.com/test", "XamarinBug3003")] // bug #3003
+[assembly: XmlnsPrefix ("http://schemas.example.com/test", "test")] // bug #3003
+
namespace MonoTests.System.Xaml
{
public class ArgumentAttributed
@@ -1164,4 +1168,138 @@ namespace XamarinBug2927
}
#endregion
+#region "xamarin bug 3003"
+
+namespace XamarinBug3003
+{
+ public static class TestContext
+ {
+ public static StringWriter Writer = new StringWriter ();
+
+ public const string XmlInput = @"<Parent xmlns='http://schemas.example.com/test' Title='Parent Title'>
+ <Child Parent.AssociatedProperty='child 1' Title='Child Title 1'></Child>
+ <Child Parent.AssociatedProperty='child 2' Title='Child Title 2'></Child>
+</Parent>";
+
+ // In bug #3003 repro, there is output "Item 'Child' inserted at index 'x'" , but I couldn't get it in the output either on .NET or Mono.
+ // On the other hand, in the standalone repro case they are in the output either in mono or in .NET. So I just stopped caring about that as it works as expected.
+ public const string ExpectedResult = @"
+Parent Constructed
+ISupportInitialize.BeginInit: Parent
+XamlObjectWriterSettings.AfterBeginInit: Parent
+XamlObjectWriterSettings.BeforeProperties: Parent
+XamlObjectWriterSettings.XamlSetValue: Parent Title, Member: Title
+Parent.Title_set: Parent
+Child Constructed
+ISupportInitialize.BeginInit: Child
+XamlObjectWriterSettings.AfterBeginInit: Child
+XamlObjectWriterSettings.BeforeProperties: Child
+XamlObjectWriterSettings.XamlSetValue: child 1, Member: AssociatedProperty
+Parent.SetAssociatedProperty: child 1
+XamlObjectWriterSettings.XamlSetValue: Child Title 1, Member: Title
+Child.Title_set: Child
+XamlObjectWriterSettings.AfterProperties: Child
+ISupportInitialize.EndInit: Child
+XamlObjectWriterSettings.AfterEndInit: Child
+Child Constructed
+ISupportInitialize.BeginInit: Child
+XamlObjectWriterSettings.AfterBeginInit: Child
+XamlObjectWriterSettings.BeforeProperties: Child
+XamlObjectWriterSettings.XamlSetValue: child 2, Member: AssociatedProperty
+Parent.SetAssociatedProperty: child 2
+XamlObjectWriterSettings.XamlSetValue: Child Title 2, Member: Title
+Child.Title_set: Child
+XamlObjectWriterSettings.AfterProperties: Child
+ISupportInitialize.EndInit: Child
+XamlObjectWriterSettings.AfterEndInit: Child
+XamlObjectWriterSettings.AfterProperties: Parent
+ISupportInitialize.EndInit: Parent
+XamlObjectWriterSettings.AfterEndInit: Parent
+Loaded Parent
+";
+ }
+
+ public class BaseItemCollection : Collection<BaseItem>
+ {
+ protected override void InsertItem (int index, BaseItem item)
+ {
+ base.InsertItem (index, item);
+ Console.WriteLine ("Item '{0}' inserted at index '{1}'", item, index);
+ }
+ }
+
+ public class BaseItem : ISupportInitialize
+ {
+ Dictionary<string, object> properties = new Dictionary<string, object> ();
+
+ public Dictionary<string, object> Properties
+ {
+ get { return properties; }
+ }
+
+ string title;
+
+ public string Title
+ {
+ get { return title; }
+ set
+ {
+ title = value;
+ TestContext.Writer.WriteLine ("{0}.Title_set: {0}", this.GetType ().Name, value);
+ }
+ }
+
+ public BaseItem ()
+ {
+ TestContext.Writer.WriteLine ("{0} Constructed", this.GetType ().Name);
+ }
+
+
+ public void BeginInit ()
+ {
+ TestContext.Writer.WriteLine ("ISupportInitialize.BeginInit: {0}", this);
+ }
+
+ public void EndInit ()
+ {
+ TestContext.Writer.WriteLine ("ISupportInitialize.EndInit: {0}", this);
+ }
+ public override string ToString ()
+ {
+ return this.GetType ().Name.ToString ();
+ }
+ }
+
+ public class Child : BaseItem
+ {
+ }
+
+ [ContentProperty ("Children")]
+ public class Parent : BaseItem
+ {
+ BaseItemCollection children = new BaseItemCollection ();
+
+ public BaseItemCollection Children
+ {
+ get { return children; }
+ }
+
+
+ public static string GetAssociatedProperty (Child child)
+ {
+ object value;
+ if (child.Properties.TryGetValue ("myassociatedproperty", out value)) return value as string;
+ return null;
+ }
+
+ public static void SetAssociatedProperty (Child child, string value)
+ {
+ TestContext.Writer.WriteLine ("Parent.SetAssociatedProperty: {0}", value);
+ child.Properties ["myassociatedproperty"] = value;
+ }
+
+ }
+}
+
+#endregion
diff --git a/mcs/class/System.Xaml/Test/System.Xaml/XamlObjectWriterTest.cs b/mcs/class/System.Xaml/Test/System.Xaml/XamlObjectWriterTest.cs
index 95e32c14fa6..f3e89003b3b 100755
--- a/mcs/class/System.Xaml/Test/System.Xaml/XamlObjectWriterTest.cs
+++ b/mcs/class/System.Xaml/Test/System.Xaml/XamlObjectWriterTest.cs
@@ -737,6 +737,45 @@ namespace MonoTests.System.Xaml
var ret = xow.Result as TestClass3;
Assert.IsNotNull (ret.Nested, "#8");
}
+
+ [Test] // bug #3003 repro
+ public void EventsAndProcessingOrder ()
+ {
+ var asm = Assembly.GetExecutingAssembly ();
+ var context = new XamlSchemaContext (new Assembly [] { asm });
+ var output = XamarinBug3003.TestContext.Writer;
+ output.WriteLine ();
+
+ var reader = new XamlXmlReader (XmlReader.Create (new StringReader (XamarinBug3003.TestContext.XmlInput)), context);
+
+ var writerSettings = new XamlObjectWriterSettings ();
+ writerSettings.AfterBeginInitHandler = (sender, e) => {
+ output.WriteLine ("XamlObjectWriterSettings.AfterBeginInit: {0}", e.Instance);
+ };
+ writerSettings.AfterEndInitHandler = (sender, e) => {
+ output.WriteLine ("XamlObjectWriterSettings.AfterEndInit: {0}", e.Instance);
+ };
+
+ writerSettings.BeforePropertiesHandler = (sender, e) => {
+ output.WriteLine ("XamlObjectWriterSettings.BeforeProperties: {0}", e.Instance);
+ };
+ writerSettings.AfterPropertiesHandler = (sender, e) => {
+ output.WriteLine ("XamlObjectWriterSettings.AfterProperties: {0}", e.Instance);
+ };
+ writerSettings.XamlSetValueHandler = (sender, e) => {
+ output.WriteLine ("XamlObjectWriterSettings.XamlSetValue: {0}, Member: {1}", e.Value, e.Member.Name);
+ };
+
+ var writer = new XamlObjectWriter (context, writerSettings);
+ XamlServices.Transform (reader, writer);
+ var obj = writer.Result as XamarinBug3003.Parent;
+
+ output.WriteLine ("Loaded {0}", obj);
+
+ Assert.AreEqual (XamarinBug3003.TestContext.ExpectedResult.Replace ("\r\n", "\n"), output.ToString ().Replace ("\r\n", "\n"), "#1");
+
+ Assert.AreEqual (2, obj.Children.Count, "#2");
+ }
// extra use case based tests.
diff --git a/mcs/class/System.Xaml/Test/System.Xaml/XamlSchemaContextTest.cs b/mcs/class/System.Xaml/Test/System.Xaml/XamlSchemaContextTest.cs
index bd011f3fe2b..5cccd520731 100644
--- a/mcs/class/System.Xaml/Test/System.Xaml/XamlSchemaContextTest.cs
+++ b/mcs/class/System.Xaml/Test/System.Xaml/XamlSchemaContextTest.cs
@@ -84,7 +84,7 @@ namespace MonoTests.System.Xaml
{
var ctx = new XamlSchemaContext (null, null);
var arr = ctx.GetAllXamlNamespaces ().ToArray ();
- Assert.AreEqual (4, arr.Length, "#1");
+ Assert.AreEqual (5, arr.Length, "#1");
Assert.IsTrue (arr.Contains (XamlLanguage.Xaml2006Namespace), "#1-2");
Assert.IsTrue (arr.Contains ("urn:mono-test"), "#1-3");
Assert.IsTrue (arr.Contains ("urn:mono-test2"), "#1-4");
@@ -96,7 +96,7 @@ namespace MonoTests.System.Xaml
ctx = NewThisAssemblyContext ();
arr = ctx.GetAllXamlNamespaces ().ToArray ();
- Assert.AreEqual (3, arr.Length, "#3");
+ Assert.AreEqual (4, arr.Length, "#3");
Assert.IsTrue (arr.Contains ("urn:mono-test"), "#3-2");
Assert.IsTrue (arr.Contains ("urn:mono-test2"), "#3-3");
}