summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoss Burton <ross@linux.intel.com>2010-05-28 11:46:19 +0100
committerRoss Burton <ross@linux.intel.com>2010-08-13 11:03:14 +0100
commitf409f42ed54de724530559deda61ab827ea4578f (patch)
tree6b5b45940c8d61b55c59e7fc891336e37af5a53a
parent01852804af154ffd24f0e9ffd87da5f1756c0e7b (diff)
downloadlibrest-f409f42ed54de724530559deda61ab827ea4578f.tar.gz
tests/proxy: test some cancellation
-rw-r--r--tests/proxy.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/proxy.c b/tests/proxy.c
index 79a0683..54c456e 100644
--- a/tests/proxy.c
+++ b/tests/proxy.c
@@ -276,6 +276,44 @@ test_status_ok (RestProxy *proxy, const char *function)
}
static void
+status_error_cb (GObject *object, GAsyncResult *result, gpointer user_data)
+{
+ RestProxyCall *call = REST_PROXY_CALL (object);
+ GError *error = NULL;
+ int status = GPOINTER_TO_INT (user_data);
+
+ if (call == NULL) {
+ errors++;
+ return;
+ }
+
+ if (rest_proxy_call_invoke_finish (call, result, &error)) {
+ g_printerr ("Call succeeded incorrectly\n");
+ errors++;
+ return;
+ }
+
+ /* TODO: check error code/domain */
+}
+
+static void
+test_async_cancelled (RestProxy *proxy)
+{
+ RestProxyCall *call;
+ GCancellable *cancel;
+
+ cancel = g_cancellable_new ();
+ g_cancellable_cancel (cancel);
+
+ call = rest_proxy_new_call (proxy);
+ rest_proxy_call_set_function (call, "ping");
+
+ rest_proxy_call_invoke_async (call, cancel, NULL, status_error_cb, NULL);
+
+ g_object_unref (cancel);
+}
+
+static void
status_ok_cb (GObject *object, GAsyncResult *result, gpointer user_data)
{
RestProxyCall *call = REST_PROXY_CALL (object);
@@ -347,6 +385,8 @@ main (int argc, char **argv)
status_ok_test_async (proxy, SOUP_STATUS_OK);
status_ok_test_async (proxy, SOUP_STATUS_NO_CONTENT);
+ test_async_cancelled (proxy);
+
test_status_ok (proxy, "useragent/none");
rest_proxy_set_user_agent (proxy, "TestSuite-1.0");
test_status_ok (proxy, "useragent/testsuite");