metacity r3714 - in branches/test-system: . src/core test
- From: tthurman svn gnome org
- To: svn-commits-list gnome org
- Subject: metacity r3714 - in branches/test-system: . src/core test
- Date: Sun, 18 May 2008 22:00:59 +0000 (UTC)
Author: tthurman
Date: Sun May 18 22:00:59 2008
New Revision: 3714
URL: http://svn.gnome.org/viewvc/metacity?rev=3714&view=rev
Log:
First pass with the testing subsystem
Added:
branches/test-system/test/basic-test.py
Modified:
branches/test-system/configure.in
branches/test-system/src/core/atomnames.h
branches/test-system/src/core/window-props.c
branches/test-system/src/core/window.c
Modified: branches/test-system/configure.in
==============================================================================
--- branches/test-system/configure.in (original)
+++ branches/test-system/configure.in Sun May 18 22:00:59 2008
@@ -143,6 +143,11 @@
[disable metacity's compositing manager]),,
enable_compositor=auto)
+AC_ARG_ENABLE(testing,
+ AC_HELP_STRING([--disable-testing],
+ [disable testing subsystem]),,
+ enable_testing=no)
+
AC_ARG_ENABLE(xsync,
AC_HELP_STRING([--disable-xsync],
[disable metacity's use of the XSync extension]),,
@@ -471,6 +476,12 @@
GCONF_SCHEMAS_INSTALL_FALSE=
fi
+if test x$enable_testing = xyes; then
+ echo "Building with testing subsystem"
+ AC_DEFINE(USING_TESTING, 1, [Building with testing support])
+fi
+
+
AC_ARG_ENABLE(debug,
[ --enable-debug enable debugging],,
enable_debug=no)
@@ -520,6 +531,7 @@
Startup notification: ${have_startup_notification}
Compositing manager: ${have_xcomposite}
Session management: ${found_sm}
+ Test subsystem: ${enable_testing}
Shape extension: ${found_shape}
Resize-and-rotate: ${found_randr}
Xsync: ${found_xsync}
Modified: branches/test-system/src/core/atomnames.h
==============================================================================
--- branches/test-system/src/core/atomnames.h (original)
+++ branches/test-system/src/core/atomnames.h Sun May 18 22:00:59 2008
@@ -58,6 +58,7 @@
item(_METACITY_RELOAD_THEME_MESSAGE)
item(_METACITY_SET_KEYBINDINGS_MESSAGE)
item(_METACITY_TOGGLE_VERBOSE)
+item(_METACITY_TESTING)
item(_GNOME_PANEL_ACTION)
item(_GNOME_PANEL_ACTION_MAIN_MENU)
item(_GNOME_PANEL_ACTION_RUN_DIALOG)
Modified: branches/test-system/src/core/window-props.c
==============================================================================
--- branches/test-system/src/core/window-props.c (original)
+++ branches/test-system/src/core/window-props.c Sun May 18 22:00:59 2008
@@ -842,6 +842,37 @@
}
}
+#ifdef USING_TESTING
+
+static void
+init_metacity_testing (MetaDisplay *display,
+ Atom property,
+ MetaPropValue *value)
+{
+ value->type = META_PROP_VALUE_UTF8;
+ value->atom = display->atom__METACITY_TESTING;
+}
+
+static void
+reload_metacity_testing (MetaWindow *window,
+ MetaPropValue *value)
+{
+ if (value->type == META_PROP_VALUE_UTF8 &&
+ value->v.str != NULL &&
+ strlen(value->v.str) >= 2 &&
+ value->v.str[1] == '?')
+ {
+ meta_warning ("Okay, we have a testing request on window %lx saying %s.\n", window->xwindow, value->v.str);
+
+ /* Use a dummy answer for now */
+ meta_prop_set_utf8_string_hint (window->display,
+ window->xwindow,
+ window->display->atom__METACITY_TESTING,
+ "A=2");
+ XSync (window->display->xdisplay, False); /* push everything through */
+ }
+}
+#endif /* USING_TESTING */
static void
init_normal_hints (MetaDisplay *display,
@@ -1440,7 +1471,11 @@
meta_window_queue (window, META_QUEUE_MOVE_RESIZE);
}
+#ifdef USING_TESTING
+#define N_HOOKS 27
+#else
#define N_HOOKS 26
+#endif /* USING_TESTING */
void
meta_display_init_window_prop_hooks (MetaDisplay *display)
@@ -1585,6 +1620,13 @@
hooks[i].reload_func = reload_net_wm_user_time_window;
++i;
+#ifdef USING_TESTING
+ hooks[i].property = display->atom__METACITY_TESTING;
+ hooks[i].init_func = init_metacity_testing;
+ hooks[i].reload_func = reload_metacity_testing;
+ ++i;
+#endif
+
if (i != N_HOOKS)
{
g_error ("Initialized %d hooks should have been %d\n", i, N_HOOKS);
Modified: branches/test-system/src/core/window.c
==============================================================================
--- branches/test-system/src/core/window.c (original)
+++ branches/test-system/src/core/window.c Sun May 18 22:00:59 2008
@@ -5492,6 +5492,20 @@
xid,
atom__NET_WM_USER_TIME);
}
+ else if (event->atom == window->display->atom__METACITY_TESTING)
+ {
+#ifdef USING_TESTING
+
+ meta_verbose ("Property notify on %s for _METACITY_TESTING\n", window->desc);
+
+ meta_window_reload_property (window,
+ window->display->atom__METACITY_TESTING);
+
+#else /* USING_TESTING */
+ meta_warning("Received _METACITY_TESTING message"
+ " but testing is turned off");
+#endif /* USING_TESTING */
+ }
return TRUE;
}
Added: branches/test-system/test/basic-test.py
==============================================================================
--- (empty file)
+++ branches/test-system/test/basic-test.py Sun May 18 22:00:59 2008
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+
+import sys
+import os
+from Xlib import X, display, Xatom
+
+def query_window_manager (type, details):
+ d = display.Display ()
+ s = d.screen ()
+ r = s.root
+
+ w = r.create_window (
+ 50, 50, 300, 200, 2,
+ s.root_depth,
+ X.InputOutput,
+ X.CopyFromParent,
+ background_pixel = s.white_pixel,
+ event_mask = X.PropertyChangeMask,
+ colormap = X.CopyFromParent,
+ )
+
+ w.map()
+
+ testing_atom = d.intern_atom ("_METACITY_TESTING")
+ utf8_string = d.intern_atom ("UTF8_STRING")
+
+ query = '%c?%s' % (type, details)
+ w.change_property (testing_atom, utf8_string, 8, query)
+
+ event = None
+
+ while 1:
+ event = d.next_event()
+
+ if event.type == X.DestroyNotify:
+ sys.exit(0)
+
+ if event.type == X.PropertyNotify and event.atom==testing_atom:
+ break
+
+ result = w.get_full_property (testing_atom, utf8_string).value
+
+ if len(result)<2 or result[1]!='=':
+ if result==query:
+ raise KeyError ("No result was set by the window manager.")
+ else:
+ raise KeyError ("Received some weird test result from the window manager: %s" % (result))
+
+ if result[0]!=type:
+ raise KeyError ("Received a result of %c from the window manager, but wanted %c." % (result[0], type))
+
+ return result[2:]
+
+query = '1'
+
+print 'Querying window manager with the query: ',query
+print 'Received result: ',query_window_manager ('A', query)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]