diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2009-08-19 14:14:11 +0100 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2009-08-25 15:36:51 +0100 |
commit | 9ab532ddb545a6454c1ec51fe2f04063da4c796f (patch) | |
tree | d0a54d45d70c208bae206657c997a7337ae72d55 /tests/wocky-roster-test.c | |
parent | f0018d788796cae5c0ec386f7af2ab7e55950ce5 (diff) |
wocky-roster-test: add test_remove_two_groups
Diffstat (limited to 'tests/wocky-roster-test.c')
-rw-r--r-- | tests/wocky-roster-test.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/tests/wocky-roster-test.c b/tests/wocky-roster-test.c index 944d2d2..c577ff8 100644 --- a/tests/wocky-roster-test.c +++ b/tests/wocky-roster-test.c @@ -1898,7 +1898,91 @@ test_add_two_groups (void) g_object_unref (roster); g_object_unref (romeo); teardown_test (test); +} + +/* remove 2 groups from the same contact */ +static void +test_remove_two_groups (void) +{ + WockyRoster *roster; + test_data_t *test = setup_test (); + WockyContact *contact, *juliet; + const gchar *groups[] = { "Friends", NULL }; + const gchar *no_group[] = { NULL }; + + test_open_both_connections (test); + + roster = create_initial_roster (test); + + contact = wocky_roster_get_contact (roster, "juliet@example.net"); + g_assert (contact != NULL); + + juliet = create_juliet (); + + wocky_porter_register_handler (test->sched_out, + WOCKY_STANZA_TYPE_IQ, WOCKY_STANZA_SUB_TYPE_SET, NULL, + WOCKY_PORTER_HANDLER_PRIORITY_MAX, + iq_set_cb, test, + WOCKY_NODE, "query", + WOCKY_NODE_XMLNS, WOCKY_XMPP_NS_ROSTER, + WOCKY_NODE_END, + WOCKY_STANZA_END); + + /* Remove a group from Juliet */ + wocky_roster_contact_remove_group_async (roster, contact, "Girlz", NULL, + contact_group_removed_cb, test); + + test->outstanding += 1; + test_wait_pending (test); + g_assert (received_iq != NULL); + /* The IQ has been sent but the server didn't send the upgrade and the reply + * yet */ + + g_assert (wocky_contact_equal (contact, juliet)); + + check_edit_roster_stanza (received_iq, "juliet@example.net", "Juliet", "to", + groups); + + /* remove another group */ + wocky_roster_contact_remove_group_async (roster, contact, "Friends", NULL, + contact_group_removed_cb, test); + + /* Now the server sends the roster upgrade and reply to the first IQ */ + send_roster_update (test, "juliet@example.net", "Juliet", "to", groups); + ack_iq (test->sched_out, received_iq); + g_object_unref (received_iq); + received_iq = NULL; + + /* Wait that: + * - the first remove_group operation is completed + * - the server receives the IQ for the second remove_group + */ + test->outstanding += 2; + test_wait_pending (test); + wocky_contact_set_groups (juliet, (gchar **) groups); + g_assert (wocky_contact_equal (contact, juliet)); + + check_edit_roster_stanza (received_iq, "juliet@example.net", "Juliet", "to", + no_group); + + /* Server sends the roster upgrade and reply to the first IQ */ + send_roster_update (test, "juliet@example.net", "Juliet", "to", no_group); + ack_iq (test->sched_out, received_iq); + g_object_unref (received_iq); + received_iq = NULL; + + /* Wait second remove_group operation is completed */ + test->outstanding += 1; + test_wait_pending (test); + + wocky_contact_set_groups (juliet, (gchar **) no_group); + g_assert (wocky_contact_equal (contact, juliet)); + + test_close_both_porters (test); + g_object_unref (roster); + g_object_unref (juliet); + teardown_test (test); } int @@ -1942,6 +2026,7 @@ main (int argc, char **argv) g_test_add_func ("/xmpp-roster/change-name-add-remove", test_change_name_remove_add); g_test_add_func ("/xmpp-roster/add-two-groups", test_add_two_groups); + g_test_add_func ("/xmpp-roster/remove-two-groups", test_remove_two_groups); result = g_test_run (); test_deinit (); |