Merge lp:~ubuntu-branches/ubuntu/precise/telepathy-glib/precise-201111172307 into lp:ubuntu/precise/telepathy-glib

Proposed by Ubuntu Package Importer
Status: Rejected
Rejected by: James Westby
Proposed branch: lp:~ubuntu-branches/ubuntu/precise/telepathy-glib/precise-201111172307
Merge into: lp:ubuntu/precise/telepathy-glib
Diff against target: 2843 lines (+2832/-0) (has conflicts)
1 file modified
.pc/ludicrous-timeout-for-lp-buildd.patch/tests/dbus/contact-lists.c (+2832/-0)
Text conflict in .pc/ludicrous-timeout-for-lp-buildd.patch/tests/dbus/contact-lists.c
To merge this branch: bzr merge lp:~ubuntu-branches/ubuntu/precise/telepathy-glib/precise-201111172307
Reviewer Review Type Date Requested Status
Ubuntu branches Pending
Review via email: mp+82610@code.launchpad.net

Description of the change

The package importer has detected a possible inconsistency between the package history in the archive and the history in bzr. As the archive is authoritative the importer has made lp:ubuntu/precise/telepathy-glib reflect what is in the archive and the old bzr branch has been pushed to lp:~ubuntu-branches/ubuntu/precise/telepathy-glib/precise-201111172307. This merge proposal was created so that an Ubuntu developer can review the situations and perform a merge/upload if necessary. There are three typical cases where this can happen.
  1. Where someone pushes a change to bzr and someone else uploads the package without that change. This is the reason that this check is done by the importer. If this appears to be the case then a merge/upload should be done if the changes that were in bzr are still desirable.
  2. The importer incorrectly detected the above situation when someone made a change in bzr and then uploaded it.
  3. The importer incorrectly detected the above situation when someone just uploaded a package and didn't touch bzr.

If this case doesn't appear to be the first situation then set the status of the merge proposal to "Rejected" and help avoid the problem in future by filing a bug at https://bugs.launchpad.net/udd linking to this merge proposal.

(this is an automatically generated message)

To post a comment you must log in.

Unmerged revisions

74. By Ken VanDine

releasing version 0.17.1-0ubuntu1

73. By Ken VanDine

* debian/control
  - bump build depends for gobject-introspection to >= 1.30
* debian/libtelepathy-glib0.symbols
  - added new symbols

72. By Ken VanDine

New upstream release.

71. By Ken VanDine

merged

70. By Ken VanDine

