Merge lp:~ubuntu-branches/ubuntu/precise/telepathy-glib/precise-201111092112 into lp:ubuntu/precise/telepathy-glib
- Precise (12.04)
- precise-201111092112
- Merge into precise
Status: | Rejected |
---|---|
Rejected by: | James Westby |
Proposed branch: | lp:~ubuntu-branches/ubuntu/precise/telepathy-glib/precise-201111092112 |
Merge into: | lp:ubuntu/precise/telepathy-glib |
Diff against target: |
2803 lines (+2792/-0) (has conflicts) 1 file modified
.pc/ludicrous-timeout-for-lp-buildd.patch/tests/dbus/contact-lists.c (+2792/-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-201111092112 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu branches | Pending | ||
Review via email: mp+81778@code.launchpad.net |
Commit message
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-201111092112. 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:/
(this is an automatically generated message)
Unmerged revisions
- 70. By Ken VanDine
-
releasing version 0.16.2-1ubuntu1
Preview Diff
1 | === modified file '.pc/ludicrous-timeout-for-lp-buildd.patch/tests/dbus/contact-lists.c' | |||
2 | --- .pc/ludicrous-timeout-for-lp-buildd.patch/tests/dbus/contact-lists.c 2011-11-09 15:08:17 +0000 | |||
3 | +++ .pc/ludicrous-timeout-for-lp-buildd.patch/tests/dbus/contact-lists.c 2011-11-09 21:18:30 +0000 | |||
4 | @@ -1,3 +1,4 @@ | |||
5 | 1 | <<<<<<< TREE | ||
6 | 1 | /* Feature test for contact lists | 2 | /* Feature test for contact lists |
7 | 2 | * | 3 | * |
8 | 3 | * Copyright © 2007-2010 Collabora Ltd. <http://www.collabora.co.uk/> | 4 | * Copyright © 2007-2010 Collabora Ltd. <http://www.collabora.co.uk/> |
9 | @@ -2827,3 +2828,2794 @@ | |||
10 | 2827 | 2828 | ||
11 | 2828 | return g_test_run (); | 2829 | return g_test_run (); |
12 | 2829 | } | 2830 | } |
13 | 2831 | ======= | ||
14 | 2832 | /* Feature test for contact lists | ||
15 | 2833 | * | ||
16 | 2834 | * Copyright © 2007-2010 Collabora Ltd. <http://www.collabora.co.uk/> | ||
17 | 2835 | * Copyright © 2007-2008 Nokia Corporation | ||
18 | 2836 | * | ||
19 | 2837 | * Copying and distribution of this file, with or without modification, | ||
20 | 2838 | * are permitted in any medium without royalty provided the copyright | ||
21 | 2839 | * notice and this notice are preserved. | ||
22 | 2840 | */ | ||
23 | 2841 | |||
24 | 2842 | #include <telepathy-glib/connection.h> | ||
25 | 2843 | |||
26 | 2844 | #include "examples/cm/contactlist/conn.h" | ||
27 | 2845 | #include "tests/lib/util.h" | ||
28 | 2846 | |||
29 | 2847 | typedef enum { | ||
30 | 2848 | CONTACTS_CHANGED, | ||
31 | 2849 | GROUPS_CHANGED, | ||
32 | 2850 | GROUPS_CREATED, | ||
33 | 2851 | GROUPS_REMOVED, | ||
34 | 2852 | GROUP_RENAMED, | ||
35 | 2853 | BLOCKED_CONTACTS_CHANGED | ||
36 | 2854 | } LogEntryType; | ||
37 | 2855 | |||
38 | 2856 | typedef struct { | ||
39 | 2857 | LogEntryType type; | ||
40 | 2858 | /* ContactsChanged */ | ||
41 | 2859 | GHashTable *contacts_changed; | ||
42 | 2860 | TpIntset *contacts_removed; | ||
43 | 2861 | /* GroupsChanged */ | ||
44 | 2862 | GArray *contacts; | ||
45 | 2863 | /* GroupsChanged, GroupsCreated, GroupRenamed */ | ||
46 | 2864 | GStrv groups_added; | ||
47 | 2865 | /* GroupsChanged, GroupsRemoved, GroupRenamed */ | ||
48 | 2866 | GStrv groups_removed; | ||
49 | 2867 | /* BlockedContactsChanged */ | ||
50 | 2868 | GHashTable *blocked_contacts; | ||
51 | 2869 | GHashTable *unblocked_contacts; | ||
52 | 2870 | } LogEntry; | ||
53 | 2871 | |||
54 | 2872 | static void | ||
55 | 2873 | log_entry_free (LogEntry *le) | ||
56 | 2874 | { | ||
57 | 2875 | if (le->contacts_changed != NULL) | ||
58 | 2876 | g_hash_table_unref (le->contacts_changed); | ||
59 | 2877 | |||
60 | 2878 | if (le->contacts_removed != NULL) | ||
61 | 2879 | tp_intset_destroy (le->contacts_removed); | ||
62 | 2880 | |||
63 | 2881 | if (le->contacts != NULL) | ||
64 | 2882 | g_array_unref (le->contacts); | ||
65 | 2883 | |||
66 | 2884 | g_strfreev (le->groups_added); | ||
67 | 2885 | g_strfreev (le->groups_removed); | ||
68 | 2886 | |||
69 | 2887 | if (le->blocked_contacts != NULL) | ||
70 | 2888 | g_hash_table_unref (le->blocked_contacts); | ||
71 | 2889 | |||
72 | 2890 | if (le->unblocked_contacts != NULL) | ||
73 | 2891 | g_hash_table_unref (le->unblocked_contacts); | ||
74 | 2892 | |||
75 | 2893 | g_slice_free (LogEntry, le); | ||
76 | 2894 | } | ||
77 | 2895 | |||
78 | 2896 | typedef struct { | ||
79 | 2897 | TpDBusDaemon *dbus; | ||
80 | 2898 | ExampleContactListConnection *service_conn; | ||
81 | 2899 | TpBaseConnection *service_conn_as_base; | ||
82 | 2900 | gchar *conn_name; | ||
83 | 2901 | gchar *conn_path; | ||
84 | 2902 | TpConnection *conn; | ||
85 | 2903 | |||
86 | 2904 | TpChannel *publish; | ||
87 | 2905 | TpChannel *subscribe; | ||
88 | 2906 | TpChannel *stored; | ||
89 | 2907 | TpChannel *deny; | ||
90 | 2908 | |||
91 | 2909 | TpChannel *group; | ||
92 | 2910 | |||
93 | 2911 | TpHandleRepoIface *contact_repo; | ||
94 | 2912 | TpHandle sjoerd; | ||
95 | 2913 | TpHandle helen; | ||
96 | 2914 | TpHandle wim; | ||
97 | 2915 | TpHandle bill; | ||
98 | 2916 | TpHandle ninja; | ||
99 | 2917 | TpHandle canceller; | ||
100 | 2918 | |||
101 | 2919 | GArray *arr; | ||
102 | 2920 | |||
103 | 2921 | /* list of LogEntry */ | ||
104 | 2922 | GPtrArray *log; | ||
105 | 2923 | |||
106 | 2924 | GAsyncResult *prepare_result; | ||
107 | 2925 | GHashTable *contact_attributes; | ||
108 | 2926 | |||
109 | 2927 | GMainLoop *main_loop; | ||
110 | 2928 | } Test; | ||
111 | 2929 | |||
112 | 2930 | static void | ||
113 | 2931 | test_quit_loop (gpointer p) | ||
114 | 2932 | { | ||
115 | 2933 | Test *test = p; | ||
116 | 2934 | |||
117 | 2935 | g_main_loop_quit (test->main_loop); | ||
118 | 2936 | } | ||
119 | 2937 | |||
120 | 2938 | static void | ||
121 | 2939 | contacts_changed_with_id_cb (TpConnection *connection, | ||
122 | 2940 | GHashTable *changes, | ||
123 | 2941 | GHashTable *identifiers, | ||
124 | 2942 | GHashTable *removals, | ||
125 | 2943 | gpointer user_data, | ||
126 | 2944 | GObject *weak_object G_GNUC_UNUSED) | ||
127 | 2945 | { | ||
128 | 2946 | Test *test = user_data; | ||
129 | 2947 | LogEntry *le = g_slice_new0 (LogEntry); | ||
130 | 2948 | GHashTableIter i; | ||
131 | 2949 | gpointer key, value; | ||
132 | 2950 | |||
133 | 2951 | if (g_hash_table_size (changes) > 0) | ||
134 | 2952 | g_assert_cmpuint (g_hash_table_size (changes), ==, | ||
135 | 2953 | g_hash_table_size (identifiers)); | ||
136 | 2954 | else | ||
137 | 2955 | g_assert_cmpuint (g_hash_table_size (removals), >, 0); | ||
138 | 2956 | |||
139 | 2957 | le->type = CONTACTS_CHANGED; | ||
140 | 2958 | le->contacts_changed = g_boxed_copy (TP_HASH_TYPE_CONTACT_SUBSCRIPTION_MAP, | ||
141 | 2959 | changes); | ||
142 | 2960 | |||
143 | 2961 | /* We asserted above that we have as many identifiers as we have changes. */ | ||
144 | 2962 | g_hash_table_iter_init (&i, identifiers); | ||
145 | 2963 | while (g_hash_table_iter_next (&i, &key, &value)) | ||
146 | 2964 | { | ||
147 | 2965 | TpHandle handle = GPOINTER_TO_UINT (key); | ||
148 | 2966 | |||
149 | 2967 | g_assert_cmpstr (value, ==, | ||
150 | 2968 | tp_handle_inspect (test->contact_repo, handle)); | ||
151 | 2969 | } | ||
152 | 2970 | |||
153 | 2971 | le->contacts_removed = tp_intset_new (); | ||
154 | 2972 | |||
155 | 2973 | g_hash_table_iter_init (&i, removals); | ||
156 | 2974 | while (g_hash_table_iter_next (&i, &key, &value)) | ||
157 | 2975 | { | ||
158 | 2976 | TpHandle handle = GPOINTER_TO_UINT (key); | ||
159 | 2977 | |||
160 | 2978 | g_assert_cmpstr (value, ==, | ||
161 | 2979 | tp_handle_inspect (test->contact_repo, handle)); | ||
162 | 2980 | tp_intset_add (le->contacts_removed, handle); | ||
163 | 2981 | } | ||
164 | 2982 | |||
165 | 2983 | g_ptr_array_add (test->log, le); | ||
166 | 2984 | } | ||
167 | 2985 | |||
168 | 2986 | static void | ||
169 | 2987 | contacts_changed_cb (TpConnection *connection, | ||
170 | 2988 | GHashTable *changes, | ||
171 | 2989 | const GArray *removals, | ||
172 | 2990 | gpointer user_data, | ||
173 | 2991 | GObject *weak_object G_GNUC_UNUSED) | ||
174 | 2992 | { | ||
175 | 2993 | Test *test = user_data; | ||
176 | 2994 | LogEntry *le; | ||
177 | 2995 | GHashTableIter i; | ||
178 | 2996 | gpointer key, value; | ||
179 | 2997 | TpIntset *removal_set; | ||
180 | 2998 | |||
181 | 2999 | g_assert (g_hash_table_size (changes) > 0 || removals->len > 0); | ||
182 | 3000 | |||
183 | 3001 | /* We should have had a ContactsChangedByID signal immediately before this | ||
184 | 3002 | * signal */ | ||
185 | 3003 | g_assert_cmpuint (test->log->len, >, 0); | ||
186 | 3004 | |||
187 | 3005 | le = g_ptr_array_index (test->log, test->log->len - 1); | ||
188 | 3006 | g_assert_cmpuint (le->type, ==, CONTACTS_CHANGED); | ||
189 | 3007 | |||
190 | 3008 | /* The changes should all have been the same as in the previous signal */ | ||
191 | 3009 | g_assert_cmpuint (g_hash_table_size (changes), ==, | ||
192 | 3010 | g_hash_table_size (le->contacts_changed)); | ||
193 | 3011 | |||
194 | 3012 | g_hash_table_iter_init (&i, changes); | ||
195 | 3013 | while (g_hash_table_iter_next (&i, &key, &value)) | ||
196 | 3014 | { | ||
197 | 3015 | GValueArray *existing = g_hash_table_lookup (le->contacts_changed, key); | ||
198 | 3016 | GValueArray *emitted = value; | ||
199 | 3017 | guint existing_sub, existing_pub, emitted_sub, emitted_pub; | ||
200 | 3018 | const gchar *existing_req, *emitted_req; | ||
201 | 3019 | |||
202 | 3020 | g_assert (existing != NULL); | ||
203 | 3021 | |||
204 | 3022 | tp_value_array_unpack (existing, 3, &existing_sub, &existing_pub, | ||
205 | 3023 | &existing_req); | ||
206 | 3024 | tp_value_array_unpack (emitted, 3, &emitted_sub, &emitted_pub, | ||
207 | 3025 | &emitted_req); | ||
208 | 3026 | |||
209 | 3027 | g_assert_cmpuint (existing_sub, ==, emitted_sub); | ||
210 | 3028 | g_assert_cmpuint (existing_pub, ==, emitted_pub); | ||
211 | 3029 | g_assert_cmpstr (existing_req, ==, emitted_req); | ||
212 | 3030 | } | ||
213 | 3031 | |||
214 | 3032 | removal_set = tp_intset_from_array (removals); | ||
215 | 3033 | |||
216 | 3034 | if (!tp_intset_is_equal (removal_set, le->contacts_removed)) | ||
217 | 3035 | g_error ("Removals from ContactsChangedById (%s) != " | ||
218 | 3036 | "Removals from ContactsChanged (%s)", | ||
219 | 3037 | tp_intset_dump (le->contacts_removed), | ||
220 | 3038 | tp_intset_dump (removal_set)); | ||
221 | 3039 | |||
222 | 3040 | tp_intset_destroy (removal_set); | ||
223 | 3041 | } | ||
224 | 3042 | |||
225 | 3043 | static void | ||
226 | 3044 | groups_changed_cb (TpConnection *connection, | ||
227 | 3045 | const GArray *contacts, | ||
228 | 3046 | const gchar **groups_added, | ||
229 | 3047 | const gchar **groups_removed, | ||
230 | 3048 | gpointer user_data, | ||
231 | 3049 | GObject *weak_object G_GNUC_UNUSED) | ||
232 | 3050 | { | ||
233 | 3051 | Test *test = user_data; | ||
234 | 3052 | LogEntry *le = g_slice_new0 (LogEntry); | ||
235 | 3053 | |||
236 | 3054 | g_assert (contacts->len > 0); | ||
237 | 3055 | g_assert ((groups_added != NULL && groups_added[0] != NULL) || | ||
238 | 3056 | (groups_removed != NULL && groups_removed[0] != NULL)); | ||
239 | 3057 | |||
240 | 3058 | le->type = GROUPS_CHANGED; | ||
241 | 3059 | le->contacts = g_array_sized_new (FALSE, FALSE, sizeof (guint), | ||
242 | 3060 | contacts->len); | ||
243 | 3061 | g_array_append_vals (le->contacts, contacts->data, contacts->len); | ||
244 | 3062 | le->groups_added = g_strdupv ((GStrv) groups_added); | ||
245 | 3063 | le->groups_removed = g_strdupv ((GStrv) groups_removed); | ||
246 | 3064 | |||
247 | 3065 | g_ptr_array_add (test->log, le); | ||
248 | 3066 | } | ||
249 | 3067 | |||
250 | 3068 | static void | ||
251 | 3069 | groups_created_cb (TpConnection *connection, | ||
252 | 3070 | const gchar **groups_added, | ||
253 | 3071 | gpointer user_data, | ||
254 | 3072 | GObject *weak_object G_GNUC_UNUSED) | ||
255 | 3073 | { | ||
256 | 3074 | Test *test = user_data; | ||
257 | 3075 | LogEntry *le = g_slice_new0 (LogEntry); | ||
258 | 3076 | |||
259 | 3077 | g_assert (groups_added != NULL); | ||
260 | 3078 | g_assert (groups_added[0] != NULL); | ||
261 | 3079 | |||
262 | 3080 | le->type = GROUPS_CREATED; | ||
263 | 3081 | le->groups_added = g_strdupv ((GStrv) groups_added); | ||
264 | 3082 | |||
265 | 3083 | g_ptr_array_add (test->log, le); | ||
266 | 3084 | } | ||
267 | 3085 | |||
268 | 3086 | static void | ||
269 | 3087 | groups_removed_cb (TpConnection *connection, | ||
270 | 3088 | const gchar **groups_removed, | ||
271 | 3089 | gpointer user_data, | ||
272 | 3090 | GObject *weak_object G_GNUC_UNUSED) | ||
273 | 3091 | { | ||
274 | 3092 | Test *test = user_data; | ||
275 | 3093 | LogEntry *le = g_slice_new0 (LogEntry); | ||
276 | 3094 | |||
277 | 3095 | g_assert (groups_removed != NULL); | ||
278 | 3096 | g_assert (groups_removed[0] != NULL); | ||
279 | 3097 | |||
280 | 3098 | le->type = GROUPS_REMOVED; | ||
281 | 3099 | le->groups_removed = g_strdupv ((GStrv) groups_removed); | ||
282 | 3100 | |||
283 | 3101 | g_ptr_array_add (test->log, le); | ||
284 | 3102 | } | ||
285 | 3103 | |||
286 | 3104 | static void | ||
287 | 3105 | group_renamed_cb (TpConnection *connection, | ||
288 | 3106 | const gchar *old_name, | ||
289 | 3107 | const gchar *new_name, | ||
290 | 3108 | gpointer user_data, | ||
291 | 3109 | GObject *weak_object G_GNUC_UNUSED) | ||
292 | 3110 | { | ||
293 | 3111 | Test *test = user_data; | ||
294 | 3112 | LogEntry *le = g_slice_new0 (LogEntry); | ||
295 | 3113 | |||
296 | 3114 | le->type = GROUP_RENAMED; | ||
297 | 3115 | le->groups_added = g_new0 (gchar *, 2); | ||
298 | 3116 | le->groups_added[0] = g_strdup (new_name); | ||
299 | 3117 | le->groups_removed = g_new0 (gchar *, 2); | ||
300 | 3118 | le->groups_removed[0] = g_strdup (old_name); | ||
301 | 3119 | |||
302 | 3120 | g_ptr_array_add (test->log, le); | ||
303 | 3121 | } | ||
304 | 3122 | |||
305 | 3123 | static void | ||
306 | 3124 | blocked_contacts_changed_cb (TpConnection *connection, | ||
307 | 3125 | GHashTable *blocked_contacts, | ||
308 | 3126 | GHashTable *unblocked_contacts, | ||
309 | 3127 | gpointer user_data, | ||
310 | 3128 | GObject *weak_object G_GNUC_UNUSED) | ||
311 | 3129 | { | ||
312 | 3130 | Test *test = user_data; | ||
313 | 3131 | LogEntry *le = g_slice_new0 (LogEntry); | ||
314 | 3132 | |||
315 | 3133 | le->type = BLOCKED_CONTACTS_CHANGED; | ||
316 | 3134 | le->blocked_contacts = g_hash_table_ref (blocked_contacts); | ||
317 | 3135 | le->unblocked_contacts = g_hash_table_ref (unblocked_contacts); | ||
318 | 3136 | |||
319 | 3137 | g_ptr_array_add (test->log, le); | ||
320 | 3138 | } | ||
321 | 3139 | |||
322 | 3140 | static void | ||
323 | 3141 | maybe_queue_disconnect (TpProxySignalConnection *sc) | ||
324 | 3142 | { | ||
325 | 3143 | if (sc != NULL) | ||
326 | 3144 | g_test_queue_destroy ( | ||
327 | 3145 | (GDestroyNotify) tp_proxy_signal_connection_disconnect, sc); | ||
328 | 3146 | } | ||
329 | 3147 | |||
330 | 3148 | static void | ||
331 | 3149 | setup_pre_connect ( | ||
332 | 3150 | Test *test, | ||
333 | 3151 | gconstpointer data) | ||
334 | 3152 | { | ||
335 | 3153 | GError *error = NULL; | ||
336 | 3154 | const gchar *account; | ||
337 | 3155 | |||
338 | 3156 | g_type_init (); | ||
339 | 3157 | tp_debug_set_flags ("all"); | ||
340 | 3158 | test->dbus = tp_tests_dbus_daemon_dup_or_die (); | ||
341 | 3159 | test->main_loop = g_main_loop_new (NULL, FALSE); | ||
342 | 3160 | |||
343 | 3161 | /* Some tests want 'account' to be an invalid identifier, so that Connect() | ||
344 | 3162 | * will fail (and the status will change to Disconnected). | ||
345 | 3163 | */ | ||
346 | 3164 | if (!tp_strdiff (data, "break-account-parameter")) | ||
347 | 3165 | account = ""; | ||
348 | 3166 | else | ||
349 | 3167 | account = "me@example.com"; | ||
350 | 3168 | |||
351 | 3169 | test->service_conn = tp_tests_object_new_static_class ( | ||
352 | 3170 | EXAMPLE_TYPE_CONTACT_LIST_CONNECTION, | ||
353 | 3171 | "account", account, | ||
354 | 3172 | "simulation-delay", 0, | ||
355 | 3173 | "protocol", "example-contact-list", | ||
356 | 3174 | NULL); | ||
357 | 3175 | test->service_conn_as_base = TP_BASE_CONNECTION (test->service_conn); | ||
358 | 3176 | g_assert (test->service_conn != NULL); | ||
359 | 3177 | g_assert (test->service_conn_as_base != NULL); | ||
360 | 3178 | |||
361 | 3179 | g_assert (tp_base_connection_register (test->service_conn_as_base, "example", | ||
362 | 3180 | &test->conn_name, &test->conn_path, &error)); | ||
363 | 3181 | g_assert_no_error (error); | ||
364 | 3182 | |||
365 | 3183 | test->contact_repo = tp_base_connection_get_handles ( | ||
366 | 3184 | test->service_conn_as_base, TP_HANDLE_TYPE_CONTACT); | ||
367 | 3185 | |||
368 | 3186 | test->conn = tp_connection_new (test->dbus, test->conn_name, test->conn_path, | ||
369 | 3187 | &error); | ||
370 | 3188 | g_assert (test->conn != NULL); | ||
371 | 3189 | g_assert_no_error (error); | ||
372 | 3190 | |||
373 | 3191 | /* Prepare the connection far enough to know its own interfaces. */ | ||
374 | 3192 | tp_tests_proxy_run_until_prepared (test->conn, NULL); | ||
375 | 3193 | } | ||
376 | 3194 | |||
377 | 3195 | static void | ||
378 | 3196 | setup (Test *test, | ||
379 | 3197 | gconstpointer data) | ||
380 | 3198 | { | ||
381 | 3199 | GQuark features[] = { TP_CONNECTION_FEATURE_CONNECTED, 0 }; | ||
382 | 3200 | |||
383 | 3201 | setup_pre_connect (test, data); | ||
384 | 3202 | |||
385 | 3203 | tp_cli_connection_call_connect (test->conn, -1, NULL, NULL, NULL, NULL); | ||
386 | 3204 | tp_tests_proxy_run_until_prepared (test->conn, features); | ||
387 | 3205 | |||
388 | 3206 | g_assert (tp_proxy_is_prepared (test->conn, TP_CONNECTION_FEATURE_CORE)); | ||
389 | 3207 | g_assert (tp_proxy_is_prepared (test->conn, | ||
390 | 3208 | TP_CONNECTION_FEATURE_CONNECTED)); | ||
391 | 3209 | |||
392 | 3210 | test->log = g_ptr_array_new (); | ||
393 | 3211 | |||
394 | 3212 | maybe_queue_disconnect ( | ||
395 | 3213 | tp_cli_connection_interface_contact_list_connect_to_contacts_changed_with_id ( | ||
396 | 3214 | test->conn, contacts_changed_with_id_cb, test, NULL, NULL, NULL)); | ||
397 | 3215 | maybe_queue_disconnect ( | ||
398 | 3216 | tp_cli_connection_interface_contact_list_connect_to_contacts_changed ( | ||
399 | 3217 | test->conn, contacts_changed_cb, test, NULL, NULL, NULL)); | ||
400 | 3218 | maybe_queue_disconnect ( | ||
401 | 3219 | tp_cli_connection_interface_contact_groups_connect_to_groups_changed ( | ||
402 | 3220 | test->conn, groups_changed_cb, test, NULL, NULL, NULL)); | ||
403 | 3221 | maybe_queue_disconnect ( | ||
404 | 3222 | tp_cli_connection_interface_contact_groups_connect_to_groups_created ( | ||
405 | 3223 | test->conn, groups_created_cb, test, NULL, NULL, NULL)); | ||
406 | 3224 | maybe_queue_disconnect ( | ||
407 | 3225 | tp_cli_connection_interface_contact_groups_connect_to_groups_removed ( | ||
408 | 3226 | test->conn, groups_removed_cb, test, NULL, NULL, NULL)); | ||
409 | 3227 | maybe_queue_disconnect ( | ||
410 | 3228 | tp_cli_connection_interface_contact_groups_connect_to_group_renamed ( | ||
411 | 3229 | test->conn, group_renamed_cb, test, NULL, NULL, NULL)); | ||
412 | 3230 | maybe_queue_disconnect ( | ||
413 | 3231 | tp_cli_connection_interface_contact_blocking_connect_to_blocked_contacts_changed ( | ||
414 | 3232 | test->conn, blocked_contacts_changed_cb, test, NULL, NULL, NULL)); | ||
415 | 3233 | |||
416 | 3234 | test->sjoerd = tp_handle_ensure (test->contact_repo, "sjoerd@example.com", | ||
417 | 3235 | NULL, NULL); | ||
418 | 3236 | g_assert (test->sjoerd != 0); | ||
419 | 3237 | test->helen = tp_handle_ensure (test->contact_repo, "helen@example.com", | ||
420 | 3238 | NULL, NULL); | ||
421 | 3239 | g_assert (test->helen != 0); | ||
422 | 3240 | test->wim = tp_handle_ensure (test->contact_repo, "wim@example.com", | ||
423 | 3241 | NULL, NULL); | ||
424 | 3242 | g_assert (test->wim != 0); | ||
425 | 3243 | test->bill = tp_handle_ensure (test->contact_repo, "bill@example.com", | ||
426 | 3244 | NULL, NULL); | ||
427 | 3245 | g_assert (test->bill != 0); | ||
428 | 3246 | test->ninja = tp_handle_ensure (test->contact_repo, "ninja@example.com", | ||
429 | 3247 | NULL, NULL); | ||
430 | 3248 | g_assert (test->ninja != 0); | ||
431 | 3249 | test->canceller = tp_handle_ensure (test->contact_repo, | ||
432 | 3250 | "canceller@cancel.example.com", NULL, NULL); | ||
433 | 3251 | g_assert (test->canceller != 0); | ||
434 | 3252 | |||
435 | 3253 | test->arr = g_array_new (FALSE, FALSE, sizeof (TpHandle)); | ||
436 | 3254 | } | ||
437 | 3255 | |||
438 | 3256 | static void | ||
439 | 3257 | test_clear_log (Test *test) | ||
440 | 3258 | { | ||
441 | 3259 | g_ptr_array_foreach (test->log, (GFunc) log_entry_free, NULL); | ||
442 | 3260 | g_ptr_array_set_size (test->log, 0); | ||
443 | 3261 | } | ||
444 | 3262 | |||
445 | 3263 | static void | ||
446 | 3264 | teardown_pre_connect ( | ||
447 | 3265 | Test *test, | ||
448 | 3266 | gconstpointer data) | ||
449 | 3267 | { | ||
450 | 3268 | test->service_conn_as_base = NULL; | ||
451 | 3269 | g_object_unref (test->service_conn); | ||
452 | 3270 | g_free (test->conn_name); | ||
453 | 3271 | g_free (test->conn_path); | ||
454 | 3272 | tp_clear_object (&test->conn); | ||
455 | 3273 | tp_clear_object (&test->dbus); | ||
456 | 3274 | tp_clear_pointer (&test->main_loop, g_main_loop_unref); | ||
457 | 3275 | } | ||
458 | 3276 | |||
459 | 3277 | static void | ||
460 | 3278 | teardown (Test *test, | ||
461 | 3279 | gconstpointer data) | ||
462 | 3280 | { | ||
463 | 3281 | TpConnection *conn; | ||
464 | 3282 | gboolean ok; | ||
465 | 3283 | GError *error = NULL; | ||
466 | 3284 | |||
467 | 3285 | g_array_free (test->arr, TRUE); | ||
468 | 3286 | |||
469 | 3287 | test_clear_log (test); | ||
470 | 3288 | g_ptr_array_free (test->log, TRUE); | ||
471 | 3289 | |||
472 | 3290 | tp_handle_unref (test->contact_repo, test->sjoerd); | ||
473 | 3291 | tp_handle_unref (test->contact_repo, test->helen); | ||
474 | 3292 | tp_handle_unref (test->contact_repo, test->wim); | ||
475 | 3293 | tp_handle_unref (test->contact_repo, test->bill); | ||
476 | 3294 | tp_handle_unref (test->contact_repo, test->ninja); | ||
477 | 3295 | tp_handle_unref (test->contact_repo, test->canceller); | ||
478 | 3296 | |||
479 | 3297 | tp_clear_object (&test->publish); | ||
480 | 3298 | tp_clear_object (&test->subscribe); | ||
481 | 3299 | tp_clear_object (&test->stored); | ||
482 | 3300 | tp_clear_object (&test->group); | ||
483 | 3301 | |||
484 | 3302 | /* make a new TpConnection just to disconnect the underlying Connection, | ||
485 | 3303 | * so we don't leak it */ | ||
486 | 3304 | conn = tp_connection_new (test->dbus, test->conn_name, test->conn_path, | ||
487 | 3305 | &error); | ||
488 | 3306 | g_assert (conn != NULL); | ||
489 | 3307 | g_assert_no_error (error); | ||
490 | 3308 | ok = tp_cli_connection_run_disconnect (conn, -1, &error, NULL); | ||
491 | 3309 | g_assert (ok); | ||
492 | 3310 | g_assert_no_error (error); | ||
493 | 3311 | g_assert (!tp_connection_run_until_ready (conn, FALSE, &error, NULL)); | ||
494 | 3312 | g_assert_error (error, TP_ERRORS, TP_ERROR_CANCELLED); | ||
495 | 3313 | g_clear_error (&error); | ||
496 | 3314 | |||
497 | 3315 | tp_clear_pointer (&test->contact_attributes, g_hash_table_unref); | ||
498 | 3316 | |||
499 | 3317 | teardown_pre_connect (test, data); | ||
500 | 3318 | } | ||
501 | 3319 | |||
502 | 3320 | static TpChannel * | ||
503 | 3321 | test_ensure_channel (Test *test, | ||
504 | 3322 | guint channel_type, | ||
505 | 3323 | const gchar *id) | ||
506 | 3324 | { | ||
507 | 3325 | GError *error = NULL; | ||
508 | 3326 | GHashTable *asv, *props; | ||
509 | 3327 | gchar *path; | ||
510 | 3328 | TpChannel *ret; | ||
511 | 3329 | |||
512 | 3330 | asv = tp_asv_new ( | ||
513 | 3331 | TP_PROP_CHANNEL_CHANNEL_TYPE, | ||
514 | 3332 | G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST, | ||
515 | 3333 | TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, | ||
516 | 3334 | G_TYPE_UINT, channel_type, | ||
517 | 3335 | TP_PROP_CHANNEL_TARGET_ID, | ||
518 | 3336 | G_TYPE_STRING, id, | ||
519 | 3337 | NULL); | ||
520 | 3338 | tp_cli_connection_interface_requests_run_ensure_channel (test->conn, -1, | ||
521 | 3339 | asv, NULL, &path, &props, &error, NULL); | ||
522 | 3340 | g_assert_no_error (error); | ||
523 | 3341 | ret = tp_channel_new_from_properties (test->conn, path, props, | ||
524 | 3342 | &error); | ||
525 | 3343 | g_assert (ret != NULL); | ||
526 | 3344 | g_assert_no_error (error); | ||
527 | 3345 | g_free (path); | ||
528 | 3346 | g_hash_table_unref (props); | ||
529 | 3347 | g_hash_table_unref (asv); | ||
530 | 3348 | |||
531 | 3349 | tp_tests_proxy_run_until_prepared (ret, NULL); | ||
532 | 3350 | return ret; | ||
533 | 3351 | } | ||
534 | 3352 | |||
535 | 3353 | static void | ||
536 | 3354 | test_assert_one_contact_changed (Test *test, | ||
537 | 3355 | guint index, | ||
538 | 3356 | TpHandle handle, | ||
539 | 3357 | TpSubscriptionState expected_sub_state, | ||
540 | 3358 | TpSubscriptionState expected_pub_state, | ||
541 | 3359 | const gchar *expected_pub_request) | ||
542 | 3360 | { | ||
543 | 3361 | LogEntry *le; | ||
544 | 3362 | GValueArray *va; | ||
545 | 3363 | guint sub_state; | ||
546 | 3364 | guint pub_state; | ||
547 | 3365 | const gchar *pub_request; | ||
548 | 3366 | |||
549 | 3367 | le = g_ptr_array_index (test->log, index); | ||
550 | 3368 | g_assert_cmpint (le->type, ==, CONTACTS_CHANGED); | ||
551 | 3369 | |||
552 | 3370 | g_assert_cmpuint (g_hash_table_size (le->contacts_changed), ==, 1); | ||
553 | 3371 | va = g_hash_table_lookup (le->contacts_changed, GUINT_TO_POINTER (handle)); | ||
554 | 3372 | g_assert (va != NULL); | ||
555 | 3373 | tp_value_array_unpack (va, 3, | ||
556 | 3374 | &sub_state, | ||
557 | 3375 | &pub_state, | ||
558 | 3376 | &pub_request); | ||
559 | 3377 | g_assert_cmpuint (sub_state, ==, expected_sub_state); | ||
560 | 3378 | g_assert_cmpuint (pub_state, ==, expected_pub_state); | ||
561 | 3379 | g_assert_cmpstr (pub_request, ==, expected_pub_request); | ||
562 | 3380 | |||
563 | 3381 | g_assert_cmpuint (tp_intset_size (le->contacts_removed), ==, 0); | ||
564 | 3382 | } | ||
565 | 3383 | |||
566 | 3384 | static void | ||
567 | 3385 | test_assert_one_contact_removed (Test *test, | ||
568 | 3386 | guint index, | ||
569 | 3387 | TpHandle handle) | ||
570 | 3388 | { | ||
571 | 3389 | LogEntry *le; | ||
572 | 3390 | |||
573 | 3391 | le = g_ptr_array_index (test->log, index); | ||
574 | 3392 | g_assert_cmpint (le->type, ==, CONTACTS_CHANGED); | ||
575 | 3393 | |||
576 | 3394 | g_assert_cmpuint (g_hash_table_size (le->contacts_changed), ==, 0); | ||
577 | 3395 | g_assert_cmpuint (tp_intset_size (le->contacts_removed), ==, 1); | ||
578 | 3396 | g_assert (tp_intset_is_member (le->contacts_removed, handle)); | ||
579 | 3397 | } | ||
580 | 3398 | |||
581 | 3399 | static void | ||
582 | 3400 | test_assert_one_group_joined (Test *test, | ||
583 | 3401 | guint index, | ||
584 | 3402 | TpHandle handle, | ||
585 | 3403 | const gchar *group) | ||
586 | 3404 | { | ||
587 | 3405 | LogEntry *le; | ||
588 | 3406 | |||
589 | 3407 | le = g_ptr_array_index (test->log, index); | ||
590 | 3408 | g_assert_cmpint (le->type, ==, GROUPS_CHANGED); | ||
591 | 3409 | g_assert_cmpuint (le->contacts->len, ==, 1); | ||
592 | 3410 | g_assert_cmpuint (g_array_index (le->contacts, guint, 0), ==, handle); | ||
593 | 3411 | g_assert (le->groups_added != NULL); | ||
594 | 3412 | g_assert_cmpstr (le->groups_added[0], ==, group); | ||
595 | 3413 | g_assert_cmpstr (le->groups_added[1], ==, NULL); | ||
596 | 3414 | g_assert (le->groups_removed == NULL || le->groups_removed[0] == NULL); | ||
597 | 3415 | } | ||
598 | 3416 | |||
599 | 3417 | static void | ||
600 | 3418 | test_assert_one_group_left (Test *test, | ||
601 | 3419 | guint index, | ||
602 | 3420 | TpHandle handle, | ||
603 | 3421 | const gchar *group) | ||
604 | 3422 | { | ||
605 | 3423 | LogEntry *le; | ||
606 | 3424 | |||
607 | 3425 | le = g_ptr_array_index (test->log, index); | ||
608 | 3426 | g_assert_cmpint (le->type, ==, GROUPS_CHANGED); | ||
609 | 3427 | g_assert_cmpuint (le->contacts->len, ==, 1); | ||
610 | 3428 | g_assert_cmpuint (g_array_index (le->contacts, guint, 0), ==, handle); | ||
611 | 3429 | g_assert (le->groups_added == NULL || le->groups_added[0] == NULL); | ||
612 | 3430 | g_assert (le->groups_removed != NULL); | ||
613 | 3431 | g_assert_cmpstr (le->groups_removed[0], ==, group); | ||
614 | 3432 | g_assert_cmpstr (le->groups_removed[1], ==, NULL); | ||
615 | 3433 | } | ||
616 | 3434 | |||
617 | 3435 | static void | ||
618 | 3436 | test_assert_one_group_created (Test *test, | ||
619 | 3437 | guint index, | ||
620 | 3438 | const gchar *group) | ||
621 | 3439 | { | ||
622 | 3440 | LogEntry *le; | ||
623 | 3441 | |||
624 | 3442 | le = g_ptr_array_index (test->log, index); | ||
625 | 3443 | g_assert_cmpint (le->type, ==, GROUPS_CREATED); | ||
626 | 3444 | g_assert (le->groups_added != NULL); | ||
627 | 3445 | g_assert_cmpstr (le->groups_added[0], ==, group); | ||
628 | 3446 | g_assert_cmpstr (le->groups_added[1], ==, NULL); | ||
629 | 3447 | } | ||
630 | 3448 | |||
631 | 3449 | static void | ||
632 | 3450 | test_assert_one_group_removed (Test *test, | ||
633 | 3451 | guint index, | ||
634 | 3452 | const gchar *group) | ||
635 | 3453 | { | ||
636 | 3454 | LogEntry *le; | ||
637 | 3455 | |||
638 | 3456 | le = g_ptr_array_index (test->log, index); | ||
639 | 3457 | g_assert_cmpint (le->type, ==, GROUPS_REMOVED); | ||
640 | 3458 | g_assert (le->groups_removed != NULL); | ||
641 | 3459 | g_assert_cmpstr (le->groups_removed[0], ==, group); | ||
642 | 3460 | g_assert_cmpstr (le->groups_removed[1], ==, NULL); | ||
643 | 3461 | } | ||
644 | 3462 | |||
645 | 3463 | static void | ||
646 | 3464 | test_assert_one_contact_blocked (Test *test, | ||
647 | 3465 | guint index, | ||
648 | 3466 | TpHandle handle, | ||
649 | 3467 | const gchar *id) | ||
650 | 3468 | { | ||
651 | 3469 | LogEntry *le; | ||
652 | 3470 | |||
653 | 3471 | le = g_ptr_array_index (test->log, index); | ||
654 | 3472 | g_assert_cmpint (le->type, ==, BLOCKED_CONTACTS_CHANGED); | ||
655 | 3473 | |||
656 | 3474 | g_assert (le->blocked_contacts != NULL); | ||
657 | 3475 | g_assert_cmpuint (g_hash_table_size (le->blocked_contacts), ==, 1); | ||
658 | 3476 | g_assert_cmpstr (g_hash_table_lookup (le->blocked_contacts, GUINT_TO_POINTER (handle)), | ||
659 | 3477 | ==, id); | ||
660 | 3478 | |||
661 | 3479 | g_assert (le->unblocked_contacts != NULL); | ||
662 | 3480 | g_assert_cmpuint (g_hash_table_size (le->unblocked_contacts), ==, 0); | ||
663 | 3481 | } | ||
664 | 3482 | |||
665 | 3483 | static void | ||
666 | 3484 | test_assert_one_contact_unblocked (Test *test, | ||
667 | 3485 | guint index, | ||
668 | 3486 | TpHandle handle, | ||
669 | 3487 | const gchar *id) | ||
670 | 3488 | { | ||
671 | 3489 | LogEntry *le; | ||
672 | 3490 | |||
673 | 3491 | le = g_ptr_array_index (test->log, index); | ||
674 | 3492 | g_assert_cmpint (le->type, ==, BLOCKED_CONTACTS_CHANGED); | ||
675 | 3493 | |||
676 | 3494 | g_assert (le->blocked_contacts != NULL); | ||
677 | 3495 | g_assert_cmpuint (g_hash_table_size (le->blocked_contacts), ==, 0); | ||
678 | 3496 | |||
679 | 3497 | g_assert (le->unblocked_contacts != NULL); | ||
680 | 3498 | g_assert_cmpuint (g_hash_table_size (le->unblocked_contacts), ==, 1); | ||
681 | 3499 | g_assert_cmpstr (g_hash_table_lookup (le->unblocked_contacts, GUINT_TO_POINTER (handle)), | ||
682 | 3500 | ==, id); | ||
683 | 3501 | } | ||
684 | 3502 | |||
685 | 3503 | static void | ||
686 | 3504 | test_nothing (Test *test, | ||
687 | 3505 | gconstpointer nil G_GNUC_UNUSED) | ||
688 | 3506 | { | ||
689 | 3507 | /* this is actually a valuable test - it ensures that shutting down the | ||
690 | 3508 | * CM before the contact list has been retrieved works! */ | ||
691 | 3509 | } | ||
692 | 3510 | |||
693 | 3511 | static void | ||
694 | 3512 | test_initial_channels (Test *test, | ||
695 | 3513 | gconstpointer nil G_GNUC_UNUSED) | ||
696 | 3514 | { | ||
697 | 3515 | test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish"); | ||
698 | 3516 | test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, | ||
699 | 3517 | "subscribe"); | ||
700 | 3518 | test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored"); | ||
701 | 3519 | test->deny = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "deny"); | ||
702 | 3520 | |||
703 | 3521 | g_assert_cmpuint ( | ||
704 | 3522 | tp_intset_size (tp_channel_group_get_members (test->publish)), ==, 4); | ||
705 | 3523 | g_assert_cmpuint ( | ||
706 | 3524 | tp_intset_size (tp_channel_group_get_local_pending (test->publish)), | ||
707 | 3525 | ==, 2); | ||
708 | 3526 | g_assert_cmpuint ( | ||
709 | 3527 | tp_intset_size (tp_channel_group_get_remote_pending (test->publish)), | ||
710 | 3528 | ==, 0); | ||
711 | 3529 | g_assert (tp_intset_is_member (tp_channel_group_get_members (test->publish), | ||
712 | 3530 | test->sjoerd)); | ||
713 | 3531 | g_assert (tp_intset_is_member ( | ||
714 | 3532 | tp_channel_group_get_local_pending (test->publish), | ||
715 | 3533 | test->wim)); | ||
716 | 3534 | |||
717 | 3535 | g_assert_cmpuint ( | ||
718 | 3536 | tp_intset_size (tp_channel_group_get_members (test->subscribe)), ==, 4); | ||
719 | 3537 | g_assert_cmpuint ( | ||
720 | 3538 | tp_intset_size (tp_channel_group_get_local_pending (test->subscribe)), | ||
721 | 3539 | ==, 0); | ||
722 | 3540 | g_assert_cmpuint ( | ||
723 | 3541 | tp_intset_size (tp_channel_group_get_remote_pending (test->subscribe)), | ||
724 | 3542 | ==, 2); | ||
725 | 3543 | g_assert (tp_intset_is_member ( | ||
726 | 3544 | tp_channel_group_get_members (test->subscribe), | ||
727 | 3545 | test->sjoerd)); | ||
728 | 3546 | g_assert (tp_intset_is_member ( | ||
729 | 3547 | tp_channel_group_get_remote_pending (test->subscribe), | ||
730 | 3548 | test->helen)); | ||
731 | 3549 | |||
732 | 3550 | g_assert_cmpuint ( | ||
733 | 3551 | tp_intset_size (tp_channel_group_get_members (test->stored)), ==, 8); | ||
734 | 3552 | g_assert_cmpuint ( | ||
735 | 3553 | tp_intset_size (tp_channel_group_get_local_pending (test->stored)), | ||
736 | 3554 | ==, 0); | ||
737 | 3555 | g_assert_cmpuint ( | ||
738 | 3556 | tp_intset_size (tp_channel_group_get_remote_pending (test->stored)), | ||
739 | 3557 | ==, 0); | ||
740 | 3558 | g_assert (tp_intset_is_member (tp_channel_group_get_members (test->stored), | ||
741 | 3559 | test->sjoerd)); | ||
742 | 3560 | |||
743 | 3561 | g_assert (!tp_intset_is_member (tp_channel_group_get_members (test->publish), | ||
744 | 3562 | test->ninja)); | ||
745 | 3563 | g_assert (!tp_intset_is_member (tp_channel_group_get_members ( | ||
746 | 3564 | test->subscribe), | ||
747 | 3565 | test->ninja)); | ||
748 | 3566 | g_assert (!tp_intset_is_member (tp_channel_group_get_members (test->stored), | ||
749 | 3567 | test->ninja)); | ||
750 | 3568 | |||
751 | 3569 | g_assert_cmpuint ( | ||
752 | 3570 | tp_intset_size (tp_channel_group_get_members (test->deny)), ==, 2); | ||
753 | 3571 | g_assert_cmpuint ( | ||
754 | 3572 | tp_intset_size (tp_channel_group_get_local_pending (test->deny)), | ||
755 | 3573 | ==, 0); | ||
756 | 3574 | g_assert_cmpuint ( | ||
757 | 3575 | tp_intset_size (tp_channel_group_get_remote_pending (test->deny)), | ||
758 | 3576 | ==, 0); | ||
759 | 3577 | g_assert (tp_intset_is_member (tp_channel_group_get_members (test->deny), | ||
760 | 3578 | test->bill)); | ||
761 | 3579 | } | ||
762 | 3580 | |||
763 | 3581 | static void | ||
764 | 3582 | test_properties (Test *test, | ||
765 | 3583 | gconstpointer nil G_GNUC_UNUSED) | ||
766 | 3584 | { | ||
767 | 3585 | GHashTable *asv; | ||
768 | 3586 | GError *error = NULL; | ||
769 | 3587 | guint32 blocking_caps; | ||
770 | 3588 | gboolean valid; | ||
771 | 3589 | |||
772 | 3590 | tp_cli_dbus_properties_run_get_all (test->conn, -1, | ||
773 | 3591 | TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST, &asv, &error, NULL); | ||
774 | 3592 | g_assert_no_error (error); | ||
775 | 3593 | g_assert_cmpuint (g_hash_table_size (asv), >=, 3); | ||
776 | 3594 | g_assert (tp_asv_get_boolean (asv, "ContactListPersists", NULL)); | ||
777 | 3595 | g_assert (tp_asv_get_boolean (asv, "CanChangeContactList", NULL)); | ||
778 | 3596 | g_assert (tp_asv_get_boolean (asv, "RequestUsesMessage", NULL)); | ||
779 | 3597 | g_hash_table_unref (asv); | ||
780 | 3598 | |||
781 | 3599 | tp_cli_dbus_properties_run_get_all (test->conn, -1, | ||
782 | 3600 | TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS, &asv, &error, NULL); | ||
783 | 3601 | g_assert_no_error (error); | ||
784 | 3602 | g_assert_cmpuint (g_hash_table_size (asv), >=, 3); | ||
785 | 3603 | g_assert (G_VALUE_HOLDS_BOOLEAN (tp_asv_lookup (asv, "DisjointGroups"))); | ||
786 | 3604 | g_assert (!tp_asv_get_boolean (asv, "DisjointGroups", NULL)); | ||
787 | 3605 | g_assert (G_VALUE_HOLDS_UINT (tp_asv_lookup (asv, "GroupStorage"))); | ||
788 | 3606 | g_assert_cmpuint (tp_asv_get_uint32 (asv, "GroupStorage", NULL), ==, | ||
789 | 3607 | TP_CONTACT_METADATA_STORAGE_TYPE_ANYONE); | ||
790 | 3608 | /* Don't assert about the contents yet - we might not have received the | ||
791 | 3609 | * contact list yet */ | ||
792 | 3610 | g_assert (G_VALUE_HOLDS (tp_asv_lookup (asv, "Groups"), G_TYPE_STRV)); | ||
793 | 3611 | g_hash_table_unref (asv); | ||
794 | 3612 | |||
795 | 3613 | /* this has the side-effect of waiting for the contact list to be received */ | ||
796 | 3614 | test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish"); | ||
797 | 3615 | |||
798 | 3616 | tp_cli_dbus_properties_run_get_all (test->conn, -1, | ||
799 | 3617 | TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST, &asv, &error, NULL); | ||
800 | 3618 | g_assert_no_error (error); | ||
801 | 3619 | g_assert_cmpuint (g_hash_table_size (asv), >=, 3); | ||
802 | 3620 | g_assert (tp_asv_get_boolean (asv, "ContactListPersists", NULL)); | ||
803 | 3621 | g_assert (tp_asv_get_boolean (asv, "CanChangeContactList", NULL)); | ||
804 | 3622 | g_assert (tp_asv_get_boolean (asv, "RequestUsesMessage", NULL)); | ||
805 | 3623 | g_hash_table_unref (asv); | ||
806 | 3624 | |||
807 | 3625 | tp_cli_dbus_properties_run_get_all (test->conn, -1, | ||
808 | 3626 | TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS, &asv, &error, NULL); | ||
809 | 3627 | g_assert_no_error (error); | ||
810 | 3628 | g_assert_cmpuint (g_hash_table_size (asv), >=, 3); | ||
811 | 3629 | g_assert (G_VALUE_HOLDS_BOOLEAN (tp_asv_lookup (asv, "DisjointGroups"))); | ||
812 | 3630 | g_assert (G_VALUE_HOLDS_UINT (tp_asv_lookup (asv, "GroupStorage"))); | ||
813 | 3631 | g_assert (tp_asv_get_strv (asv, "Groups") != NULL); | ||
814 | 3632 | g_assert (tp_strv_contains (tp_asv_get_strv (asv, "Groups"), "Cambridge")); | ||
815 | 3633 | g_assert (tp_strv_contains (tp_asv_get_strv (asv, "Groups"), "Montreal")); | ||
816 | 3634 | g_assert (tp_strv_contains (tp_asv_get_strv (asv, "Groups"), | ||
817 | 3635 | "Francophones")); | ||
818 | 3636 | g_hash_table_unref (asv); | ||
819 | 3637 | |||
820 | 3638 | tp_cli_dbus_properties_run_get_all (test->conn, -1, | ||
821 | 3639 | TP_IFACE_CONNECTION_INTERFACE_CONTACT_BLOCKING, &asv, &error, NULL); | ||
822 | 3640 | g_assert_no_error (error); | ||
823 | 3641 | g_assert_cmpuint (g_hash_table_size (asv), ==, 1); | ||
824 | 3642 | blocking_caps = tp_asv_get_uint32 (asv, "ContactBlockingCapabilities", | ||
825 | 3643 | &valid); | ||
826 | 3644 | g_assert (valid); | ||
827 | 3645 | g_assert_cmpuint (blocking_caps, ==, 0); | ||
828 | 3646 | g_hash_table_unref (asv); | ||
829 | 3647 | |||
830 | 3648 | g_assert_cmpuint (test->log->len, ==, 0); | ||
831 | 3649 | } | ||
832 | 3650 | |||
833 | 3651 | static void | ||
834 | 3652 | contact_attrs_cb (TpConnection *conn G_GNUC_UNUSED, | ||
835 | 3653 | GHashTable *attributes, | ||
836 | 3654 | const GError *error, | ||
837 | 3655 | gpointer user_data, | ||
838 | 3656 | GObject *object G_GNUC_UNUSED) | ||
839 | 3657 | { | ||
840 | 3658 | Test *test = user_data; | ||
841 | 3659 | |||
842 | 3660 | g_assert_no_error ((GError *) error); | ||
843 | 3661 | tp_clear_pointer (&test->contact_attributes, g_hash_table_unref); | ||
844 | 3662 | test->contact_attributes = g_boxed_copy (TP_HASH_TYPE_CONTACT_ATTRIBUTES_MAP, | ||
845 | 3663 | attributes); | ||
846 | 3664 | } | ||
847 | 3665 | |||
848 | 3666 | static void | ||
849 | 3667 | test_assert_contact_list_attrs (Test *test, | ||
850 | 3668 | TpHandle handle, | ||
851 | 3669 | TpSubscriptionState expected_sub_state, | ||
852 | 3670 | TpSubscriptionState expected_pub_state, | ||
853 | 3671 | const gchar *expected_pub_request) | ||
854 | 3672 | { | ||
855 | 3673 | GHashTable *asv; | ||
856 | 3674 | gboolean valid; | ||
857 | 3675 | |||
858 | 3676 | g_assert_cmpuint (g_hash_table_size (test->contact_attributes), >=, 1); | ||
859 | 3677 | asv = g_hash_table_lookup (test->contact_attributes, | ||
860 | 3678 | GUINT_TO_POINTER (handle)); | ||
861 | 3679 | g_assert (asv != NULL); | ||
862 | 3680 | g_assert_cmpuint (tp_asv_get_uint32 (asv, | ||
863 | 3681 | TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST_SUBSCRIBE, &valid), ==, | ||
864 | 3682 | expected_sub_state); | ||
865 | 3683 | g_assert (valid); | ||
866 | 3684 | g_assert_cmpuint (tp_asv_get_uint32 (asv, | ||
867 | 3685 | TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST_PUBLISH, &valid), ==, | ||
868 | 3686 | expected_pub_state); | ||
869 | 3687 | g_assert (valid); | ||
870 | 3688 | g_assert_cmpstr (tp_asv_get_string (asv, | ||
871 | 3689 | TP_TOKEN_CONNECTION_INTERFACE_CONTACT_LIST_PUBLISH_REQUEST), ==, | ||
872 | 3690 | expected_pub_request); | ||
873 | 3691 | g_assert (valid); | ||
874 | 3692 | } | ||
875 | 3693 | |||
876 | 3694 | /* We simplify here by assuming that contacts are in at most one group, | ||
877 | 3695 | * which happens to be true for all of these tests. */ | ||
878 | 3696 | static void | ||
879 | 3697 | test_assert_contact_groups_attr (Test *test, | ||
880 | 3698 | TpHandle handle, | ||
881 | 3699 | const gchar *group) | ||
882 | 3700 | { | ||
883 | 3701 | GHashTable *asv; | ||
884 | 3702 | const gchar * const *strv; | ||
885 | 3703 | |||
886 | 3704 | g_assert_cmpuint (g_hash_table_size (test->contact_attributes), >=, 1); | ||
887 | 3705 | asv = g_hash_table_lookup (test->contact_attributes, | ||
888 | 3706 | GUINT_TO_POINTER (handle)); | ||
889 | 3707 | g_assert (asv != NULL); | ||
890 | 3708 | tp_asv_dump (asv); | ||
891 | 3709 | g_assert (tp_asv_lookup (asv, | ||
892 | 3710 | TP_TOKEN_CONNECTION_INTERFACE_CONTACT_GROUPS_GROUPS) != NULL); | ||
893 | 3711 | g_assert (G_VALUE_HOLDS (tp_asv_lookup (asv, | ||
894 | 3712 | TP_TOKEN_CONNECTION_INTERFACE_CONTACT_GROUPS_GROUPS), G_TYPE_STRV)); | ||
895 | 3713 | strv = tp_asv_get_strv (asv, | ||
896 | 3714 | TP_TOKEN_CONNECTION_INTERFACE_CONTACT_GROUPS_GROUPS); | ||
897 | 3715 | |||
898 | 3716 | if (group == NULL) | ||
899 | 3717 | { | ||
900 | 3718 | if (strv != NULL) | ||
901 | 3719 | g_assert_cmpstr (strv[0], ==, NULL); | ||
902 | 3720 | } | ||
903 | 3721 | else | ||
904 | 3722 | { | ||
905 | 3723 | g_assert (strv != NULL); | ||
906 | 3724 | g_assert_cmpstr (strv[0], ==, group); | ||
907 | 3725 | g_assert_cmpstr (strv[1], ==, NULL); | ||
908 | 3726 | } | ||
909 | 3727 | } | ||
910 | 3728 | |||
911 | 3729 | static void | ||
912 | 3730 | test_assert_contact_state (Test *test, | ||
913 | 3731 | TpHandle handle, | ||
914 | 3732 | TpSubscriptionState expected_sub_state, | ||
915 | 3733 | TpSubscriptionState expected_pub_state, | ||
916 | 3734 | const gchar *expected_pub_request, | ||
917 | 3735 | const gchar *expected_group) | ||
918 | 3736 | { | ||
919 | 3737 | const gchar * const interfaces[] = { | ||
920 | 3738 | TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST, | ||
921 | 3739 | TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS, | ||
922 | 3740 | NULL }; | ||
923 | 3741 | |||
924 | 3742 | tp_connection_get_contact_attributes (test->conn, -1, | ||
925 | 3743 | 1, &handle, interfaces, FALSE, contact_attrs_cb, | ||
926 | 3744 | test, test_quit_loop, NULL); | ||
927 | 3745 | g_main_loop_run (test->main_loop); | ||
928 | 3746 | |||
929 | 3747 | g_assert_cmpuint (g_hash_table_size (test->contact_attributes), ==, 1); | ||
930 | 3748 | test_assert_contact_list_attrs (test, handle, expected_sub_state, | ||
931 | 3749 | expected_pub_state, expected_pub_request); | ||
932 | 3750 | test_assert_contact_groups_attr (test, handle, expected_group); | ||
933 | 3751 | } | ||
934 | 3752 | |||
935 | 3753 | static void | ||
936 | 3754 | test_contacts (Test *test, | ||
937 | 3755 | gconstpointer nil G_GNUC_UNUSED) | ||
938 | 3756 | { | ||
939 | 3757 | /* ensure the contact list has been received */ | ||
940 | 3758 | test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish"); | ||
941 | 3759 | |||
942 | 3760 | test_assert_contact_state (test, test->sjoerd, | ||
943 | 3761 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_YES, NULL, "Cambridge"); | ||
944 | 3762 | test_assert_contact_state (test, test->wim, | ||
945 | 3763 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_ASK, | ||
946 | 3764 | "I'm more metal than you!", NULL); | ||
947 | 3765 | test_assert_contact_state (test, test->helen, | ||
948 | 3766 | TP_SUBSCRIPTION_STATE_ASK, TP_SUBSCRIPTION_STATE_NO, NULL, "Cambridge"); | ||
949 | 3767 | test_assert_contact_state (test, test->ninja, | ||
950 | 3768 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL); | ||
951 | 3769 | test_assert_contact_state (test, test->bill, | ||
952 | 3770 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL); | ||
953 | 3771 | } | ||
954 | 3772 | |||
955 | 3773 | static void | ||
956 | 3774 | test_contact_list_attrs (Test *test, | ||
957 | 3775 | gconstpointer nil G_GNUC_UNUSED) | ||
958 | 3776 | { | ||
959 | 3777 | const gchar * const interfaces[] = { | ||
960 | 3778 | TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS, | ||
961 | 3779 | NULL }; | ||
962 | 3780 | |||
963 | 3781 | tp_connection_get_contact_list_attributes (test->conn, -1, | ||
964 | 3782 | interfaces, FALSE, contact_attrs_cb, test, test_quit_loop, NULL); | ||
965 | 3783 | g_main_loop_run (test->main_loop); | ||
966 | 3784 | |||
967 | 3785 | test_assert_contact_list_attrs (test, test->sjoerd, | ||
968 | 3786 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_YES, NULL); | ||
969 | 3787 | test_assert_contact_list_attrs (test, test->wim, | ||
970 | 3788 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_ASK, | ||
971 | 3789 | "I'm more metal than you!"); | ||
972 | 3790 | test_assert_contact_list_attrs (test, test->helen, | ||
973 | 3791 | TP_SUBSCRIPTION_STATE_ASK, TP_SUBSCRIPTION_STATE_NO, NULL); | ||
974 | 3792 | |||
975 | 3793 | test_assert_contact_groups_attr (test, test->sjoerd, "Cambridge"); | ||
976 | 3794 | test_assert_contact_groups_attr (test, test->wim, NULL); | ||
977 | 3795 | test_assert_contact_groups_attr (test, test->helen, "Cambridge"); | ||
978 | 3796 | |||
979 | 3797 | /* bill is blocked, but is not on the contact list as such; the ninja isn't | ||
980 | 3798 | * in the initial state at all */ | ||
981 | 3799 | g_assert (g_hash_table_lookup (test->contact_attributes, | ||
982 | 3800 | GUINT_TO_POINTER (test->bill)) == NULL); | ||
983 | 3801 | g_assert (g_hash_table_lookup (test->contact_attributes, | ||
984 | 3802 | GUINT_TO_POINTER (test->ninja)) == NULL); | ||
985 | 3803 | } | ||
986 | 3804 | |||
987 | 3805 | static void | ||
988 | 3806 | test_accept_publish_request (Test *test, | ||
989 | 3807 | gconstpointer mode) | ||
990 | 3808 | { | ||
991 | 3809 | GError *error = NULL; | ||
992 | 3810 | |||
993 | 3811 | test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish"); | ||
994 | 3812 | |||
995 | 3813 | g_assert_cmpuint ( | ||
996 | 3814 | tp_intset_size (tp_channel_group_get_local_pending (test->publish)), | ||
997 | 3815 | ==, 2); | ||
998 | 3816 | g_assert (tp_intset_is_member ( | ||
999 | 3817 | tp_channel_group_get_local_pending (test->publish), | ||
1000 | 3818 | test->wim)); | ||
1001 | 3819 | |||
1002 | 3820 | g_array_append_val (test->arr, test->wim); | ||
1003 | 3821 | |||
1004 | 3822 | if (!tp_strdiff (mode, "old")) | ||
1005 | 3823 | tp_cli_channel_interface_group_run_add_members (test->publish, | ||
1006 | 3824 | -1, test->arr, "", &error, NULL); | ||
1007 | 3825 | else | ||
1008 | 3826 | tp_cli_connection_interface_contact_list_run_authorize_publication ( | ||
1009 | 3827 | test->conn, -1, test->arr, &error, NULL); | ||
1010 | 3828 | |||
1011 | 3829 | g_assert_no_error (error); | ||
1012 | 3830 | |||
1013 | 3831 | /* by the time the method returns, we should have had the | ||
1014 | 3832 | * change-notification, too */ | ||
1015 | 3833 | g_assert_cmpuint ( | ||
1016 | 3834 | tp_intset_size (tp_channel_group_get_local_pending (test->publish)), | ||
1017 | 3835 | ==, 1); | ||
1018 | 3836 | g_assert (tp_intset_is_member ( | ||
1019 | 3837 | tp_channel_group_get_members (test->publish), | ||
1020 | 3838 | test->wim)); | ||
1021 | 3839 | g_assert (!tp_intset_is_member ( | ||
1022 | 3840 | tp_channel_group_get_local_pending (test->publish), | ||
1023 | 3841 | test->wim)); | ||
1024 | 3842 | |||
1025 | 3843 | g_assert_cmpuint (test->log->len, ==, 1); | ||
1026 | 3844 | test_assert_one_contact_changed (test, 0, test->wim, TP_SUBSCRIPTION_STATE_NO, | ||
1027 | 3845 | TP_SUBSCRIPTION_STATE_YES, ""); | ||
1028 | 3846 | test_assert_contact_state (test, test->wim, | ||
1029 | 3847 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_YES, NULL, NULL); | ||
1030 | 3848 | } | ||
1031 | 3849 | |||
1032 | 3850 | static void | ||
1033 | 3851 | test_reject_publish_request (Test *test, | ||
1034 | 3852 | gconstpointer mode) | ||
1035 | 3853 | { | ||
1036 | 3854 | GError *error = NULL; | ||
1037 | 3855 | |||
1038 | 3856 | test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish"); | ||
1039 | 3857 | |||
1040 | 3858 | g_assert (tp_intset_is_member ( | ||
1041 | 3859 | tp_channel_group_get_local_pending (test->publish), | ||
1042 | 3860 | test->wim)); | ||
1043 | 3861 | g_assert (!tp_intset_is_member ( | ||
1044 | 3862 | tp_channel_group_get_members (test->publish), | ||
1045 | 3863 | test->wim)); | ||
1046 | 3864 | |||
1047 | 3865 | g_array_append_val (test->arr, test->wim); | ||
1048 | 3866 | |||
1049 | 3867 | if (!tp_strdiff (mode, "old")) | ||
1050 | 3868 | { | ||
1051 | 3869 | tp_cli_channel_interface_group_run_remove_members (test->publish, | ||
1052 | 3870 | -1, test->arr, "", &error, NULL); | ||
1053 | 3871 | } | ||
1054 | 3872 | else if (!tp_strdiff (mode, "unpublish")) | ||
1055 | 3873 | { | ||
1056 | 3874 | /* directly equivalent, but in practice people won't do this */ | ||
1057 | 3875 | tp_cli_connection_interface_contact_list_run_unpublish ( | ||
1058 | 3876 | test->conn, -1, test->arr, &error, NULL); | ||
1059 | 3877 | } | ||
1060 | 3878 | else | ||
1061 | 3879 | { | ||
1062 | 3880 | /* this isn't directly equivalent, but in practice it's what people | ||
1063 | 3881 | * will do */ | ||
1064 | 3882 | tp_cli_connection_interface_contact_list_run_remove_contacts ( | ||
1065 | 3883 | test->conn, -1, test->arr, &error, NULL); | ||
1066 | 3884 | } | ||
1067 | 3885 | |||
1068 | 3886 | g_assert_no_error (error); | ||
1069 | 3887 | |||
1070 | 3888 | /* by the time the method returns, we should have had the | ||
1071 | 3889 | * removal-notification, too */ | ||
1072 | 3890 | g_assert_cmpuint ( | ||
1073 | 3891 | tp_intset_size (tp_channel_group_get_local_pending (test->publish)), | ||
1074 | 3892 | ==, 1); | ||
1075 | 3893 | g_assert (!tp_intset_is_member ( | ||
1076 | 3894 | tp_channel_group_get_members (test->publish), | ||
1077 | 3895 | test->wim)); | ||
1078 | 3896 | g_assert (!tp_intset_is_member ( | ||
1079 | 3897 | tp_channel_group_get_local_pending (test->publish), | ||
1080 | 3898 | test->wim)); | ||
1081 | 3899 | |||
1082 | 3900 | g_assert_cmpuint (test->log->len, ==, 1); | ||
1083 | 3901 | |||
1084 | 3902 | /* because Wim wasn't really on our contact list, he's removed as a | ||
1085 | 3903 | * side-effect, even if we only unpublished */ | ||
1086 | 3904 | test_assert_one_contact_removed (test, 0, test->wim); | ||
1087 | 3905 | |||
1088 | 3906 | test_assert_contact_state (test, test->wim, | ||
1089 | 3907 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL); | ||
1090 | 3908 | } | ||
1091 | 3909 | |||
1092 | 3910 | static void | ||
1093 | 3911 | test_add_to_publish_pre_approve (Test *test, | ||
1094 | 3912 | gconstpointer mode) | ||
1095 | 3913 | { | ||
1096 | 3914 | GError *error = NULL; | ||
1097 | 3915 | |||
1098 | 3916 | /* Unilaterally adding a member to the publish channel doesn't work, but | ||
1099 | 3917 | * in the new contact list manager the method "succeeds" anyway, and | ||
1100 | 3918 | * any subsequent subscription request succeeds instantly. */ | ||
1101 | 3919 | |||
1102 | 3920 | test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish"); | ||
1103 | 3921 | test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored"); | ||
1104 | 3922 | test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "subscribe"); | ||
1105 | 3923 | |||
1106 | 3924 | g_array_append_val (test->arr, test->ninja); | ||
1107 | 3925 | |||
1108 | 3926 | g_assert (!tp_intset_is_member ( | ||
1109 | 3927 | tp_channel_group_get_local_pending (test->publish), | ||
1110 | 3928 | test->ninja)); | ||
1111 | 3929 | |||
1112 | 3930 | if (!tp_strdiff (mode, "old")) | ||
1113 | 3931 | tp_cli_channel_interface_group_run_add_members (test->publish, | ||
1114 | 3932 | -1, test->arr, "", &error, NULL); | ||
1115 | 3933 | else | ||
1116 | 3934 | tp_cli_connection_interface_contact_list_run_authorize_publication ( | ||
1117 | 3935 | test->conn, -1, test->arr, &error, NULL); | ||
1118 | 3936 | |||
1119 | 3937 | g_assert_no_error (error); | ||
1120 | 3938 | |||
1121 | 3939 | g_assert (!tp_intset_is_member ( | ||
1122 | 3940 | tp_channel_group_get_local_pending (test->publish), | ||
1123 | 3941 | test->ninja)); | ||
1124 | 3942 | |||
1125 | 3943 | /* the example CM's fake contacts accept requests that contain "please" */ | ||
1126 | 3944 | if (!tp_strdiff (mode, "old")) | ||
1127 | 3945 | tp_cli_channel_interface_group_run_add_members (test->subscribe, | ||
1128 | 3946 | -1, test->arr, "Please may I see your presence?", &error, NULL); | ||
1129 | 3947 | else | ||
1130 | 3948 | tp_cli_connection_interface_contact_list_run_request_subscription ( | ||
1131 | 3949 | test->conn, -1, test->arr, "Please may I see your presence?", &error, | ||
1132 | 3950 | NULL); | ||
1133 | 3951 | |||
1134 | 3952 | g_assert_no_error (error); | ||
1135 | 3953 | |||
1136 | 3954 | /* by the time the method returns, we should have had the | ||
1137 | 3955 | * change-notification, too */ | ||
1138 | 3956 | g_assert (tp_intset_is_member ( | ||
1139 | 3957 | tp_channel_group_get_remote_pending (test->subscribe), | ||
1140 | 3958 | test->ninja)); | ||
1141 | 3959 | g_assert (tp_intset_is_member ( | ||
1142 | 3960 | tp_channel_group_get_members (test->stored), | ||
1143 | 3961 | test->ninja)); | ||
1144 | 3962 | g_assert (!tp_intset_is_member ( | ||
1145 | 3963 | tp_channel_group_get_remote_pending (test->stored), | ||
1146 | 3964 | test->ninja)); | ||
1147 | 3965 | |||
1148 | 3966 | /* after a short delay, the contact accepts our request */ | ||
1149 | 3967 | while (tp_intset_is_member ( | ||
1150 | 3968 | tp_channel_group_get_remote_pending (test->subscribe), | ||
1151 | 3969 | test->ninja)) | ||
1152 | 3970 | g_main_context_iteration (NULL, TRUE); | ||
1153 | 3971 | |||
1154 | 3972 | g_assert (tp_intset_is_member ( | ||
1155 | 3973 | tp_channel_group_get_members (test->subscribe), | ||
1156 | 3974 | test->ninja)); | ||
1157 | 3975 | g_assert (!tp_intset_is_member ( | ||
1158 | 3976 | tp_channel_group_get_remote_pending (test->subscribe), | ||
1159 | 3977 | test->ninja)); | ||
1160 | 3978 | |||
1161 | 3979 | /* the contact also requests our presence after a short delay - we | ||
1162 | 3980 | * pre-approved, so they go straight to full membership */ | ||
1163 | 3981 | while (!tp_intset_is_member ( | ||
1164 | 3982 | tp_channel_group_get_members (test->publish), | ||
1165 | 3983 | test->ninja) || test->log->len < 3) | ||
1166 | 3984 | g_main_context_iteration (NULL, TRUE); | ||
1167 | 3985 | |||
1168 | 3986 | g_assert (tp_intset_is_member ( | ||
1169 | 3987 | tp_channel_group_get_members (test->publish), | ||
1170 | 3988 | test->ninja)); | ||
1171 | 3989 | g_assert (!tp_intset_is_member ( | ||
1172 | 3990 | tp_channel_group_get_local_pending (test->publish), | ||
1173 | 3991 | test->ninja)); | ||
1174 | 3992 | |||
1175 | 3993 | g_assert_cmpuint (test->log->len, ==, 3); | ||
1176 | 3994 | test_assert_one_contact_changed (test, 0, test->ninja, TP_SUBSCRIPTION_STATE_ASK, | ||
1177 | 3995 | TP_SUBSCRIPTION_STATE_NO, ""); | ||
1178 | 3996 | test_assert_one_contact_changed (test, 1, test->ninja, TP_SUBSCRIPTION_STATE_YES, | ||
1179 | 3997 | TP_SUBSCRIPTION_STATE_NO, ""); | ||
1180 | 3998 | test_assert_one_contact_changed (test, 2, test->ninja, TP_SUBSCRIPTION_STATE_YES, | ||
1181 | 3999 | TP_SUBSCRIPTION_STATE_YES, ""); | ||
1182 | 4000 | |||
1183 | 4001 | test_assert_contact_state (test, test->ninja, | ||
1184 | 4002 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_YES, NULL, NULL); | ||
1185 | 4003 | } | ||
1186 | 4004 | |||
1187 | 4005 | static void | ||
1188 | 4006 | test_add_to_publish_no_op (Test *test, | ||
1189 | 4007 | gconstpointer mode) | ||
1190 | 4008 | { | ||
1191 | 4009 | GError *error = NULL; | ||
1192 | 4010 | |||
1193 | 4011 | /* Adding a member to the publish channel when they're already there is | ||
1194 | 4012 | * valid. */ | ||
1195 | 4013 | |||
1196 | 4014 | test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish"); | ||
1197 | 4015 | |||
1198 | 4016 | g_assert (tp_intset_is_member ( | ||
1199 | 4017 | tp_channel_group_get_members (test->publish), | ||
1200 | 4018 | test->sjoerd)); | ||
1201 | 4019 | |||
1202 | 4020 | g_array_append_val (test->arr, test->sjoerd); | ||
1203 | 4021 | |||
1204 | 4022 | if (!tp_strdiff (mode, "old")) | ||
1205 | 4023 | tp_cli_channel_interface_group_run_add_members (test->publish, | ||
1206 | 4024 | -1, test->arr, "", &error, NULL); | ||
1207 | 4025 | else | ||
1208 | 4026 | tp_cli_connection_interface_contact_list_run_authorize_publication ( | ||
1209 | 4027 | test->conn, -1, test->arr, &error, NULL); | ||
1210 | 4028 | |||
1211 | 4029 | g_assert_no_error (error); | ||
1212 | 4030 | |||
1213 | 4031 | g_assert (tp_intset_is_member ( | ||
1214 | 4032 | tp_channel_group_get_members (test->publish), | ||
1215 | 4033 | test->sjoerd)); | ||
1216 | 4034 | |||
1217 | 4035 | g_assert_cmpuint (test->log->len, ==, 0); | ||
1218 | 4036 | test_assert_contact_state (test, test->sjoerd, | ||
1219 | 4037 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_YES, NULL, "Cambridge"); | ||
1220 | 4038 | } | ||
1221 | 4039 | |||
1222 | 4040 | static void | ||
1223 | 4041 | test_remove_from_publish (Test *test, | ||
1224 | 4042 | gconstpointer mode) | ||
1225 | 4043 | { | ||
1226 | 4044 | GError *error = NULL; | ||
1227 | 4045 | |||
1228 | 4046 | test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish"); | ||
1229 | 4047 | |||
1230 | 4048 | g_assert_cmpuint ( | ||
1231 | 4049 | tp_intset_size (tp_channel_group_get_members (test->publish)), | ||
1232 | 4050 | ==, 4); | ||
1233 | 4051 | g_assert (tp_intset_is_member ( | ||
1234 | 4052 | tp_channel_group_get_members (test->publish), | ||
1235 | 4053 | test->sjoerd)); | ||
1236 | 4054 | |||
1237 | 4055 | g_array_append_val (test->arr, test->sjoerd); | ||
1238 | 4056 | |||
1239 | 4057 | if (!tp_strdiff (mode, "old")) | ||
1240 | 4058 | tp_cli_channel_interface_group_run_remove_members (test->publish, | ||
1241 | 4059 | -1, test->arr, "", &error, NULL); | ||
1242 | 4060 | else | ||
1243 | 4061 | tp_cli_connection_interface_contact_list_run_unpublish ( | ||
1244 | 4062 | test->conn, -1, test->arr, &error, NULL); | ||
1245 | 4063 | |||
1246 | 4064 | g_assert_no_error (error); | ||
1247 | 4065 | |||
1248 | 4066 | /* by the time the method returns, we should have had the | ||
1249 | 4067 | * removal-notification, too */ | ||
1250 | 4068 | g_assert (!tp_intset_is_member ( | ||
1251 | 4069 | tp_channel_group_get_members (test->publish), | ||
1252 | 4070 | test->sjoerd)); | ||
1253 | 4071 | |||
1254 | 4072 | /* the contact re-requests our presence after a short delay */ | ||
1255 | 4073 | while (!tp_intset_is_member ( | ||
1256 | 4074 | tp_channel_group_get_local_pending (test->publish), | ||
1257 | 4075 | test->sjoerd) || | ||
1258 | 4076 | test->log->len < 2) | ||
1259 | 4077 | g_main_context_iteration (NULL, TRUE); | ||
1260 | 4078 | |||
1261 | 4079 | g_assert (!tp_intset_is_member ( | ||
1262 | 4080 | tp_channel_group_get_members (test->publish), | ||
1263 | 4081 | test->sjoerd)); | ||
1264 | 4082 | g_assert (tp_intset_is_member ( | ||
1265 | 4083 | tp_channel_group_get_local_pending (test->publish), | ||
1266 | 4084 | test->sjoerd)); | ||
1267 | 4085 | |||
1268 | 4086 | g_assert_cmpuint (test->log->len, ==, 2); | ||
1269 | 4087 | test_assert_one_contact_changed (test, 0, test->sjoerd, | ||
1270 | 4088 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_NO, ""); | ||
1271 | 4089 | test_assert_one_contact_changed (test, 1, test->sjoerd, | ||
1272 | 4090 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_ASK, | ||
1273 | 4091 | "May I see your presence, please?"); | ||
1274 | 4092 | test_assert_contact_state (test, test->sjoerd, | ||
1275 | 4093 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_ASK, | ||
1276 | 4094 | "May I see your presence, please?", "Cambridge"); | ||
1277 | 4095 | } | ||
1278 | 4096 | |||
1279 | 4097 | static void | ||
1280 | 4098 | test_remove_from_publish_no_op (Test *test, | ||
1281 | 4099 | gconstpointer mode) | ||
1282 | 4100 | { | ||
1283 | 4101 | GError *error = NULL; | ||
1284 | 4102 | |||
1285 | 4103 | test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish"); | ||
1286 | 4104 | |||
1287 | 4105 | g_assert_cmpuint ( | ||
1288 | 4106 | tp_intset_size (tp_channel_group_get_members (test->publish)), | ||
1289 | 4107 | ==, 4); | ||
1290 | 4108 | g_assert (!tp_intset_is_member ( | ||
1291 | 4109 | tp_channel_group_get_members (test->publish), | ||
1292 | 4110 | test->ninja)); | ||
1293 | 4111 | |||
1294 | 4112 | g_array_append_val (test->arr, test->ninja); | ||
1295 | 4113 | |||
1296 | 4114 | if (!tp_strdiff (mode, "old")) | ||
1297 | 4115 | tp_cli_channel_interface_group_run_remove_members (test->publish, | ||
1298 | 4116 | -1, test->arr, "", &error, NULL); | ||
1299 | 4117 | else | ||
1300 | 4118 | tp_cli_connection_interface_contact_list_run_unpublish ( | ||
1301 | 4119 | test->conn, -1, test->arr, &error, NULL); | ||
1302 | 4120 | |||
1303 | 4121 | g_assert_no_error (error); | ||
1304 | 4122 | |||
1305 | 4123 | g_assert_cmpuint (test->log->len, ==, 0); | ||
1306 | 4124 | test_assert_contact_state (test, test->ninja, | ||
1307 | 4125 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL); | ||
1308 | 4126 | } | ||
1309 | 4127 | |||
1310 | 4128 | static void | ||
1311 | 4129 | test_cancelled_publish_request (Test *test, | ||
1312 | 4130 | gconstpointer mode) | ||
1313 | 4131 | { | ||
1314 | 4132 | GError *error = NULL; | ||
1315 | 4133 | |||
1316 | 4134 | test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "subscribe"); | ||
1317 | 4135 | test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish"); | ||
1318 | 4136 | test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored"); | ||
1319 | 4137 | |||
1320 | 4138 | g_assert_cmpuint ( | ||
1321 | 4139 | tp_intset_size (tp_channel_group_get_members (test->subscribe)), | ||
1322 | 4140 | ==, 4); | ||
1323 | 4141 | g_assert (!tp_intset_is_member ( | ||
1324 | 4142 | tp_channel_group_get_members (test->subscribe), | ||
1325 | 4143 | test->canceller)); | ||
1326 | 4144 | g_assert (!tp_intset_is_member ( | ||
1327 | 4145 | tp_channel_group_get_remote_pending (test->subscribe), | ||
1328 | 4146 | test->canceller)); | ||
1329 | 4147 | |||
1330 | 4148 | /* the example CM's fake contacts accept requests that contain "please" */ | ||
1331 | 4149 | g_array_append_val (test->arr, test->canceller); | ||
1332 | 4150 | |||
1333 | 4151 | tp_cli_connection_interface_contact_list_run_request_subscription ( | ||
1334 | 4152 | test->conn, -1, test->arr, "Please may I see your presence?", | ||
1335 | 4153 | &error, NULL); | ||
1336 | 4154 | |||
1337 | 4155 | /* It starts off the same as test_accept_subscribe_request, but because | ||
1338 | 4156 | * we're using an identifier with special significance, the contact cancels | ||
1339 | 4157 | * the request immediately after */ | ||
1340 | 4158 | while (tp_intset_is_member ( | ||
1341 | 4159 | tp_channel_group_get_local_pending (test->publish), | ||
1342 | 4160 | test->canceller) || | ||
1343 | 4161 | test->log->len < 4) | ||
1344 | 4162 | g_main_context_iteration (NULL, TRUE); | ||
1345 | 4163 | |||
1346 | 4164 | g_assert (!tp_intset_is_member ( | ||
1347 | 4165 | tp_channel_group_get_members (test->publish), | ||
1348 | 4166 | test->canceller)); | ||
1349 | 4167 | g_assert (!tp_intset_is_member ( | ||
1350 | 4168 | tp_channel_group_get_local_pending (test->publish), | ||
1351 | 4169 | test->canceller)); | ||
1352 | 4170 | |||
1353 | 4171 | g_assert_cmpuint (test->log->len, ==, 4); | ||
1354 | 4172 | test_assert_one_contact_changed (test, 0, test->canceller, | ||
1355 | 4173 | TP_SUBSCRIPTION_STATE_ASK, TP_SUBSCRIPTION_STATE_NO, ""); | ||
1356 | 4174 | test_assert_one_contact_changed (test, 1, test->canceller, | ||
1357 | 4175 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_NO, ""); | ||
1358 | 4176 | test_assert_one_contact_changed (test, 2, test->canceller, | ||
1359 | 4177 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_ASK, | ||
1360 | 4178 | "May I see your presence, please?"); | ||
1361 | 4179 | test_assert_one_contact_changed (test, 3, test->canceller, | ||
1362 | 4180 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_REMOVED_REMOTELY, ""); | ||
1363 | 4181 | test_assert_contact_state (test, test->canceller, | ||
1364 | 4182 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_REMOVED_REMOTELY, | ||
1365 | 4183 | NULL, NULL); | ||
1366 | 4184 | |||
1367 | 4185 | test_clear_log (test); | ||
1368 | 4186 | |||
1369 | 4187 | /* We can acknowledge the cancellation with Unpublish() or | ||
1370 | 4188 | * RemoveContacts(). We can't use the old API here, because in the old API, | ||
1371 | 4189 | * the contact has already vanished from the Group */ | ||
1372 | 4190 | if (!tp_strdiff (mode, "remove-after")) | ||
1373 | 4191 | tp_cli_connection_interface_contact_list_run_remove_contacts (test->conn, | ||
1374 | 4192 | -1, test->arr, &error, NULL); | ||
1375 | 4193 | else | ||
1376 | 4194 | tp_cli_connection_interface_contact_list_run_unpublish ( | ||
1377 | 4195 | test->conn, -1, test->arr, &error, NULL); | ||
1378 | 4196 | |||
1379 | 4197 | while (test->log->len < 1) | ||
1380 | 4198 | g_main_context_iteration (NULL, TRUE); | ||
1381 | 4199 | |||
1382 | 4200 | g_assert_cmpuint (test->log->len, ==, 1); | ||
1383 | 4201 | |||
1384 | 4202 | if (!tp_strdiff (mode, "remove-after")) | ||
1385 | 4203 | test_assert_one_contact_removed (test, 0, test->canceller); | ||
1386 | 4204 | else | ||
1387 | 4205 | test_assert_one_contact_changed (test, 0, test->canceller, | ||
1388 | 4206 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_NO, ""); | ||
1389 | 4207 | } | ||
1390 | 4208 | |||
1391 | 4209 | static void | ||
1392 | 4210 | test_add_to_stored (Test *test, | ||
1393 | 4211 | gconstpointer mode) | ||
1394 | 4212 | { | ||
1395 | 4213 | GError *error = NULL; | ||
1396 | 4214 | |||
1397 | 4215 | test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored"); | ||
1398 | 4216 | test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish"); | ||
1399 | 4217 | test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, | ||
1400 | 4218 | "subscribe"); | ||
1401 | 4219 | |||
1402 | 4220 | g_assert_cmpuint ( | ||
1403 | 4221 | tp_intset_size (tp_channel_group_get_members (test->stored)), | ||
1404 | 4222 | ==, 8); | ||
1405 | 4223 | g_assert (!tp_intset_is_member ( | ||
1406 | 4224 | tp_channel_group_get_members (test->stored), | ||
1407 | 4225 | test->ninja)); | ||
1408 | 4226 | |||
1409 | 4227 | g_array_append_val (test->arr, test->ninja); | ||
1410 | 4228 | |||
1411 | 4229 | if (!tp_strdiff (mode, "old")) | ||
1412 | 4230 | { | ||
1413 | 4231 | tp_cli_channel_interface_group_run_add_members (test->stored, | ||
1414 | 4232 | -1, test->arr, "", &error, NULL); | ||
1415 | 4233 | } | ||
1416 | 4234 | else | ||
1417 | 4235 | { | ||
1418 | 4236 | /* there's no specific API for adding contacts to stored (it's not a | ||
1419 | 4237 | * very useful action in general), but setting an alias has it as a | ||
1420 | 4238 | * side-effect */ | ||
1421 | 4239 | GHashTable *table = g_hash_table_new (NULL, NULL); | ||
1422 | 4240 | |||
1423 | 4241 | g_hash_table_insert (table, GUINT_TO_POINTER (test->ninja), | ||
1424 | 4242 | "The Wee Ninja"); | ||
1425 | 4243 | tp_cli_connection_interface_aliasing_run_set_aliases (test->conn, | ||
1426 | 4244 | -1, table, &error, NULL); | ||
1427 | 4245 | g_hash_table_unref (table); | ||
1428 | 4246 | } | ||
1429 | 4247 | |||
1430 | 4248 | g_assert_no_error (error); | ||
1431 | 4249 | |||
1432 | 4250 | /* by the time the method returns, we should have had the | ||
1433 | 4251 | * change-notification, too */ | ||
1434 | 4252 | g_assert_cmpuint ( | ||
1435 | 4253 | tp_intset_size (tp_channel_group_get_members (test->stored)), | ||
1436 | 4254 | ==, 9); | ||
1437 | 4255 | g_assert (tp_intset_is_member ( | ||
1438 | 4256 | tp_channel_group_get_members (test->stored), | ||
1439 | 4257 | test->ninja)); | ||
1440 | 4258 | |||
1441 | 4259 | g_assert (!tp_intset_is_member ( | ||
1442 | 4260 | tp_channel_group_get_members (test->subscribe), | ||
1443 | 4261 | test->ninja)); | ||
1444 | 4262 | g_assert (!tp_intset_is_member ( | ||
1445 | 4263 | tp_channel_group_get_members (test->publish), | ||
1446 | 4264 | test->ninja)); | ||
1447 | 4265 | |||
1448 | 4266 | g_assert_cmpuint (test->log->len, ==, 1); | ||
1449 | 4267 | test_assert_one_contact_changed (test, 0, test->ninja, | ||
1450 | 4268 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, ""); | ||
1451 | 4269 | test_assert_contact_state (test, test->ninja, | ||
1452 | 4270 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL); | ||
1453 | 4271 | } | ||
1454 | 4272 | |||
1455 | 4273 | static void | ||
1456 | 4274 | test_add_to_stored_no_op (Test *test, | ||
1457 | 4275 | gconstpointer mode) | ||
1458 | 4276 | { | ||
1459 | 4277 | GError *error = NULL; | ||
1460 | 4278 | |||
1461 | 4279 | test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored"); | ||
1462 | 4280 | |||
1463 | 4281 | g_assert_cmpuint ( | ||
1464 | 4282 | tp_intset_size (tp_channel_group_get_members (test->stored)), | ||
1465 | 4283 | ==, 8); | ||
1466 | 4284 | g_assert (tp_intset_is_member ( | ||
1467 | 4285 | tp_channel_group_get_members (test->stored), | ||
1468 | 4286 | test->sjoerd)); | ||
1469 | 4287 | |||
1470 | 4288 | g_array_append_val (test->arr, test->sjoerd); | ||
1471 | 4289 | |||
1472 | 4290 | if (!tp_strdiff (mode, "old")) | ||
1473 | 4291 | { | ||
1474 | 4292 | tp_cli_channel_interface_group_run_add_members (test->stored, | ||
1475 | 4293 | -1, test->arr, "", &error, NULL); | ||
1476 | 4294 | } | ||
1477 | 4295 | else | ||
1478 | 4296 | { | ||
1479 | 4297 | /* there's no specific API for adding contacts to stored (it's not a | ||
1480 | 4298 | * very useful action in general), but setting an alias has it as a | ||
1481 | 4299 | * side-effect */ | ||
1482 | 4300 | GHashTable *table = g_hash_table_new (NULL, NULL); | ||
1483 | 4301 | |||
1484 | 4302 | g_hash_table_insert (table, GUINT_TO_POINTER (test->sjoerd), | ||
1485 | 4303 | "Sjoerd"); | ||
1486 | 4304 | tp_cli_connection_interface_aliasing_run_set_aliases (test->conn, | ||
1487 | 4305 | -1, table, &error, NULL); | ||
1488 | 4306 | g_hash_table_unref (table); | ||
1489 | 4307 | } | ||
1490 | 4308 | |||
1491 | 4309 | g_assert_no_error (error); | ||
1492 | 4310 | |||
1493 | 4311 | g_assert_cmpuint (test->log->len, ==, 0); | ||
1494 | 4312 | test_assert_contact_state (test, test->sjoerd, | ||
1495 | 4313 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_YES, NULL, "Cambridge"); | ||
1496 | 4314 | } | ||
1497 | 4315 | |||
1498 | 4316 | static void | ||
1499 | 4317 | test_remove_from_stored (Test *test, | ||
1500 | 4318 | gconstpointer mode) | ||
1501 | 4319 | { | ||
1502 | 4320 | GError *error = NULL; | ||
1503 | 4321 | |||
1504 | 4322 | test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored"); | ||
1505 | 4323 | test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish"); | ||
1506 | 4324 | test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, | ||
1507 | 4325 | "subscribe"); | ||
1508 | 4326 | |||
1509 | 4327 | g_assert (tp_intset_is_member ( | ||
1510 | 4328 | tp_channel_group_get_members (test->stored), | ||
1511 | 4329 | test->sjoerd)); | ||
1512 | 4330 | |||
1513 | 4331 | g_array_append_val (test->arr, test->sjoerd); | ||
1514 | 4332 | |||
1515 | 4333 | if (!tp_strdiff (mode, "old")) | ||
1516 | 4334 | tp_cli_channel_interface_group_run_remove_members (test->stored, | ||
1517 | 4335 | -1, test->arr, "", &error, NULL); | ||
1518 | 4336 | else | ||
1519 | 4337 | tp_cli_connection_interface_contact_list_run_remove_contacts (test->conn, | ||
1520 | 4338 | -1, test->arr, &error, NULL); | ||
1521 | 4339 | |||
1522 | 4340 | g_assert_no_error (error); | ||
1523 | 4341 | |||
1524 | 4342 | /* by the time the method returns, we should have had the | ||
1525 | 4343 | * removal-notification, too */ | ||
1526 | 4344 | g_assert (!tp_intset_is_member ( | ||
1527 | 4345 | tp_channel_group_get_members (test->stored), | ||
1528 | 4346 | test->sjoerd)); | ||
1529 | 4347 | g_assert (!tp_intset_is_member ( | ||
1530 | 4348 | tp_channel_group_get_members (test->subscribe), | ||
1531 | 4349 | test->sjoerd)); | ||
1532 | 4350 | g_assert (!tp_intset_is_member ( | ||
1533 | 4351 | tp_channel_group_get_members (test->publish), | ||
1534 | 4352 | test->sjoerd)); | ||
1535 | 4353 | |||
1536 | 4354 | g_assert_cmpuint (test->log->len, ==, 1); | ||
1537 | 4355 | test_assert_one_contact_removed (test, 0, test->sjoerd); | ||
1538 | 4356 | test_assert_contact_state (test, test->sjoerd, | ||
1539 | 4357 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL); | ||
1540 | 4358 | } | ||
1541 | 4359 | |||
1542 | 4360 | static void | ||
1543 | 4361 | test_remove_from_stored_no_op (Test *test, | ||
1544 | 4362 | gconstpointer mode) | ||
1545 | 4363 | { | ||
1546 | 4364 | GError *error = NULL; | ||
1547 | 4365 | |||
1548 | 4366 | test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored"); | ||
1549 | 4367 | |||
1550 | 4368 | g_assert_cmpuint ( | ||
1551 | 4369 | tp_intset_size (tp_channel_group_get_members (test->stored)), | ||
1552 | 4370 | ==, 8); | ||
1553 | 4371 | g_assert (!tp_intset_is_member ( | ||
1554 | 4372 | tp_channel_group_get_members (test->stored), | ||
1555 | 4373 | test->ninja)); | ||
1556 | 4374 | |||
1557 | 4375 | g_array_append_val (test->arr, test->ninja); | ||
1558 | 4376 | |||
1559 | 4377 | if (!tp_strdiff (mode, "old")) | ||
1560 | 4378 | tp_cli_channel_interface_group_run_remove_members (test->stored, | ||
1561 | 4379 | -1, test->arr, "", &error, NULL); | ||
1562 | 4380 | else | ||
1563 | 4381 | tp_cli_connection_interface_contact_list_run_remove_contacts (test->conn, | ||
1564 | 4382 | -1, test->arr, &error, NULL); | ||
1565 | 4383 | |||
1566 | 4384 | g_assert_no_error (error); | ||
1567 | 4385 | |||
1568 | 4386 | g_assert_cmpuint (test->log->len, ==, 0); | ||
1569 | 4387 | test_assert_contact_state (test, test->ninja, | ||
1570 | 4388 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL); | ||
1571 | 4389 | } | ||
1572 | 4390 | |||
1573 | 4391 | static void | ||
1574 | 4392 | test_accept_subscribe_request (Test *test, | ||
1575 | 4393 | gconstpointer mode) | ||
1576 | 4394 | { | ||
1577 | 4395 | GError *error = NULL; | ||
1578 | 4396 | |||
1579 | 4397 | test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "subscribe"); | ||
1580 | 4398 | test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish"); | ||
1581 | 4399 | test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored"); | ||
1582 | 4400 | |||
1583 | 4401 | g_assert_cmpuint ( | ||
1584 | 4402 | tp_intset_size (tp_channel_group_get_members (test->subscribe)), | ||
1585 | 4403 | ==, 4); | ||
1586 | 4404 | g_assert (!tp_intset_is_member ( | ||
1587 | 4405 | tp_channel_group_get_members (test->subscribe), | ||
1588 | 4406 | test->ninja)); | ||
1589 | 4407 | g_assert (!tp_intset_is_member ( | ||
1590 | 4408 | tp_channel_group_get_remote_pending (test->subscribe), | ||
1591 | 4409 | test->ninja)); | ||
1592 | 4410 | |||
1593 | 4411 | /* the example CM's fake contacts accept requests that contain "please" */ | ||
1594 | 4412 | g_array_append_val (test->arr, test->ninja); | ||
1595 | 4413 | |||
1596 | 4414 | if (!tp_strdiff (mode, "old")) | ||
1597 | 4415 | tp_cli_channel_interface_group_run_add_members (test->subscribe, | ||
1598 | 4416 | -1, test->arr, "Please may I see your presence?", &error, NULL); | ||
1599 | 4417 | else | ||
1600 | 4418 | tp_cli_connection_interface_contact_list_run_request_subscription ( | ||
1601 | 4419 | test->conn, -1, test->arr, "Please may I see your presence?", | ||
1602 | 4420 | &error, NULL); | ||
1603 | 4421 | |||
1604 | 4422 | g_assert_no_error (error); | ||
1605 | 4423 | |||
1606 | 4424 | /* by the time the method returns, we should have had the | ||
1607 | 4425 | * change-notification, too */ | ||
1608 | 4426 | g_assert (tp_intset_is_member ( | ||
1609 | 4427 | tp_channel_group_get_remote_pending (test->subscribe), | ||
1610 | 4428 | test->ninja)); | ||
1611 | 4429 | g_assert (tp_intset_is_member ( | ||
1612 | 4430 | tp_channel_group_get_members (test->stored), | ||
1613 | 4431 | test->ninja)); | ||
1614 | 4432 | g_assert (!tp_intset_is_member ( | ||
1615 | 4433 | tp_channel_group_get_remote_pending (test->stored), | ||
1616 | 4434 | test->ninja)); | ||
1617 | 4435 | |||
1618 | 4436 | /* after a short delay, the contact accepts our request */ | ||
1619 | 4437 | while (tp_intset_is_member ( | ||
1620 | 4438 | tp_channel_group_get_remote_pending (test->subscribe), | ||
1621 | 4439 | test->ninja)) | ||
1622 | 4440 | g_main_context_iteration (NULL, TRUE); | ||
1623 | 4441 | |||
1624 | 4442 | g_assert (tp_intset_is_member ( | ||
1625 | 4443 | tp_channel_group_get_members (test->subscribe), | ||
1626 | 4444 | test->ninja)); | ||
1627 | 4445 | g_assert (!tp_intset_is_member ( | ||
1628 | 4446 | tp_channel_group_get_remote_pending (test->subscribe), | ||
1629 | 4447 | test->ninja)); | ||
1630 | 4448 | |||
1631 | 4449 | /* the contact also requests our presence after a short delay */ | ||
1632 | 4450 | while (!tp_intset_is_member ( | ||
1633 | 4451 | tp_channel_group_get_local_pending (test->publish), | ||
1634 | 4452 | test->ninja) || | ||
1635 | 4453 | test->log->len < 3) | ||
1636 | 4454 | g_main_context_iteration (NULL, TRUE); | ||
1637 | 4455 | |||
1638 | 4456 | g_assert (!tp_intset_is_member ( | ||
1639 | 4457 | tp_channel_group_get_members (test->publish), | ||
1640 | 4458 | test->ninja)); | ||
1641 | 4459 | g_assert (tp_intset_is_member ( | ||
1642 | 4460 | tp_channel_group_get_local_pending (test->publish), | ||
1643 | 4461 | test->ninja)); | ||
1644 | 4462 | |||
1645 | 4463 | g_assert_cmpuint (test->log->len, ==, 3); | ||
1646 | 4464 | test_assert_one_contact_changed (test, 0, test->ninja, | ||
1647 | 4465 | TP_SUBSCRIPTION_STATE_ASK, TP_SUBSCRIPTION_STATE_NO, ""); | ||
1648 | 4466 | test_assert_one_contact_changed (test, 1, test->ninja, | ||
1649 | 4467 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_NO, ""); | ||
1650 | 4468 | test_assert_one_contact_changed (test, 2, test->ninja, | ||
1651 | 4469 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_ASK, | ||
1652 | 4470 | "May I see your presence, please?"); | ||
1653 | 4471 | test_assert_contact_state (test, test->ninja, | ||
1654 | 4472 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_ASK, | ||
1655 | 4473 | "May I see your presence, please?", NULL); | ||
1656 | 4474 | } | ||
1657 | 4475 | |||
1658 | 4476 | static void | ||
1659 | 4477 | test_reject_subscribe_request (Test *test, | ||
1660 | 4478 | gconstpointer mode) | ||
1661 | 4479 | { | ||
1662 | 4480 | GError *error = NULL; | ||
1663 | 4481 | |||
1664 | 4482 | test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "subscribe"); | ||
1665 | 4483 | test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored"); | ||
1666 | 4484 | |||
1667 | 4485 | g_assert_cmpuint ( | ||
1668 | 4486 | tp_intset_size (tp_channel_group_get_members (test->subscribe)), | ||
1669 | 4487 | ==, 4); | ||
1670 | 4488 | g_assert (!tp_intset_is_member ( | ||
1671 | 4489 | tp_channel_group_get_members (test->subscribe), | ||
1672 | 4490 | test->ninja)); | ||
1673 | 4491 | g_assert (!tp_intset_is_member ( | ||
1674 | 4492 | tp_channel_group_get_remote_pending (test->subscribe), | ||
1675 | 4493 | test->ninja)); | ||
1676 | 4494 | |||
1677 | 4495 | /* the example CM's fake contacts reject requests that don't contain | ||
1678 | 4496 | * "please" */ | ||
1679 | 4497 | g_array_append_val (test->arr, test->ninja); | ||
1680 | 4498 | |||
1681 | 4499 | if (!tp_strdiff (mode, "old")) | ||
1682 | 4500 | tp_cli_channel_interface_group_run_add_members (test->subscribe, | ||
1683 | 4501 | -1, test->arr, "I demand to see your presence?", &error, NULL); | ||
1684 | 4502 | else | ||
1685 | 4503 | tp_cli_connection_interface_contact_list_run_request_subscription ( | ||
1686 | 4504 | test->conn, -1, test->arr, "I demand to see your presence?", | ||
1687 | 4505 | &error, NULL); | ||
1688 | 4506 | |||
1689 | 4507 | g_assert_no_error (error); | ||
1690 | 4508 | |||
1691 | 4509 | /* by the time the method returns, we should have had the | ||
1692 | 4510 | * change-notification, too */ | ||
1693 | 4511 | g_assert (tp_intset_is_member ( | ||
1694 | 4512 | tp_channel_group_get_remote_pending (test->subscribe), | ||
1695 | 4513 | test->ninja)); | ||
1696 | 4514 | g_assert (tp_intset_is_member ( | ||
1697 | 4515 | tp_channel_group_get_members (test->stored), | ||
1698 | 4516 | test->ninja)); | ||
1699 | 4517 | g_assert (!tp_intset_is_member ( | ||
1700 | 4518 | tp_channel_group_get_remote_pending (test->stored), | ||
1701 | 4519 | test->ninja)); | ||
1702 | 4520 | |||
1703 | 4521 | /* after a short delay, the contact rejects our request. Say please! */ | ||
1704 | 4522 | while (tp_intset_is_member ( | ||
1705 | 4523 | tp_channel_group_get_remote_pending (test->subscribe), | ||
1706 | 4524 | test->ninja) || | ||
1707 | 4525 | test->log->len < 2) | ||
1708 | 4526 | g_main_context_iteration (NULL, TRUE); | ||
1709 | 4527 | |||
1710 | 4528 | g_assert (!tp_intset_is_member ( | ||
1711 | 4529 | tp_channel_group_get_members (test->subscribe), | ||
1712 | 4530 | test->ninja)); | ||
1713 | 4531 | g_assert (!tp_intset_is_member ( | ||
1714 | 4532 | tp_channel_group_get_remote_pending (test->subscribe), | ||
1715 | 4533 | test->ninja)); | ||
1716 | 4534 | |||
1717 | 4535 | /* the ninja is still on the stored list */ | ||
1718 | 4536 | g_assert (tp_intset_is_member ( | ||
1719 | 4537 | tp_channel_group_get_members (test->stored), | ||
1720 | 4538 | test->ninja)); | ||
1721 | 4539 | g_assert (!tp_intset_is_member ( | ||
1722 | 4540 | tp_channel_group_get_remote_pending (test->stored), | ||
1723 | 4541 | test->ninja)); | ||
1724 | 4542 | |||
1725 | 4543 | g_assert_cmpuint (test->log->len, ==, 2); | ||
1726 | 4544 | test_assert_one_contact_changed (test, 0, test->ninja, | ||
1727 | 4545 | TP_SUBSCRIPTION_STATE_ASK, TP_SUBSCRIPTION_STATE_NO, ""); | ||
1728 | 4546 | test_assert_one_contact_changed (test, 1, test->ninja, | ||
1729 | 4547 | TP_SUBSCRIPTION_STATE_REMOVED_REMOTELY, TP_SUBSCRIPTION_STATE_NO, ""); | ||
1730 | 4548 | test_assert_contact_state (test, test->ninja, | ||
1731 | 4549 | TP_SUBSCRIPTION_STATE_REMOVED_REMOTELY, TP_SUBSCRIPTION_STATE_NO, NULL, | ||
1732 | 4550 | NULL); | ||
1733 | 4551 | |||
1734 | 4552 | test_clear_log (test); | ||
1735 | 4553 | |||
1736 | 4554 | /* We can acknowledge the failure to subscribe with Unsubscribe() or | ||
1737 | 4555 | * RemoveContacts(). We can't use the old API here, because in the old API, | ||
1738 | 4556 | * the contact has already vanished from the Group */ | ||
1739 | 4557 | if (!tp_strdiff (mode, "remove-after")) | ||
1740 | 4558 | tp_cli_connection_interface_contact_list_run_remove_contacts (test->conn, | ||
1741 | 4559 | -1, test->arr, &error, NULL); | ||
1742 | 4560 | else | ||
1743 | 4561 | tp_cli_connection_interface_contact_list_run_unsubscribe ( | ||
1744 | 4562 | test->conn, -1, test->arr, &error, NULL); | ||
1745 | 4563 | |||
1746 | 4564 | /* the ninja falls off our subscribe list */ | ||
1747 | 4565 | while (test->log->len < 1) | ||
1748 | 4566 | g_main_context_iteration (NULL, TRUE); | ||
1749 | 4567 | |||
1750 | 4568 | g_assert_cmpuint (test->log->len, ==, 1); | ||
1751 | 4569 | |||
1752 | 4570 | if (!tp_strdiff (mode, "remove-after")) | ||
1753 | 4571 | test_assert_one_contact_removed (test, 0, test->ninja); | ||
1754 | 4572 | else | ||
1755 | 4573 | test_assert_one_contact_changed (test, 0, test->ninja, | ||
1756 | 4574 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, ""); | ||
1757 | 4575 | } | ||
1758 | 4576 | |||
1759 | 4577 | static void | ||
1760 | 4578 | test_remove_from_subscribe (Test *test, | ||
1761 | 4579 | gconstpointer mode) | ||
1762 | 4580 | { | ||
1763 | 4581 | GError *error = NULL; | ||
1764 | 4582 | |||
1765 | 4583 | test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "subscribe"); | ||
1766 | 4584 | test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored"); | ||
1767 | 4585 | |||
1768 | 4586 | g_assert_cmpuint ( | ||
1769 | 4587 | tp_intset_size (tp_channel_group_get_members (test->subscribe)), | ||
1770 | 4588 | ==, 4); | ||
1771 | 4589 | g_assert (tp_intset_is_member ( | ||
1772 | 4590 | tp_channel_group_get_members (test->subscribe), | ||
1773 | 4591 | test->sjoerd)); | ||
1774 | 4592 | |||
1775 | 4593 | g_array_append_val (test->arr, test->sjoerd); | ||
1776 | 4594 | |||
1777 | 4595 | if (!tp_strdiff (mode, "old")) | ||
1778 | 4596 | tp_cli_channel_interface_group_run_remove_members (test->subscribe, | ||
1779 | 4597 | -1, test->arr, "", &error, NULL); | ||
1780 | 4598 | else | ||
1781 | 4599 | tp_cli_connection_interface_contact_list_run_unsubscribe ( | ||
1782 | 4600 | test->conn, -1, test->arr, &error, NULL); | ||
1783 | 4601 | |||
1784 | 4602 | g_assert_no_error (error); | ||
1785 | 4603 | |||
1786 | 4604 | /* by the time the method returns, we should have had the | ||
1787 | 4605 | * removal-notification, too */ | ||
1788 | 4606 | g_assert (!tp_intset_is_member ( | ||
1789 | 4607 | tp_channel_group_get_members (test->subscribe), | ||
1790 | 4608 | test->sjoerd)); | ||
1791 | 4609 | g_assert (tp_intset_is_member ( | ||
1792 | 4610 | tp_channel_group_get_members (test->stored), | ||
1793 | 4611 | test->sjoerd)); | ||
1794 | 4612 | |||
1795 | 4613 | g_assert_cmpuint (test->log->len, ==, 1); | ||
1796 | 4614 | test_assert_one_contact_changed (test, 0, test->sjoerd, | ||
1797 | 4615 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_YES, ""); | ||
1798 | 4616 | test_assert_contact_state (test, test->sjoerd, | ||
1799 | 4617 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_YES, NULL, "Cambridge"); | ||
1800 | 4618 | } | ||
1801 | 4619 | |||
1802 | 4620 | static void | ||
1803 | 4621 | test_remove_from_subscribe_pending (Test *test, | ||
1804 | 4622 | gconstpointer mode) | ||
1805 | 4623 | { | ||
1806 | 4624 | GError *error = NULL; | ||
1807 | 4625 | |||
1808 | 4626 | test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "subscribe"); | ||
1809 | 4627 | test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored"); | ||
1810 | 4628 | |||
1811 | 4629 | g_assert_cmpuint ( | ||
1812 | 4630 | tp_intset_size (tp_channel_group_get_remote_pending (test->subscribe)), | ||
1813 | 4631 | ==, 2); | ||
1814 | 4632 | g_assert (tp_intset_is_member ( | ||
1815 | 4633 | tp_channel_group_get_remote_pending (test->subscribe), | ||
1816 | 4634 | test->helen)); | ||
1817 | 4635 | |||
1818 | 4636 | g_array_append_val (test->arr, test->helen); | ||
1819 | 4637 | |||
1820 | 4638 | if (!tp_strdiff (mode, "old")) | ||
1821 | 4639 | tp_cli_channel_interface_group_run_remove_members (test->subscribe, | ||
1822 | 4640 | -1, test->arr, "", &error, NULL); | ||
1823 | 4641 | else | ||
1824 | 4642 | tp_cli_connection_interface_contact_list_run_unsubscribe ( | ||
1825 | 4643 | test->conn, -1, test->arr, &error, NULL); | ||
1826 | 4644 | |||
1827 | 4645 | g_assert_no_error (error); | ||
1828 | 4646 | |||
1829 | 4647 | /* by the time the method returns, we should have had the | ||
1830 | 4648 | * removal-notification, too */ | ||
1831 | 4649 | g_assert (!tp_intset_is_member ( | ||
1832 | 4650 | tp_channel_group_get_members (test->subscribe), | ||
1833 | 4651 | test->helen)); | ||
1834 | 4652 | g_assert (!tp_intset_is_member ( | ||
1835 | 4653 | tp_channel_group_get_remote_pending (test->subscribe), | ||
1836 | 4654 | test->helen)); | ||
1837 | 4655 | g_assert (tp_intset_is_member ( | ||
1838 | 4656 | tp_channel_group_get_members (test->stored), | ||
1839 | 4657 | test->helen)); | ||
1840 | 4658 | |||
1841 | 4659 | g_assert_cmpuint (test->log->len, ==, 1); | ||
1842 | 4660 | test_assert_one_contact_changed (test, 0, test->helen, | ||
1843 | 4661 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, ""); | ||
1844 | 4662 | test_assert_contact_state (test, test->helen, | ||
1845 | 4663 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, "Cambridge"); | ||
1846 | 4664 | } | ||
1847 | 4665 | |||
1848 | 4666 | static void | ||
1849 | 4667 | test_remove_from_subscribe_no_op (Test *test, | ||
1850 | 4668 | gconstpointer mode) | ||
1851 | 4669 | { | ||
1852 | 4670 | GError *error = NULL; | ||
1853 | 4671 | |||
1854 | 4672 | test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "subscribe"); | ||
1855 | 4673 | |||
1856 | 4674 | g_assert_cmpuint ( | ||
1857 | 4675 | tp_intset_size (tp_channel_group_get_members (test->subscribe)), | ||
1858 | 4676 | ==, 4); | ||
1859 | 4677 | g_assert (!tp_intset_is_member ( | ||
1860 | 4678 | tp_channel_group_get_members (test->subscribe), | ||
1861 | 4679 | test->ninja)); | ||
1862 | 4680 | |||
1863 | 4681 | g_array_append_val (test->arr, test->ninja); | ||
1864 | 4682 | |||
1865 | 4683 | if (!tp_strdiff (mode, "old")) | ||
1866 | 4684 | tp_cli_channel_interface_group_run_remove_members (test->subscribe, | ||
1867 | 4685 | -1, test->arr, "", &error, NULL); | ||
1868 | 4686 | else | ||
1869 | 4687 | tp_cli_connection_interface_contact_list_run_unsubscribe ( | ||
1870 | 4688 | test->conn, -1, test->arr, &error, NULL); | ||
1871 | 4689 | |||
1872 | 4690 | g_assert_no_error (error); | ||
1873 | 4691 | |||
1874 | 4692 | g_assert_cmpuint (test->log->len, ==, 0); | ||
1875 | 4693 | test_assert_contact_state (test, test->ninja, | ||
1876 | 4694 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL); | ||
1877 | 4695 | } | ||
1878 | 4696 | |||
1879 | 4697 | static void | ||
1880 | 4698 | test_add_to_group (Test *test, | ||
1881 | 4699 | gconstpointer mode) | ||
1882 | 4700 | { | ||
1883 | 4701 | GError *error = NULL; | ||
1884 | 4702 | LogEntry *le; | ||
1885 | 4703 | guint i; | ||
1886 | 4704 | |||
1887 | 4705 | test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP, | ||
1888 | 4706 | "Cambridge"); | ||
1889 | 4707 | test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored"); | ||
1890 | 4708 | test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish"); | ||
1891 | 4709 | test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, | ||
1892 | 4710 | "subscribe"); | ||
1893 | 4711 | |||
1894 | 4712 | g_assert_cmpuint ( | ||
1895 | 4713 | tp_intset_size (tp_channel_group_get_members (test->group)), | ||
1896 | 4714 | ==, 4); | ||
1897 | 4715 | g_assert (!tp_intset_is_member ( | ||
1898 | 4716 | tp_channel_group_get_members (test->group), | ||
1899 | 4717 | test->ninja)); | ||
1900 | 4718 | |||
1901 | 4719 | g_array_append_val (test->arr, test->ninja); | ||
1902 | 4720 | |||
1903 | 4721 | if (!tp_strdiff (mode, "old")) | ||
1904 | 4722 | tp_cli_channel_interface_group_run_add_members (test->group, | ||
1905 | 4723 | -1, test->arr, "", &error, NULL); | ||
1906 | 4724 | else | ||
1907 | 4725 | tp_cli_connection_interface_contact_groups_run_add_to_group (test->conn, | ||
1908 | 4726 | -1, "Cambridge", test->arr, &error, NULL); | ||
1909 | 4727 | |||
1910 | 4728 | g_assert_no_error (error); | ||
1911 | 4729 | |||
1912 | 4730 | /* by the time the method returns, we should have had the | ||
1913 | 4731 | * change-notification, too */ | ||
1914 | 4732 | g_assert_cmpuint ( | ||
1915 | 4733 | tp_intset_size (tp_channel_group_get_members (test->group)), | ||
1916 | 4734 | ==, 5); | ||
1917 | 4735 | g_assert (tp_intset_is_member ( | ||
1918 | 4736 | tp_channel_group_get_members (test->group), | ||
1919 | 4737 | test->ninja)); | ||
1920 | 4738 | |||
1921 | 4739 | g_assert (tp_intset_is_member ( | ||
1922 | 4740 | tp_channel_group_get_members (test->stored), | ||
1923 | 4741 | test->ninja)); | ||
1924 | 4742 | g_assert (!tp_intset_is_member ( | ||
1925 | 4743 | tp_channel_group_get_members (test->subscribe), | ||
1926 | 4744 | test->ninja)); | ||
1927 | 4745 | g_assert (!tp_intset_is_member ( | ||
1928 | 4746 | tp_channel_group_get_members (test->publish), | ||
1929 | 4747 | test->ninja)); | ||
1930 | 4748 | |||
1931 | 4749 | g_assert_cmpuint (test->log->len, ==, 2); | ||
1932 | 4750 | |||
1933 | 4751 | le = g_ptr_array_index (test->log, 0); | ||
1934 | 4752 | |||
1935 | 4753 | if (le->type == CONTACTS_CHANGED) | ||
1936 | 4754 | { | ||
1937 | 4755 | test_assert_one_contact_changed (test, 0, test->ninja, | ||
1938 | 4756 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, ""); | ||
1939 | 4757 | i = 1; | ||
1940 | 4758 | } | ||
1941 | 4759 | else | ||
1942 | 4760 | { | ||
1943 | 4761 | test_assert_one_contact_changed (test, 1, test->ninja, | ||
1944 | 4762 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, ""); | ||
1945 | 4763 | i = 0; | ||
1946 | 4764 | } | ||
1947 | 4765 | |||
1948 | 4766 | /* either way, the i'th entry is now the GroupsChanged signal */ | ||
1949 | 4767 | test_assert_one_group_joined (test, i, test->ninja, "Cambridge"); | ||
1950 | 4768 | |||
1951 | 4769 | test_assert_contact_state (test, test->ninja, | ||
1952 | 4770 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, "Cambridge"); | ||
1953 | 4771 | } | ||
1954 | 4772 | |||
1955 | 4773 | static void | ||
1956 | 4774 | test_add_to_group_no_op (Test *test, | ||
1957 | 4775 | gconstpointer mode) | ||
1958 | 4776 | { | ||
1959 | 4777 | GError *error = NULL; | ||
1960 | 4778 | |||
1961 | 4779 | test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP, | ||
1962 | 4780 | "Cambridge"); | ||
1963 | 4781 | |||
1964 | 4782 | g_assert (tp_intset_is_member ( | ||
1965 | 4783 | tp_channel_group_get_members (test->group), | ||
1966 | 4784 | test->sjoerd)); | ||
1967 | 4785 | |||
1968 | 4786 | g_array_append_val (test->arr, test->sjoerd); | ||
1969 | 4787 | |||
1970 | 4788 | if (!tp_strdiff (mode, "old")) | ||
1971 | 4789 | tp_cli_channel_interface_group_run_add_members (test->group, | ||
1972 | 4790 | -1, test->arr, "", &error, NULL); | ||
1973 | 4791 | else | ||
1974 | 4792 | tp_cli_connection_interface_contact_groups_run_add_to_group (test->conn, | ||
1975 | 4793 | -1, "Cambridge", test->arr, &error, NULL); | ||
1976 | 4794 | |||
1977 | 4795 | g_assert_no_error (error); | ||
1978 | 4796 | |||
1979 | 4797 | g_assert_cmpuint (test->log->len, ==, 0); | ||
1980 | 4798 | test_assert_contact_state (test, test->sjoerd, | ||
1981 | 4799 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_YES, NULL, "Cambridge"); | ||
1982 | 4800 | } | ||
1983 | 4801 | |||
1984 | 4802 | static void | ||
1985 | 4803 | test_remove_from_group (Test *test, | ||
1986 | 4804 | gconstpointer mode) | ||
1987 | 4805 | { | ||
1988 | 4806 | GError *error = NULL; | ||
1989 | 4807 | |||
1990 | 4808 | test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP, | ||
1991 | 4809 | "Cambridge"); | ||
1992 | 4810 | |||
1993 | 4811 | g_assert (tp_intset_is_member ( | ||
1994 | 4812 | tp_channel_group_get_members (test->group), | ||
1995 | 4813 | test->sjoerd)); | ||
1996 | 4814 | |||
1997 | 4815 | g_array_append_val (test->arr, test->sjoerd); | ||
1998 | 4816 | |||
1999 | 4817 | if (!tp_strdiff (mode, "old")) | ||
2000 | 4818 | tp_cli_channel_interface_group_run_remove_members (test->group, | ||
2001 | 4819 | -1, test->arr, "", &error, NULL); | ||
2002 | 4820 | else | ||
2003 | 4821 | tp_cli_connection_interface_contact_groups_run_remove_from_group ( | ||
2004 | 4822 | test->conn, -1, "Cambridge", test->arr, &error, NULL); | ||
2005 | 4823 | |||
2006 | 4824 | g_assert_no_error (error); | ||
2007 | 4825 | |||
2008 | 4826 | /* by the time the method returns, we should have had the | ||
2009 | 4827 | * removal-notification, too */ | ||
2010 | 4828 | g_assert (!tp_intset_is_member ( | ||
2011 | 4829 | tp_channel_group_get_members (test->group), | ||
2012 | 4830 | test->sjoerd)); | ||
2013 | 4831 | |||
2014 | 4832 | g_assert_cmpuint (test->log->len, ==, 1); | ||
2015 | 4833 | test_assert_one_group_left (test, 0, test->sjoerd, "Cambridge"); | ||
2016 | 4834 | test_assert_contact_state (test, test->sjoerd, | ||
2017 | 4835 | TP_SUBSCRIPTION_STATE_YES, TP_SUBSCRIPTION_STATE_YES, NULL, NULL); | ||
2018 | 4836 | } | ||
2019 | 4837 | |||
2020 | 4838 | static void | ||
2021 | 4839 | test_remove_from_group_no_op (Test *test, | ||
2022 | 4840 | gconstpointer mode) | ||
2023 | 4841 | { | ||
2024 | 4842 | GError *error = NULL; | ||
2025 | 4843 | |||
2026 | 4844 | test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP, | ||
2027 | 4845 | "Cambridge"); | ||
2028 | 4846 | |||
2029 | 4847 | g_assert (!tp_intset_is_member ( | ||
2030 | 4848 | tp_channel_group_get_members (test->group), | ||
2031 | 4849 | test->ninja)); | ||
2032 | 4850 | |||
2033 | 4851 | g_array_append_val (test->arr, test->ninja); | ||
2034 | 4852 | |||
2035 | 4853 | if (!tp_strdiff (mode, "old")) | ||
2036 | 4854 | tp_cli_channel_interface_group_run_remove_members (test->group, | ||
2037 | 4855 | -1, test->arr, "", &error, NULL); | ||
2038 | 4856 | else | ||
2039 | 4857 | tp_cli_connection_interface_contact_groups_run_remove_from_group ( | ||
2040 | 4858 | test->conn, -1, "Cambridge", test->arr, &error, NULL); | ||
2041 | 4859 | |||
2042 | 4860 | g_assert_no_error (error); | ||
2043 | 4861 | |||
2044 | 4862 | g_assert_cmpuint (test->log->len, ==, 0); | ||
2045 | 4863 | test_assert_contact_state (test, test->ninja, | ||
2046 | 4864 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL); | ||
2047 | 4865 | } | ||
2048 | 4866 | |||
2049 | 4867 | static void | ||
2050 | 4868 | test_remove_group (Test *test, | ||
2051 | 4869 | gconstpointer mode) | ||
2052 | 4870 | { | ||
2053 | 4871 | GError *error = NULL; | ||
2054 | 4872 | |||
2055 | 4873 | test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP, | ||
2056 | 4874 | "Cambridge"); | ||
2057 | 4875 | |||
2058 | 4876 | g_assert (!tp_intset_is_empty ( | ||
2059 | 4877 | tp_channel_group_get_members (test->group))); | ||
2060 | 4878 | |||
2061 | 4879 | if (!tp_strdiff (mode, "old")) | ||
2062 | 4880 | { | ||
2063 | 4881 | /* The old API can't remove non-empty groups... */ | ||
2064 | 4882 | tp_cli_channel_run_close (test->group, -1, &error, NULL); | ||
2065 | 4883 | g_assert_error (error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE); | ||
2066 | 4884 | |||
2067 | 4885 | g_assert_cmpuint (test->log->len, ==, 0); | ||
2068 | 4886 | } | ||
2069 | 4887 | else | ||
2070 | 4888 | { | ||
2071 | 4889 | /* ... but the new API can */ | ||
2072 | 4890 | LogEntry *le; | ||
2073 | 4891 | |||
2074 | 4892 | tp_cli_connection_interface_contact_groups_run_remove_group (test->conn, | ||
2075 | 4893 | -1, "Cambridge", &error, NULL); | ||
2076 | 4894 | g_assert_no_error (error); | ||
2077 | 4895 | |||
2078 | 4896 | g_assert (tp_proxy_get_invalidated (test->group) != NULL); | ||
2079 | 4897 | g_assert_cmpuint (test->log->len, ==, 2); | ||
2080 | 4898 | test_assert_one_group_removed (test, 0, "Cambridge"); | ||
2081 | 4899 | |||
2082 | 4900 | le = g_ptr_array_index (test->log, 1); | ||
2083 | 4901 | g_assert_cmpint (le->type, ==, GROUPS_CHANGED); | ||
2084 | 4902 | g_assert_cmpuint (le->contacts->len, ==, 4); | ||
2085 | 4903 | g_assert (le->groups_added == NULL || le->groups_added[0] == NULL); | ||
2086 | 4904 | g_assert (le->groups_removed != NULL); | ||
2087 | 4905 | g_assert_cmpstr (le->groups_removed[0], ==, "Cambridge"); | ||
2088 | 4906 | g_assert_cmpstr (le->groups_removed[1], ==, NULL); | ||
2089 | 4907 | } | ||
2090 | 4908 | } | ||
2091 | 4909 | |||
2092 | 4910 | static void | ||
2093 | 4911 | test_remove_group_empty (Test *test, | ||
2094 | 4912 | gconstpointer mode) | ||
2095 | 4913 | { | ||
2096 | 4914 | GError *error = NULL; | ||
2097 | 4915 | |||
2098 | 4916 | g_assert_cmpuint (test->log->len, ==, 0); | ||
2099 | 4917 | test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP, | ||
2100 | 4918 | "people who understand const in C"); | ||
2101 | 4919 | |||
2102 | 4920 | g_assert_cmpuint (test->log->len, ==, 1); | ||
2103 | 4921 | test_assert_one_group_created (test, 0, "people who understand const in C"); | ||
2104 | 4922 | |||
2105 | 4923 | g_assert (tp_intset_is_empty ( | ||
2106 | 4924 | tp_channel_group_get_members (test->group))); | ||
2107 | 4925 | |||
2108 | 4926 | tp_cli_channel_run_close (test->group, -1, &error, NULL); | ||
2109 | 4927 | g_assert_no_error (error); | ||
2110 | 4928 | |||
2111 | 4929 | g_assert_cmpuint (test->log->len, ==, 2); | ||
2112 | 4930 | test_assert_one_group_removed (test, 1, "people who understand const in C"); | ||
2113 | 4931 | } | ||
2114 | 4932 | |||
2115 | 4933 | static void | ||
2116 | 4934 | test_set_contact_groups (Test *test, | ||
2117 | 4935 | gconstpointer nil G_GNUC_UNUSED) | ||
2118 | 4936 | { | ||
2119 | 4937 | GError *error = NULL; | ||
2120 | 4938 | LogEntry *le; | ||
2121 | 4939 | const gchar *montreal_strv[] = { "Montreal", NULL }; | ||
2122 | 4940 | |||
2123 | 4941 | test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP, | ||
2124 | 4942 | "Cambridge"); | ||
2125 | 4943 | |||
2126 | 4944 | g_assert_cmpuint ( | ||
2127 | 4945 | tp_intset_size (tp_channel_group_get_members (test->group)), | ||
2128 | 4946 | ==, 4); | ||
2129 | 4947 | g_assert (tp_intset_is_member ( | ||
2130 | 4948 | tp_channel_group_get_members (test->group), | ||
2131 | 4949 | test->sjoerd)); | ||
2132 | 4950 | |||
2133 | 4951 | g_array_append_val (test->arr, test->sjoerd); | ||
2134 | 4952 | g_array_append_val (test->arr, test->wim); | ||
2135 | 4953 | |||
2136 | 4954 | tp_cli_connection_interface_contact_groups_run_set_contact_groups ( | ||
2137 | 4955 | test->conn, -1, test->sjoerd, montreal_strv, &error, NULL); | ||
2138 | 4956 | |||
2139 | 4957 | g_assert_no_error (error); | ||
2140 | 4958 | |||
2141 | 4959 | /* by the time the method returns, we should have had the | ||
2142 | 4960 | * change-notification, too */ | ||
2143 | 4961 | g_assert_cmpuint ( | ||
2144 | 4962 | tp_intset_size (tp_channel_group_get_members (test->group)), | ||
2145 | 4963 | ==, 3); | ||
2146 | 4964 | g_assert (!tp_intset_is_member ( | ||
2147 | 4965 | tp_channel_group_get_members (test->group), | ||
2148 | 4966 | test->sjoerd)); | ||
2149 | 4967 | |||
2150 | 4968 | g_assert_cmpuint (test->log->len, ==, 1); | ||
2151 | 4969 | |||
2152 | 4970 | le = g_ptr_array_index (test->log, 0); | ||
2153 | 4971 | g_assert_cmpint (le->type, ==, GROUPS_CHANGED); | ||
2154 | 4972 | g_assert_cmpuint (le->contacts->len, ==, 1); | ||
2155 | 4973 | g_assert_cmpuint (g_array_index (le->contacts, guint, 0), ==, test->sjoerd); | ||
2156 | 4974 | g_assert (le->groups_added != NULL); | ||
2157 | 4975 | g_assert_cmpstr (le->groups_added[0], ==, "Montreal"); | ||
2158 | 4976 | g_assert_cmpstr (le->groups_added[1], ==, NULL); | ||
2159 | 4977 | g_assert (le->groups_removed != NULL); | ||
2160 | 4978 | g_assert_cmpstr (le->groups_removed[0], ==, "Cambridge"); | ||
2161 | 4979 | g_assert_cmpstr (le->groups_removed[1], ==, NULL); | ||
2162 | 4980 | } | ||
2163 | 4981 | |||
2164 | 4982 | static void | ||
2165 | 4983 | test_set_contact_groups_no_op (Test *test, | ||
2166 | 4984 | gconstpointer nil G_GNUC_UNUSED) | ||
2167 | 4985 | { | ||
2168 | 4986 | GError *error = NULL; | ||
2169 | 4987 | const gchar *cambridge_strv[] = { "Cambridge", NULL }; | ||
2170 | 4988 | |||
2171 | 4989 | test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP, | ||
2172 | 4990 | "Cambridge"); | ||
2173 | 4991 | |||
2174 | 4992 | g_assert_cmpuint ( | ||
2175 | 4993 | tp_intset_size (tp_channel_group_get_members (test->group)), | ||
2176 | 4994 | ==, 4); | ||
2177 | 4995 | g_assert (tp_intset_is_member ( | ||
2178 | 4996 | tp_channel_group_get_members (test->group), | ||
2179 | 4997 | test->sjoerd)); | ||
2180 | 4998 | |||
2181 | 4999 | g_array_append_val (test->arr, test->sjoerd); | ||
2182 | 5000 | g_array_append_val (test->arr, test->wim); | ||
2183 | 5001 | |||
2184 | 5002 | tp_cli_connection_interface_contact_groups_run_set_contact_groups ( | ||
2185 | 5003 | test->conn, -1, test->sjoerd, cambridge_strv, &error, NULL); | ||
2186 | 5004 | |||
2187 | 5005 | g_assert_no_error (error); | ||
2188 | 5006 | |||
2189 | 5007 | g_assert_cmpuint ( | ||
2190 | 5008 | tp_intset_size (tp_channel_group_get_members (test->group)), | ||
2191 | 5009 | ==, 4); | ||
2192 | 5010 | g_assert (tp_intset_is_member ( | ||
2193 | 5011 | tp_channel_group_get_members (test->group), | ||
2194 | 5012 | test->sjoerd)); | ||
2195 | 5013 | |||
2196 | 5014 | g_assert_cmpuint (test->log->len, ==, 0); | ||
2197 | 5015 | } | ||
2198 | 5016 | |||
2199 | 5017 | static void | ||
2200 | 5018 | test_set_group_members (Test *test, | ||
2201 | 5019 | gconstpointer nil G_GNUC_UNUSED) | ||
2202 | 5020 | { | ||
2203 | 5021 | GError *error = NULL; | ||
2204 | 5022 | LogEntry *le; | ||
2205 | 5023 | |||
2206 | 5024 | test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP, | ||
2207 | 5025 | "Cambridge"); | ||
2208 | 5026 | |||
2209 | 5027 | g_assert_cmpuint ( | ||
2210 | 5028 | tp_intset_size (tp_channel_group_get_members (test->group)), | ||
2211 | 5029 | ==, 4); | ||
2212 | 5030 | g_assert (tp_intset_is_member ( | ||
2213 | 5031 | tp_channel_group_get_members (test->group), | ||
2214 | 5032 | test->sjoerd)); | ||
2215 | 5033 | g_assert (tp_intset_is_member ( | ||
2216 | 5034 | tp_channel_group_get_members (test->group), | ||
2217 | 5035 | test->helen)); | ||
2218 | 5036 | g_assert (!tp_intset_is_member ( | ||
2219 | 5037 | tp_channel_group_get_members (test->group), | ||
2220 | 5038 | test->wim)); | ||
2221 | 5039 | |||
2222 | 5040 | g_array_append_val (test->arr, test->sjoerd); | ||
2223 | 5041 | g_array_append_val (test->arr, test->wim); | ||
2224 | 5042 | |||
2225 | 5043 | tp_cli_connection_interface_contact_groups_run_set_group_members (test->conn, | ||
2226 | 5044 | -1, "Cambridge", test->arr, &error, NULL); | ||
2227 | 5045 | |||
2228 | 5046 | g_assert_no_error (error); | ||
2229 | 5047 | |||
2230 | 5048 | /* by the time the method returns, we should have had the | ||
2231 | 5049 | * change-notification, too */ | ||
2232 | 5050 | g_assert_cmpuint ( | ||
2233 | 5051 | tp_intset_size (tp_channel_group_get_members (test->group)), | ||
2234 | 5052 | ==, 2); | ||
2235 | 5053 | g_assert (tp_intset_is_member ( | ||
2236 | 5054 | tp_channel_group_get_members (test->group), | ||
2237 | 5055 | test->wim)); | ||
2238 | 5056 | g_assert (tp_intset_is_member ( | ||
2239 | 5057 | tp_channel_group_get_members (test->group), | ||
2240 | 5058 | test->sjoerd)); | ||
2241 | 5059 | g_assert (!tp_intset_is_member ( | ||
2242 | 5060 | tp_channel_group_get_members (test->group), | ||
2243 | 5061 | test->helen)); | ||
2244 | 5062 | |||
2245 | 5063 | g_assert_cmpuint (test->log->len, ==, 2); | ||
2246 | 5064 | |||
2247 | 5065 | /* Wim was added */ | ||
2248 | 5066 | test_assert_one_group_joined (test, 0, test->wim, "Cambridge"); | ||
2249 | 5067 | |||
2250 | 5068 | /* The three other members, other than Sjoerd, left */ | ||
2251 | 5069 | le = g_ptr_array_index (test->log, 1); | ||
2252 | 5070 | g_assert_cmpint (le->type, ==, GROUPS_CHANGED); | ||
2253 | 5071 | g_assert_cmpuint (le->contacts->len, ==, 3); | ||
2254 | 5072 | g_assert (le->groups_added == NULL || le->groups_added[0] == NULL); | ||
2255 | 5073 | g_assert (le->groups_removed != NULL); | ||
2256 | 5074 | g_assert_cmpstr (le->groups_removed[0], ==, "Cambridge"); | ||
2257 | 5075 | g_assert_cmpstr (le->groups_removed[1], ==, NULL); | ||
2258 | 5076 | } | ||
2259 | 5077 | |||
2260 | 5078 | static void | ||
2261 | 5079 | test_rename_group (Test *test, | ||
2262 | 5080 | gconstpointer nil G_GNUC_UNUSED) | ||
2263 | 5081 | { | ||
2264 | 5082 | LogEntry *le; | ||
2265 | 5083 | GError *error = NULL; | ||
2266 | 5084 | |||
2267 | 5085 | test->group = test_ensure_channel (test, TP_HANDLE_TYPE_GROUP, | ||
2268 | 5086 | "Cambridge"); | ||
2269 | 5087 | |||
2270 | 5088 | g_assert_cmpuint ( | ||
2271 | 5089 | tp_intset_size (tp_channel_group_get_members (test->group)), | ||
2272 | 5090 | ==, 4); | ||
2273 | 5091 | |||
2274 | 5092 | tp_cli_connection_interface_contact_groups_run_rename_group (test->conn, | ||
2275 | 5093 | -1, "Cambridge", "Grantabrugge", &error, NULL); | ||
2276 | 5094 | g_assert_no_error (error); | ||
2277 | 5095 | |||
2278 | 5096 | g_assert (tp_proxy_get_invalidated (test->group) != NULL); | ||
2279 | 5097 | g_assert_cmpuint (test->log->len, ==, 4); | ||
2280 | 5098 | |||
2281 | 5099 | le = g_ptr_array_index (test->log, 0); | ||
2282 | 5100 | g_assert_cmpint (le->type, ==, GROUP_RENAMED); | ||
2283 | 5101 | g_assert (le->groups_added != NULL); | ||
2284 | 5102 | g_assert_cmpstr (le->groups_added[0], ==, "Grantabrugge"); | ||
2285 | 5103 | g_assert_cmpstr (le->groups_added[1], ==, NULL); | ||
2286 | 5104 | g_assert (le->groups_removed != NULL); | ||
2287 | 5105 | g_assert_cmpstr (le->groups_removed[0], ==, "Cambridge"); | ||
2288 | 5106 | g_assert_cmpstr (le->groups_removed[1], ==, NULL); | ||
2289 | 5107 | |||
2290 | 5108 | test_assert_one_group_created (test, 1, "Grantabrugge"); | ||
2291 | 5109 | |||
2292 | 5110 | test_assert_one_group_removed (test, 2, "Cambridge"); | ||
2293 | 5111 | |||
2294 | 5112 | le = g_ptr_array_index (test->log, 3); | ||
2295 | 5113 | g_assert_cmpint (le->type, ==, GROUPS_CHANGED); | ||
2296 | 5114 | g_assert_cmpuint (le->contacts->len, ==, 4); | ||
2297 | 5115 | g_assert (le->groups_added != NULL); | ||
2298 | 5116 | g_assert_cmpstr (le->groups_added[0], ==, "Grantabrugge"); | ||
2299 | 5117 | g_assert_cmpstr (le->groups_added[1], ==, NULL); | ||
2300 | 5118 | g_assert_cmpstr (le->groups_removed[0], ==, "Cambridge"); | ||
2301 | 5119 | g_assert_cmpstr (le->groups_removed[1], ==, NULL); | ||
2302 | 5120 | } | ||
2303 | 5121 | |||
2304 | 5122 | static void | ||
2305 | 5123 | test_rename_group_overwrite (Test *test, | ||
2306 | 5124 | gconstpointer nil G_GNUC_UNUSED) | ||
2307 | 5125 | { | ||
2308 | 5126 | GError *error = NULL; | ||
2309 | 5127 | |||
2310 | 5128 | tp_cli_connection_interface_contact_groups_run_rename_group (test->conn, | ||
2311 | 5129 | -1, "Cambridge", "Montreal", &error, NULL); | ||
2312 | 5130 | g_assert_error (error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE); | ||
2313 | 5131 | g_assert_cmpuint (test->log->len, ==, 0); | ||
2314 | 5132 | g_clear_error (&error); | ||
2315 | 5133 | } | ||
2316 | 5134 | |||
2317 | 5135 | static void | ||
2318 | 5136 | test_rename_group_absent (Test *test, | ||
2319 | 5137 | gconstpointer nil G_GNUC_UNUSED) | ||
2320 | 5138 | { | ||
2321 | 5139 | GError *error = NULL; | ||
2322 | 5140 | |||
2323 | 5141 | tp_cli_connection_interface_contact_groups_run_rename_group (test->conn, | ||
2324 | 5142 | -1, "Badgers", "Mushrooms", &error, NULL); | ||
2325 | 5143 | g_assert_error (error, TP_ERRORS, TP_ERROR_DOES_NOT_EXIST); | ||
2326 | 5144 | g_assert_cmpuint (test->log->len, ==, 0); | ||
2327 | 5145 | g_clear_error (&error); | ||
2328 | 5146 | } | ||
2329 | 5147 | |||
2330 | 5148 | /* Signature of a function which does something with test->arr */ | ||
2331 | 5149 | typedef void (*ManipulateContactsFunc) ( | ||
2332 | 5150 | Test *test, | ||
2333 | 5151 | GError **error); | ||
2334 | 5152 | |||
2335 | 5153 | static void | ||
2336 | 5154 | block_contacts (Test *test, | ||
2337 | 5155 | ManipulateContactsFunc func) | ||
2338 | 5156 | { | ||
2339 | 5157 | GError *error = NULL; | ||
2340 | 5158 | |||
2341 | 5159 | test->deny = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "deny"); | ||
2342 | 5160 | test->stored = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "stored"); | ||
2343 | 5161 | |||
2344 | 5162 | g_assert_cmpuint ( | ||
2345 | 5163 | tp_intset_size (tp_channel_group_get_members (test->deny)), | ||
2346 | 5164 | ==, 2); | ||
2347 | 5165 | g_assert (!tp_intset_is_member ( | ||
2348 | 5166 | tp_channel_group_get_members (test->deny), | ||
2349 | 5167 | test->ninja)); | ||
2350 | 5168 | |||
2351 | 5169 | g_array_append_val (test->arr, test->ninja); | ||
2352 | 5170 | func (test, &error); | ||
2353 | 5171 | g_assert_no_error (error); | ||
2354 | 5172 | |||
2355 | 5173 | /* by the time the method returns, we should have had the | ||
2356 | 5174 | * change-notification, on both the deny channel and the ContactBlocking | ||
2357 | 5175 | * connection interface */ | ||
2358 | 5176 | g_assert_cmpuint ( | ||
2359 | 5177 | tp_intset_size (tp_channel_group_get_members (test->deny)), | ||
2360 | 5178 | ==, 3); | ||
2361 | 5179 | g_assert (tp_intset_is_member ( | ||
2362 | 5180 | tp_channel_group_get_members (test->deny), | ||
2363 | 5181 | test->ninja)); | ||
2364 | 5182 | |||
2365 | 5183 | g_assert (!tp_intset_is_member ( | ||
2366 | 5184 | tp_channel_group_get_members (test->stored), | ||
2367 | 5185 | test->ninja)); | ||
2368 | 5186 | test_assert_contact_state (test, test->ninja, | ||
2369 | 5187 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL); | ||
2370 | 5188 | |||
2371 | 5189 | g_assert_cmpuint (test->log->len, ==, 1); | ||
2372 | 5190 | test_assert_one_contact_blocked (test, 0, test->ninja, | ||
2373 | 5191 | tp_handle_inspect (test->contact_repo, test->ninja)); | ||
2374 | 5192 | } | ||
2375 | 5193 | |||
2376 | 5194 | static void | ||
2377 | 5195 | block_contacts_no_op (Test *test, | ||
2378 | 5196 | ManipulateContactsFunc func) | ||
2379 | 5197 | { | ||
2380 | 5198 | GError *error = NULL; | ||
2381 | 5199 | |||
2382 | 5200 | test->deny = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "deny"); | ||
2383 | 5201 | |||
2384 | 5202 | g_assert (tp_intset_is_member ( | ||
2385 | 5203 | tp_channel_group_get_members (test->deny), | ||
2386 | 5204 | test->bill)); | ||
2387 | 5205 | |||
2388 | 5206 | g_array_append_val (test->arr, test->bill); | ||
2389 | 5207 | func (test, &error); | ||
2390 | 5208 | g_assert_no_error (error); | ||
2391 | 5209 | |||
2392 | 5210 | g_assert (tp_intset_is_member ( | ||
2393 | 5211 | tp_channel_group_get_members (test->deny), | ||
2394 | 5212 | test->bill)); | ||
2395 | 5213 | test_assert_contact_state (test, test->bill, | ||
2396 | 5214 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL); | ||
2397 | 5215 | |||
2398 | 5216 | /* We shouldn't emit spurious empty BlockedContactsChanged signals. */ | ||
2399 | 5217 | g_assert_cmpuint (test->log->len, ==, 0); | ||
2400 | 5218 | } | ||
2401 | 5219 | |||
2402 | 5220 | static void | ||
2403 | 5221 | unblock_contacts (Test *test, | ||
2404 | 5222 | ManipulateContactsFunc func) | ||
2405 | 5223 | { | ||
2406 | 5224 | GError *error = NULL; | ||
2407 | 5225 | |||
2408 | 5226 | test->deny = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "deny"); | ||
2409 | 5227 | test->publish = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "publish"); | ||
2410 | 5228 | test->subscribe = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, | ||
2411 | 5229 | "subscribe"); | ||
2412 | 5230 | |||
2413 | 5231 | g_assert (tp_intset_is_member ( | ||
2414 | 5232 | tp_channel_group_get_members (test->deny), | ||
2415 | 5233 | test->bill)); | ||
2416 | 5234 | |||
2417 | 5235 | g_array_append_val (test->arr, test->bill); | ||
2418 | 5236 | func (test, &error); | ||
2419 | 5237 | g_assert_no_error (error); | ||
2420 | 5238 | |||
2421 | 5239 | /* by the time the method returns, we should have had the | ||
2422 | 5240 | * removal-notification, too */ | ||
2423 | 5241 | g_assert (!tp_intset_is_member ( | ||
2424 | 5242 | tp_channel_group_get_members (test->deny), | ||
2425 | 5243 | test->bill)); | ||
2426 | 5244 | test_assert_contact_state (test, test->bill, | ||
2427 | 5245 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL); | ||
2428 | 5246 | |||
2429 | 5247 | g_assert_cmpuint (test->log->len, ==, 1); | ||
2430 | 5248 | test_assert_one_contact_unblocked (test, 0, test->bill, | ||
2431 | 5249 | tp_handle_inspect (test->contact_repo, test->bill)); | ||
2432 | 5250 | } | ||
2433 | 5251 | |||
2434 | 5252 | static void | ||
2435 | 5253 | unblock_contacts_no_op (Test *test, | ||
2436 | 5254 | ManipulateContactsFunc func) | ||
2437 | 5255 | { | ||
2438 | 5256 | GError *error = NULL; | ||
2439 | 5257 | |||
2440 | 5258 | test->deny = test_ensure_channel (test, TP_HANDLE_TYPE_LIST, "deny"); | ||
2441 | 5259 | |||
2442 | 5260 | g_assert (!tp_intset_is_member ( | ||
2443 | 5261 | tp_channel_group_get_members (test->deny), | ||
2444 | 5262 | test->ninja)); | ||
2445 | 5263 | |||
2446 | 5264 | g_array_append_val (test->arr, test->ninja); | ||
2447 | 5265 | func (test, &error); | ||
2448 | 5266 | g_assert_no_error (error); | ||
2449 | 5267 | g_assert (!tp_intset_is_member ( | ||
2450 | 5268 | tp_channel_group_get_members (test->deny), | ||
2451 | 5269 | test->ninja)); | ||
2452 | 5270 | test_assert_contact_state (test, test->ninja, | ||
2453 | 5271 | TP_SUBSCRIPTION_STATE_NO, TP_SUBSCRIPTION_STATE_NO, NULL, NULL); | ||
2454 | 5272 | |||
2455 | 5273 | /* We shouldn't emit spurious empty BlockedContactsChanged signals. */ | ||
2456 | 5274 | g_assert_cmpuint (test->log->len, ==, 0); | ||
2457 | 5275 | } | ||
2458 | 5276 | |||
2459 | 5277 | static void | ||
2460 | 5278 | add_to_deny (Test *test, | ||
2461 | 5279 | GError **error) | ||
2462 | 5280 | { | ||
2463 | 5281 | tp_cli_channel_interface_group_run_add_members (test->deny, | ||
2464 | 5282 | -1, test->arr, "", error, NULL); | ||
2465 | 5283 | } | ||
2466 | 5284 | |||
2467 | 5285 | static void | ||
2468 | 5286 | test_add_to_deny (Test *test, | ||
2469 | 5287 | gconstpointer nil G_GNUC_UNUSED) | ||
2470 | 5288 | { | ||
2471 | 5289 | block_contacts (test, add_to_deny); | ||
2472 | 5290 | } | ||
2473 | 5291 | |||
2474 | 5292 | static void | ||
2475 | 5293 | test_add_to_deny_no_op (Test *test, | ||
2476 | 5294 | gconstpointer nil G_GNUC_UNUSED) | ||
2477 | 5295 | { | ||
2478 | 5296 | block_contacts_no_op (test, add_to_deny); | ||
2479 | 5297 | } | ||
2480 | 5298 | |||
2481 | 5299 | static void | ||
2482 | 5300 | remove_from_deny (Test *test, | ||
2483 | 5301 | GError **error) | ||
2484 | 5302 | { | ||
2485 | 5303 | tp_cli_channel_interface_group_run_remove_members (test->deny, | ||
2486 | 5304 | -1, test->arr, "", error, NULL); | ||
2487 | 5305 | } | ||
2488 | 5306 | |||
2489 | 5307 | static void | ||
2490 | 5308 | test_remove_from_deny (Test *test, | ||
2491 | 5309 | gconstpointer nil G_GNUC_UNUSED) | ||
2492 | 5310 | { | ||
2493 | 5311 | unblock_contacts (test, remove_from_deny); | ||
2494 | 5312 | } | ||
2495 | 5313 | |||
2496 | 5314 | static void | ||
2497 | 5315 | test_remove_from_deny_no_op (Test *test, | ||
2498 | 5316 | gconstpointer nil G_GNUC_UNUSED) | ||
2499 | 5317 | { | ||
2500 | 5318 | unblock_contacts_no_op (test, remove_from_deny); | ||
2501 | 5319 | } | ||
2502 | 5320 | |||
2503 | 5321 | static void | ||
2504 | 5322 | test_request_blocked_contacts (Test *test, | ||
2505 | 5323 | gconstpointer nil G_GNUC_UNUSED) | ||
2506 | 5324 | { | ||
2507 | 5325 | GHashTable *blocked_contacts; | ||
2508 | 5326 | GError *error = NULL; | ||
2509 | 5327 | |||
2510 | 5328 | tp_cli_connection_interface_contact_blocking_run_request_blocked_contacts ( | ||
2511 | 5329 | test->conn, -1, &blocked_contacts, &error, NULL); | ||
2512 | 5330 | g_assert_no_error (error); | ||
2513 | 5331 | g_assert (blocked_contacts != NULL); | ||
2514 | 5332 | |||
2515 | 5333 | /* Both Bill and the shadowy Steve are blocked; Steve does not appear in this | ||
2516 | 5334 | * test, as he is in poor health. | ||
2517 | 5335 | */ | ||
2518 | 5336 | g_assert_cmpuint (g_hash_table_size (blocked_contacts), ==, 2); | ||
2519 | 5337 | g_assert_cmpstr (tp_handle_inspect (test->contact_repo, test->bill), ==, | ||
2520 | 5338 | g_hash_table_lookup (blocked_contacts, GUINT_TO_POINTER (test->bill))); | ||
2521 | 5339 | g_hash_table_unref (blocked_contacts); | ||
2522 | 5340 | } | ||
2523 | 5341 | |||
2524 | 5342 | static void | ||
2525 | 5343 | request_blocked_contacts_succeeded_cb ( | ||
2526 | 5344 | TpConnection *conn, | ||
2527 | 5345 | GHashTable *blocked_contacts, | ||
2528 | 5346 | const GError *error, | ||
2529 | 5347 | gpointer user_data, | ||
2530 | 5348 | GObject *weak_object) | ||
2531 | 5349 | { | ||
2532 | 5350 | g_assert_no_error (error); | ||
2533 | 5351 | |||
2534 | 5352 | /* As above. */ | ||
2535 | 5353 | g_assert_cmpuint (g_hash_table_size (blocked_contacts), ==, 2); | ||
2536 | 5354 | } | ||
2537 | 5355 | |||
2538 | 5356 | static void | ||
2539 | 5357 | test_request_blocked_contacts_pre_connect (Test *test, | ||
2540 | 5358 | gconstpointer nil G_GNUC_UNUSED) | ||
2541 | 5359 | { | ||
2542 | 5360 | gboolean ok; | ||
2543 | 5361 | |||
2544 | 5362 | /* This verifies that calling RequestBlockedContacts() | ||
2545 | 5363 | * before Connect(), when Connect() ultimately succeeds, returns correctly. | ||
2546 | 5364 | */ | ||
2547 | 5365 | tp_cli_connection_interface_contact_blocking_call_request_blocked_contacts ( | ||
2548 | 5366 | test->conn, -1, request_blocked_contacts_succeeded_cb, | ||
2549 | 5367 | test, test_quit_loop, NULL); | ||
2550 | 5368 | tp_cli_connection_call_connect (test->conn, -1, NULL, NULL, NULL, NULL); | ||
2551 | 5369 | g_main_loop_run (test->main_loop); | ||
2552 | 5370 | |||
2553 | 5371 | ok = tp_cli_connection_run_disconnect (test->conn, -1, NULL, NULL); | ||
2554 | 5372 | g_assert (ok); | ||
2555 | 5373 | } | ||
2556 | 5374 | |||
2557 | 5375 | static void | ||
2558 | 5376 | request_blocked_contacts_failed_cb ( | ||
2559 | 5377 | TpConnection *conn, | ||
2560 | 5378 | GHashTable *blocked_contacts, | ||
2561 | 5379 | const GError *error, | ||
2562 | 5380 | gpointer user_data, | ||
2563 | 5381 | GObject *weak_object) | ||
2564 | 5382 | { | ||
2565 | 5383 | g_assert_error (error, TP_ERRORS, TP_ERROR_DISCONNECTED); | ||
2566 | 5384 | } | ||
2567 | 5385 | |||
2568 | 5386 | static void | ||
2569 | 5387 | test_request_blocked_contacts_connect_failed (Test *test, | ||
2570 | 5388 | gconstpointer nil G_GNUC_UNUSED) | ||
2571 | 5389 | { | ||
2572 | 5390 | /* This verifies that calling RequestBlockedContacts() (twice, no less) | ||
2573 | 5391 | * before Connect(), when Connect() ultimately fails, returns an appropriate | ||
2574 | 5392 | * error. | ||
2575 | 5393 | */ | ||
2576 | 5394 | tp_cli_connection_interface_contact_blocking_call_request_blocked_contacts ( | ||
2577 | 5395 | test->conn, -1, request_blocked_contacts_failed_cb, | ||
2578 | 5396 | test, test_quit_loop, NULL); | ||
2579 | 5397 | tp_cli_connection_interface_contact_blocking_call_request_blocked_contacts ( | ||
2580 | 5398 | test->conn, -1, request_blocked_contacts_failed_cb, | ||
2581 | 5399 | test, test_quit_loop, NULL); | ||
2582 | 5400 | |||
2583 | 5401 | /* We expect calling Connect() to fail because the handle was invalid, but | ||
2584 | 5402 | * don't wait around for it. | ||
2585 | 5403 | */ | ||
2586 | 5404 | tp_cli_connection_call_connect (test->conn, -1, NULL, NULL, NULL, NULL); | ||
2587 | 5405 | /* Spin the mainloop twice, once for each outstanding call. */ | ||
2588 | 5406 | g_main_loop_run (test->main_loop); | ||
2589 | 5407 | g_main_loop_run (test->main_loop); | ||
2590 | 5408 | } | ||
2591 | 5409 | |||
2592 | 5410 | static void | ||
2593 | 5411 | call_block_contacts (Test *test, | ||
2594 | 5412 | GError **error) | ||
2595 | 5413 | { | ||
2596 | 5414 | tp_cli_connection_interface_contact_blocking_run_block_contacts (test->conn, | ||
2597 | 5415 | -1, test->arr, FALSE, error, NULL); | ||
2598 | 5416 | } | ||
2599 | 5417 | |||
2600 | 5418 | static void | ||
2601 | 5419 | test_block_contacts (Test *test, | ||
2602 | 5420 | gconstpointer nil G_GNUC_UNUSED) | ||
2603 | 5421 | { | ||
2604 | 5422 | block_contacts (test, call_block_contacts); | ||
2605 | 5423 | } | ||
2606 | 5424 | |||
2607 | 5425 | static void | ||
2608 | 5426 | test_block_contacts_no_op (Test *test, | ||
2609 | 5427 | gconstpointer nil G_GNUC_UNUSED) | ||
2610 | 5428 | { | ||
2611 | 5429 | block_contacts_no_op (test, call_block_contacts); | ||
2612 | 5430 | } | ||
2613 | 5431 | |||
2614 | 5432 | static void | ||
2615 | 5433 | call_unblock_contacts (Test *test, | ||
2616 | 5434 | GError **error) | ||
2617 | 5435 | { | ||
2618 | 5436 | tp_cli_connection_interface_contact_blocking_run_unblock_contacts ( | ||
2619 | 5437 | test->conn, -1, test->arr, error, NULL); | ||
2620 | 5438 | } | ||
2621 | 5439 | |||
2622 | 5440 | static void | ||
2623 | 5441 | test_unblock_contacts (Test *test, | ||
2624 | 5442 | gconstpointer nil G_GNUC_UNUSED) | ||
2625 | 5443 | { | ||
2626 | 5444 | unblock_contacts (test, call_unblock_contacts); | ||
2627 | 5445 | } | ||
2628 | 5446 | |||
2629 | 5447 | static void | ||
2630 | 5448 | test_unblock_contacts_no_op (Test *test, | ||
2631 | 5449 | gconstpointer nil G_GNUC_UNUSED) | ||
2632 | 5450 | { | ||
2633 | 5451 | unblock_contacts_no_op (test, call_unblock_contacts); | ||
2634 | 5452 | } | ||
2635 | 5453 | |||
2636 | 5454 | int | ||
2637 | 5455 | main (int argc, | ||
2638 | 5456 | char **argv) | ||
2639 | 5457 | { | ||
2640 | 5458 | g_type_init (); | ||
2641 | 5459 | tp_tests_abort_after (30); | ||
2642 | 5460 | tp_debug_set_flags ("all"); | ||
2643 | 5461 | |||
2644 | 5462 | g_test_init (&argc, &argv, NULL); | ||
2645 | 5463 | |||
2646 | 5464 | g_test_add ("/contact-lists/nothing", | ||
2647 | 5465 | Test, NULL, setup, test_nothing, teardown); | ||
2648 | 5466 | |||
2649 | 5467 | g_test_add ("/contact-lists/initial-channels", | ||
2650 | 5468 | Test, NULL, setup, test_initial_channels, teardown); | ||
2651 | 5469 | g_test_add ("/contact-lists/properties", | ||
2652 | 5470 | Test, NULL, setup, test_properties, teardown); | ||
2653 | 5471 | g_test_add ("/contact-lists/contacts", | ||
2654 | 5472 | Test, NULL, setup, test_contacts, teardown); | ||
2655 | 5473 | g_test_add ("/contact-lists/contact-list-attrs", | ||
2656 | 5474 | Test, NULL, setup, test_contact_list_attrs, teardown); | ||
2657 | 5475 | |||
2658 | 5476 | g_test_add ("/contact-lists/accept-publish-request", | ||
2659 | 5477 | Test, NULL, setup, test_accept_publish_request, teardown); | ||
2660 | 5478 | g_test_add ("/contact-lists/reject-publish-request", | ||
2661 | 5479 | Test, NULL, setup, test_reject_publish_request, teardown); | ||
2662 | 5480 | g_test_add ("/contact-lists/reject-publish-request/unpublish", | ||
2663 | 5481 | Test, "unpublish", setup, test_reject_publish_request, teardown); | ||
2664 | 5482 | g_test_add ("/contact-lists/add-to-publish/pre-approve", | ||
2665 | 5483 | Test, NULL, setup, test_add_to_publish_pre_approve, teardown); | ||
2666 | 5484 | g_test_add ("/contact-lists/add-to-publish/no-op", | ||
2667 | 5485 | Test, NULL, setup, test_add_to_publish_no_op, teardown); | ||
2668 | 5486 | g_test_add ("/contact-lists/remove-from-publish", | ||
2669 | 5487 | Test, NULL, setup, test_remove_from_publish, teardown); | ||
2670 | 5488 | g_test_add ("/contact-lists/remove-from-publish/no-op", | ||
2671 | 5489 | Test, NULL, setup, test_remove_from_publish_no_op, teardown); | ||
2672 | 5490 | |||
2673 | 5491 | g_test_add ("/contact-lists/accept-publish-request/old", | ||
2674 | 5492 | Test, "old", setup, test_accept_publish_request, teardown); | ||
2675 | 5493 | g_test_add ("/contact-lists/reject-publish-request/old", | ||
2676 | 5494 | Test, "old", setup, test_reject_publish_request, teardown); | ||
2677 | 5495 | g_test_add ("/contact-lists/add-to-publish/pre-approve/old", | ||
2678 | 5496 | Test, "old", setup, test_add_to_publish_pre_approve, teardown); | ||
2679 | 5497 | g_test_add ("/contact-lists/add-to-publish/no-op/old", | ||
2680 | 5498 | Test, "old", setup, test_add_to_publish_no_op, teardown); | ||
2681 | 5499 | g_test_add ("/contact-lists/remove-from-publish/old", | ||
2682 | 5500 | Test, "old", setup, test_remove_from_publish, teardown); | ||
2683 | 5501 | g_test_add ("/contact-lists/remove-from-publish/no-op/old", | ||
2684 | 5502 | Test, "old", setup, test_remove_from_publish_no_op, teardown); | ||
2685 | 5503 | |||
2686 | 5504 | g_test_add ("/contact-lists/cancelled-publish-request", | ||
2687 | 5505 | Test, NULL, setup, test_cancelled_publish_request, teardown); | ||
2688 | 5506 | g_test_add ("/contact-lists/cancelled-publish-request", | ||
2689 | 5507 | Test, "remove-after", setup, test_cancelled_publish_request, teardown); | ||
2690 | 5508 | |||
2691 | 5509 | g_test_add ("/contact-lists/add-to-stored", | ||
2692 | 5510 | Test, NULL, setup, test_add_to_stored, teardown); | ||
2693 | 5511 | g_test_add ("/contact-lists/add-to-stored/no-op", | ||
2694 | 5512 | Test, NULL, setup, test_add_to_stored_no_op, teardown); | ||
2695 | 5513 | g_test_add ("/contact-lists/remove-from-stored", | ||
2696 | 5514 | Test, NULL, setup, test_remove_from_stored, teardown); | ||
2697 | 5515 | g_test_add ("/contact-lists/remove-from-stored/no-op", | ||
2698 | 5516 | Test, NULL, setup, test_remove_from_stored_no_op, teardown); | ||
2699 | 5517 | |||
2700 | 5518 | g_test_add ("/contact-lists/add-to-stored/old", | ||
2701 | 5519 | Test, "old", setup, test_add_to_stored, teardown); | ||
2702 | 5520 | g_test_add ("/contact-lists/add-to-stored/no-op/old", | ||
2703 | 5521 | Test, "old", setup, test_add_to_stored_no_op, teardown); | ||
2704 | 5522 | g_test_add ("/contact-lists/remove-from-stored/old", | ||
2705 | 5523 | Test, "old", setup, test_remove_from_stored, teardown); | ||
2706 | 5524 | g_test_add ("/contact-lists/remove-from-stored/no-op/old", | ||
2707 | 5525 | Test, "old", setup, test_remove_from_stored_no_op, teardown); | ||
2708 | 5526 | |||
2709 | 5527 | g_test_add ("/contact-lists/accept-subscribe-request", | ||
2710 | 5528 | Test, NULL, setup, test_accept_subscribe_request, teardown); | ||
2711 | 5529 | g_test_add ("/contact-lists/reject-subscribe-request", | ||
2712 | 5530 | Test, NULL, setup, test_reject_subscribe_request, teardown); | ||
2713 | 5531 | g_test_add ("/contact-lists/remove-from-subscribe", | ||
2714 | 5532 | Test, NULL, setup, test_remove_from_subscribe, teardown); | ||
2715 | 5533 | g_test_add ("/contact-lists/remove-from-subscribe/pending", | ||
2716 | 5534 | Test, NULL, setup, test_remove_from_subscribe_pending, teardown); | ||
2717 | 5535 | g_test_add ("/contact-lists/remove-from-subscribe/no-op", | ||
2718 | 5536 | Test, NULL, setup, test_remove_from_subscribe_no_op, teardown); | ||
2719 | 5537 | |||
2720 | 5538 | g_test_add ("/contact-lists/accept-subscribe-request/old", | ||
2721 | 5539 | Test, "old", setup, test_accept_subscribe_request, teardown); | ||
2722 | 5540 | g_test_add ("/contact-lists/reject-subscribe-request/old", | ||
2723 | 5541 | Test, "old", setup, test_reject_subscribe_request, teardown); | ||
2724 | 5542 | g_test_add ("/contact-lists/remove-from-subscribe/old", | ||
2725 | 5543 | Test, "old", setup, test_remove_from_subscribe, teardown); | ||
2726 | 5544 | g_test_add ("/contact-lists/remove-from-subscribe/pending/old", | ||
2727 | 5545 | Test, "old", setup, test_remove_from_subscribe_pending, teardown); | ||
2728 | 5546 | g_test_add ("/contact-lists/remove-from-subscribe/no-op/old", | ||
2729 | 5547 | Test, "old", setup, test_remove_from_subscribe_no_op, teardown); | ||
2730 | 5548 | |||
2731 | 5549 | g_test_add ("/contact-lists/reject-subscribe-request/remove-after", | ||
2732 | 5550 | Test, "remove-after", setup, test_reject_subscribe_request, teardown); | ||
2733 | 5551 | |||
2734 | 5552 | g_test_add ("/contact-lists/add-to-group", | ||
2735 | 5553 | Test, NULL, setup, test_add_to_group, teardown); | ||
2736 | 5554 | g_test_add ("/contact-lists/add-to-group/no-op", | ||
2737 | 5555 | Test, NULL, setup, test_add_to_group_no_op, teardown); | ||
2738 | 5556 | g_test_add ("/contact-lists/remove-from-group", | ||
2739 | 5557 | Test, NULL, setup, test_remove_from_group, teardown); | ||
2740 | 5558 | g_test_add ("/contact-lists/remove-from-group/no-op", | ||
2741 | 5559 | Test, NULL, setup, test_remove_from_group_no_op, teardown); | ||
2742 | 5560 | g_test_add ("/contact-lists/remove-group", | ||
2743 | 5561 | Test, NULL, setup, test_remove_group, teardown); | ||
2744 | 5562 | g_test_add ("/contact-lists/remove-group/empty", | ||
2745 | 5563 | Test, NULL, setup, test_remove_group_empty, teardown); | ||
2746 | 5564 | |||
2747 | 5565 | g_test_add ("/contact-lists/add-to-group/old", | ||
2748 | 5566 | Test, "old", setup, test_add_to_group, teardown); | ||
2749 | 5567 | g_test_add ("/contact-lists/add-to-group/no-op/old", | ||
2750 | 5568 | Test, "old", setup, test_add_to_group_no_op, teardown); | ||
2751 | 5569 | g_test_add ("/contact-lists/remove-from-group/old", | ||
2752 | 5570 | Test, "old", setup, test_remove_from_group, teardown); | ||
2753 | 5571 | g_test_add ("/contact-lists/remove-from-group/no-op/old", | ||
2754 | 5572 | Test, "old", setup, test_remove_from_group_no_op, teardown); | ||
2755 | 5573 | g_test_add ("/contact-lists/remove-group/old", | ||
2756 | 5574 | Test, "old", setup, test_remove_group, teardown); | ||
2757 | 5575 | g_test_add ("/contact-lists/remove-group/empty/old", | ||
2758 | 5576 | Test, "old", setup, test_remove_group_empty, teardown); | ||
2759 | 5577 | |||
2760 | 5578 | g_test_add ("/contact-lists/set_contact_groups", | ||
2761 | 5579 | Test, NULL, setup, test_set_contact_groups, teardown); | ||
2762 | 5580 | g_test_add ("/contact-lists/set_contact_groups/no-op", | ||
2763 | 5581 | Test, NULL, setup, test_set_contact_groups_no_op, teardown); | ||
2764 | 5582 | g_test_add ("/contact-lists/set_group_members", | ||
2765 | 5583 | Test, NULL, setup, test_set_group_members, teardown); | ||
2766 | 5584 | |||
2767 | 5585 | g_test_add ("/contact-lists/rename_group", | ||
2768 | 5586 | Test, NULL, setup, test_rename_group, teardown); | ||
2769 | 5587 | g_test_add ("/contact-lists/rename_group/absent", | ||
2770 | 5588 | Test, NULL, setup, test_rename_group_absent, teardown); | ||
2771 | 5589 | g_test_add ("/contact-lists/rename_group/overwrite", | ||
2772 | 5590 | Test, NULL, setup, test_rename_group_overwrite, teardown); | ||
2773 | 5591 | |||
2774 | 5592 | g_test_add ("/contact-lists/add-to-deny", | ||
2775 | 5593 | Test, NULL, setup, test_add_to_deny, teardown); | ||
2776 | 5594 | g_test_add ("/contact-lists/add-to-deny/no-op", | ||
2777 | 5595 | Test, NULL, setup, test_add_to_deny_no_op, teardown); | ||
2778 | 5596 | g_test_add ("/contact-lists/remove-from-deny", | ||
2779 | 5597 | Test, NULL, setup, test_remove_from_deny, teardown); | ||
2780 | 5598 | g_test_add ("/contact-lists/remove-from-deny/no-op", | ||
2781 | 5599 | Test, NULL, setup, test_remove_from_deny_no_op, teardown); | ||
2782 | 5600 | |||
2783 | 5601 | g_test_add ("/contact-lists/request-blocked-contacts", | ||
2784 | 5602 | Test, NULL, setup, test_request_blocked_contacts, teardown); | ||
2785 | 5603 | g_test_add ("/contact-lists/request-blocked-contacts-before-connect", | ||
2786 | 5604 | Test, NULL, setup_pre_connect, | ||
2787 | 5605 | test_request_blocked_contacts_pre_connect, teardown_pre_connect); | ||
2788 | 5606 | g_test_add ("/contact-lists/request-blocked-contacts-connect-failed", | ||
2789 | 5607 | Test, "break-account-parameter", setup_pre_connect, | ||
2790 | 5608 | test_request_blocked_contacts_connect_failed, | ||
2791 | 5609 | teardown_pre_connect); | ||
2792 | 5610 | g_test_add ("/contact-lists/block-contacts", | ||
2793 | 5611 | Test, NULL, setup, test_block_contacts, teardown); | ||
2794 | 5612 | g_test_add ("/contact-lists/block-contacts/no-op", | ||
2795 | 5613 | Test, NULL, setup, test_block_contacts_no_op, teardown); | ||
2796 | 5614 | g_test_add ("/contact-lists/unblock-contacts", | ||
2797 | 5615 | Test, NULL, setup, test_unblock_contacts, teardown); | ||
2798 | 5616 | g_test_add ("/contact-lists/unblock-contacts/no-op", | ||
2799 | 5617 | Test, NULL, setup, test_unblock_contacts_no_op, teardown); | ||
2800 | 5618 | |||
2801 | 5619 | return g_test_run (); | ||
2802 | 5620 | } | ||
2803 | 5621 | >>>>>>> MERGE-SOURCE |