metacity r4079 - in branches/veracity: . test/veracity test/veracity/build test/veracity/stress test/veracity/unit
- From: tthurman svn gnome org
- To: svn-commits-list gnome org
- Subject: metacity r4079 - in branches/veracity: . test/veracity test/veracity/build test/veracity/stress test/veracity/unit
- Date: Wed, 21 Jan 2009 19:24:34 +0000 (UTC)
Author: tthurman
Date: Wed Jan 21 19:24:34 2009
New Revision: 4079
URL: http://svn.gnome.org/viewvc/metacity?rev=4079&view=rev
Log:
added bones of Veracity test suite
* test/veracity/Makefile.am:
* test/veracity/TODO:
* test/veracity/unit/reparent.js:
* test/veracity/unit/reparent.scm:
* test/veracity/veracity.c:
* test/veracity (added):
* test/veracity/unit (added):
* test/veracity/unit/reparent.scm (added):
* test/veracity/unit/reparent.js (added):
* test/veracity/build (added):
* test/veracity/stress (added):
* test/veracity/TODO (added):
* test/veracity/veracity.c (added):
* test/veracity/Makefile.am (added):
Added:
branches/veracity/test/veracity/
branches/veracity/test/veracity/Makefile.am
branches/veracity/test/veracity/TODO
branches/veracity/test/veracity/build/
branches/veracity/test/veracity/stress/
branches/veracity/test/veracity/unit/
branches/veracity/test/veracity/unit/reparent.js
branches/veracity/test/veracity/unit/reparent.scm
branches/veracity/test/veracity/veracity.c
Modified:
branches/veracity/ChangeLog
Added: branches/veracity/test/veracity/Makefile.am
==============================================================================
--- (empty file)
+++ branches/veracity/test/veracity/Makefile.am Wed Jan 21 19:24:34 2009
@@ -0,0 +1,19 @@
+if BUILD_TESTS
+
+ INTLTOOL_DESKTOP_RULE@
+dfdfdf
+
+#INCLUDES= METACITY_WINDOW_DEMO_CFLAGS@ @METACITY_MESSAGE_CFLAGS@ \
+# -DMETACITY_ICON_DIR=\"$(pkgdatadir)/icons\" \
+# -DMETACITY_LOCALEDIR=\"$(prefix)/@DATADIRNAME@/locale\"
+
+veracity_SOURCES= \
+ veracity.c
+
+## don't install the test suite
+#noinst_PROGRAMS=veracity
+
+veracity_LDADD= @METACITY_LIBS@
+
+endif
+
Added: branches/veracity/test/veracity/TODO
==============================================================================
--- (empty file)
+++ branches/veracity/test/veracity/TODO Wed Jan 21 19:24:34 2009
@@ -0,0 +1,6 @@
+Replace gconf_test with actual gconf setting code. Check types.
+Command-line switches.
+Iterate over all in directory unless one was specified.
+Pick display number sensibly.
+Implement (listen) to call its argument with every X event until it returns false.
+Wrap call to Xephyr with Xvfb (except if they specify -V).
Added: branches/veracity/test/veracity/unit/reparent.js
==============================================================================
--- (empty file)
+++ branches/veracity/test/veracity/unit/reparent.js Wed Jan 21 19:24:34 2009
@@ -0,0 +1,30 @@
+// Test for Metacity
+// Do windows get reparented when the WM starts?
+//
+// Copyright (C) 2008 Thomas Thurman
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program 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
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+// 02111-1307, USA.
+
+function test()
+{
+ a = make_window ();
+ b = make_window ();
+ if (parent (a) || parent (b))
+ throw "Window has a parent at the beginning";
+ start_wm ();
+ if (!parent (a) || !parent (b))
+ throw "Window was not reparented";
+}
Added: branches/veracity/test/veracity/unit/reparent.scm
==============================================================================
--- (empty file)
+++ branches/veracity/test/veracity/unit/reparent.scm Wed Jan 21 19:24:34 2009
@@ -0,0 +1,36 @@
+;;; Test for Metacity
+;;; Do windows get reparented when the WM starts?
+;;;
+;;; Copyright (C) 2008 Thomas Thurman
+;;;
+;;; This program is free software; you can redistribute it and/or
+;;; modify it under the terms of the GNU General Public License as
+;;; published by the Free Software Foundation; either version 2 of the
+;;; License, or (at your option) any later version.
+;;;
+;;; This program 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
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program; if not, write to the Free Software
+;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+;;; 02111-1307, USA.
+
+(define test
+ (lambda ()
+ (define a (make-window))
+ (define b (make-window))
+ (if (or (parent a) (parent b))
+ "Window has a parent at the beginning"
+ ;;; otherwise let's start the wm
+ (begin
+ (start-wm)
+ ;;; now, do we have a parent?
+ (if (or (not (parent a)) (not (parent b)))
+ "Window was not reparented"
+ ;;; otherwise pass
+ #t)
+ )
+ )))
Added: branches/veracity/test/veracity/veracity.c
==============================================================================
--- (empty file)
+++ branches/veracity/test/veracity/veracity.c Wed Jan 21 19:24:34 2009
@@ -0,0 +1,284 @@
+/*
+ * veracity - test metacity
+ *
+ * Copyright (C) 2008 Thomas Thurman
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+#include <stdio.h>
+#include <libguile.h>
+#include <guile/gh.h>
+#include <sys/types.h>
+#include <signal.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Shell.h>
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+
+#include <gconf/gconf.h>
+
+int x_server = 0; /* PID of the tame X server */
+int window_manager = 0; /* PID of the window manager */
+int dbus_daemon = 0;
+int gconf_daemon = 0;
+
+Display *current_display = NULL;
+
+gboolean verbose = FALSE;
+
+SCM
+make_window()
+{
+ Window newbie;
+
+ newbie = XCreateWindow(current_display,
+ DefaultRootWindow(current_display),
+ 0, 0, 300, 300, 0,
+ CopyFromParent,
+ InputOutput,
+ CopyFromParent,
+ 0, 0);
+
+ XMapWindow (current_display, newbie);
+
+ XSync (current_display, True);
+
+ if (verbose)
+ printf ("Created window %x\n", (int) newbie);
+
+ return scm_int2num(newbie);
+}
+
+SCM
+parent(SCM raw_window)
+{
+ Window window = gh_scm2int (raw_window);
+ Display *display;
+ Window w;
+ Window root_return;
+ Window parent_return;
+ Window *children_return;
+ unsigned int nchildren_return;
+
+ XQueryTree(current_display, window,
+ &root_return, &parent_return,
+ &children_return, &nchildren_return);
+
+ XFree (children_return);
+
+ if (verbose)
+ printf ("Parent of %x is %x (root is %x)\n", (int) window, (int) parent_return, (int) root_return);
+
+ if (root_return == parent_return)
+ return SCM_BOOL(0);
+ else
+ return scm_int2num (parent_return);
+}
+
+static SCM
+start_wm ()
+{
+ /* FIXME: Which WM ought to be configurable */
+
+ if (!(window_manager = fork()))
+ {
+ execlp ("metacity", "metacity", NULL);
+ }
+
+ /* have to wait a moment here while metacity starts up */
+ sleep(2);
+
+}
+
+static SCM
+key_event ()
+{
+ /*
+ * Based around some public domain code by Adam Pierce
+ * http://www.doctort.org/adam/nerd-notes/x11-fake-keypress-event.html
+ */
+}
+
+static void
+gconf_test (char *test)
+{
+ GConfValue *val = gconf_value_new_from_string (GCONF_VALUE_STRING,
+ test, NULL);
+
+ if (verbose)
+ printf ("Setting the theme to %s\n", test);
+ gconf_client_set (gconf_client_get_default (),
+ "/apps/metacity/general/theme",
+ val,
+ NULL);
+
+ gconf_value_free (val);
+}
+
+static void
+start_dbus_daemon ()
+{
+ FILE *dbus_input;
+ int pipes[2];
+ char text[10240];
+ char *cursor = text;
+ ssize_t size;
+
+ pipe (pipes);
+
+ if (!(dbus_daemon = fork()))
+ {
+ close(1);
+ dup2(pipes[1], 1);
+ execlp ("dbus-launch", "dbus-launch", NULL);
+ }
+ sleep(1);
+
+ size = read (pipes[0], &text, sizeof (text)-1);
+ text[size] = 0;
+
+ /* okay, now we have FOO=bar\nBAZ=wombat\n... in text */
+
+ while (*cursor) {
+ char *newline = index (cursor, '\n');
+
+ *newline = 0;
+ putenv (cursor);
+
+ cursor = newline+1;
+ }
+
+}
+
+static void
+start_gconf_daemon ()
+{
+ if (!(gconf_daemon = fork()))
+ {
+ execlp ("gconftool-2", "gconftool-2", "--spawn", NULL);
+ }
+ sleep(1);
+
+ gconf_test ("Atlanta");
+}
+
+void
+start_x_server ()
+{
+ /* FIXME: Pick a sane number automagically */
+ char *displaynumber = ":23";
+
+ if (!(x_server = fork()))
+ {
+ fclose(stderr); /* hide all the useless spew */
+
+ /*
+ execlp ("Xnest", "Xnest", displaynumber, "-ac", NULL);
+ */
+ /*
+ execlp ("Xvfb", "Xvfb", displaynumber, "-ac", "+extension", "RANDR", NULL);
+ */
+ execlp ("Xephyr", "Xephyr", displaynumber, "-nolisten", "tcp", "-host-cursor",
+ "-screen", "800x480x16", "-dpi", "96", "-ac",
+ "+extension", "Composite",
+ "+extension", "XFIXES",
+ "+extension", "DAMAGE",
+ "+extension", "RENDER",
+ "+extension", "GLX",
+ NULL);
+ }
+ sleep (1);
+
+ current_display = XOpenDisplay (displaynumber);
+ setenv ("DISPLAY", displaynumber, 1);
+}
+
+static void
+start_guile ()
+{
+ scm_init_guile ();
+
+ scm_c_define_gsubr("make-window", 0, 0, 0, make_window);
+ scm_c_define_gsubr("parent", 1, 0, 0, parent);
+ scm_c_define_gsubr("start-wm", 0, 0, 0, start_wm);
+ scm_c_define_gsubr("key-event", 2, 0, 0, key_event);
+ scm_c_define_gsubr("gconf-set!", 2, 0, 0, gconf_set);
+}
+
+static void
+start ()
+{
+ /* Normalise error messages */
+ putenv ("LANG=C");
+
+ start_dbus_daemon ();
+ start_gconf_daemon ();
+ start_x_server ();
+ start_guile ();
+}
+
+static gboolean
+run_test (char *name)
+{
+ printf("%20s: ", name);
+ fflush(stdout);
+
+ // Load the scheme function definitions
+ scm_c_primitive_load (name);
+
+ SCM result = scm_c_eval_string("(test)");
+
+ if (scm_is_string (result))
+ {
+ int length;
+ char *raw_text = gh_scm2newstr (result, &length);
+ printf ("FAIL (%s)\n", raw_text);
+ free (raw_text);
+ return FALSE;
+ }
+ else
+ {
+ printf ("pass\n");
+ return TRUE;
+ }
+}
+
+static void
+finish ()
+{
+ if (x_server) kill(x_server, SIGKILL);
+ if (window_manager) kill(window_manager, SIGKILL);
+ if (dbus_daemon) kill(dbus_daemon, SIGKILL);
+ if (gconf_daemon) kill(gconf_daemon, SIGKILL);
+
+ XCloseDisplay (current_display);
+}
+
+int
+main (int argc, char *argv[])
+{
+ start ();
+
+ run_test ("001-reparent.scm");
+
+ finish ();
+
+ /* I'm making a note here: HUGE SUCCESS. */
+ exit(EXIT_SUCCESS);
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]