[maemo-commits] [maemo-commits] r17144 - in projects/haf/trunk/libmatchbox2: . tests

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Mon Jan 12 23:52:27 EET 2009
Author: tthurman
Date: 2009-01-12 23:52:06 +0200 (Mon, 12 Jan 2009)
New Revision: 17144

Added:
   projects/haf/trunk/libmatchbox2/tests/
   projects/haf/trunk/libmatchbox2/tests/test-toplevel.c
   projects/haf/trunk/libmatchbox2/tests/test-transience.c
Modified:
   projects/haf/trunk/libmatchbox2/ChangeLog
Log:
        Added some basic test programs (not part of the build system yet)
	* tests (added):
	* tests/test-toplevel.c (added):
	* tests/test-transience.c (added):



Modified: projects/haf/trunk/libmatchbox2/ChangeLog
===================================================================
--- projects/haf/trunk/libmatchbox2/ChangeLog	2009-01-12 16:23:31 UTC (rev 17143)
+++ projects/haf/trunk/libmatchbox2/ChangeLog	2009-01-12 21:52:06 UTC (rev 17144)
@@ -1,3 +1,11 @@
+2009-01-12  Thomas Thurman  <thomas.thurman at collabora.co.uk>
+
+        Added some basic test programs (not part of the build system yet)
+
+	* tests (added):
+	* tests/test-toplevel.c (added):
+	* tests/test-transience.c (added):
+
 2009-01-12  Kimmo Hämäläinen  <kimmo.hamalainen at nokia.com>
 
 	Release 0.2.13

Added: projects/haf/trunk/libmatchbox2/tests/test-toplevel.c
===================================================================
--- projects/haf/trunk/libmatchbox2/tests/test-toplevel.c	2009-01-12 16:23:31 UTC (rev 17143)
+++ projects/haf/trunk/libmatchbox2/tests/test-toplevel.c	2009-01-12 21:52:06 UTC (rev 17144)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2009 Nokia Corporation, all rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+#define MAEMO_CHANGES 1
+
+#include <X11/Xlib.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+
+GtkWidget *a, *b, *c;
+
+static char current_window (void)
+{
+	if (gtk_window_has_toplevel_focus (GTK_WINDOW (a)))
+		return 'a';
+	else if (gtk_window_has_toplevel_focus (GTK_WINDOW (b)))
+		return 'b';
+	else if (gtk_window_has_toplevel_focus (GTK_WINDOW (c)))
+		return 'c';
+	else
+		return '?';
+}
+
+gboolean do_something (gpointer dummy)
+{
+	static count = 0;
+	static char expecting = '?';
+
+	switch (count++)
+	{
+		case 0:
+			a = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+			gtk_widget_show_all (a);
+			g_warning ("Opened one window a");
+			expecting = 'a';
+			break;
+			
+		case 2:
+			b = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+			gtk_widget_show_all (b);
+			g_warning ("Opened another window b");
+			expecting = 'b';
+			break;
+
+		case 4:
+			c = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+			gtk_widget_show_all (c);
+			g_warning ("Opened a third window c");
+			expecting = 'c';
+			break;
+	
+		case 6:
+			gtk_widget_hide_all (c);
+
+			g_warning ("Hidden that third window");
+			expecting = 'b';
+			break;
+
+		case 8:
+			g_warning ("Pass.");
+			gtk_main_quit ();
+			break;
+
+		default: /* odd numbers */
+			if (current_window () == expecting)
+				g_warning ("%c is focussed as expected", current_window ());
+			else
+			{
+				g_warning ("Fail: %c is focussed but we expected %c.", current_window (),
+					expecting);
+				gtk_main_quit ();
+			}
+	}
+}
+
+int
+main (int argc, char **argv)
+{
+
+	gtk_init (&argc, &argv);
+
+	gtk_timeout_add (1000, do_something, NULL);
+
+	gtk_main ();
+
+	return 0;
+}

Added: projects/haf/trunk/libmatchbox2/tests/test-transience.c
===================================================================
--- projects/haf/trunk/libmatchbox2/tests/test-transience.c	2009-01-12 16:23:31 UTC (rev 17143)
+++ projects/haf/trunk/libmatchbox2/tests/test-transience.c	2009-01-12 21:52:06 UTC (rev 17144)
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2009 Nokia Corporation, all rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+#define MAEMO_CHANGES 1
+
+#include <X11/Xlib.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+
+GtkWidget *a, *b, *c;
+
+static char current_window (void)
+{
+	if (gtk_window_has_toplevel_focus (GTK_WINDOW (a)))
+		return 'a';
+	else if (gtk_window_has_toplevel_focus (GTK_WINDOW (b)))
+		return 'b';
+	else if (gtk_window_has_toplevel_focus (GTK_WINDOW (c)))
+		return 'c';
+	else
+		return '?';
+}
+
+gboolean do_something (gpointer dummy)
+{
+	static count = 0;
+	static char expecting = '?';
+
+	switch (count++)
+	{
+		case 0:
+			a = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+			gtk_widget_show_all (a);
+			g_warning ("Opened one window a");
+			expecting = 'a';
+			break;
+			
+		case 2:
+			b = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+			gtk_widget_show_all (b);
+			gtk_window_set_transient_for (GTK_WINDOW (a), GTK_WINDOW (b));
+			g_warning ("Opened another window b, and set 'a' transient to 'b'");
+			expecting = 'b';
+			break;
+
+		case 4:
+			c = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+			gtk_widget_show_all (c);
+			gtk_window_set_transient_for (GTK_WINDOW (c), GTK_WINDOW (b));
+			g_warning ("Opened a third window c, and set 'c' transient to 'b'");
+			expecting = 'c';
+			break;
+	
+		case 6:
+			gtk_widget_hide_all (c);
+
+			g_warning ("Hidden that third window 'c'; focus should now pass to the other transient, 'a'");
+			expecting = 'a';
+			break;
+
+		case 8:
+			g_warning ("Pass.");
+			gtk_main_quit ();
+			break;
+
+		default: /* odd numbers */
+			if (current_window () == expecting)
+				g_warning ("%c is focussed as expected", current_window ());
+			else
+			{
+				g_warning ("Fail: %c is focussed but we expected %c.", current_window (),
+					expecting);
+				gtk_main_quit ();
+			}
+	}
+}
+
+int
+main (int argc, char **argv)
+{
+
+	gtk_init (&argc, &argv);
+
+	gtk_timeout_add (1000, do_something, NULL);
+
+	gtk_main ();
+
+	return 0;
+}


More information about the maemo-commits mailing list