| 234 g_signal_connect(person, "notify::priority-contact", |
234 g_signal_connect(person, "notify::priority-contact", |
| 235 G_CALLBACK(test_purple_person_notify_cb), &called); |
235 G_CALLBACK(test_purple_person_notify_cb), &called); |
| 236 priority = purple_person_get_priority_contact(person); |
236 priority = purple_person_get_priority_contact(person); |
| 237 g_assert_null(priority); |
237 g_assert_null(priority); |
| 238 |
238 |
| 239 /* Build the presence and status for the contact. */ |
239 /* Now create a real contact. */ |
| 240 presence = g_object_new(PURPLE_TYPE_PRESENCE, NULL); |
240 contact = purple_contact_new(account, "username"); |
| |
241 purple_person_add_contact(person, contact); |
| |
242 |
| |
243 /* Set the status of the contact. */ |
| |
244 presence = purple_contact_get_presence(contact); |
| 241 status_type = purple_status_type_new(PURPLE_STATUS_AVAILABLE, "available", |
245 status_type = purple_status_type_new(PURPLE_STATUS_AVAILABLE, "available", |
| 242 "Available", FALSE); |
246 "Available", FALSE); |
| 243 status = purple_status_new(status_type, presence); |
247 status = purple_status_new(status_type, presence); |
| 244 g_object_set(G_OBJECT(presence), "active-status", status, NULL); |
248 g_object_set(G_OBJECT(presence), "active-status", status, NULL); |
| 245 g_clear_object(&status); |
249 g_clear_object(&status); |
| 246 |
|
| 247 /* Now create a real contact. */ |
|
| 248 contact = purple_contact_new(account, "username"); |
|
| 249 purple_contact_set_presence(contact, presence); |
|
| 250 purple_person_add_contact(person, contact); |
|
| 251 |
250 |
| 252 g_assert_true(called); |
251 g_assert_true(called); |
| 253 |
252 |
| 254 priority = purple_person_get_priority_contact(person); |
253 priority = purple_person_get_priority_contact(person); |
| 255 g_assert_true(priority == contact); |
254 g_assert_true(priority == contact); |
| 307 gchar *username = NULL; |
306 gchar *username = NULL; |
| 308 |
307 |
| 309 /* Set changed to false as it shouldn't be changed. */ |
308 /* Set changed to false as it shouldn't be changed. */ |
| 310 changed = FALSE; |
309 changed = FALSE; |
| 311 |
310 |
| 312 /* Build the presence and status for the contact. */ |
|
| 313 presence = g_object_new(PURPLE_TYPE_PRESENCE, NULL); |
|
| 314 status = purple_status_new(offline, presence); |
|
| 315 g_object_set(G_OBJECT(presence), "active-status", status, NULL); |
|
| 316 g_clear_object(&status); |
|
| 317 |
|
| 318 /* Now create a real contact. */ |
311 /* Now create a real contact. */ |
| 319 username = g_strdup_printf("username%d", i + 1); |
312 username = g_strdup_printf("username%d", i + 1); |
| 320 contact = purple_contact_new(account, username); |
313 contact = purple_contact_new(account, username); |
| 321 g_free(username); |
314 g_free(username); |
| 322 purple_contact_set_presence(contact, presence); |
315 |
| |
316 /* Set the status for the contact. */ |
| |
317 presence = purple_contact_get_presence(contact); |
| |
318 status = purple_status_new(offline, presence); |
| |
319 g_object_set(G_OBJECT(presence), "active-status", status, NULL); |
| |
320 g_clear_object(&status); |
| 323 |
321 |
| 324 purple_person_add_contact(person, contact); |
322 purple_person_add_contact(person, contact); |
| 325 |
323 |
| 326 if(i == 0) { |
324 if(i == 0) { |
| 327 first = g_object_ref(contact); |
325 first = g_object_ref(contact); |
| 334 sorted_presence = g_object_ref(presence); |
332 sorted_presence = g_object_ref(presence); |
| 335 } |
333 } |
| 336 } |
334 } |
| 337 |
335 |
| 338 g_clear_object(&contact); |
336 g_clear_object(&contact); |
| 339 g_clear_object(&presence); |
|
| 340 } |
337 } |
| 341 |
338 |
| 342 n_items = g_list_model_get_n_items(G_LIST_MODEL(person)); |
339 n_items = g_list_model_get_n_items(G_LIST_MODEL(person)); |
| 343 g_assert_cmpuint(n_items, ==, n_contacts); |
340 g_assert_cmpuint(n_items, ==, n_contacts); |
| 344 |
341 |