libpurple/tests/test_notification_manager.c

changeset 43004
06521648500e
parent 42988
c2357ee36551
child 43265
7960b5f85729
equal deleted inserted replaced
43003:7b54f6fa1e6a 43004:06521648500e
238 g_assert_finalize_object(accounts[2]); 238 g_assert_finalize_object(accounts[2]);
239 } 239 }
240 240
241 static void 241 static void
242 test_purple_notification_manager_remove_with_account_all(void) { 242 test_purple_notification_manager_remove_with_account_all(void) {
243 PurpleConnectionErrorInfo *info = NULL;
244 PurpleNotificationManager *manager = NULL;
245 PurpleNotification *notification = NULL;
246 PurpleAccount *account = NULL; 243 PurpleAccount *account = NULL;
244 PurpleNotificationManager *manager = NULL;
245 PurpleNotification *notification = NULL;
246 GError *error = NULL;
247 GListModel *model = NULL; 247 GListModel *model = NULL;
248 248
249 /* This test will add 3 notifications to the notification manager for the 249 /* This test will add 3 notifications to the notification manager for the
250 * same account. In order, they will be of types generic, connection error, 250 * same account. In order, they will be of types generic, connection error,
251 * and generic. We will also add a generic notification with no account, to 251 * and generic. We will also add a generic notification with no account, to
280 purple_notification_set_account(notification, account); 280 purple_notification_set_account(notification, account);
281 purple_notification_manager_add(manager, notification); 281 purple_notification_manager_add(manager, notification);
282 g_clear_object(&notification); 282 g_clear_object(&notification);
283 283
284 /* Add a connection error notification with the account. */ 284 /* Add a connection error notification with the account. */
285 info = purple_connection_error_info_new(PURPLE_CONNECTION_ERROR_NETWORK_ERROR, 285 error = g_error_new_literal(PURPLE_CONNECTION_ERROR,
286 "the network is borked."); 286 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
287 notification = purple_notification_connection_error_new(NULL, account, 287 "the network is borked.");
288 info); 288 purple_account_set_error(account, error);
289 purple_connection_error_info_free(info); 289 notification = purple_notification_connection_error_new(NULL, account);
290 purple_notification_manager_add(manager, notification); 290 purple_notification_manager_add(manager, notification);
291 g_clear_object(&notification); 291 g_clear_object(&notification);
292 292
293 /* Add a generic notification with the account. */ 293 /* Add a generic notification with the account. */
294 notification = purple_notification_new(NULL, NULL); 294 notification = purple_notification_new(NULL, NULL);
318 g_assert_cmpuint(g_list_model_get_n_items(model), ==, 1); 318 g_assert_cmpuint(g_list_model_get_n_items(model), ==, 1);
319 319
320 /* Remove the generic notification that's not tied to an account. */ 320 /* Remove the generic notification that's not tied to an account. */
321 purple_notification_manager_clear(manager); 321 purple_notification_manager_clear(manager);
322 g_assert_cmpuint(g_list_model_get_n_items(model), ==, 0); 322 g_assert_cmpuint(g_list_model_get_n_items(model), ==, 0);
323
324 /* We have a reference cycle between the account and its error
325 * notification. The dispose method does not get called in this case. So to
326 * break the stalemate, we just set the error to NULL.
327 */
328 purple_account_set_error(account, NULL);
323 329
324 g_assert_finalize_object(manager); 330 g_assert_finalize_object(manager);
325 g_assert_finalize_object(account); 331 g_assert_finalize_object(account);
326 } 332 }
327 333

mercurial