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:
authorIain McCoy <iainmc@mono-cvs.ximian.com>2005-09-01 17:48:26 +0400
committerIain McCoy <iainmc@mono-cvs.ximian.com>2005-09-01 17:48:26 +0400
commit47d54c523d17a1260245fbfb02d59cd263368c67 (patch)
tree2e3bfa422f7cac62632b8be79c68df0d2767406d /mcs/class/PresentationFramework
parent8e8cd038e75784d1bf357c24a2b526c0dbbbc9e3 (diff)
2005-09-01 Iain McCoy <iain@mccoy.id.au>
* Mono.Windows.Serialization/ParserToCode.cs Test/Parser.cs Test/XamlParser.cs Test/ParserToCode.cs: Added tests for x:Key and StaticResource, fixed bug in handling of x:Key in the code generator svn path=/trunk/mcs/; revision=49266
Diffstat (limited to 'mcs/class/PresentationFramework')
-rw-r--r--mcs/class/PresentationFramework/ChangeLog8
-rw-r--r--mcs/class/PresentationFramework/Mono.Windows.Serialization/ParserToCode.cs2
-rw-r--r--mcs/class/PresentationFramework/Test/Parser.cs24
-rw-r--r--mcs/class/PresentationFramework/Test/ParserToCode.cs23
-rw-r--r--mcs/class/PresentationFramework/Test/XamlParser.cs61
5 files changed, 113 insertions, 5 deletions
diff --git a/mcs/class/PresentationFramework/ChangeLog b/mcs/class/PresentationFramework/ChangeLog
index 23e4762dfca..6ac6a603bc2 100644
--- a/mcs/class/PresentationFramework/ChangeLog
+++ b/mcs/class/PresentationFramework/ChangeLog
@@ -1,3 +1,11 @@
+2005-09-01 Iain McCoy <iain@mccoy.id.au>
+
+ * Mono.Windows.Serialization/ParserToCode.cs
+ Test/Parser.cs
+ Test/XamlParser.cs
+ Test/ParserToCode.cs: Added tests for x:Key and StaticResource,
+ fixed bug in handling of x:Key in the code generator
+
2005-08-31 Iain McCoy <iain@mccoy.id.au>
* System.Windows.Serialization/Parser.cs,
diff --git a/mcs/class/PresentationFramework/Mono.Windows.Serialization/ParserToCode.cs b/mcs/class/PresentationFramework/Mono.Windows.Serialization/ParserToCode.cs
index cf663e9002b..57476f2cfd8 100644
--- a/mcs/class/PresentationFramework/Mono.Windows.Serialization/ParserToCode.cs
+++ b/mcs/class/PresentationFramework/Mono.Windows.Serialization/ParserToCode.cs
@@ -302,7 +302,7 @@ namespace Mono.Windows.Serialization {
{
CodeAssignStatement assignment = new CodeAssignStatement(
(CodeExpression)peek(),
- new CodeVariableReferenceExpression(key));
+ new CodeVariableReferenceExpression((string)keys[key]));
constructor.Statements.Add(assignment);
}
diff --git a/mcs/class/PresentationFramework/Test/Parser.cs b/mcs/class/PresentationFramework/Test/Parser.cs
index f324b06425f..c9ae874e754 100644
--- a/mcs/class/PresentationFramework/Test/Parser.cs
+++ b/mcs/class/PresentationFramework/Test/Parser.cs
@@ -162,15 +162,31 @@ public class ParserTest {
public void TestObjectAsPropertyValue()
{
code = "<ConsoleApp xmlns=\"console\" xmlns:x=\"http://schemas.microsoft.com/winfx/xaml/2005\">\n"+
- "<ConsoleReader>\n" +
- "<ConsoleReader.Prompt><ConsoleWriter /></ConsoleReader.Prompt>\n" +
- "</ConsoleReader>\n" +
+ "<ConsoleReader>\n" +
+ "<ConsoleReader.Prompt><ConsoleWriter /></ConsoleReader.Prompt>\n" +
+ "</ConsoleReader>\n" +
+ "</ConsoleApp>";
+ ConsoleApp app = new ConsoleApp();
+ ConsoleReader reader = new ConsoleReader();
+ app.AddChild(reader);
+ ConsoleWriter writer = new ConsoleWriter();
+ reader.Prompt = writer;
+ compare(app);
+ }
+ [Test]
+ public void TestKeyAndStaticResource()
+ {
+ code = "<ConsoleApp xmlns=\"console\" xmlns:x=\"http://schemas.microsoft.com/winfx/xaml/2005\">\n"+
+ "<ConsoleWriter Text=\"xyz\" x:Key=\"foobar\" />\n" +
+ "<ConsoleReader Prompt=\"{StaticResource foobar}\" />\n" +
"</ConsoleApp>";
ConsoleApp app = new ConsoleApp();
+ ConsoleWriter writer = new ConsoleWriter();
+ writer.Text = new ConsoleValueString("xyz");
+ app.AddChild(writer);
ConsoleReader reader = new ConsoleReader();
app.AddChild(reader);
- ConsoleWriter writer = new ConsoleWriter();
reader.Prompt = writer;
compare(app);
diff --git a/mcs/class/PresentationFramework/Test/ParserToCode.cs b/mcs/class/PresentationFramework/Test/ParserToCode.cs
index f4ec88fccc2..9cd6921b8e5 100644
--- a/mcs/class/PresentationFramework/Test/ParserToCode.cs
+++ b/mcs/class/PresentationFramework/Test/ParserToCode.cs
@@ -316,6 +316,29 @@ public class ParserToCodeTest {
);
}
+ [Test]
+ public void TestKeyAndStaticResource()
+ {
+ code = "<ConsoleApp xmlns=\"console\" xmlns:x=\"http://schemas.microsoft.com/winfx/xaml/2005\">\n"+
+ "<ConsoleWriter Text=\"xyz\" x:Key=\"foobar\" />\n" +
+ "<ConsoleReader Prompt=\"{StaticResource foobar}\" />\n" +
+ "</ConsoleApp>";
+
+ compare(
+ "namespace DefaultNamespace {\n" +
+ " public class derivedConsoleApp : Xaml.TestVocab.Console.ConsoleApp {\n" +
+ " private derivedConsoleApp() {\n" +
+ " Xaml.TestVocab.Console.ConsoleWriter consoleWriter1 = new Xaml.TestVocab.Console.ConsoleWriter();\n" +
+ " this.AddChild(consoleWriter1);\n" +
+ " consoleWriter1.Text = ((Xaml.TestVocab.Console.ConsoleValue)(System.ComponentModel.TypeDescriptor.GetConverter(typeof(Xaml.TestVocab.Console.ConsoleValue)).ConvertFromString(\"xyz\")));\n" +
+ " Xaml.TestVocab.Console.ConsoleReader consoleReader1 = new Xaml.TestVocab.Console.ConsoleReader();\n" +
+ " this.AddChild(consoleReader1);\n" +
+ " consoleReader1.Prompt = consoleWriter1;\n" +
+ " }\n" +
+ " }\n" +
+ "}");
+ }
+
[Test]
public void TestEvent()
diff --git a/mcs/class/PresentationFramework/Test/XamlParser.cs b/mcs/class/PresentationFramework/Test/XamlParser.cs
index 5e2afcf4e37..724cb18021d 100644
--- a/mcs/class/PresentationFramework/Test/XamlParser.cs
+++ b/mcs/class/PresentationFramework/Test/XamlParser.cs
@@ -607,6 +607,67 @@ public class XamlParserTest {
}
+ [Test]
+ public void TestKeyAndStaticResource()
+ {
+ string s = "<ConsoleApp xmlns=\"console\" xmlns:x=\"http://schemas.microsoft.com/winfx/xaml/2005\">\n"+
+ "<ConsoleWriter Text=\"xyz\" x:Key=\"foobar\" />\n" +
+ "<ConsoleReader Prompt=\"{StaticResource foobar}\" />\n" +
+ "</ConsoleApp>";
+ object p = buildParser(new StringReader(MAPPING + s));
+ XamlNode n;
+ n = getNextNode(p);
+ Assert.IsTrue(n is XamlDocumentStartNode, "A1");
+
+ n = getNextNode(p);
+ Assert.IsTrue(n is XamlElementStartNode, "B1");
+ Assert.AreEqual(n.Depth, 0, "B2");
+ Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleApp), "B3");
+
+ n = getNextNode(p);
+ Assert.IsTrue(n is XamlKeyElementStartNode, "C1");
+ Assert.AreEqual(n.Depth, 1, "C2");
+ Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleWriter), "C3");
+ string key = (string)n.GetType().GetProperty("key", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(n, null);
+ Assert.AreEqual(key, "foobar", "C4");
+
+ n = getNextNode(p);
+ Assert.IsTrue(n is XamlPropertyNode, "D1");
+ Assert.AreEqual(1, n.Depth, "D2");
+ Assert.AreEqual(((XamlPropertyNode)n).PropInfo, typeof(ConsoleWriter).GetProperty("Text"), "D3");
+
+ n = getNextNode(p);
+ Assert.IsTrue(n is XamlTextNode, "DD1");
+
+ n = getNextNode(p);
+ Assert.IsTrue(n is XamlElementEndNode, "E1");
+
+ n = getNextNode(p);
+ Assert.IsTrue(n is XamlElementStartNode, "F1" + n.GetType());
+ Assert.AreEqual(1, n.Depth, "F2");
+ Assert.AreEqual(((XamlElementStartNode)n).ElementType, typeof(ConsoleReader), "F3");
+
+ n = getNextNode(p);
+ Assert.IsTrue(n is XamlPropertyNode, "G1");
+ Assert.AreEqual(1, n.Depth, "G2");
+ Assert.AreEqual(((XamlPropertyNode)n).PropInfo, typeof(ConsoleReader).GetProperty("Prompt"), "G3");
+
+ n = getNextNode(p);
+ Assert.IsTrue(n is XamlTextNode, "H1");
+ Assert.AreEqual(1, n.Depth, "H2");
+ key = (string)n.GetType().GetProperty("keyText", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(n, null);
+ Assert.AreEqual("foobar", key, "H3");
+
+ n = getNextNode(p);
+ Assert.IsTrue(n is XamlElementEndNode, "I1");
+
+ n = getNextNode(p);
+ Assert.IsTrue(n is XamlElementEndNode, "J1");
+
+ n = getNextNode(p);
+ Assert.IsTrue(n is XamlDocumentEndNode, "K1");
+
+ }
[Test]
[ExpectedException(typeof(Exception), "Cannot add object to instance of 'Xaml.TestVocab.Console.ConsoleValueString'.")]