Author: miguel
Date: 2007-06-10 13:56:10 -0400 (Sun, 10 Jun 2007)
New Revision: 79122
Modified:
trunk/moon/test/Makefile
trunk/moon/test/demo.cs
trunk/moon/test/gtk.cs
Log:
Add testing framework to go over all the xaml files
Modified: trunk/moon/test/Makefile
===================================================================
--- trunk/moon/test/Makefile 2007-06-10 16:39:36 UTC (rev 79121)
+++ trunk/moon/test/Makefile 2007-06-10 17:56:10 UTC (rev 79122)
@@ -1,5 +1,8 @@
demo.exe: demo.cs gtk.cs
- gmcs -g demo.cs gtk.cs -pkg:gtk-sharp-2.0 -pkg:silver
+ gmcs -debug demo.cs gtk.cs -pkg:gtk-sharp-2.0 -pkg:silver
run: demo.exe
- mono --debug demo.exe
\ No newline at end of file
+ mono --debug demo.exe
+
+test: demo.exe
+ mono --debug demo.exe xaml/*xaml
Modified: trunk/moon/test/demo.cs
===================================================================
--- trunk/moon/test/demo.cs 2007-06-10 16:39:36 UTC (rev 79121)
+++ trunk/moon/test/demo.cs 2007-06-10 17:56:10 UTC (rev 79122)
@@ -7,13 +7,69 @@
using System.IO;
class X {
+ static GtkSilver silver;
+ static Window w;
+
+ static void Load (string file)
+ {
+ string xaml = null;
+
+ Console.WriteLine ("Loading: {0}", file);
+ try {
+ using (FileStream fs = File.OpenRead (file)){
+ using (StreamReader sr = new StreamReader (fs)){
+ xaml = sr.ReadToEnd ();
+ }
+ }
+ } catch (Exception e) {
+ Console.Error.WriteLine ("Error loading XAML file {0}:
{1}", file, e.GetType());
+ return;
+ }
+
+ if (xaml == null){
+ Console.Error.WriteLine ("Error loading XAML file {0}",
file);
+ return;
+ }
+ DependencyObject d = XamlReader.Load (xaml);
+ if (d == null){
+ Console.Error.WriteLine ("No dependency object returned
from XamlReader");
+ return;
+ }
+
+ if (!(d is Canvas)){
+ Console.Error.WriteLine ("No Canvas as root");
+ return;
+ }
+ w.Title = file;
+ silver.Attach ((Canvas) d);
+ }
+
static void Main (string [] args)
{
+ int i = 0;
Application.Init ();
- Window w = new Window ("Top");
- GtkSilver silver = new GtkSilver (400, 400);
- w.Add (silver);
+ w = new Window ("Top");
+ Box vb = new VBox ();
+ Box hb = new HBox ();
+ vb.Add (hb);
+
+ if (args.Length > 1){
+ Button next = new Button ("Load next file");
+ hb.Add (next);
+ next.Clicked += delegate {
+ Load (args [++i]);
+ if (i == args.Length-1)
+ next.Sensitive = false;
+ };
+ }
+
+ Button quit = new Button ("Quit");
+ quit.Clicked += delegate { Application.Quit (); };
+ hb.Add (quit);
+ silver = new GtkSilver (400, 400);
+ vb.Add (silver);
+ w.Add (vb);
w.ShowAll ();
//
@@ -45,34 +101,7 @@
c.Children.Add (l);
} else {
- string xaml = null;
-
- try {
- using (FileStream fs = File.OpenRead (args
[0])){
- using (StreamReader sr = new
StreamReader (fs)){
- xaml = sr.ReadToEnd ();
- }
- }
- } catch (Exception e) {
- Console.Error.WriteLine ("Error loading XAML
file {0}: {1}", args [0], e.GetType());
- return;
- }
-
- if (xaml == null){
- Console.Error.WriteLine ("Error loading XAML
file {0}", args [0]);
- return;
- }
- DependencyObject d = XamlReader.Load (xaml);
- if (d == null){
- Console.Error.WriteLine ("No dependency object
returned from XamlReader");
- return;
- }
-
- if (!(d is Canvas)){
- Console.Error.WriteLine ("No Canvas as root");
- return;
- }
- silver.Attach ((Canvas) d);
+ Load (args [i]);
}
Application.Run ();
Modified: trunk/moon/test/gtk.cs
===================================================================
--- trunk/moon/test/gtk.cs 2007-06-10 16:39:36 UTC (rev 79121)
+++ trunk/moon/test/gtk.cs 2007-06-10 17:56:10 UTC (rev 79122)
@@ -54,6 +54,9 @@
MethodInfo m = typeof (Canvas).GetMethod ("FromPtr",
BindingFlags.Static | BindingFlags.NonPublic);
Canvas c = (Canvas) m.Invoke (null, new object [] { x });
+ if (c == null)
+ return false;
+
Attach (c);
return true;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches