metacity r3719 - in branches/test-system: src/core test



Author: tthurman
Date: Tue May 20 04:32:44 2008
New Revision: 3719
URL: http://svn.gnome.org/viewvc/metacity?rev=3719&view=rev

Log:
Partial checkin

Modified:
   branches/test-system/src/core/prefs.c
   branches/test-system/src/core/testing.c
   branches/test-system/src/core/testing.h
   branches/test-system/test/basic-test.py

Modified: branches/test-system/src/core/prefs.c
==============================================================================
--- branches/test-system/src/core/prefs.c	(original)
+++ branches/test-system/src/core/prefs.c	Tue May 20 04:32:44 2008
@@ -32,6 +32,10 @@
 #include <string.h>
 #include <stdlib.h>
 
+#ifdef USING_TESTING
+#include "testing.h"
+#endif /* USING_TESTING */
+
 #define MAX_REASONABLE_WORKSPACES 36
 
 #define MAX_COMMANDS (32 + NUM_EXTRA_COMMANDS)
@@ -126,6 +130,11 @@
                                            const char  *value);
 static gboolean update_cursor_size        (int size);
 
+static void handle_configuration_update (const char *key,
+                                         GConfValue *value);
+
+static char* prefs_testing_handler (char type, char *details);
+
 static void change_notify (GConfClient    *client,
                            guint           cnxn_id,
                            GConfEntry     *entry,
@@ -913,6 +922,15 @@
   /* workspace names */
   init_workspace_names ();
 
+#ifdef USING_TESTING
+
+  meta_warning ("We could call %p or %p\n", prefs_testing_handler, change_notify);
+
+  /* testing, if we're doing testing */
+  meta_testing_register (prefs_testing_handler);
+
+#endif /* USING_TESTING */
+
 }
 
 #ifdef HAVE_GCONF
@@ -924,18 +942,77 @@
   NULL
 };
 
+#ifdef USING_TESTING
+static char*
+prefs_testing_handler (char type, char *details)
+{
+#ifdef HAVE_GCONF
+  GConfValue value;
+  char *space_position = NULL;
+  char *key = NULL;  
+
+  if (type!='C' || strlen(details)<3 || details[1]!=' ')
+    return NULL;
+
+  space_position = strchr (details+2, ' ');
+
+  if (space_position==NULL || *(space_position+1)==0)
+    return NULL;
+
+  key = g_strndup (details+2, (space_position-details)-2);
+
+  meta_warning ("Key is [%s], value is [%s]\n", key, space_position+1);
+
+  /* FIXME: Does gconf_value_set_* set the type too? */
+  switch (details[0])
+    {
+    case 'I':
+      value.type = GCONF_VALUE_INT;
+      /* gconf_value_set_int (value, xxx atoi or something FIXME */
+      break;
+
+    case 'S':
+      value.type = GCONF_VALUE_STRING;
+      break;
+
+    case 'B':
+      value.type = GCONF_VALUE_BOOL;
+      gconf_valu
+      break;
+
+    default:
+      meta_verbose ("Strange configuration type: %s\n", details);
+      return NULL;
+    }
+
+  handle_configuration_update (key, &value);
+
+  return g_strdup("Y"); /* success */
+
+#else /* HAVE_GCONF */
+
+  return g_strdup("N"); /* impossible! */
+
+#endif /* HAVE_GCONF */
+
+}
+#endif /* USING_TESTING */
+
 static void
 change_notify (GConfClient    *client,
                guint           cnxn_id,
                GConfEntry     *entry,
                gpointer        user_data)
 {
-  const char *key;
-  GConfValue *value;
+  handle_configuration_update (gconf_entry_get_key (entry),
+                               gconf_entry_get_value (entry));
+}
+
+static void
+handle_configuration_update (const char *key,
+                             GConfValue *value)
+{
   gint i=0;
-  
-  key = gconf_entry_get_key (entry);
-  value = gconf_entry_get_value (entry);
 
   /* First, search for a handler that might know what to do. */
 

Modified: branches/test-system/src/core/testing.c
==============================================================================
--- branches/test-system/src/core/testing.c	(original)
+++ branches/test-system/src/core/testing.c	Tue May 20 04:32:44 2008
@@ -33,9 +33,11 @@
 static GSList *handlers = NULL;
 
 void
-meta_testing_register (MetaTestingHandler *handler)
+meta_testing_register (MetaTestingHandler handler)
 {
   handlers = g_slist_prepend (handlers, handler);
+
+  g_warning ("New testing handler registered: %p\n", handler);
 }
 
 char *
@@ -51,20 +53,27 @@
   
   GSList *cursor = handlers;
 
+  g_warning ("We are notifying.\n");
+  g_warning ("The type is %c and the details are [%s].\n", type, details);
+  
   while (cursor)
     {
       char *possible_result;
+      MetaTestingHandler handler = (MetaTestingHandler) cursor->data;
 
-      possible_result = (*((MetaTestingHandler*)cursor->data)) (type, details);
+      g_warning ("What about %p?\n", handler);
+      possible_result = (*handler) (type, details);
 
       if (possible_result)
         {
+          g_warning ("Yes.  The answer is [%s].\n", possible_result);
           return possible_result;
         }
 
       cursor = g_slist_next (cursor);
     }
 
+  g_warning ("No.  Giving up with the testing.\n");
   return NULL; /* Give up. */
 
 }

Modified: branches/test-system/src/core/testing.h
==============================================================================
--- branches/test-system/src/core/testing.h	(original)
+++ branches/test-system/src/core/testing.h	Tue May 20 04:32:44 2008
@@ -48,7 +48,7 @@
  *
  * \param handler  The handler.
  */
-void meta_testing_register (MetaTestingHandler *handler);
+void meta_testing_register (MetaTestingHandler handler);
 
 /**
  * After a __METACITY_TESTING property has been set, this function runs

Modified: branches/test-system/test/basic-test.py
==============================================================================
--- branches/test-system/test/basic-test.py	(original)
+++ branches/test-system/test/basic-test.py	Tue May 20 04:32:44 2008
@@ -51,7 +51,7 @@
 
     return result[2:]
 
-query = '1'
+query = 'B /apps/metacity/general/disable_workarounds 1'
 
 print 'Querying window manager with the query: ',query
-print 'Received result: ',query_window_manager ('A', query)
+print 'Received result: ',query_window_manager ('C', query)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]