[pygobject] Wrap gio.Socket.condition_wait() and add a test



commit 771a7c3fdef7b2e98e509293a8376a81c1282286
Author: Gian Mario Tagliaretti <gianmt gnome org>
Date:   Wed Dec 30 17:20:35 2009 +0100

    Wrap gio.Socket.condition_wait() and add a test

 gio/gsocket.override  |   27 +++++++++++++++++++++++++++
 tests/test_gsocket.py |    6 +++++-
 2 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/gio/gsocket.override b/gio/gsocket.override
index 2f009fc..d2283bb 100644
--- a/gio/gsocket.override
+++ b/gio/gsocket.override
@@ -39,3 +39,30 @@ _wrap_g_socket_condition_check(PyGObject *self,
     
     return pyg_flags_from_gtype(G_TYPE_IO_CONDITION, ret);
 }
+%%
+override g_socket_condition_wait kwargs
+static PyObject *
+_wrap_g_socket_condition_wait(PyGObject *self,
+                              PyObject *args,
+                              PyObject *kwargs)
+{
+    static char *kwlist[] = { "condition", "cancellable", NULL };
+    gboolean ret;
+    gint condition;
+    PyGObject *py_cancellable = NULL;
+    GCancellable *cancellable;
+    GError *error;
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+                                     "i|O:gio.Socket.condition_wait",
+                                     kwlist, &condition, &cancellable))
+        return NULL;
+
+    if (!pygio_check_cancellable(py_cancellable, &cancellable))
+        return NULL;
+    
+    ret = g_socket_condition_wait(G_SOCKET(self->obj), condition,
+                                  cancellable, &error);
+    
+    return PyBool_FromLong(ret);
+}
diff --git a/tests/test_gsocket.py b/tests/test_gsocket.py
index 8f138a4..671026f 100644
--- a/tests/test_gsocket.py
+++ b/tests/test_gsocket.py
@@ -12,10 +12,14 @@ class TestSocket(unittest.TestCase):
                                gio.SOCKET_TYPE_STREAM,
                                gio.SOCKET_PROTOCOL_TCP)
 
-    def test_socket_condition(self):
+    def test_socket_condition_check(self):
         check = self.sock.condition_check(glib.IO_OUT)
         self.failUnless(isinstance(check, gobject.GFlags))
         self.failUnlessEqual(check, glib.IO_OUT | glib.IO_HUP)
 
+    def test_socket_condition_wait(self):
+        res = self.sock.condition_wait(glib.IO_OUT)
+        self.failUnless(res)
+
     def tearDown(self):
         self.sock.close()



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