releasing version 0.16.2-1ubuntu1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.pc/ludicrous-timeout-for-lp-buildd.patch/tests/dbus/contact-lists.c'
--- .pc/ludicrous-timeout-for-lp-buildd.patch/tests/dbus/contact-lists.c 2011-11-17 16:02:36 +0000
+++ .pc/ludicrous-timeout-for-lp-buildd.patch/tests/dbus/contact-lists.c 2011-11-17 23:14:36 +0000
@@ -1,3 +1,4 @@
1<<<<<<< TREE
1/* Feature test for contact lists2/* Feature test for contact lists
2 *3 *
3 * Copyright © 2007-2010 Collabora Ltd. <http://www.collabora.co.uk/>4 * Copyright © 2007-2010 Collabora Ltd. <http://www.collabora.co.uk/>
@@ -2828,3 +2829,2834 @@
28282829
2829 return g_test_run ();2830 return g_test_run ();
2830}2831}
2832=======
2833/* Feature test for contact lists
2834 *
2835 * Copyright © 2007-2010 Collabora Ltd. <http://www.collabora.co.uk/>
2836 * Copyright © 2007-2008 Nokia Corporation
2837 *
2838 * Copying and distribution of this file, with or without modification,
2839 * are permitted in any medium without royalty provided the copyright
2840 * notice and this notice are preserved.
2841 */
2842
2843#include <telepathy-glib/connection.h>
2844
2845#include "examples/cm/contactlist/conn.h"
2846#include "tests/lib/util.h"
2847
2848typedef enum {
2849 CONTACTS_CHANGED,
2850 GROUPS_CHANGED,
2851 GROUPS_CREATED,
2852 GROUPS_REMOVED,
2853 GROUP_RENAMED,
2854 BLOCKED_CONTACTS_CHANGED
2855} LogEntryType;
2856
2857typedef struct {
2858 LogEntryType type;
2859 /* ContactsChanged */
2860 GHashTable *contacts_changed;
2861 TpIntset *contacts_removed;
2862 /* GroupsChanged */
2863 GArray *contacts;
2864 /* GroupsChanged, GroupsCreated, GroupRenamed */
2865 GStrv groups_added;
2866 /* GroupsChanged, GroupsRemoved, GroupRenamed */
2867 GStrv groups_removed;
2868 /* BlockedContactsChanged */
2869 GHashTable *blocked_contacts;
2870 GHashTable *unblocked_contacts;
2871} LogEntry;
2872
2873static void
2874log_entry_free (LogEntry *le)
2875{
2876 if (le->contacts_changed != NULL)
2877 g_hash_table_unref (le->contacts_changed);
2878
2879 if (le->contacts_removed != NULL)
2880 tp_intset_destroy (le->contacts_removed);
2881
2882 if (le->contacts != NULL)
2883 g_array_unref (le->contacts);
2884
2885 g_strfreev (le->groups_added);
2886 g_strfreev (le->groups_removed);
2887
2888 if (le->blocked_contacts != NULL)
2889 g_hash_table_unref (le->blocked_contacts);
2890
2891 if (le->unblocked_contacts != NULL)
2892 g_hash_table_unref (le->unblocked_contacts);
2893
2894 g_slice_free (LogEntry, le);
2895}
2896
2897typedef struct {
2898 TpDBusDaemon *dbus;
2899 ExampleContactListConnection *service_conn;
2900 TpBaseConnection *service_conn_as_base;
2901 gchar *conn_name;
2902 gchar *conn_path;
2903 TpConnection *conn;
2904
2905 TpChannel *publish;
2906 TpChannel *subscribe;
2907 TpChannel *stored;
2908 TpChannel *deny;
2909
2910 TpChannel *group;
2911
2912 TpHandleRepoIface *contact_repo;
2913 TpHandle sjoerd;
2914 TpHandle helen;
2915 TpHandle wim;
2916 TpHandle bill;
2917 TpHandle ninja;
2918 TpHandle canceller;
2919
2920 GArray *arr;
2921
2922 /* list of LogEntry */
2923 GPtrArray *log;
2924
2925 GAsyncResult *prepare_result;
2926 GHashTable *contact_attributes;
2927
2928 GMainLoop *main_loop;
2929} Test;
2930
2931static void
2932test_quit_loop (gpointer p)
2933{
2934 Test *test = p;
2935
2936 g_main_loop_quit (test->main_loop);
2937}
2938
2939static void
2940contacts_changed_with_id_cb (TpConnection *connection,
2941 GHashTable *changes,
2942 GHashTable *identifiers,
2943 GHashTable *removals,
2944 gpointer user_data,
2945 GObject *weak_object G_GNUC_UNUSED)
2946{
2947 Test *test = user_data;
2948 LogEntry *le = g_slice_new0 (LogEntry);
2949 GHashTableIter i;
2950 gpointer key, value;
2951
2952 if (g_hash_table_size (changes) > 0)
2953 g_assert_cmpuint (g_hash_table_size (changes), ==,
2954 g_hash_table_size (identifiers));
2955 else
2956 g_assert_cmpuint (g_hash_table_size (removals), >, 0);
2957
2958 le->type = CONTACTS_CHANGED;
2959 le->contacts_changed = g_boxed_copy (TP_HASH_TYPE_CONTACT_SUBSCRIPTION_MAP,
2960 changes);
2961
2962 /* We asserted above that we have as many identifiers as we have changes. */
2963 g_hash_table_iter_init (&i, identifiers);
2964 while (g_hash_table_iter_next (&i, &key, &value))
2965 {
2966 TpHandle handle = GPOINTER_TO_UINT (key);
2967
2968 g_assert_cmpstr (value, ==,
2969 tp_handle_inspect (test->contact_repo, handle));
2970 }
2971
2972 le->contacts_removed = tp_intset_new ();
2973
2974 g_hash_table_iter_init (&i, removals);
2975 while (g_hash_table_iter_next (&i, &key, &value))
2976 {
2977 TpHandle handle = GPOINTER_TO_UINT (key);
2978
2979 g_assert_cmpstr (value, ==,
2980 tp_handle_inspect (test->contact_repo, handle));
2981 tp_intset_add (le->contacts_removed, handle);
2982 }
2983
2984 g_ptr_array_add (test->log, le);
2985}
2986
2987static void
2988contacts_changed_cb (TpConnection *connection,
2989 GHashTable *changes,
2990 const GArray *removals,
2991 gpointer user_data,
2992 GObject *weak_object G_GNUC_UNUSED)
2993{
2994 Test *test = user_data;
2995 LogEntry *le;
2996 GHashTableIter i;
2997 gpointer key, value;
2998 TpIntset *removal_set;
2999
3000 g_assert (g_hash_table_size (changes) > 0 || removals->len > 0);
3001
3002 /* We should have had a ContactsChangedByID signal immediately before this
3003 * signal */
3004 g_assert_cmpuint (test->log->len, >, 0);
3005
3006 le = g_ptr_array_index (test->log, test->log->len - 1);
3007 g_assert_cmpuint (le->type, ==, CONTACTS_CHANGED);
3008
3009 /* The changes should all have been the same as in the previous signal */
3010 g_assert_cmpuint (g_hash_table_size (changes), ==,
3011 g_hash_table_size (le->contacts_changed));
3012
3013 g_hash_table_iter_init (&i, changes);
3014 while (g_hash_table_iter_next (&i, &key, &value))
3015 {
3016 GValueArray *existing = g_hash_table_lookup (le->contacts_changed, key);
3017 GValueArray *emitted = value;
3018 guint existing_sub, existing_pub, emitted_sub, emitted_pub;
3019 const gchar *existing_req, *emitted_req;
3020
3021 g_assert (existing != NULL);
3022
3023 tp_value_array_unpack (existing, 3, &existing_sub, &existing_pub,
3024 &existing_req);
3025 tp_value_array_unpack (emitted, 3, &emitted_sub, &emitted_pub,
3026 &emitted_req);
3027
3028 g_assert_cmpuint (existing_sub, ==, emitted_sub);
3029 g_assert_cmpuint (existing_pub, ==, emitted_pub);
3030 g_assert_cmpstr (existing_req, ==, emitted_req);
3031 }
3032
3033 removal_set = tp_intset_from_array (removals);
3034
3035 if (!tp_intset_is_equal (removal_set, le->contacts_removed))
3036 g_error ("Removals from ContactsChangedById (%s) != "
3037 "Removals from ContactsChanged (%s)",
3038 tp_intset_dump (le->contacts_removed),
3039 tp_intset_dump (removal_set));
3040
3041 tp_intset_destroy (removal_set);
3042}
3043
3044static void
3045groups_changed_cb (TpConnection *connection,
3046 const GArray *contacts,
3047 const gchar **groups_added,
3048 const gchar **groups_removed,
3049 gpointer user_data,
3050 GObject *weak_object G_GNUC_UNUSED)
3051{
3052 Test *test = user_data;
3053 LogEntry *le = g_slice_new0 (LogEntry);
3054
3055 g_assert (contacts->len > 0);
3056 g_assert ((groups_added != NULL && groups_added[0] != NULL) ||
3057 (groups_removed != NULL && groups_removed[0] != NULL));
3058
3059 le->type = GROUPS_CHANGED;
3060 le->contacts = g_array_sized_new (FALSE, FALSE, sizeof (guint),
3061 contacts->len);
3062 g_array_append_vals (le->contacts, contacts->data, contacts->len);
3063 le->groups_added = g_strdupv ((GStrv) groups_added);
3064 le->groups_removed = g_strdupv ((GStrv) groups_removed);
3065
3066 g_ptr_array_add (test->log, le);
3067}
3068
3069static void
3070groups_created_cb (TpConnection *connection,
3071 const gchar **groups_added,
3072 gpointer user_data,
3073 GObject *weak_object G_GNUC_UNUSED)
3074{
3075 Test *test = user_data;
3076 LogEntry *le = g_slice_new0 (LogEntry);
3077
3078 g_assert (groups_added != NULL);
3079 g_assert (groups_added[0] != NULL);
3080
3081 le->type = GROUPS_CREATED;
3082 le->groups_added = g_strdupv ((GStrv) groups_added);
3083
3084 g_ptr_array_add (test->log, le);
3085}
3086
3087static void
3088groups_removed_cb (TpConnection *connection,
3089 const gchar **groups_removed,
3090 gpointer user_data,
3091 GObject *weak_object G_GNUC_UNUSED)
3092{
3093 Test *test = user_data;
3094 LogEntry *le = g_slice_new0 (LogEntry);
3095
3096 g_assert (groups_removed != NULL);
3097 g_assert (groups_removed[0] != NULL);
3098
3099 le->type = GROUPS_REMOVED;
3100 le->groups_removed = g_strdupv ((GStrv) groups_removed);
3101
3102 g_ptr_array_add (test->log, le);
3103}
3104
3105static void
3106group_renamed_cb (TpConnection *connection,
3107 const gchar *old_name,
3108 const gchar *new_name,
3109 gpointer user_data,
3110 GObject *weak_object G_GNUC_UNUSED)
3111{
3112 Test *test = user_data;
3113 LogEntry *le = g_slice_new0 (LogEntry);
3114
3115 le->type = GROUP_RENAMED;
3116 le->groups_added = g_new0 (gchar *, 2);
3117 le->groups_added[0] = g_strdup (new_name);
3118 le->groups_removed = g_new0 (gchar *, 2);
3119 le->groups_removed[0] = g_strdup (old_name);
3120
3121 g_ptr_array_add (test->log, le);
3122}
3123
3124static void
3125blocked_contacts_changed_cb (TpConnection *connection,
3126 GHashTable *blocked_contacts,
3127 GHashTable *unblocked_contacts,
3128 gpointer user_data,
3129 GObject *weak_object G_GNUC_UNUSED)
3130{
3131 Test *test = user_data;
3132 LogEntry *le = g_slice_new0 (LogEntry);
3133
3134 le->type = BLOCKED_CONTACTS_CHANGED;
3135 le->blocked_contacts = g_hash_table_ref (blocked_contacts);
3136 le->unblocked_contacts = g_hash_table_ref (unblocked_contacts);
3137
3138 g_ptr_array_add (test->log, le);
3139}
3140
3141static void
3142maybe_queue_disconnect (TpProxySignalConnection *sc)
3143{
3144 if (sc != NULL)
3145 g_test_queue_destroy (
3146 (GDestroyNotify) tp_proxy_signal_connection_disconnect, sc);
3147}
3148
3149static void
3150setup_pre_connect (
3151 Test *test,
3152 gconstpointer data)
3153{
3154 GError *error = NULL;
3155 const gchar *account;
3156
3157 g_type_init ();
3158 tp_debug_set_flags ("all");
3159 test->dbus = tp_tests_dbus_daemon_dup_or_die ();
3160 test->main_loop = g_main_loop_new (NULL, FALSE);
3161
3162 /* Some tests want 'account' to be an invalid identifier, so that Connect()
3163 * will fail (and the status will change to Disconnected).
3164 */
3165 if (!tp_strdiff (data, "break-account-parameter"))
3166 account = "";
3167 else
3168 account = "me@example.com";
3169
3170 test->service_conn = tp_tests_object_new_static_class (
3171 EXAMPLE_TYPE_CONTACT_LIST_CONNECTION,
3172 "account", account,
3173 "simulation-delay", 0,
3174 "protocol", "example-contact-list",
3175 NULL);
3176 test->service_conn_as_base = TP_BASE_CONNECTION (test->service_conn);
3177 g_assert (test->service_conn != NULL);
3178 g_assert (test->service_conn_as_base != NULL);
3179
3180 g_assert (tp_base_connection_register (test->service_conn_as_base, "example",
3181 &test->conn_name, &test->conn_path, &error));
3182 g_assert_no_error (error);
3183
3184 test->contact_repo = tp_base_connection_get_handles (
3185 test->service_conn_as_base, TP_HANDLE_TYPE_CONTACT);
3186
3187 test->conn = tp_connection_new (test->dbus, test->conn_name, test->conn_path,
3188 &error);
3189 g_assert (test->conn != NULL);
3190 g_assert_no_error (error);
3191
3192 /* Prepare the connection far enough to know its own interfaces. */
3193 tp_tests_proxy_run_until_prepared (test->conn, NULL);
3194}
3195
3196static void
3197setup (Test *test,
3198 gconstpointer data)
3199{
3200 GQuark features[] = { TP_CONNECTION_FEATURE_CONNECTED, 0 };
3201
3202 setup_pre_connect (test, data);
3203
3204 tp_cli_connection_call_connect (test->conn, -1, NULL, NULL, NULL, NULL);
3205 tp_tests_proxy_run_until_prepared (test->conn, features);
3206
3207 g_assert (tp_proxy_is_prepared (test->conn, TP_CONNECTION_FEATURE_CORE));
3208 g_assert (tp_proxy_is_prepared (test->conn,
3209 TP_CONNECTION_FEATURE_CONNECTED));
3210
3211 test->log = g_ptr_array_new ();
3212
3213 maybe_queue_disconnect (
3214 tp_cli_connection_interface_contact_list_connect_to_contacts_changed_with_id (
3215 test->conn, contacts_changed_with_id_cb, test, NULL, NULL, NULL));
3216 maybe_queue_disconnect (
3217 tp_cli_connection_interface_contact_list_connect_to_contacts_changed (
3218 test->conn, contacts_changed_cb, test, NULL, NULL, NULL));
3219 maybe_queue_disconnect (
3220 tp_cli_connection_interface_contact_groups_connect_to_groups_changed (
3221 test->conn, groups_changed_cb, test, NULL, NULL, NULL));
3222 maybe_queue_disconnect (
3223 tp_cli_connection_interface_contact_groups_connect_to_groups_created (
3224 test->conn, groups_created_cb, test, NULL, NULL, NULL));
3225 maybe_queue_disconnect (
3226 tp_cli_connection_interface_contact_groups_connect_to_groups_removed (
3227 test->conn, groups_removed_cb, test, NULL, NULL, NULL));
3228 maybe_queue_disconnect (
3229 tp_cli_connection_interface_contact_groups_connect_to_group_renamed (
3230 test->conn, group_renamed_cb, test, NULL, NULL, NULL));
3231 maybe_queue_disconnect (
3232 tp_cli_connection_interface_contact_blocking_connect_to_blocked_contacts_changed (
3233 test->conn, blocked_contacts_changed_cb, test, NULL, NULL, NULL));
3234
3235 test->sjoerd = tp_handle_ensure (test->contact_repo, "sjoerd@example.com",
3236 NULL, NULL);
3237 g_assert (test->sjoerd != 0);
3238 test->helen = tp_handle_ensure (test->contact_repo, "helen@example.com",
3239 NULL, NULL);
3240 g_assert (test->helen != 0);
3241 test->wim = tp_handle_ensure (test->contact_repo, "wim@example.com",
3242 NULL, NULL);
3243 g_assert (test->wim != 0);
3244 test->bill = tp_handle_ensure (test->contact_repo, "bill@example.com",
3245 NULL, NULL);
3246 g_assert (test->bill != 0);
3247 test->ninja = tp_handle_ensure (test->contact_repo, "ninja@example.com",
3248 NULL, NULL);
3249 g_assert (test->ninja != 0);
3250 test->canceller = tp_handle_ensure (test->contact_repo,
3251 "canceller@cancel.example.com", NULL, NULL);
3252 g_assert (test->canceller != 0);
3253
3254 test->arr = g_array_new (FALSE, FALSE, sizeof (TpHandle));
3255}
3256
3257static void
3258test_clear_log (Test *test)
3259{
3260 g_ptr_array_foreach (test->log, (GFunc) log_entry_free, NULL);
3261 g_ptr_array_set_size (test->log, 0);
3262}
3263
3264static void
3265teardown_pre_connect (
3266 Test *test,
3267 gconstpointer data)
3268{
3269 test->service_conn_as_base = NULL;
3270 g_object_unref (test->service_conn);
3271 g_free (test->conn_name);
3272 g_free (test->conn_path);
3273 tp_clear_object (&test->conn);
3274 tp_clear_object (&test->dbus);
3275 tp_clear_pointer (&test->main_loop, g_main_loop_unref);
3276}
3277
3278static void
3279teardown (Test *test,
3280 gconstpointer data)
3281{
3282 TpConnection *conn;
3283 gboolean ok;
3284 GError *error = NULL;
3285
3286 g_array_free (test->arr, TRUE);
3287
3288 test_clear_log (test);
3289 g_ptr_array_free (test->log, TRUE);
3290
3291 tp_handle_unref (test->contact_repo, test->sjoerd);
3292 tp_handle_unref (test->contact_repo, test->helen);
3293 tp_handle_unref (test->contact_repo, test->wim);
3294 tp_handle_unref (test->contact_repo, test->bill);
3295 tp_handle_unref (test->contact_repo, test->ninja);
3296 tp_handle_unref (test->contact_repo, test->canceller);
3297
3298 tp_clear_object (&test->publish);
3299 tp_clear_object (&test->subscribe);
3300 tp_clear_object (&test->stored);
3301 tp_clear_object (&test->group);
3302
3303 /* make a new TpConnection just to disconnect the underlying Connection,
3304 * so we don't leak it */
3305 conn = tp_connection_new (test->dbus, test->conn_name, test->conn_path,
3306 &error);
3307 g_assert (conn != NULL);
3308 g_assert_no_error (error);
3309 ok = tp_cli_connection_run_disconnect (conn, -1, &error, NULL);
3310 g_assert (ok);
3311 g_assert_no_error (error);
3312 g_assert (!tp_connection_run_until_ready (conn, FALSE, &error, NULL));
3313 g_assert_error (error, TP_ERRORS, TP_ERROR_CANCELLED);
3314 g_clear_error (&error);
3315
3316 tp_clear_pointer (&test->contact_attributes, g_hash_table_unref);
3317
3318 teardown_pre_connect (test, data);
3319}
3320
3321static TpChannel *
3322test_ensure_channel (Test *test,
3323 guint channel_type,
3324 const gchar *id)
3325{
3326 GError *error = NULL;
3327 GHashTable *asv, *props;
3328 gchar *path;
3329 TpChannel *ret;
3330
3331 asv = tp_asv_new (
3332 TP_PROP_CHANNEL_CHANNEL_TYPE,
3333 G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST,
3334 TP_PROP_CHANNEL_TARGET_HANDLE_TYPE,
3335 G_TYPE_UINT, channel_type,
3336 TP_PROP_CHANNEL_TARGET_ID,
3337 G_TYPE_STRING, id,
3338 NULL);
3339 tp_cli_connection_interface_requests_run_ensure_channel (test->conn, -1,
3340 asv, NULL, &path, &props, &error, NULL);
3341 g_assert_no_error (error);
3342 ret = tp_channel_new_from_properties (test->conn, path, props,
3343 &error);
3344 g_assert (ret != NULL);
3345 g_assert_no_error (error);
3346 g_free (path);
3347 g_hash_table_unref (props);
3348 g_hash_table_unref (asv);
3349
3350 tp_tests_proxy_run_until_prepared (ret, NULL);
3351 return ret;
3352}
3353
3354static void
3355test_assert_one_contact_changed (Test *test,
3356 guint index,
3357 TpHandle handle,
3358 TpSubscriptionState expected_sub_state,
3359 TpSubscriptionState expected_pub_state,
3360 const gchar *expected_pub_request)
3361{
3362 LogEntry *le;
3363 GValueArray *va;
3364 guint sub_state;
3365 guint pub_state;
3366 const gchar *pub_request;
3367
3368 le = g_ptr_array_index (test->log, index);
3369 g_assert_cmpint (le->type, ==, CONTACTS_CHANGED);
3370
3371 g_assert_cmpuint (g_hash_table_size (le->contacts_changed), ==, 1);
3372 va = g_hash_table_lookup (le->contacts_changed, GUINT_TO_POINTER (handle));
3373 g_assert (va != NULL);
3374 tp_value_array_unpack (va, 3,
3375 &sub_state,
3376 &pub_state,
3377 &pub_request);
3378 g_assert_cmpuint (sub_state, ==, expected_sub_state);
3379 g_assert_cmpuint (pub_state, ==, expected_pub_state);
3380 g_assert_cmpstr (pub_request, ==, expected_pub_request);
3381
3382 g_assert_cmpuint (tp_intset_size (le->contacts_removed), ==, 0);
3383}
3384
3385static void
3386test_assert_one_contact_removed (Test *test,
3387 guint index,
3388 TpHandle handle)
3389{
3390 LogEntry *le;
3391
3392 le = g_ptr_array_index (test->log, index);
3393 g_assert_cmpint (le->type, ==, CONTACTS_CHANGED);
3394
3395 g_assert_cmpuint (g_hash_table_size (le->contacts_changed), ==, 0);
3396 g_assert_cmpuint (tp_intset_size (le->contacts_removed), ==, 1);
3397 g_assert (tp_intset_is_member (le->contacts_removed, handle));
3398}
3399
3400static void
3401test_assert_one_group_joined (Test *test,
3402 guint index,
3403 TpHandle handle,
3404 const gchar *group)
3405{
3406 LogEntry *le;
3407
3408 le = g_ptr_array_index (test->log, index);
3409 g_assert_cmpint (le->type, ==, GROUPS_CHANGED);
3410 g_assert_cmpuint (le->contacts->len, ==, 1);
3411 g_assert_cmpuint (g_array_index (le->contacts, guint, 0), ==, handle);
3412 g_assert (le->groups_added != NULL);
3413 g_assert_cmpstr (le->groups_added[0], ==, group);
3414 g_assert_cmpstr (le->groups_added[1], ==, NULL);
3415 g_assert (le->groups_removed == NULL || le->groups_removed[0] == NULL);
3416}
3417
3418static void
3419test_assert_one_group_left (Test *test,
3420 guint index,
3421 TpHandle handle,
3422 const gchar *group)
3423{
3424 LogEntry *le;
3425
3426 le = g_ptr_array_index (test->log, index);
3427 g_assert_cmpint (le->type, ==, GROUPS_CHANGED);
3428 g_assert_cmpuint (le->contacts->len, ==, 1);
3429 g_assert_cmpuint (g_array_index (le->contacts, guint, 0), ==, handle);
3430 g_assert (le->groups_added == NULL || le->groups_added[0] == NULL);
3431 g_assert (le->groups_removed != NULL);
3432 g_assert_cmpstr (le->groups_removed[0], ==, group);
3433 g_assert_cmpstr (le->groups_removed[1], ==, NULL);
3434}
3435
3436static void
3437test_assert_one_group_created (Test *test,
3438 guint index,
3439 const gchar *group)
3440{
3441 LogEntry *le;
3442
3443 le = g_ptr_array_index (test->log, index);
3444 g_assert_cmpint (le->type, ==, GROUPS_CREATED);
3445 g_assert (le->groups_added != NULL);
3446 g_assert_cmpstr (le->groups_added[0], ==, group);
3447 g_assert_cmpstr (le->groups_added[1], ==, NULL);
3448}
3449
3450static void
3451test_assert_one_group_removed (Test *test,
3452 guint index,
3453 const gchar *group)
3454{
3455 LogEntry *le;
3456
3457 le = g_ptr_array_index (test->log, index);
3458 g_assert_cmpint (le->type, ==, GROUPS_REMOVED);
3459 g_assert (le->groups_removed != NULL);
3460 g_assert_cmpstr (le->groups_removed[0], ==, group);
3461 g_assert_cmpstr (le->groups_removed[1], ==, NULL);
3462}
3463
3464static void
3465test_assert_one_contact_blocked (Test *test,
3466 guint index,
3467 TpHandle handle,
3468 const gchar *id)
3469{
3470 LogEntry *le;
3471
3472 le = g_ptr_array_index (test->log, index);
3473 g_assert_cmpint (le->type, ==, BLOCKED_CONTACTS_CHANGED);
3474
3475 g_assert (le->blocked_contacts != NULL);
3476 g_assert_cmpuint (g_hash_table_size (le->blocked_contacts), ==, 1);
3477 g_assert_cmpstr (g_hash_table_lookup (le->blocked_contacts, GUINT_TO_POINTER (handle)),
3478 ==, id);
3479
3480 g_assert (le->unblocked_contacts != NULL);
3481 g_assert_cmpuint (g_hash_table_size (le->unblocked_contacts), ==, 0);
3482}
3483
3484static void
3485test_assert_one_contact_unblocked (Test *test,
3486 guint index,
3487 TpHandle handle,
3488 const gchar *id)
3489{
3490 LogEntry *le;
3491
3492 le = g_ptr_array_index (test->log, index);
3493 g_assert_cmpint (le->type, ==, BLOCKED_CONTACTS_CHANGED);
3494
3495 g_assert (le->blocked_contacts != NULL);
3496 g_assert_cmpuint (g_hash_table_size (le->blocked_contacts), ==, 0);
3497
3498 g_assert (le->unblocked_contacts != NULL);
3499 g_assert_cmpuint (g_hash_table_size (le->unblocked_contacts), ==, 1);
3500 g_assert_cmpstr (g_hash_table_lookup (le->unblocked_contacts, GUINT_TO_POINTER (handle)),
3501 ==, id);
3502}
3503
3504static void
3505test_nothing (Test *test,
3506 gconstpointer nil G_GNUC_UNUSED)
3507{
3508 /* this is actually a valuable test - it ensures that shutting down the
3509 * CM before the contact list has been retrieved works! */
3510}
3511
3512static void
3513test_initial_channels (Test *test,
3514 gconstpointer nil G_GNUC_UNUSED)
3515{
3516 test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish");
3517 test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST,
3518 "subscribe");
3519 test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored");
3520 test->deny = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "deny");
3521
3522 g_assert_cmpuint (
3523 tp_intset_size (tp_channel_group_get_members (test->publish)), ==, 4);
3524 g_assert_cmpuint (
3525 tp_intset_size (tp_channel_group_get_local_pending (test->publish)),
3526 ==, 2);
3527 g_assert_cmpuint (
3528 tp_intset_size (tp_channel_group_get_remote_pending (test->publish)),
3529 ==, 0);
3530 g_assert (tp_intset_is_member (tp_channel_group_get_members (test->publish),
3531 test->sjoerd));
3532 g_assert (tp_intset_is_member (
3533 tp_channel_group_get_local_pending (test->publish),
3534 test->wim));
3535
3536 g_assert_cmpuint (
3537 tp_intset_size (tp_channel_group_get_members (test->subscribe)), ==, 4);
3538 g_assert_cmpuint (
3539 tp_intset_size (tp_channel_group_get_local_pending (test->subscribe)),
3540 ==, 0);
3541 g_assert_cmpuint (
3542 tp_intset_size (tp_channel_group_get_remote_pending (test->subscribe)),
3543 ==, 2);
3544 g_assert (tp_intset_is_member (
3545 tp_channel_group_get_members (test->subscribe),
3546 test->sjoerd));
3547 g_assert (tp_intset_is_member (
3548 tp_channel_group_get_remote_pending (test->subscribe),
3549 test->helen));
3550
3551 g_assert_cmpuint (
3552 tp_intset_size (tp_channel_group_get_members (test->stored)), ==, 8);
3553 g_assert_cmpuint (
3554 tp_intset_size (tp_channel_group_get_local_pending (test->stored)),
3555 ==, 0);
3556 g_assert_cmpuint (
3557 tp_intset_size (tp_channel_group_get_remote_pending (test->stored)),
3558 ==, 0);
3559 g_assert (tp_intset_is_member (tp_channel_group_get_members (test->stored),
3560 test->sjoerd));
3561
3562 g_assert (!tp_intset_is_member (tp_channel_group_get_members (test->publish),
3563 test->ninja));
3564 g_assert (!tp_intset_is_member (tp_channel_group_get_members (
3565 test->subscribe),
3566 test->ninja));
3567 g_assert (!tp_intset_is_member (tp_channel_group_get_members (test->stored),
3568 test->ninja));
3569
3570 g_assert_cmpuint (
3571 tp_intset_size (tp_channel_group_get_members (test->deny)), ==, 2);
3572 g_assert_cmpuint (
3573 tp_intset_size (tp_channel_group_get_local_pending (test->deny)),
3574 ==, 0);
3575 g_assert_cmpuint (
3576 tp_intset_size (tp_channel_group_get_remote_pending (test->deny)),
3577 ==, 0);
3578 g_assert (tp_intset_is_member (tp_channel_group_get_members (test->deny),
3579 test->bill));
3580}
3581
3582static void
3583test_properties (Test *test,
3584 gconstpointer nil G_GNUC_UNUSED)
3585{
3586 GHashTable *asv;
3587 GError *error = NULL;
3588 guint32 blocking_caps;
3589 gboolean valid;
3590
3591 tp_cli_dbus_properties_run_get_all (test->conn, -1,
3592 TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST, &asv, &error, NULL);
3593 g_assert_no_error (error);
3594 g_assert_cmpuint (g_hash_table_size (asv), >=, 3);
3595 g_assert (tp_asv_get_boolean (asv, "ContactListPersists", NULL));
3596 g_assert (tp_asv_get_boolean (asv, "CanChangeContactList", NULL));
3597 g_assert (tp_asv_get_boolean (asv, "RequestUsesMessage", NULL));
3598 g_hash_table_unref (asv);
3599
3600 tp_cli_dbus_properties_run_get_all (test->conn, -1,
3601 TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS, &asv, &error, NULL);
3602 g_assert_no_error (error);
3603 g_assert_cmpuint (g_hash_table_size (asv), >=, 3);
3604 g_assert (G_VALUE_HOLDS_BOOLEAN (tp_asv_lookup (asv, "DisjointGroups")));
3605 g_assert (!tp_asv_get_boolean (asv, "DisjointGroups", NULL));
3606 g_assert (G_VALUE_HOLDS_UINT (tp_asv_lookup (asv, "GroupStorage")));
3607 g_assert_cmpuint (tp_asv_get_uint32 (asv, "GroupStorage", NULL), ==,
3608 TP_CONTACT_METADATA_STORAGE_TYPE_ANYONE);
3609 /* Don't assert about the contents yet - we might not have received the
3610 * contact list yet */
3611 g_assert (G_VALUE_HOLDS (tp_asv_lookup (asv, "Groups"), G_TYPE_STRV));
3612 g_hash_table_unref (asv);
3613
3614 /* this has the side-effect of waiting for the contact list to be received */
3615 test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish");
3616
3617 tp_cli_dbus_properties_run_get_all (test->conn, -1,
3618 TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST, &asv, &error, NULL);
3619 g_assert_no_error (error);
3620 g_assert_cmpuint (g_hash_table_size (asv), >=, 3);
3621 g_assert (tp_asv_get_boolean (asv, "ContactListPersists", NULL));
3622 g_assert (tp_asv_get_boolean (asv, "CanChangeContactList", NULL));
3623 g_assert (tp_asv_get_boolean (asv, "RequestUsesMessage", NULL));
3624 g_hash_table_unref (asv);
3625
3626 tp_cli_dbus_properties_run_get_all (test->conn, -1,
3627 TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS, &asv, &error, NULL);
3628 g_assert_no_error (error);
3629 g_assert_cmpuint (g_hash_table_size (asv), >=, 3);
3630 g_assert (G_VALUE_HOLDS_BOOLEAN (tp_asv_lookup (asv, "DisjointGroups")));
3631 g_assert (G_VALUE_HOLDS_UINT (tp_asv_lookup (asv, "GroupStorage")));
3632 g_assert (tp_asv_get_strv (asv, "Groups") != NULL);
3633 g_assert (tp_strv_contains (tp_asv_get_strv (asv, "Groups"), "Cambridge"));
3634 g_assert (tp_strv_contains (tp_asv_get_strv (asv, "Groups"), "Montreal"));
3635 g_assert (tp_strv_contains (tp_asv_get_strv (asv, "Groups"),
3636 "Francophones"));
3637 g_hash_table_unref (asv);
3638
3639 tp_cli_dbus_properties_run_get_all (test->conn, -1,
3640 TP_IFACE_CONNECTION_INTERFACE_CONTACT_BLOCKING, &asv, &error, NULL);
3641 g_assert_no_error (error);
3642 g_assert_cmpuint (g_hash_table_size (asv), ==, 1);
3643 blocking_caps = tp_asv_get_uint32 (asv, "ContactBlockingCapabilities",
3644 &valid);
3645 g_assert (valid);
3646 g_assert_cmpuint (blocking_caps, ==, 0);
3647 g_hash_table_unref (asv);
3648
3649 g_assert_cmpuint (test->log->len, ==, 0);
3650}
3651
3652static void
3653contact_attrs_cb (TpConnection *conn G_GNUC_UNUSED,
3654 GHashTable *attributes,
3655 const GError *error,
3656 gpointer user_data,
3657 GObject *object G_GNUC_UNUSED)
3658{
3659 Test *test = user_data;
3660
3661 g_assert_no_error ((GError *) error);
3662 tp_clear_pointer (&test->contact_attributes, g_hash_table_unref);
3663 test->contact_attributes = g_boxed_copy (TP_HASH_TYPE_CONTACT_ATTRIBUTES_MAP,
3664 attributes);
3665}
3666
3667static void
3668test_assert_contact_list_attrs (Test *test,
3669 TpHandle handle,
3670 TpSubscriptionState expected_sub_state,
3671 TpSubscriptionState expected_pub_state,
3672 const gchar *expected_pub_request)
3673{
3674 GHashTable *asv;
3675 gboolean valid;
3676
3677 g_assert_cmpuint (g_hash_table_size (test->contact_attributes), >=, 1);
3678 asv = g_hash_table_lookup (test->contact_attributes,
3679 GUINT_TO_POINTER (handle));
3680 g_assert (asv != NULL);
3681 g_assert_cmpuint (tp_asv_get_uint32 (asv,
3682 TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST_SUBSCRIBE, &valid), ==,
3683 expected_sub_state);
3684 g_assert (valid);
3685 g_assert_cmpuint (tp_asv_get_uint32 (asv,
3686 TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST_PUBLISH, &valid), ==,
3687 expected_pub_state);
3688 g_assert (valid);
3689 g_assert_cmpstr (tp_asv_get_string (asv,
3690 TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST_PUBLISH_REQUEST), ==,
3691 expected_pub_request);
3692 g_assert (valid);
3693}
3694
3695/* We simplify here by assuming that contacts are in at most one group,
3696 * which happens to be true for all of these tests. */
3697static void
3698test_assert_contact_groups_attr (Test *test,
3699 TpHandle handle,
3700 const gchar *group)
3701{
3702 GHashTable *asv;
3703 const gchar * const *strv;
3704
3705 g_assert_cmpuint (g_hash_table_size (test->contact_attributes), >=, 1);
3706 asv = g_hash_table_lookup (test->contact_attributes,
3707 GUINT_TO_POINTER (handle));
3708 g_assert (asv != NULL);
3709 tp_asv_dump (asv);
3710 g_assert (tp_asv_lookup (asv,
3711 TP_TOKEN_CONNECTION_INTERFACE_CONTACT_GROUPS_GROUPS) != NULL);
3712 g_assert (G_VALUE_HOLDS (tp_asv_lookup (asv,
3713 TP_TOKEN_CONNECTION_INTERFACE_CONTACT_GROUPS_GROUPS), G_TYPE_STRV));
3714 strv = tp_asv_get_strv (asv,
3715 TP_TOKEN_CONNECTION_INTERFACE_CONTACT_GROUPS_GROUPS);
3716
3717 if (group == NULL)
3718 {
3719 if (strv != NULL)
3720 g_assert_cmpstr (strv[0], ==, NULL);
3721 }
3722 else
3723 {
3724 g_assert (strv != NULL);
3725 g_assert_cmpstr (strv[0], ==, group);
3726 g_assert_cmpstr (strv[1], ==, NULL);
3727 }
3728}
3729
3730static void
3731test_assert_contact_state (Test *test,
3732 TpHandle handle,
3733 TpSubscriptionState expected_sub_state,
3734 TpSubscriptionState expected_pub_state,
3735 const gchar *expected_pub_request,
3736 const gchar *expected_group)
3737{
3738 const gchar * const interfaces[] = {
3739 TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST,
3740 TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS,
3741 NULL };
3742
3743 tp_connection_get_contact_attributes (test->conn, -1,
3744 1, &handle, interfaces, FALSE, contact_attrs_cb,
3745 test, test_quit_loop, NULL);
3746 g_main_loop_run (test->main_loop);
3747
3748 g_assert_cmpuint (g_hash_table_size (test->contact_attributes), ==, 1);
3749 test_assert_contact_list_attrs (test, handle, expected_sub_state,
3750 expected_pub_state, expected_pub_request);
3751 test_assert_contact_groups_attr (test, handle, expected_group);
3752}
3753
3754static void
3755test_contacts (Test *test,
3756 gconstpointer nil G_GNUC_UNUSED)
3757{
3758 /* ensure the contact list has been received */
3759 test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish");
3760
3761 test_assert_contact_state (test, test->sjoerd,
3762 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_YES, NULL, "Cambridge");
3763 test_assert_contact_state (test, test->wim,
3764 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_ASK,
3765 "I'm more metal than you!", NULL);
3766 test_assert_contact_state (test, test->helen,
3767 TP_SUBSCRIPTION_STATE_ASK, TP_SUBSCRIPTION_STATE_NO, NULL, "Cambridge");
3768 test_assert_contact_state (test, test->ninja,
3769 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL);
3770 test_assert_contact_state (test, test->bill,
3771 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL);
3772}
3773
3774static void
3775test_contact_list_attrs (Test *test,
3776 gconstpointer nil G_GNUC_UNUSED)
3777{
3778 const gchar * const interfaces[] = {
3779 TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS,
3780 NULL };
3781
3782 tp_connection_get_contact_list_attributes (test->conn, -1,
3783 interfaces, FALSE, contact_attrs_cb, test, test_quit_loop, NULL);
3784 g_main_loop_run (test->main_loop);
3785
3786 test_assert_contact_list_attrs (test, test->sjoerd,
3787 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_YES, NULL);
3788 test_assert_contact_list_attrs (test, test->wim,
3789 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_ASK,
3790 "I'm more metal than you!");
3791 test_assert_contact_list_attrs (test, test->helen,
3792 TP_SUBSCRIPTION_STATE_ASK, TP_SUBSCRIPTION_STATE_NO, NULL);
3793
3794 test_assert_contact_groups_attr (test, test->sjoerd, "Cambridge");
3795 test_assert_contact_groups_attr (test, test->wim, NULL);
3796 test_assert_contact_groups_attr (test, test->helen, "Cambridge");
3797
3798 /* bill is blocked, but is not on the contact list as such; the ninja isn't
3799 * in the initial state at all */
3800 g_assert (g_hash_table_lookup (test->contact_attributes,
3801 GUINT_TO_POINTER (test->bill)) == NULL);
3802 g_assert (g_hash_table_lookup (test->contact_attributes,
3803 GUINT_TO_POINTER (test->ninja)) == NULL);
3804}
3805
3806static void
3807test_assert_contact_blocking_attrs (Test *test,
3808 TpHandle handle,
3809 gboolean expected_blocked)
3810{
3811 GHashTable *asv;
3812 gboolean blocked, valid;
3813
3814 g_assert_cmpuint (g_hash_table_size (test->contact_attributes), >=, 1);
3815 asv = g_hash_table_lookup (test->contact_attributes,
3816 GUINT_TO_POINTER (handle));
3817 g_assert (asv != NULL);
3818 tp_asv_dump (asv);
3819
3820 blocked = tp_asv_get_boolean (asv,
3821 TP_TOKEN_CONNECTION_INTERFACE_CONTACT_BLOCKING_BLOCKED, &valid);
3822 g_assert (valid);
3823 g_assert (blocked == expected_blocked);
3824}
3825
3826static void
3827test_contact_blocking_attrs (Test *test,
3828 gconstpointer nil G_GNUC_UNUSED)
3829{
3830 const gchar * const interfaces[] = {
3831 TP_IFACE_CONNECTION_INTERFACE_CONTACT_BLOCKING,
3832 NULL };
3833 TpHandle handles[] = { test->sjoerd, test->bill };
3834
3835 tp_connection_get_contact_attributes (test->conn, -1,
3836 G_N_ELEMENTS (handles), handles,
3837 interfaces, FALSE, contact_attrs_cb, test, test_quit_loop, NULL);
3838 g_main_loop_run (test->main_loop);
3839
3840 test_assert_contact_blocking_attrs (test, test->sjoerd, FALSE);
3841 test_assert_contact_blocking_attrs (test, test->bill, TRUE);
3842}
3843
3844static void
3845test_accept_publish_request (Test *test,
3846 gconstpointer mode)
3847{
3848 GError *error = NULL;
3849
3850 test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish");
3851
3852 g_assert_cmpuint (
3853 tp_intset_size (tp_channel_group_get_local_pending (test->publish)),
3854 ==, 2);
3855 g_assert (tp_intset_is_member (
3856 tp_channel_group_get_local_pending (test->publish),
3857 test->wim));
3858
3859 g_array_append_val (test->arr, test->wim);
3860
3861 if (!tp_strdiff (mode, "old"))
3862 tp_cli_channel_interface_group_run_add_members (test->publish,
3863 -1, test->arr, "", &error, NULL);
3864 else
3865 tp_cli_connection_interface_contact_list_run_authorize_publication (
3866 test->conn, -1, test->arr, &error, NULL);
3867
3868 g_assert_no_error (error);
3869
3870 /* by the time the method returns, we should have had the
3871 * change-notification, too */
3872 g_assert_cmpuint (
3873 tp_intset_size (tp_channel_group_get_local_pending (test->publish)),
3874 ==, 1);
3875 g_assert (tp_intset_is_member (
3876 tp_channel_group_get_members (test->publish),
3877 test->wim));
3878 g_assert (!tp_intset_is_member (
3879 tp_channel_group_get_local_pending (test->publish),
3880 test->wim));
3881
3882 g_assert_cmpuint (test->log->len, ==, 1);
3883 test_assert_one_contact_changed (test, 0, test->wim, TP_SUBSCRIPTION_STATE_NO,
3884 TP_SUBSCRIPTION_STATE_YES, "");
3885 test_assert_contact_state (test, test->wim,
3886 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_YES, NULL, NULL);
3887}
3888
3889static void
3890test_reject_publish_request (Test *test,
3891 gconstpointer mode)
3892{
3893 GError *error = NULL;
3894
3895 test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish");
3896
3897 g_assert (tp_intset_is_member (
3898 tp_channel_group_get_local_pending (test->publish),
3899 test->wim));
3900 g_assert (!tp_intset_is_member (
3901 tp_channel_group_get_members (test->publish),
3902 test->wim));
3903
3904 g_array_append_val (test->arr, test->wim);
3905
3906 if (!tp_strdiff (mode, "old"))
3907 {
3908 tp_cli_channel_interface_group_run_remove_members (test->publish,
3909 -1, test->arr, "", &error, NULL);
3910 }
3911 else if (!tp_strdiff (mode, "unpublish"))
3912 {
3913 /* directly equivalent, but in practice people won't do this */
3914 tp_cli_connection_interface_contact_list_run_unpublish (
3915 test->conn, -1, test->arr, &error, NULL);
3916 }
3917 else
3918 {
3919 /* this isn't directly equivalent, but in practice it's what people
3920 * will do */
3921 tp_cli_connection_interface_contact_list_run_remove_contacts (
3922 test->conn, -1, test->arr, &error, NULL);
3923 }
3924
3925 g_assert_no_error (error);
3926
3927 /* by the time the method returns, we should have had the
3928 * removal-notification, too */
3929 g_assert_cmpuint (
3930 tp_intset_size (tp_channel_group_get_local_pending (test->publish)),
3931 ==, 1);
3932 g_assert (!tp_intset_is_member (
3933 tp_channel_group_get_members (test->publish),
3934 test->wim));
3935 g_assert (!tp_intset_is_member (
3936 tp_channel_group_get_local_pending (test->publish),
3937 test->wim));
3938
3939 g_assert_cmpuint (test->log->len, ==, 1);
3940
3941 /* because Wim wasn't really on our contact list, he's removed as a
3942 * side-effect, even if we only unpublished */
3943 test_assert_one_contact_removed (test, 0, test->wim);
3944
3945 test_assert_contact_state (test, test->wim,
3946 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL);
3947}
3948
3949static void
3950test_add_to_publish_pre_approve (Test *test,
3951 gconstpointer mode)
3952{
3953 GError *error = NULL;
3954
3955 /* Unilaterally adding a member to the publish channel doesn't work, but
3956 * in the new contact list manager the method "succeeds" anyway, and
3957 * any subsequent subscription request succeeds instantly. */
3958
3959 test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish");
3960 test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored");
3961 test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "subscribe");
3962
3963 g_array_append_val (test->arr, test->ninja);
3964
3965 g_assert (!tp_intset_is_member (
3966 tp_channel_group_get_local_pending (test->publish),
3967 test->ninja));
3968
3969 if (!tp_strdiff (mode, "old"))
3970 tp_cli_channel_interface_group_run_add_members (test->publish,
3971 -1, test->arr, "", &error, NULL);
3972 else
3973 tp_cli_connection_interface_contact_list_run_authorize_publication (
3974 test->conn, -1, test->arr, &error, NULL);
3975
3976 g_assert_no_error (error);
3977
3978 g_assert (!tp_intset_is_member (
3979 tp_channel_group_get_local_pending (test->publish),
3980 test->ninja));
3981
3982 /* the example CM's fake contacts accept requests that contain "please" */
3983 if (!tp_strdiff (mode, "old"))
3984 tp_cli_channel_interface_group_run_add_members (test->subscribe,
3985 -1, test->arr, "Please may I see your presence?", &error, NULL);
3986 else
3987 tp_cli_connection_interface_contact_list_run_request_subscription (
3988 test->conn, -1, test->arr, "Please may I see your presence?", &error,
3989 NULL);
3990
3991 g_assert_no_error (error);
3992
3993 /* by the time the method returns, we should have had the
3994 * change-notification, too */
3995 g_assert (tp_intset_is_member (
3996 tp_channel_group_get_remote_pending (test->subscribe),
3997 test->ninja));
3998 g_assert (tp_intset_is_member (
3999 tp_channel_group_get_members (test->stored),
4000 test->ninja));
4001 g_assert (!tp_intset_is_member (
4002 tp_channel_group_get_remote_pending (test->stored),
4003 test->ninja));
4004
4005 /* after a short delay, the contact accepts our request */
4006 while (tp_intset_is_member (
4007 tp_channel_group_get_remote_pending (test->subscribe),
4008 test->ninja))
4009 g_main_context_iteration (NULL, TRUE);
4010
4011 g_assert (tp_intset_is_member (
4012 tp_channel_group_get_members (test->subscribe),
4013 test->ninja));
4014 g_assert (!tp_intset_is_member (
4015 tp_channel_group_get_remote_pending (test->subscribe),
4016 test->ninja));
4017
4018 /* the contact also requests our presence after a short delay - we
4019 * pre-approved, so they go straight to full membership */
4020 while (!tp_intset_is_member (
4021 tp_channel_group_get_members (test->publish),
4022 test->ninja) || test->log->len < 3)
4023 g_main_context_iteration (NULL, TRUE);
4024
4025 g_assert (tp_intset_is_member (
4026 tp_channel_group_get_members (test->publish),
4027 test->ninja));
4028 g_assert (!tp_intset_is_member (
4029 tp_channel_group_get_local_pending (test->publish),
4030 test->ninja));
4031
4032 g_assert_cmpuint (test->log->len, ==, 3);
4033 test_assert_one_contact_changed (test, 0, test->ninja, TP_SUBSCRIPTION_STATE_ASK,
4034 TP_SUBSCRIPTION_STATE_NO, "");
4035 test_assert_one_contact_changed (test, 1, test->ninja, TP_SUBSCRIPTION_STATE_YES,
4036 TP_SUBSCRIPTION_STATE_NO, "");
4037 test_assert_one_contact_changed (test, 2, test->ninja, TP_SUBSCRIPTION_STATE_YES,
4038 TP_SUBSCRIPTION_STATE_YES, "");
4039
4040 test_assert_contact_state (test, test->ninja,
4041 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_YES, NULL, NULL);
4042}
4043
4044static void
4045test_add_to_publish_no_op (Test *test,
4046 gconstpointer mode)
4047{
4048 GError *error = NULL;
4049
4050 /* Adding a member to the publish channel when they're already there is
4051 * valid. */
4052
4053 test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish");
4054
4055 g_assert (tp_intset_is_member (
4056 tp_channel_group_get_members (test->publish),
4057 test->sjoerd));
4058
4059 g_array_append_val (test->arr, test->sjoerd);
4060
4061 if (!tp_strdiff (mode, "old"))
4062 tp_cli_channel_interface_group_run_add_members (test->publish,
4063 -1, test->arr, "", &error, NULL);
4064 else
4065 tp_cli_connection_interface_contact_list_run_authorize_publication (
4066 test->conn, -1, test->arr, &error, NULL);
4067
4068 g_assert_no_error (error);
4069
4070 g_assert (tp_intset_is_member (
4071 tp_channel_group_get_members (test->publish),
4072 test->sjoerd));
4073
4074 g_assert_cmpuint (test->log->len, ==, 0);
4075 test_assert_contact_state (test, test->sjoerd,
4076 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_YES, NULL, "Cambridge");
4077}
4078
4079static void
4080test_remove_from_publish (Test *test,
4081 gconstpointer mode)
4082{
4083 GError *error = NULL;
4084
4085 test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish");
4086
4087 g_assert_cmpuint (
4088 tp_intset_size (tp_channel_group_get_members (test->publish)),
4089 ==, 4);
4090 g_assert (tp_intset_is_member (
4091 tp_channel_group_get_members (test->publish),
4092 test->sjoerd));
4093
4094 g_array_append_val (test->arr, test->sjoerd);
4095
4096 if (!tp_strdiff (mode, "old"))
4097 tp_cli_channel_interface_group_run_remove_members (test->publish,
4098 -1, test->arr, "", &error, NULL);
4099 else
4100 tp_cli_connection_interface_contact_list_run_unpublish (
4101 test->conn, -1, test->arr, &error, NULL);
4102
4103 g_assert_no_error (error);
4104
4105 /* by the time the method returns, we should have had the
4106 * removal-notification, too */
4107 g_assert (!tp_intset_is_member (
4108 tp_channel_group_get_members (test->publish),
4109 test->sjoerd));
4110
4111 /* the contact re-requests our presence after a short delay */
4112 while (!tp_intset_is_member (
4113 tp_channel_group_get_local_pending (test->publish),
4114 test->sjoerd) ||
4115 test->log->len < 2)
4116 g_main_context_iteration (NULL, TRUE);
4117
4118 g_assert (!tp_intset_is_member (
4119 tp_channel_group_get_members (test->publish),
4120 test->sjoerd));
4121 g_assert (tp_intset_is_member (
4122 tp_channel_group_get_local_pending (test->publish),
4123 test->sjoerd));
4124
4125 g_assert_cmpuint (test->log->len, ==, 2);
4126 test_assert_one_contact_changed (test, 0, test->sjoerd,
4127 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_NO, "");
4128 test_assert_one_contact_changed (test, 1, test->sjoerd,
4129 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_ASK,
4130 "May I see your presence, please?");
4131 test_assert_contact_state (test, test->sjoerd,
4132 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_ASK,
4133 "May I see your presence, please?", "Cambridge");
4134}
4135
4136static void
4137test_remove_from_publish_no_op (Test *test,
4138 gconstpointer mode)
4139{
4140 GError *error = NULL;
4141
4142 test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish");
4143
4144 g_assert_cmpuint (
4145 tp_intset_size (tp_channel_group_get_members (test->publish)),
4146 ==, 4);
4147 g_assert (!tp_intset_is_member (
4148 tp_channel_group_get_members (test->publish),
4149 test->ninja));
4150
4151 g_array_append_val (test->arr, test->ninja);
4152
4153 if (!tp_strdiff (mode, "old"))
4154 tp_cli_channel_interface_group_run_remove_members (test->publish,
4155 -1, test->arr, "", &error, NULL);
4156 else
4157 tp_cli_connection_interface_contact_list_run_unpublish (
4158 test->conn, -1, test->arr, &error, NULL);
4159
4160 g_assert_no_error (error);
4161
4162 g_assert_cmpuint (test->log->len, ==, 0);
4163 test_assert_contact_state (test, test->ninja,
4164 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL);
4165}
4166
4167static void
4168test_cancelled_publish_request (Test *test,
4169 gconstpointer mode)
4170{
4171 GError *error = NULL;
4172
4173 test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "subscribe");
4174 test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish");
4175 test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored");
4176
4177 g_assert_cmpuint (
4178 tp_intset_size (tp_channel_group_get_members (test->subscribe)),
4179 ==, 4);
4180 g_assert (!tp_intset_is_member (
4181 tp_channel_group_get_members (test->subscribe),
4182 test->canceller));
4183 g_assert (!tp_intset_is_member (
4184 tp_channel_group_get_remote_pending (test->subscribe),
4185 test->canceller));
4186
4187 /* the example CM's fake contacts accept requests that contain "please" */
4188 g_array_append_val (test->arr, test->canceller);
4189
4190 tp_cli_connection_interface_contact_list_run_request_subscription (
4191 test->conn, -1, test->arr, "Please may I see your presence?",
4192 &error, NULL);
4193
4194 /* It starts off the same as test_accept_subscribe_request, but because
4195 * we're using an identifier with special significance, the contact cancels
4196 * the request immediately after */
4197 while (tp_intset_is_member (
4198 tp_channel_group_get_local_pending (test->publish),
4199 test->canceller) ||
4200 test->log->len < 4)
4201 g_main_context_iteration (NULL, TRUE);
4202
4203 g_assert (!tp_intset_is_member (
4204 tp_channel_group_get_members (test->publish),
4205 test->canceller));
4206 g_assert (!tp_intset_is_member (
4207 tp_channel_group_get_local_pending (test->publish),
4208 test->canceller));
4209
4210 g_assert_cmpuint (test->log->len, ==, 4);
4211 test_assert_one_contact_changed (test, 0, test->canceller,
4212 TP_SUBSCRIPTION_STATE_ASK, TP_SUBSCRIPTION_STATE_NO, "");
4213 test_assert_one_contact_changed (test, 1, test->canceller,
4214 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_NO, "");
4215 test_assert_one_contact_changed (test, 2, test->canceller,
4216 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_ASK,
4217 "May I see your presence, please?");
4218 test_assert_one_contact_changed (test, 3, test->canceller,
4219 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_REMOVED_REMOTELY, "");
4220 test_assert_contact_state (test, test->canceller,
4221 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_REMOVED_REMOTELY,
4222 NULL, NULL);
4223
4224 test_clear_log (test);
4225
4226 /* We can acknowledge the cancellation with Unpublish() or
4227 * RemoveContacts(). We can't use the old API here, because in the old API,
4228 * the contact has already vanished from the Group */
4229 if (!tp_strdiff (mode, "remove-after"))
4230 tp_cli_connection_interface_contact_list_run_remove_contacts (test->conn,
4231 -1, test->arr, &error, NULL);
4232 else
4233 tp_cli_connection_interface_contact_list_run_unpublish (
4234 test->conn, -1, test->arr, &error, NULL);
4235
4236 while (test->log->len < 1)
4237 g_main_context_iteration (NULL, TRUE);
4238
4239 g_assert_cmpuint (test->log->len, ==, 1);
4240
4241 if (!tp_strdiff (mode, "remove-after"))
4242 test_assert_one_contact_removed (test, 0, test->canceller);
4243 else
4244 test_assert_one_contact_changed (test, 0, test->canceller,
4245 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_NO, "");
4246}
4247
4248static void
4249test_add_to_stored (Test *test,
4250 gconstpointer mode)
4251{
4252 GError *error = NULL;
4253
4254 test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored");
4255 test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish");
4256 test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST,
4257 "subscribe");
4258
4259 g_assert_cmpuint (
4260 tp_intset_size (tp_channel_group_get_members (test->stored)),
4261 ==, 8);
4262 g_assert (!tp_intset_is_member (
4263 tp_channel_group_get_members (test->stored),
4264 test->ninja));
4265
4266 g_array_append_val (test->arr, test->ninja);
4267
4268 if (!tp_strdiff (mode, "old"))
4269 {
4270 tp_cli_channel_interface_group_run_add_members (test->stored,
4271 -1, test->arr, "", &error, NULL);
4272 }
4273 else
4274 {
4275 /* there's no specific API for adding contacts to stored (it's not a
4276 * very useful action in general), but setting an alias has it as a
4277 * side-effect */
4278 GHashTable *table = g_hash_table_new (NULL, NULL);
4279
4280 g_hash_table_insert (table, GUINT_TO_POINTER (test->ninja),
4281 "The Wee Ninja");
4282 tp_cli_connection_interface_aliasing_run_set_aliases (test->conn,
4283 -1, table, &error, NULL);
4284 g_hash_table_unref (table);
4285 }
4286
4287 g_assert_no_error (error);
4288
4289 /* by the time the method returns, we should have had the
4290 * change-notification, too */
4291 g_assert_cmpuint (
4292 tp_intset_size (tp_channel_group_get_members (test->stored)),
4293 ==, 9);
4294 g_assert (tp_intset_is_member (
4295 tp_channel_group_get_members (test->stored),
4296 test->ninja));
4297
4298 g_assert (!tp_intset_is_member (
4299 tp_channel_group_get_members (test->subscribe),
4300 test->ninja));
4301 g_assert (!tp_intset_is_member (
4302 tp_channel_group_get_members (test->publish),
4303 test->ninja));
4304
4305 g_assert_cmpuint (test->log->len, ==, 1);
4306 test_assert_one_contact_changed (test, 0, test->ninja,
4307 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, "");
4308 test_assert_contact_state (test, test->ninja,
4309 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL);
4310}
4311
4312static void
4313test_add_to_stored_no_op (Test *test,
4314 gconstpointer mode)
4315{
4316 GError *error = NULL;
4317
4318 test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored");
4319
4320 g_assert_cmpuint (
4321 tp_intset_size (tp_channel_group_get_members (test->stored)),
4322 ==, 8);
4323 g_assert (tp_intset_is_member (
4324 tp_channel_group_get_members (test->stored),
4325 test->sjoerd));
4326
4327 g_array_append_val (test->arr, test->sjoerd);
4328
4329 if (!tp_strdiff (mode, "old"))
4330 {
4331 tp_cli_channel_interface_group_run_add_members (test->stored,
4332 -1, test->arr, "", &error, NULL);
4333 }
4334 else
4335 {
4336 /* there's no specific API for adding contacts to stored (it's not a
4337 * very useful action in general), but setting an alias has it as a
4338 * side-effect */
4339 GHashTable *table = g_hash_table_new (NULL, NULL);
4340
4341 g_hash_table_insert (table, GUINT_TO_POINTER (test->sjoerd),
4342 "Sjoerd");
4343 tp_cli_connection_interface_aliasing_run_set_aliases (test->conn,
4344 -1, table, &error, NULL);
4345 g_hash_table_unref (table);
4346 }
4347
4348 g_assert_no_error (error);
4349
4350 g_assert_cmpuint (test->log->len, ==, 0);
4351 test_assert_contact_state (test, test->sjoerd,
4352 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_YES, NULL, "Cambridge");
4353}
4354
4355static void
4356test_remove_from_stored (Test *test,
4357 gconstpointer mode)
4358{
4359 GError *error = NULL;
4360
4361 test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored");
4362 test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish");
4363 test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST,
4364 "subscribe");
4365
4366 g_assert (tp_intset_is_member (
4367 tp_channel_group_get_members (test->stored),
4368 test->sjoerd));
4369
4370 g_array_append_val (test->arr, test->sjoerd);
4371
4372 if (!tp_strdiff (mode, "old"))
4373 tp_cli_channel_interface_group_run_remove_members (test->stored,
4374 -1, test->arr, "", &error, NULL);
4375 else
4376 tp_cli_connection_interface_contact_list_run_remove_contacts (test->conn,
4377 -1, test->arr, &error, NULL);
4378
4379 g_assert_no_error (error);
4380
4381 /* by the time the method returns, we should have had the
4382 * removal-notification, too */
4383 g_assert (!tp_intset_is_member (
4384 tp_channel_group_get_members (test->stored),
4385 test->sjoerd));
4386 g_assert (!tp_intset_is_member (
4387 tp_channel_group_get_members (test->subscribe),
4388 test->sjoerd));
4389 g_assert (!tp_intset_is_member (
4390 tp_channel_group_get_members (test->publish),
4391 test->sjoerd));
4392
4393 g_assert_cmpuint (test->log->len, ==, 1);
4394 test_assert_one_contact_removed (test, 0, test->sjoerd);
4395 test_assert_contact_state (test, test->sjoerd,
4396 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL);
4397}
4398
4399static void
4400test_remove_from_stored_no_op (Test *test,
4401 gconstpointer mode)
4402{
4403 GError *error = NULL;
4404
4405 test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored");
4406
4407 g_assert_cmpuint (
4408 tp_intset_size (tp_channel_group_get_members (test->stored)),
4409 ==, 8);
4410 g_assert (!tp_intset_is_member (
4411 tp_channel_group_get_members (test->stored),
4412 test->ninja));
4413
4414 g_array_append_val (test->arr, test->ninja);
4415
4416 if (!tp_strdiff (mode, "old"))
4417 tp_cli_channel_interface_group_run_remove_members (test->stored,
4418 -1, test->arr, "", &error, NULL);
4419 else
4420 tp_cli_connection_interface_contact_list_run_remove_contacts (test->conn,
4421 -1, test->arr, &error, NULL);
4422
4423 g_assert_no_error (error);
4424
4425 g_assert_cmpuint (test->log->len, ==, 0);
4426 test_assert_contact_state (test, test->ninja,
4427 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL);
4428}
4429
4430static void
4431test_accept_subscribe_request (Test *test,
4432 gconstpointer mode)
4433{
4434 GError *error = NULL;
4435
4436 test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "subscribe");
4437 test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish");
4438 test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored");
4439
4440 g_assert_cmpuint (
4441 tp_intset_size (tp_channel_group_get_members (test->subscribe)),
4442 ==, 4);
4443 g_assert (!tp_intset_is_member (
4444 tp_channel_group_get_members (test->subscribe),
4445 test->ninja));
4446 g_assert (!tp_intset_is_member (
4447 tp_channel_group_get_remote_pending (test->subscribe),
4448 test->ninja));
4449
4450 /* the example CM's fake contacts accept requests that contain "please" */
4451 g_array_append_val (test->arr, test->ninja);
4452
4453 if (!tp_strdiff (mode, "old"))
4454 tp_cli_channel_interface_group_run_add_members (test->subscribe,
4455 -1, test->arr, "Please may I see your presence?", &error, NULL);
4456 else
4457 tp_cli_connection_interface_contact_list_run_request_subscription (
4458 test->conn, -1, test->arr, "Please may I see your presence?",
4459 &error, NULL);
4460
4461 g_assert_no_error (error);
4462
4463 /* by the time the method returns, we should have had the
4464 * change-notification, too */
4465 g_assert (tp_intset_is_member (
4466 tp_channel_group_get_remote_pending (test->subscribe),
4467 test->ninja));
4468 g_assert (tp_intset_is_member (
4469 tp_channel_group_get_members (test->stored),
4470 test->ninja));
4471 g_assert (!tp_intset_is_member (
4472 tp_channel_group_get_remote_pending (test->stored),
4473 test->ninja));
4474
4475 /* after a short delay, the contact accepts our request */
4476 while (tp_intset_is_member (
4477 tp_channel_group_get_remote_pending (test->subscribe),
4478 test->ninja))
4479 g_main_context_iteration (NULL, TRUE);
4480
4481 g_assert (tp_intset_is_member (
4482 tp_channel_group_get_members (test->subscribe),
4483 test->ninja));
4484 g_assert (!tp_intset_is_member (
4485 tp_channel_group_get_remote_pending (test->subscribe),
4486 test->ninja));
4487
4488 /* the contact also requests our presence after a short delay */
4489 while (!tp_intset_is_member (
4490 tp_channel_group_get_local_pending (test->publish),
4491 test->ninja) ||
4492 test->log->len < 3)
4493 g_main_context_iteration (NULL, TRUE);
4494
4495 g_assert (!tp_intset_is_member (
4496 tp_channel_group_get_members (test->publish),
4497 test->ninja));
4498 g_assert (tp_intset_is_member (
4499 tp_channel_group_get_local_pending (test->publish),
4500 test->ninja));
4501
4502 g_assert_cmpuint (test->log->len, ==, 3);
4503 test_assert_one_contact_changed (test, 0, test->ninja,
4504 TP_SUBSCRIPTION_STATE_ASK, TP_SUBSCRIPTION_STATE_NO, "");
4505 test_assert_one_contact_changed (test, 1, test->ninja,
4506 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_NO, "");
4507 test_assert_one_contact_changed (test, 2, test->ninja,
4508 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_ASK,
4509 "May I see your presence, please?");
4510 test_assert_contact_state (test, test->ninja,
4511 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_ASK,
4512 "May I see your presence, please?", NULL);
4513}
4514
4515static void
4516test_reject_subscribe_request (Test *test,
4517 gconstpointer mode)
4518{
4519 GError *error = NULL;
4520
4521 test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "subscribe");
4522 test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored");
4523
4524 g_assert_cmpuint (
4525 tp_intset_size (tp_channel_group_get_members (test->subscribe)),
4526 ==, 4);
4527 g_assert (!tp_intset_is_member (
4528 tp_channel_group_get_members (test->subscribe),
4529 test->ninja));
4530 g_assert (!tp_intset_is_member (
4531 tp_channel_group_get_remote_pending (test->subscribe),
4532 test->ninja));
4533
4534 /* the example CM's fake contacts reject requests that don't contain
4535 * "please" */
4536 g_array_append_val (test->arr, test->ninja);
4537
4538 if (!tp_strdiff (mode, "old"))
4539 tp_cli_channel_interface_group_run_add_members (test->subscribe,
4540 -1, test->arr, "I demand to see your presence?", &error, NULL);
4541 else
4542 tp_cli_connection_interface_contact_list_run_request_subscription (
4543 test->conn, -1, test->arr, "I demand to see your presence?",
4544 &error, NULL);
4545
4546 g_assert_no_error (error);
4547
4548 /* by the time the method returns, we should have had the
4549 * change-notification, too */
4550 g_assert (tp_intset_is_member (
4551 tp_channel_group_get_remote_pending (test->subscribe),
4552 test->ninja));
4553 g_assert (tp_intset_is_member (
4554 tp_channel_group_get_members (test->stored),
4555 test->ninja));
4556 g_assert (!tp_intset_is_member (
4557 tp_channel_group_get_remote_pending (test->stored),
4558 test->ninja));
4559
4560 /* after a short delay, the contact rejects our request. Say please! */
4561 while (tp_intset_is_member (
4562 tp_channel_group_get_remote_pending (test->subscribe),
4563 test->ninja) ||
4564 test->log->len < 2)
4565 g_main_context_iteration (NULL, TRUE);
4566
4567 g_assert (!tp_intset_is_member (
4568 tp_channel_group_get_members (test->subscribe),
4569 test->ninja));
4570 g_assert (!tp_intset_is_member (
4571 tp_channel_group_get_remote_pending (test->subscribe),
4572 test->ninja));
4573
4574 /* the ninja is still on the stored list */
4575 g_assert (tp_intset_is_member (
4576 tp_channel_group_get_members (test->stored),
4577 test->ninja));
4578 g_assert (!tp_intset_is_member (
4579 tp_channel_group_get_remote_pending (test->stored),
4580 test->ninja));
4581
4582 g_assert_cmpuint (test->log->len, ==, 2);
4583 test_assert_one_contact_changed (test, 0, test->ninja,
4584 TP_SUBSCRIPTION_STATE_ASK, TP_SUBSCRIPTION_STATE_NO, "");
4585 test_assert_one_contact_changed (test, 1, test->ninja,
4586 TP_SUBSCRIPTION_STATE_REMOVED_REMOTELY, TP_SUBSCRIPTION_STATE_NO, "");
4587 test_assert_contact_state (test, test->ninja,
4588 TP_SUBSCRIPTION_STATE_REMOVED_REMOTELY, TP_SUBSCRIPTION_STATE_NO, NULL,
4589 NULL);
4590
4591 test_clear_log (test);
4592
4593 /* We can acknowledge the failure to subscribe with Unsubscribe() or
4594 * RemoveContacts(). We can't use the old API here, because in the old API,
4595 * the contact has already vanished from the Group */
4596 if (!tp_strdiff (mode, "remove-after"))
4597 tp_cli_connection_interface_contact_list_run_remove_contacts (test->conn,
4598 -1, test->arr, &error, NULL);
4599 else
4600 tp_cli_connection_interface_contact_list_run_unsubscribe (
4601 test->conn, -1, test->arr, &error, NULL);
4602
4603 /* the ninja falls off our subscribe list */
4604 while (test->log->len < 1)
4605 g_main_context_iteration (NULL, TRUE);
4606
4607 g_assert_cmpuint (test->log->len, ==, 1);
4608
4609 if (!tp_strdiff (mode, "remove-after"))
4610 test_assert_one_contact_removed (test, 0, test->ninja);
4611 else
4612 test_assert_one_contact_changed (test, 0, test->ninja,
4613 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, "");
4614}
4615
4616static void
4617test_remove_from_subscribe (Test *test,
4618 gconstpointer mode)
4619{
4620 GError *error = NULL;
4621
4622 test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "subscribe");
4623 test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored");
4624
4625 g_assert_cmpuint (
4626 tp_intset_size (tp_channel_group_get_members (test->subscribe)),
4627 ==, 4);
4628 g_assert (tp_intset_is_member (
4629 tp_channel_group_get_members (test->subscribe),
4630 test->sjoerd));
4631
4632 g_array_append_val (test->arr, test->sjoerd);
4633
4634 if (!tp_strdiff (mode, "old"))
4635 tp_cli_channel_interface_group_run_remove_members (test->subscribe,
4636 -1, test->arr, "", &error, NULL);
4637 else
4638 tp_cli_connection_interface_contact_list_run_unsubscribe (
4639 test->conn, -1, test->arr, &error, NULL);
4640
4641 g_assert_no_error (error);
4642
4643 /* by the time the method returns, we should have had the
4644 * removal-notification, too */
4645 g_assert (!tp_intset_is_member (
4646 tp_channel_group_get_members (test->subscribe),
4647 test->sjoerd));
4648 g_assert (tp_intset_is_member (
4649 tp_channel_group_get_members (test->stored),
4650 test->sjoerd));
4651
4652 g_assert_cmpuint (test->log->len, ==, 1);
4653 test_assert_one_contact_changed (test, 0, test->sjoerd,
4654 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_YES, "");
4655 test_assert_contact_state (test, test->sjoerd,
4656 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_YES, NULL, "Cambridge");
4657}
4658
4659static void
4660test_remove_from_subscribe_pending (Test *test,
4661 gconstpointer mode)
4662{
4663 GError *error = NULL;
4664
4665 test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "subscribe");
4666 test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored");
4667
4668 g_assert_cmpuint (
4669 tp_intset_size (tp_channel_group_get_remote_pending (test->subscribe)),
4670 ==, 2);
4671 g_assert (tp_intset_is_member (
4672 tp_channel_group_get_remote_pending (test->subscribe),
4673 test->helen));
4674
4675 g_array_append_val (test->arr, test->helen);
4676
4677 if (!tp_strdiff (mode, "old"))
4678 tp_cli_channel_interface_group_run_remove_members (test->subscribe,
4679 -1, test->arr, "", &error, NULL);
4680 else
4681 tp_cli_connection_interface_contact_list_run_unsubscribe (
4682 test->conn, -1, test->arr, &error, NULL);
4683
4684 g_assert_no_error (error);
4685
4686 /* by the time the method returns, we should have had the
4687 * removal-notification, too */
4688 g_assert (!tp_intset_is_member (
4689 tp_channel_group_get_members (test->subscribe),
4690 test->helen));
4691 g_assert (!tp_intset_is_member (
4692 tp_channel_group_get_remote_pending (test->subscribe),
4693 test->helen));
4694 g_assert (tp_intset_is_member (
4695 tp_channel_group_get_members (test->stored),
4696 test->helen));
4697
4698 g_assert_cmpuint (test->log->len, ==, 1);
4699 test_assert_one_contact_changed (test, 0, test->helen,
4700 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, "");
4701 test_assert_contact_state (test, test->helen,
4702 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, "Cambridge");
4703}
4704
4705static void
4706test_remove_from_subscribe_no_op (Test *test,
4707 gconstpointer mode)
4708{
4709 GError *error = NULL;
4710
4711 test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "subscribe");
4712
4713 g_assert_cmpuint (
4714 tp_intset_size (tp_channel_group_get_members (test->subscribe)),
4715 ==, 4);
4716 g_assert (!tp_intset_is_member (
4717 tp_channel_group_get_members (test->subscribe),
4718 test->ninja));
4719
4720 g_array_append_val (test->arr, test->ninja);
4721
4722 if (!tp_strdiff (mode, "old"))
4723 tp_cli_channel_interface_group_run_remove_members (test->subscribe,
4724 -1, test->arr, "", &error, NULL);
4725 else
4726 tp_cli_connection_interface_contact_list_run_unsubscribe (
4727 test->conn, -1, test->arr, &error, NULL);
4728
4729 g_assert_no_error (error);
4730
4731 g_assert_cmpuint (test->log->len, ==, 0);
4732 test_assert_contact_state (test, test->ninja,
4733 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL);
4734}
4735
4736static void
4737test_add_to_group (Test *test,
4738 gconstpointer mode)
4739{
4740 GError *error = NULL;
4741 LogEntry *le;
4742 guint i;
4743
4744 test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP,
4745 "Cambridge");
4746 test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored");
4747 test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish");
4748 test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST,
4749 "subscribe");
4750
4751 g_assert_cmpuint (
4752 tp_intset_size (tp_channel_group_get_members (test->group)),
4753 ==, 4);
4754 g_assert (!tp_intset_is_member (
4755 tp_channel_group_get_members (test->group),
4756 test->ninja));
4757
4758 g_array_append_val (test->arr, test->ninja);
4759
4760 if (!tp_strdiff (mode, "old"))
4761 tp_cli_channel_interface_group_run_add_members (test->group,
4762 -1, test->arr, "", &error, NULL);
4763 else
4764 tp_cli_connection_interface_contact_groups_run_add_to_group (test->conn,
4765 -1, "Cambridge", test->arr, &error, NULL);
4766
4767 g_assert_no_error (error);
4768
4769 /* by the time the method returns, we should have had the
4770 * change-notification, too */
4771 g_assert_cmpuint (
4772 tp_intset_size (tp_channel_group_get_members (test->group)),
4773 ==, 5);
4774 g_assert (tp_intset_is_member (
4775 tp_channel_group_get_members (test->group),
4776 test->ninja));
4777
4778 g_assert (tp_intset_is_member (
4779 tp_channel_group_get_members (test->stored),
4780 test->ninja));
4781 g_assert (!tp_intset_is_member (
4782 tp_channel_group_get_members (test->subscribe),
4783 test->ninja));
4784 g_assert (!tp_intset_is_member (
4785 tp_channel_group_get_members (test->publish),
4786 test->ninja));
4787
4788 g_assert_cmpuint (test->log->len, ==, 2);
4789
4790 le = g_ptr_array_index (test->log, 0);
4791
4792 if (le->type == CONTACTS_CHANGED)
4793 {
4794 test_assert_one_contact_changed (test, 0, test->ninja,
4795 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, "");
4796 i = 1;
4797 }
4798 else
4799 {
4800 test_assert_one_contact_changed (test, 1, test->ninja,
4801 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, "");
4802 i = 0;
4803 }
4804
4805 /* either way, the i'th entry is now the GroupsChanged signal */
4806 test_assert_one_group_joined (test, i, test->ninja, "Cambridge");
4807
4808 test_assert_contact_state (test, test->ninja,
4809 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, "Cambridge");
4810}
4811
4812static void
4813test_add_to_group_no_op (Test *test,
4814 gconstpointer mode)
4815{
4816 GError *error = NULL;
4817
4818 test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP,
4819 "Cambridge");
4820
4821 g_assert (tp_intset_is_member (
4822 tp_channel_group_get_members (test->group),
4823 test->sjoerd));
4824
4825 g_array_append_val (test->arr, test->sjoerd);
4826
4827 if (!tp_strdiff (mode, "old"))
4828 tp_cli_channel_interface_group_run_add_members (test->group,
4829 -1, test->arr, "", &error, NULL);
4830 else
4831 tp_cli_connection_interface_contact_groups_run_add_to_group (test->conn,
4832 -1, "Cambridge", test->arr, &error, NULL);
4833
4834 g_assert_no_error (error);
4835
4836 g_assert_cmpuint (test->log->len, ==, 0);
4837 test_assert_contact_state (test, test->sjoerd,
4838 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_YES, NULL, "Cambridge");
4839}
4840
4841static void
4842test_remove_from_group (Test *test,
4843 gconstpointer mode)
4844{
4845 GError *error = NULL;
4846
4847 test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP,
4848 "Cambridge");
4849
4850 g_assert (tp_intset_is_member (
4851 tp_channel_group_get_members (test->group),
4852 test->sjoerd));
4853
4854 g_array_append_val (test->arr, test->sjoerd);
4855
4856 if (!tp_strdiff (mode, "old"))
4857 tp_cli_channel_interface_group_run_remove_members (test->group,
4858 -1, test->arr, "", &error, NULL);
4859 else
4860 tp_cli_connection_interface_contact_groups_run_remove_from_group (
4861 test->conn, -1, "Cambridge", test->arr, &error, NULL);
4862
4863 g_assert_no_error (error);
4864
4865 /* by the time the method returns, we should have had the
4866 * removal-notification, too */
4867 g_assert (!tp_intset_is_member (
4868 tp_channel_group_get_members (test->group),
4869 test->sjoerd));
4870
4871 g_assert_cmpuint (test->log->len, ==, 1);
4872 test_assert_one_group_left (test, 0, test->sjoerd, "Cambridge");
4873 test_assert_contact_state (test, test->sjoerd,
4874 TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_YES, NULL, NULL);
4875}
4876
4877static void
4878test_remove_from_group_no_op (Test *test,
4879 gconstpointer mode)
4880{
4881 GError *error = NULL;
4882
4883 test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP,
4884 "Cambridge");
4885
4886 g_assert (!tp_intset_is_member (
4887 tp_channel_group_get_members (test->group),
4888 test->ninja));
4889
4890 g_array_append_val (test->arr, test->ninja);
4891
4892 if (!tp_strdiff (mode, "old"))
4893 tp_cli_channel_interface_group_run_remove_members (test->group,
4894 -1, test->arr, "", &error, NULL);
4895 else
4896 tp_cli_connection_interface_contact_groups_run_remove_from_group (
4897 test->conn, -1, "Cambridge", test->arr, &error, NULL);
4898
4899 g_assert_no_error (error);
4900
4901 g_assert_cmpuint (test->log->len, ==, 0);
4902 test_assert_contact_state (test, test->ninja,
4903 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL);
4904}
4905
4906static void
4907test_remove_group (Test *test,
4908 gconstpointer mode)
4909{
4910 GError *error = NULL;
4911
4912 test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP,
4913 "Cambridge");
4914
4915 g_assert (!tp_intset_is_empty (
4916 tp_channel_group_get_members (test->group)));
4917
4918 if (!tp_strdiff (mode, "old"))
4919 {
4920 /* The old API can't remove non-empty groups... */
4921 tp_cli_channel_run_close (test->group, -1, &error, NULL);
4922 g_assert_error (error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE);
4923
4924 g_assert_cmpuint (test->log->len, ==, 0);
4925 }
4926 else
4927 {
4928 /* ... but the new API can */
4929 LogEntry *le;
4930
4931 tp_cli_connection_interface_contact_groups_run_remove_group (test->conn,
4932 -1, "Cambridge", &error, NULL);
4933 g_assert_no_error (error);
4934
4935 g_assert (tp_proxy_get_invalidated (test->group) != NULL);
4936 g_assert_cmpuint (test->log->len, ==, 2);
4937 test_assert_one_group_removed (test, 0, "Cambridge");
4938
4939 le = g_ptr_array_index (test->log, 1);
4940 g_assert_cmpint (le->type, ==, GROUPS_CHANGED);
4941 g_assert_cmpuint (le->contacts->len, ==, 4);
4942 g_assert (le->groups_added == NULL || le->groups_added[0] == NULL);
4943 g_assert (le->groups_removed != NULL);
4944 g_assert_cmpstr (le->groups_removed[0], ==, "Cambridge");
4945 g_assert_cmpstr (le->groups_removed[1], ==, NULL);
4946 }
4947}
4948
4949static void
4950test_remove_group_empty (Test *test,
4951 gconstpointer mode)
4952{
4953 GError *error = NULL;
4954
4955 g_assert_cmpuint (test->log->len, ==, 0);
4956 test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP,
4957 "people who understand const in C");
4958
4959 g_assert_cmpuint (test->log->len, ==, 1);
4960 test_assert_one_group_created (test, 0, "people who understand const in C");
4961
4962 g_assert (tp_intset_is_empty (
4963 tp_channel_group_get_members (test->group)));
4964
4965 tp_cli_channel_run_close (test->group, -1, &error, NULL);
4966 g_assert_no_error (error);
4967
4968 g_assert_cmpuint (test->log->len, ==, 2);
4969 test_assert_one_group_removed (test, 1, "people who understand const in C");
4970}
4971
4972static void
4973test_set_contact_groups (Test *test,
4974 gconstpointer nil G_GNUC_UNUSED)
4975{
4976 GError *error = NULL;
4977 LogEntry *le;
4978 const gchar *montreal_strv[] = { "Montreal", NULL };
4979
4980 test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP,
4981 "Cambridge");
4982
4983 g_assert_cmpuint (
4984 tp_intset_size (tp_channel_group_get_members (test->group)),
4985 ==, 4);
4986 g_assert (tp_intset_is_member (
4987 tp_channel_group_get_members (test->group),
4988 test->sjoerd));
4989
4990 g_array_append_val (test->arr, test->sjoerd);
4991 g_array_append_val (test->arr, test->wim);
4992
4993 tp_cli_connection_interface_contact_groups_run_set_contact_groups (
4994 test->conn, -1, test->sjoerd, montreal_strv, &error, NULL);
4995
4996 g_assert_no_error (error);
4997
4998 /* by the time the method returns, we should have had the
4999 * change-notification, too */
5000 g_assert_cmpuint (
5001 tp_intset_size (tp_channel_group_get_members (test->group)),
5002 ==, 3);
5003 g_assert (!tp_intset_is_member (
5004 tp_channel_group_get_members (test->group),
5005 test->sjoerd));
5006
5007 g_assert_cmpuint (test->log->len, ==, 1);
5008
5009 le = g_ptr_array_index (test->log, 0);
5010 g_assert_cmpint (le->type, ==, GROUPS_CHANGED);
5011 g_assert_cmpuint (le->contacts->len, ==, 1);
5012 g_assert_cmpuint (g_array_index (le->contacts, guint, 0), ==, test->sjoerd);
5013 g_assert (le->groups_added != NULL);
5014 g_assert_cmpstr (le->groups_added[0], ==, "Montreal");
5015 g_assert_cmpstr (le->groups_added[1], ==, NULL);
5016 g_assert (le->groups_removed != NULL);
5017 g_assert_cmpstr (le->groups_removed[0], ==, "Cambridge");
5018 g_assert_cmpstr (le->groups_removed[1], ==, NULL);
5019}
5020
5021static void
5022test_set_contact_groups_no_op (Test *test,
5023 gconstpointer nil G_GNUC_UNUSED)
5024{
5025 GError *error = NULL;
5026 const gchar *cambridge_strv[] = { "Cambridge", NULL };
5027
5028 test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP,
5029 "Cambridge");
5030
5031 g_assert_cmpuint (
5032 tp_intset_size (tp_channel_group_get_members (test->group)),
5033 ==, 4);
5034 g_assert (tp_intset_is_member (
5035 tp_channel_group_get_members (test->group),
5036 test->sjoerd));
5037
5038 g_array_append_val (test->arr, test->sjoerd);
5039 g_array_append_val (test->arr, test->wim);
5040
5041 tp_cli_connection_interface_contact_groups_run_set_contact_groups (
5042 test->conn, -1, test->sjoerd, cambridge_strv, &error, NULL);
5043
5044 g_assert_no_error (error);
5045
5046 g_assert_cmpuint (
5047 tp_intset_size (tp_channel_group_get_members (test->group)),
5048 ==, 4);
5049 g_assert (tp_intset_is_member (
5050 tp_channel_group_get_members (test->group),
5051 test->sjoerd));
5052
5053 g_assert_cmpuint (test->log->len, ==, 0);
5054}
5055
5056static void
5057test_set_group_members (Test *test,
5058 gconstpointer nil G_GNUC_UNUSED)
5059{
5060 GError *error = NULL;
5061 LogEntry *le;
5062
5063 test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP,
5064 "Cambridge");
5065
5066 g_assert_cmpuint (
5067 tp_intset_size (tp_channel_group_get_members (test->group)),
5068 ==, 4);
5069 g_assert (tp_intset_is_member (
5070 tp_channel_group_get_members (test->group),
5071 test->sjoerd));
5072 g_assert (tp_intset_is_member (
5073 tp_channel_group_get_members (test->group),
5074 test->helen));
5075 g_assert (!tp_intset_is_member (
5076 tp_channel_group_get_members (test->group),
5077 test->wim));
5078
5079 g_array_append_val (test->arr, test->sjoerd);
5080 g_array_append_val (test->arr, test->wim);
5081
5082 tp_cli_connection_interface_contact_groups_run_set_group_members (test->conn,
5083 -1, "Cambridge", test->arr, &error, NULL);
5084
5085 g_assert_no_error (error);
5086
5087 /* by the time the method returns, we should have had the
5088 * change-notification, too */
5089 g_assert_cmpuint (
5090 tp_intset_size (tp_channel_group_get_members (test->group)),
5091 ==, 2);
5092 g_assert (tp_intset_is_member (
5093 tp_channel_group_get_members (test->group),
5094 test->wim));
5095 g_assert (tp_intset_is_member (
5096 tp_channel_group_get_members (test->group),
5097 test->sjoerd));
5098 g_assert (!tp_intset_is_member (
5099 tp_channel_group_get_members (test->group),
5100 test->helen));
5101
5102 g_assert_cmpuint (test->log->len, ==, 2);
5103
5104 /* Wim was added */
5105 test_assert_one_group_joined (test, 0, test->wim, "Cambridge");
5106
5107 /* The three other members, other than Sjoerd, left */
5108 le = g_ptr_array_index (test->log, 1);
5109 g_assert_cmpint (le->type, ==, GROUPS_CHANGED);
5110 g_assert_cmpuint (le->contacts->len, ==, 3);
5111 g_assert (le->groups_added == NULL || le->groups_added[0] == NULL);
5112 g_assert (le->groups_removed != NULL);
5113 g_assert_cmpstr (le->groups_removed[0], ==, "Cambridge");
5114 g_assert_cmpstr (le->groups_removed[1], ==, NULL);
5115}
5116
5117static void
5118test_rename_group (Test *test,
5119 gconstpointer nil G_GNUC_UNUSED)
5120{
5121 LogEntry *le;
5122 GError *error = NULL;
5123
5124 test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP,
5125 "Cambridge");
5126
5127 g_assert_cmpuint (
5128 tp_intset_size (tp_channel_group_get_members (test->group)),
5129 ==, 4);
5130
5131 tp_cli_connection_interface_contact_groups_run_rename_group (test->conn,
5132 -1, "Cambridge", "Grantabrugge", &error, NULL);
5133 g_assert_no_error (error);
5134
5135 g_assert (tp_proxy_get_invalidated (test->group) != NULL);
5136 g_assert_cmpuint (test->log->len, ==, 4);
5137
5138 le = g_ptr_array_index (test->log, 0);
5139 g_assert_cmpint (le->type, ==, GROUP_RENAMED);
5140 g_assert (le->groups_added != NULL);
5141 g_assert_cmpstr (le->groups_added[0], ==, "Grantabrugge");
5142 g_assert_cmpstr (le->groups_added[1], ==, NULL);
5143 g_assert (le->groups_removed != NULL);
5144 g_assert_cmpstr (le->groups_removed[0], ==, "Cambridge");
5145 g_assert_cmpstr (le->groups_removed[1], ==, NULL);
5146
5147 test_assert_one_group_created (test, 1, "Grantabrugge");
5148
5149 test_assert_one_group_removed (test, 2, "Cambridge");
5150
5151 le = g_ptr_array_index (test->log, 3);
5152 g_assert_cmpint (le->type, ==, GROUPS_CHANGED);
5153 g_assert_cmpuint (le->contacts->len, ==, 4);
5154 g_assert (le->groups_added != NULL);
5155 g_assert_cmpstr (le->groups_added[0], ==, "Grantabrugge");
5156 g_assert_cmpstr (le->groups_added[1], ==, NULL);
5157 g_assert_cmpstr (le->groups_removed[0], ==, "Cambridge");
5158 g_assert_cmpstr (le->groups_removed[1], ==, NULL);
5159}
5160
5161static void
5162test_rename_group_overwrite (Test *test,
5163 gconstpointer nil G_GNUC_UNUSED)
5164{
5165 GError *error = NULL;
5166
5167 tp_cli_connection_interface_contact_groups_run_rename_group (test->conn,
5168 -1, "Cambridge", "Montreal", &error, NULL);
5169 g_assert_error (error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE);
5170 g_assert_cmpuint (test->log->len, ==, 0);
5171 g_clear_error (&error);
5172}
5173
5174static void
5175test_rename_group_absent (Test *test,
5176 gconstpointer nil G_GNUC_UNUSED)
5177{
5178 GError *error = NULL;
5179
5180 tp_cli_connection_interface_contact_groups_run_rename_group (test->conn,
5181 -1, "Badgers", "Mushrooms", &error, NULL);
5182 g_assert_error (error, TP_ERRORS, TP_ERROR_DOES_NOT_EXIST);
5183 g_assert_cmpuint (test->log->len, ==, 0);
5184 g_clear_error (&error);
5185}
5186
5187/* Signature of a function which does something with test->arr */
5188typedef void (*ManipulateContactsFunc) (
5189 Test *test,
5190 GError **error);
5191
5192static void
5193block_contacts (Test *test,
5194 ManipulateContactsFunc func)
5195{
5196 GError *error = NULL;
5197
5198 test->deny = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "deny");
5199 test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored");
5200
5201 g_assert_cmpuint (
5202 tp_intset_size (tp_channel_group_get_members (test->deny)),
5203 ==, 2);
5204 g_assert (!tp_intset_is_member (
5205 tp_channel_group_get_members (test->deny),
5206 test->ninja));
5207
5208 g_array_append_val (test->arr, test->ninja);
5209 func (test, &error);
5210 g_assert_no_error (error);
5211
5212 /* by the time the method returns, we should have had the
5213 * change-notification, on both the deny channel and the ContactBlocking
5214 * connection interface */
5215 g_assert_cmpuint (
5216 tp_intset_size (tp_channel_group_get_members (test->deny)),
5217 ==, 3);
5218 g_assert (tp_intset_is_member (
5219 tp_channel_group_get_members (test->deny),
5220 test->ninja));
5221
5222 g_assert (!tp_intset_is_member (
5223 tp_channel_group_get_members (test->stored),
5224 test->ninja));
5225 test_assert_contact_state (test, test->ninja,
5226 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL);
5227
5228 g_assert_cmpuint (test->log->len, ==, 1);
5229 test_assert_one_contact_blocked (test, 0, test->ninja,
5230 tp_handle_inspect (test->contact_repo, test->ninja));
5231}
5232
5233static void
5234block_contacts_no_op (Test *test,
5235 ManipulateContactsFunc func)
5236{
5237 GError *error = NULL;
5238
5239 test->deny = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "deny");
5240
5241 g_assert (tp_intset_is_member (
5242 tp_channel_group_get_members (test->deny),
5243 test->bill));
5244
5245 g_array_append_val (test->arr, test->bill);
5246 func (test, &error);
5247 g_assert_no_error (error);
5248
5249 g_assert (tp_intset_is_member (
5250 tp_channel_group_get_members (test->deny),
5251 test->bill));
5252 test_assert_contact_state (test, test->bill,
5253 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL);
5254
5255 /* We shouldn't emit spurious empty BlockedContactsChanged signals. */
5256 g_assert_cmpuint (test->log->len, ==, 0);
5257}
5258
5259static void
5260unblock_contacts (Test *test,
5261 ManipulateContactsFunc func)
5262{
5263 GError *error = NULL;
5264
5265 test->deny = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "deny");
5266 test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish");
5267 test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST,
5268 "subscribe");
5269
5270 g_assert (tp_intset_is_member (
5271 tp_channel_group_get_members (test->deny),
5272 test->bill));
5273
5274 g_array_append_val (test->arr, test->bill);
5275 func (test, &error);
5276 g_assert_no_error (error);
5277
5278 /* by the time the method returns, we should have had the
5279 * removal-notification, too */
5280 g_assert (!tp_intset_is_member (
5281 tp_channel_group_get_members (test->deny),
5282 test->bill));
5283 test_assert_contact_state (test, test->bill,
5284 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL);
5285
5286 g_assert_cmpuint (test->log->len, ==, 1);
5287 test_assert_one_contact_unblocked (test, 0, test->bill,
5288 tp_handle_inspect (test->contact_repo, test->bill));
5289}
5290
5291static void
5292unblock_contacts_no_op (Test *test,
5293 ManipulateContactsFunc func)
5294{
5295 GError *error = NULL;
5296
5297 test->deny = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "deny");
5298
5299 g_assert (!tp_intset_is_member (
5300 tp_channel_group_get_members (test->deny),
5301 test->ninja));
5302
5303 g_array_append_val (test->arr, test->ninja);
5304 func (test, &error);
5305 g_assert_no_error (error);
5306 g_assert (!tp_intset_is_member (
5307 tp_channel_group_get_members (test->deny),
5308 test->ninja));
5309 test_assert_contact_state (test, test->ninja,
5310 TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL);
5311
5312 /* We shouldn't emit spurious empty BlockedContactsChanged signals. */
5313 g_assert_cmpuint (test->log->len, ==, 0);
5314}
5315
5316static void
5317add_to_deny (Test *test,
5318 GError **error)
5319{
5320 tp_cli_channel_interface_group_run_add_members (test->deny,
5321 -1, test->arr, "", error, NULL);
5322}
5323
5324static void
5325test_add_to_deny (Test *test,
5326 gconstpointer nil G_GNUC_UNUSED)
5327{
5328 block_contacts (test, add_to_deny);
5329}
5330
5331static void
5332test_add_to_deny_no_op (Test *test,
5333 gconstpointer nil G_GNUC_UNUSED)
5334{
5335 block_contacts_no_op (test, add_to_deny);
5336}
5337
5338static void
5339remove_from_deny (Test *test,
5340 GError **error)
5341{
5342 tp_cli_channel_interface_group_run_remove_members (test->deny,
5343 -1, test->arr, "", error, NULL);
5344}
5345
5346static void
5347test_remove_from_deny (Test *test,
5348 gconstpointer nil G_GNUC_UNUSED)
5349{
5350 unblock_contacts (test, remove_from_deny);
5351}
5352
5353static void
5354test_remove_from_deny_no_op (Test *test,
5355 gconstpointer nil G_GNUC_UNUSED)
5356{
5357 unblock_contacts_no_op (test, remove_from_deny);
5358}
5359
5360static void
5361test_request_blocked_contacts (Test *test,
5362 gconstpointer nil G_GNUC_UNUSED)
5363{
5364 GHashTable *blocked_contacts;
5365 GError *error = NULL;
5366
5367 tp_cli_connection_interface_contact_blocking_run_request_blocked_contacts (
5368 test->conn, -1, &blocked_contacts, &error, NULL);
5369 g_assert_no_error (error);
5370 g_assert (blocked_contacts != NULL);
5371
5372 /* Both Bill and the shadowy Steve are blocked; Steve does not appear in this
5373 * test, as he is in poor health.
5374 */
5375 g_assert_cmpuint (g_hash_table_size (blocked_contacts), ==, 2);
5376 g_assert_cmpstr (tp_handle_inspect (test->contact_repo, test->bill), ==,
5377 g_hash_table_lookup (blocked_contacts, GUINT_TO_POINTER (test->bill)));
5378 g_hash_table_unref (blocked_contacts);
5379}
5380
5381static void
5382request_blocked_contacts_succeeded_cb (
5383 TpConnection *conn,
5384 GHashTable *blocked_contacts,
5385 const GError *error,
5386 gpointer user_data,
5387 GObject *weak_object)
5388{
5389 g_assert_no_error (error);
5390
5391 /* As above. */
5392 g_assert_cmpuint (g_hash_table_size (blocked_contacts), ==, 2);
5393}
5394
5395static void
5396test_request_blocked_contacts_pre_connect (Test *test,
5397 gconstpointer nil G_GNUC_UNUSED)
5398{
5399 gboolean ok;
5400
5401 /* This verifies that calling RequestBlockedContacts()
5402 * before Connect(), when Connect() ultimately succeeds, returns correctly.
5403 */
5404 tp_cli_connection_interface_contact_blocking_call_request_blocked_contacts (
5405 test->conn, -1, request_blocked_contacts_succeeded_cb,
5406 test, test_quit_loop, NULL);
5407 tp_cli_connection_call_connect (test->conn, -1, NULL, NULL, NULL, NULL);
5408 g_main_loop_run (test->main_loop);
5409
5410 ok = tp_cli_connection_run_disconnect (test->conn, -1, NULL, NULL);
5411 g_assert (ok);
5412}
5413
5414static void
5415request_blocked_contacts_failed_cb (
5416 TpConnection *conn,
5417 GHashTable *blocked_contacts,
5418 const GError *error,
5419 gpointer user_data,
5420 GObject *weak_object)
5421{
5422 g_assert_error (error, TP_ERRORS, TP_ERROR_DISCONNECTED);
5423}
5424
5425static void
5426test_request_blocked_contacts_connect_failed (Test *test,
5427 gconstpointer nil G_GNUC_UNUSED)
5428{
5429 /* This verifies that calling RequestBlockedContacts() (twice, no less)
5430 * before Connect(), when Connect() ultimately fails, returns an appropriate
5431 * error.
5432 */
5433 tp_cli_connection_interface_contact_blocking_call_request_blocked_contacts (
5434 test->conn, -1, request_blocked_contacts_failed_cb,
5435 test, test_quit_loop, NULL);
5436 tp_cli_connection_interface_contact_blocking_call_request_blocked_contacts (
5437 test->conn, -1, request_blocked_contacts_failed_cb,
5438 test, test_quit_loop, NULL);
5439
5440 /* We expect calling Connect() to fail because the handle was invalid, but
5441 * don't wait around for it.
5442 */
5443 tp_cli_connection_call_connect (test->conn, -1, NULL, NULL, NULL, NULL);
5444 /* Spin the mainloop twice, once for each outstanding call. */
5445 g_main_loop_run (test->main_loop);
5446 g_main_loop_run (test->main_loop);
5447}
5448
5449static void
5450call_block_contacts (Test *test,
5451 GError **error)
5452{
5453 tp_cli_connection_interface_contact_blocking_run_block_contacts (test->conn,
5454 -1, test->arr, FALSE, error, NULL);
5455}
5456
5457static void
5458test_block_contacts (Test *test,
5459 gconstpointer nil G_GNUC_UNUSED)
5460{
5461 block_contacts (test, call_block_contacts);
5462}
5463
5464static void
5465test_block_contacts_no_op (Test *test,
5466 gconstpointer nil G_GNUC_UNUSED)
5467{
5468 block_contacts_no_op (test, call_block_contacts);
5469}
5470
5471static void
5472call_unblock_contacts (Test *test,
5473 GError **error)
5474{
5475 tp_cli_connection_interface_contact_blocking_run_unblock_contacts (
5476 test->conn, -1, test->arr, error, NULL);
5477}
5478
5479static void
5480test_unblock_contacts (Test *test,
5481 gconstpointer nil G_GNUC_UNUSED)
5482{
5483 unblock_contacts (test, call_unblock_contacts);
5484}
5485
5486static void
5487test_unblock_contacts_no_op (Test *test,
5488 gconstpointer nil G_GNUC_UNUSED)
5489{
5490 unblock_contacts_no_op (test, call_unblock_contacts);
5491}
5492
5493int
5494main (int argc,
5495 char **argv)
5496{
5497 g_type_init ();
5498 tp_tests_abort_after (30);
5499 tp_debug_set_flags ("all");
5500
5501 g_test_init (&argc, &argv, NULL);
5502
5503 g_test_add ("/contact-lists/nothing",
5504 Test, NULL, setup, test_nothing, teardown);
5505
5506 g_test_add ("/contact-lists/initial-channels",
5507 Test, NULL, setup, test_initial_channels, teardown);
5508 g_test_add ("/contact-lists/properties",
5509 Test, NULL, setup, test_properties, teardown);
5510 g_test_add ("/contact-lists/contacts",
5511 Test, NULL, setup, test_contacts, teardown);
5512 g_test_add ("/contact-lists/contact-list-attrs",
5513 Test, NULL, setup, test_contact_list_attrs, teardown);
5514 g_test_add ("/contact-lists/contact-blocking-attrs",
5515 Test, NULL, setup, test_contact_blocking_attrs, teardown);
5516
5517 g_test_add ("/contact-lists/accept-publish-request",
5518 Test, NULL, setup, test_accept_publish_request, teardown);
5519 g_test_add ("/contact-lists/reject-publish-request",
5520 Test, NULL, setup, test_reject_publish_request, teardown);
5521 g_test_add ("/contact-lists/reject-publish-request/unpublish",
5522 Test, "unpublish", setup, test_reject_publish_request, teardown);
5523 g_test_add ("/contact-lists/add-to-publish/pre-approve",
5524 Test, NULL, setup, test_add_to_publish_pre_approve, teardown);
5525 g_test_add ("/contact-lists/add-to-publish/no-op",
5526 Test, NULL, setup, test_add_to_publish_no_op, teardown);
5527 g_test_add ("/contact-lists/remove-from-publish",
5528 Test, NULL, setup, test_remove_from_publish, teardown);
5529 g_test_add ("/contact-lists/remove-from-publish/no-op",
5530 Test, NULL, setup, test_remove_from_publish_no_op, teardown);
5531
5532 g_test_add ("/contact-lists/accept-publish-request/old",
5533 Test, "old", setup, test_accept_publish_request, teardown);
5534 g_test_add ("/contact-lists/reject-publish-request/old",
5535 Test, "old", setup, test_reject_publish_request, teardown);
5536 g_test_add ("/contact-lists/add-to-publish/pre-approve/old",
5537 Test, "old", setup, test_add_to_publish_pre_approve, teardown);
5538 g_test_add ("/contact-lists/add-to-publish/no-op/old",
5539 Test, "old", setup, test_add_to_publish_no_op, teardown);
5540 g_test_add ("/contact-lists/remove-from-publish/old",
5541 Test, "old", setup, test_remove_from_publish, teardown);
5542 g_test_add ("/contact-lists/remove-from-publish/no-op/old",
5543 Test, "old", setup, test_remove_from_publish_no_op, teardown);
5544
5545 g_test_add ("/contact-lists/cancelled-publish-request",
5546 Test, NULL, setup, test_cancelled_publish_request, teardown);
5547 g_test_add ("/contact-lists/cancelled-publish-request",
5548 Test, "remove-after", setup, test_cancelled_publish_request, teardown);
5549
5550 g_test_add ("/contact-lists/add-to-stored",
5551 Test, NULL, setup, test_add_to_stored, teardown);
5552 g_test_add ("/contact-lists/add-to-stored/no-op",
5553 Test, NULL, setup, test_add_to_stored_no_op, teardown);
5554 g_test_add ("/contact-lists/remove-from-stored",
5555 Test, NULL, setup, test_remove_from_stored, teardown);
5556 g_test_add ("/contact-lists/remove-from-stored/no-op",
5557 Test, NULL, setup, test_remove_from_stored_no_op, teardown);
5558
5559 g_test_add ("/contact-lists/add-to-stored/old",
5560 Test, "old", setup, test_add_to_stored, teardown);
5561 g_test_add ("/contact-lists/add-to-stored/no-op/old",
5562 Test, "old", setup, test_add_to_stored_no_op, teardown);
5563 g_test_add ("/contact-lists/remove-from-stored/old",
5564 Test, "old", setup, test_remove_from_stored, teardown);
5565 g_test_add ("/contact-lists/remove-from-stored/no-op/old",
5566 Test, "old", setup, test_remove_from_stored_no_op, teardown);
5567
5568 g_test_add ("/contact-lists/accept-subscribe-request",
5569 Test, NULL, setup, test_accept_subscribe_request, teardown);
5570 g_test_add ("/contact-lists/reject-subscribe-request",
5571 Test, NULL, setup, test_reject_subscribe_request, teardown);
5572 g_test_add ("/contact-lists/remove-from-subscribe",
5573 Test, NULL, setup, test_remove_from_subscribe, teardown);
5574 g_test_add ("/contact-lists/remove-from-subscribe/pending",
5575 Test, NULL, setup, test_remove_from_subscribe_pending, teardown);
5576 g_test_add ("/contact-lists/remove-from-subscribe/no-op",
5577 Test, NULL, setup, test_remove_from_subscribe_no_op, teardown);
5578
5579 g_test_add ("/contact-lists/accept-subscribe-request/old",
5580 Test, "old", setup, test_accept_subscribe_request, teardown);
5581 g_test_add ("/contact-lists/reject-subscribe-request/old",
5582 Test, "old", setup, test_reject_subscribe_request, teardown);
5583 g_test_add ("/contact-lists/remove-from-subscribe/old",
5584 Test, "old", setup, test_remove_from_subscribe, teardown);
5585 g_test_add ("/contact-lists/remove-from-subscribe/pending/old",
5586 Test, "old", setup, test_remove_from_subscribe_pending, teardown);
5587 g_test_add ("/contact-lists/remove-from-subscribe/no-op/old",
5588 Test, "old", setup, test_remove_from_subscribe_no_op, teardown);
5589
5590 g_test_add ("/contact-lists/reject-subscribe-request/remove-after",
5591 Test, "remove-after", setup, test_reject_subscribe_request, teardown);
5592
5593 g_test_add ("/contact-lists/add-to-group",
5594 Test, NULL, setup, test_add_to_group, teardown);
5595 g_test_add ("/contact-lists/add-to-group/no-op",
5596 Test, NULL, setup, test_add_to_group_no_op, teardown);
5597 g_test_add ("/contact-lists/remove-from-group",
5598 Test, NULL, setup, test_remove_from_group, teardown);
5599 g_test_add ("/contact-lists/remove-from-group/no-op",
5600 Test, NULL, setup, test_remove_from_group_no_op, teardown);
5601 g_test_add ("/contact-lists/remove-group",
5602 Test, NULL, setup, test_remove_group, teardown);
5603 g_test_add ("/contact-lists/remove-group/empty",
5604 Test, NULL, setup, test_remove_group_empty, teardown);
5605
5606 g_test_add ("/contact-lists/add-to-group/old",
5607 Test, "old", setup, test_add_to_group, teardown);
5608 g_test_add ("/contact-lists/add-to-group/no-op/old",
5609 Test, "old", setup, test_add_to_group_no_op, teardown);
5610 g_test_add ("/contact-lists/remove-from-group/old",
5611 Test, "old", setup, test_remove_from_group, teardown);
5612 g_test_add ("/contact-lists/remove-from-group/no-op/old",
5613 Test, "old", setup, test_remove_from_group_no_op, teardown);
5614 g_test_add ("/contact-lists/remove-group/old",
5615 Test, "old", setup, test_remove_group, teardown);
5616 g_test_add ("/contact-lists/remove-group/empty/old",
5617 Test, "old", setup, test_remove_group_empty, teardown);
5618
5619 g_test_add ("/contact-lists/set_contact_groups",
5620 Test, NULL, setup, test_set_contact_groups, teardown);
5621 g_test_add ("/contact-lists/set_contact_groups/no-op",
5622 Test, NULL, setup, test_set_contact_groups_no_op, teardown);
5623 g_test_add ("/contact-lists/set_group_members",
5624 Test, NULL, setup, test_set_group_members, teardown);
5625
5626 g_test_add ("/contact-lists/rename_group",
5627 Test, NULL, setup, test_rename_group, teardown);
5628 g_test_add ("/contact-lists/rename_group/absent",
5629 Test, NULL, setup, test_rename_group_absent, teardown);
5630 g_test_add ("/contact-lists/rename_group/overwrite",
5631 Test, NULL, setup, test_rename_group_overwrite, teardown);
5632
5633 g_test_add ("/contact-lists/add-to-deny",
5634 Test, NULL, setup, test_add_to_deny, teardown);
5635 g_test_add ("/contact-lists/add-to-deny/no-op",
5636 Test, NULL, setup, test_add_to_deny_no_op, teardown);
5637 g_test_add ("/contact-lists/remove-from-deny",
5638 Test, NULL, setup, test_remove_from_deny, teardown);
5639 g_test_add ("/contact-lists/remove-from-deny/no-op",
5640 Test, NULL, setup, test_remove_from_deny_no_op, teardown);
5641
5642 g_test_add ("/contact-lists/request-blocked-contacts",
5643 Test, NULL, setup, test_request_blocked_contacts, teardown);
5644 g_test_add ("/contact-lists/request-blocked-contacts-before-connect",
5645 Test, NULL, setup_pre_connect,
5646 test_request_blocked_contacts_pre_connect, teardown_pre_connect);
5647 g_test_add ("/contact-lists/request-blocked-contacts-connect-failed",
5648 Test, "break-account-parameter", setup_pre_connect,
5649 test_request_blocked_contacts_connect_failed,
5650 teardown_pre_connect);
5651 g_test_add ("/contact-lists/block-contacts",
5652 Test, NULL, setup, test_block_contacts, teardown);
5653 g_test_add ("/contact-lists/block-contacts/no-op",
5654 Test, NULL, setup, test_block_contacts_no_op, teardown);
5655 g_test_add ("/contact-lists/unblock-contacts",
5656 Test, NULL, setup, test_unblock_contacts, teardown);
5657 g_test_add ("/contact-lists/unblock-contacts/no-op",
5658 Test, NULL, setup, test_unblock_contacts_no_op, teardown);
5659
5660 return g_test_run ();
5661}
5662>>>>>>> MERGE-SOURCE

Subscribers

People subscribed via source and target branches

to all changes: