[Telepathy-commits] [telepathy-glib/master] callable-example test: test calls that terminate because busy, or are never answered
Simon McVittie
simon.mcvittie at collabora.co.uk
Wed Mar 18 12:12:40 PDT 2009
---
tests/dbus/callable-example.c | 133 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 128 insertions(+), 5 deletions(-)
diff --git a/tests/dbus/callable-example.c b/tests/dbus/callable-example.c
index 2f26798..2dfa060 100644
--- a/tests/dbus/callable-example.c
+++ b/tests/dbus/callable-example.c
@@ -974,6 +974,131 @@ test_basics (Test *test,
}
static void
+test_no_answer (Test *test,
+ gconstpointer data G_GNUC_UNUSED)
+{
+ GroupEvent *ge;
+ StreamEvent *se;
+
+ /* This identifier contains the magic string (no answer), which means the
+ * example will never answer. */
+ outgoing_call (test, "smcv (no answer)");
+
+ /* request an audio stream */
+ tp_cli_channel_type_streamed_media_call_request_streams (test->chan, -1,
+ tp_channel_get_handle (test->chan, NULL),
+ test->audio_request, requested_streams_cb,
+ test, NULL, NULL);
+ g_main_loop_run (test->mainloop);
+ test_assert_no_error (test->error);
+
+ test_connection_run_until_dbus_queue_processed (test->conn);
+
+ maybe_pop_stream_direction (test);
+ g_assert_cmpuint (g_slist_length (test->stream_events), ==, 1);
+ se = g_slist_nth_data (test->stream_events, 0);
+ g_assert_cmpuint (se->type, ==, STREAM_EVENT_ADDED);
+ test->audio_stream_id = se->id;
+
+ /* After the initial flurry of D-Bus messages, smcv still hasn't answered */
+ g_assert_cmpuint (tp_channel_group_get_self_handle (test->chan), ==,
+ test->self_handle);
+ g_assert_cmpuint (tp_channel_group_get_handle_owner (test->chan,
+ test->self_handle), ==, test->self_handle);
+ g_assert_cmpuint (tp_intset_size (tp_channel_group_get_members (test->chan)),
+ ==, 1);
+ g_assert_cmpuint (tp_intset_size (
+ tp_channel_group_get_local_pending (test->chan)), ==, 0);
+ g_assert_cmpuint (tp_intset_size (
+ tp_channel_group_get_remote_pending (test->chan)), ==, 1);
+ g_assert (tp_intset_is_member (tp_channel_group_get_members (test->chan),
+ test->self_handle));
+ g_assert (tp_intset_is_member (tp_channel_group_get_remote_pending (
+ test->chan),
+ tp_channel_get_handle (test->chan, NULL)));
+
+ /* assume we're never going to get an answer, and hang up */
+ g_array_set_size (test->contacts, 0);
+ g_array_append_val (test->contacts, test->self_handle);
+ tp_cli_channel_interface_group_call_remove_members_with_reason (test->chan,
+ -1, test->contacts, "", TP_CHANNEL_GROUP_CHANGE_REASON_NONE,
+ void_cb, test, NULL, NULL);
+ g_main_loop_run (test->mainloop);
+ test_assert_no_error (test->error);
+
+ /* In response to hanging up, the channel closes */
+ test_connection_run_until_dbus_queue_processed (test->conn);
+ g_assert (tp_proxy_get_invalidated (test->chan) != NULL);
+
+ /* The last event should be that the peer and the self-handle were both
+ * removed */
+ ge = g_slist_nth_data (test->group_events, 0);
+
+ g_assert_cmpuint (tp_intset_size (ge->added), ==, 0);
+ g_assert_cmpuint (tp_intset_size (ge->removed), ==, 2);
+ g_assert (tp_intset_is_member (ge->removed,
+ test->self_handle));
+ g_assert (tp_intset_is_member (ge->removed,
+ tp_channel_get_handle (test->chan, NULL)));
+ g_assert_cmpuint (tp_intset_size (ge->local_pending), ==, 0);
+ g_assert_cmpuint (tp_intset_size (ge->remote_pending), ==, 0);
+ g_assert_cmpuint (tp_asv_get_uint32 (ge->details, "actor", NULL), ==,
+ test->self_handle);
+ g_assert_cmpuint (tp_asv_get_uint32 (ge->details, "change-reason", NULL), ==,
+ TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
+}
+
+static void
+test_busy (Test *test,
+ gconstpointer data G_GNUC_UNUSED)
+{
+ GroupEvent *ge;
+ StreamEvent *se;
+
+ /* This identifier contains the magic string (busy), which means the example
+ * will simulate rejection of the call as busy rather than accepting it. */
+ outgoing_call (test, "Robot101 (busy)");
+
+ /* request an audio stream */
+ tp_cli_channel_type_streamed_media_call_request_streams (test->chan, -1,
+ tp_channel_get_handle (test->chan, NULL),
+ test->audio_request, requested_streams_cb,
+ test, NULL, NULL);
+ g_main_loop_run (test->mainloop);
+ test_assert_no_error (test->error);
+
+ /* Wait for the remote contact to reject the call */
+ while (tp_proxy_get_invalidated (test->chan) != NULL)
+ {
+ g_main_context_iteration (NULL, TRUE);
+ }
+
+ /* The last stream event should be the removal of the stream */
+
+ test_connection_run_until_dbus_queue_processed (test->conn);
+
+ se = g_slist_nth_data (test->stream_events, 0);
+ g_assert_cmpuint (se->type, ==, STREAM_EVENT_REMOVED);
+
+ /* The last event should be that the peer and the self-handle were both
+ * removed by the peer, for reason BUSY */
+ ge = g_slist_nth_data (test->group_events, 0);
+
+ g_assert_cmpuint (tp_intset_size (ge->added), ==, 0);
+ g_assert_cmpuint (tp_intset_size (ge->removed), ==, 2);
+ g_assert (tp_intset_is_member (ge->removed,
+ test->self_handle));
+ g_assert (tp_intset_is_member (ge->removed,
+ tp_channel_get_handle (test->chan, NULL)));
+ g_assert_cmpuint (tp_intset_size (ge->local_pending), ==, 0);
+ g_assert_cmpuint (tp_intset_size (ge->remote_pending), ==, 0);
+ g_assert_cmpuint (tp_asv_get_uint32 (ge->details, "actor", NULL), ==,
+ tp_channel_get_handle (test->chan, NULL));
+ g_assert_cmpuint (tp_asv_get_uint32 (ge->details, "change-reason", NULL), ==,
+ TP_CHANNEL_GROUP_CHANGE_REASON_BUSY);
+}
+
+static void
test_terminate_via_close (Test *test,
gconstpointer data G_GNUC_UNUSED)
{
@@ -1105,13 +1230,8 @@ test_terminate_via_no_streams (Test *test,
g_assert_cmpuint (se->id, ==, test->audio_stream_id);
}
-/* FIXME: add a special contact who never accepts the call, so it rings
- * forever, and test that */
-
/* FIXME: add a special contact who accepts the call, then terminates it */
-/* FIXME: add a special contact who rejects the call with BUSY */
-
/* FIXME: add a special contact who refuses to have video */
/* FIXME: add a special contact who asks us for video */
@@ -1374,6 +1494,9 @@ main (int argc,
g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id=");
g_test_add ("/callable/basics", Test, NULL, setup, test_basics, teardown);
+ g_test_add ("/callable/busy", Test, NULL, setup, test_busy, teardown);
+ g_test_add ("/callable/no-answer", Test, NULL, setup, test_no_answer,
+ teardown);
g_test_add ("/callable/terminate-via-close", Test, NULL, setup,
test_terminate_via_close, teardown);
g_test_add ("/callable/terminate-via-no-streams", Test, NULL, setup,
--
1.5.6.5
More information about the telepathy-commits
mailing list