Use GTask.report_new_error in Purple.ProtocolConversation

Thu, 25 Jul 2024 20:53:42 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 25 Jul 2024 20:53:42 -0500
changeset 42818
d8b4ef0aa09d
parent 42817
2973a9b3d225
child 42819
56553d1b795a

Use GTask.report_new_error in Purple.ProtocolConversation

Also remove the "empty" `_finish` tests as they don't really make sense now.

Also fixed a few bugs along the way.

Testing Done:
Ran the turtles and ran the `protocol_conversation` tests under valgrind.

Reviewed at https://reviews.imfreedom.org/r/3297/

libpurple/purpleprotocolconversation.c file | annotate | diff | comparison | revisions
libpurple/tests/test_protocol_conversation.c file | annotate | diff | comparison | revisions
--- a/libpurple/purpleprotocolconversation.c	Tue Jul 23 01:03:57 2024 -0500
+++ b/libpurple/purpleprotocolconversation.c	Thu Jul 25 20:53:42 2024 -0500
@@ -101,19 +101,11 @@
 		iface->create_conversation_async(protocol, account, details,
 		                                 cancellable, callback, data);
 	} else {
-		GTask *task = NULL;
-
-		task = g_task_new(protocol, cancellable, callback, data);
-		g_task_return_new_error(task, PURPLE_PROTOCOL_CONVERSATION_DOMAIN, 0,
+		g_task_report_new_error(G_OBJECT(protocol), callback, data,
+		                        purple_protocol_conversation_create_conversation_async,
+		                        PURPLE_PROTOCOL_CONVERSATION_DOMAIN, 0,
 		                        "%s does not implement create_conversation_async",
 		                        G_OBJECT_TYPE_NAME(protocol));
-		g_task_set_source_tag(task,
-		                      purple_protocol_conversation_create_conversation_async);
-
-		/* details is transfer full and has already been null checked. */
-		g_object_unref(details);
-
-		g_clear_object(&task);
 	}
 }
 
@@ -127,25 +119,22 @@
 	g_return_val_if_fail(PURPLE_IS_PROTOCOL_CONVERSATION(protocol), FALSE);
 	g_return_val_if_fail(G_IS_ASYNC_RESULT(result), FALSE);
 
+	if(g_async_result_is_tagged(result,
+	                            purple_protocol_conversation_create_conversation_async))
+	{
+		return g_task_propagate_pointer(G_TASK(result), error);
+	}
+
 	iface = PURPLE_PROTOCOL_CONVERSATION_GET_IFACE(protocol);
 	if(iface != NULL && iface->create_conversation_finish != NULL) {
 		return iface->create_conversation_finish(protocol, result, error);
 	}
 
-	if(G_IS_TASK(result)) {
-		GTask *task = G_TASK(result);
-		gpointer source = NULL;
+	g_warning("purple_protocol_conversation_create_conversation_finish called "
+	          "without calling "
+	          "purple_protocol_conversation_create_conversation_async");
 
-		source = g_task_get_source_tag(task);
-		if(source == purple_protocol_conversation_create_conversation_async) {
-			return g_task_propagate_pointer(task, error);
-		} else {
-			g_warning("%s does not implement create_conversation_finish",
-			          G_OBJECT_TYPE_NAME(protocol));
-		}
-	}
-
-	return FALSE;
+	return NULL;
 }
 
 gboolean
@@ -187,16 +176,11 @@
 		iface->leave_conversation_async(protocol, conversation, cancellable,
 		                                callback, data);
 	} else {
-		GTask *task = NULL;
-
-		task = g_task_new(protocol, cancellable, callback, data);
-		g_task_return_new_error(task, PURPLE_PROTOCOL_CONVERSATION_DOMAIN, 0,
+		g_task_report_new_error(G_OBJECT(protocol), callback, data,
+		                        purple_protocol_conversation_leave_conversation_async,
+		                        PURPLE_PROTOCOL_CONVERSATION_DOMAIN, 0,
 		                        "%s does not implement leave_conversation_async",
 		                        G_OBJECT_TYPE_NAME(protocol));
-		g_task_set_source_tag(task,
-		                      purple_protocol_conversation_leave_conversation_async);
-
-		g_clear_object(&task);
 	}
 }
 
@@ -210,23 +194,21 @@
 	g_return_val_if_fail(PURPLE_IS_PROTOCOL_CONVERSATION(protocol), FALSE);
 	g_return_val_if_fail(G_IS_ASYNC_RESULT(result), FALSE);
 
+	if(g_async_result_is_tagged(result,
+	                            purple_protocol_conversation_leave_conversation_async))
+	{
+		return g_task_propagate_boolean(G_TASK(result), error);
+	}
+
 	iface = PURPLE_PROTOCOL_CONVERSATION_GET_IFACE(protocol);
 	if(iface != NULL && iface->leave_conversation_finish != NULL) {
 		return iface->leave_conversation_finish(protocol, result, error);
 	}
 
-	if(G_IS_TASK(result)) {
-		GTask *task = G_TASK(result);
-		gpointer source = NULL;
+	g_warning("purple_protocol_conversation_leave_conversation_finish called "
+	          "without calling "
+	          "purple_protocol_conversation_set_avatar_async");
 
-		source = g_task_get_source_tag(task);
-		if(source == purple_protocol_conversation_leave_conversation_async) {
-			return g_task_propagate_boolean(task, error);
-		} else {
-			g_warning("%s does not implement leave_conversation_finish",
-			          G_OBJECT_TYPE_NAME(protocol));
-		}
-	}
 
 	return FALSE;
 }
@@ -250,8 +232,11 @@
 		iface->send_message_async(protocol, conversation, message, cancellable,
 		                          callback, data);
 	} else {
-		g_warning("%s does not implement send_message_async",
-		          G_OBJECT_TYPE_NAME(protocol));
+		g_task_report_new_error(G_OBJECT(protocol), callback, data,
+		                        purple_protocol_conversation_send_message_async,
+		                        PURPLE_PROTOCOL_CONVERSATION_DOMAIN, 0,
+		                        "%s does not implement send_message_async",
+		                        G_OBJECT_TYPE_NAME(protocol));
 	}
 }
 
@@ -265,13 +250,21 @@
 	g_return_val_if_fail(PURPLE_IS_PROTOCOL_CONVERSATION(protocol), FALSE);
 	g_return_val_if_fail(G_IS_ASYNC_RESULT(result), FALSE);
 
+	if(g_async_result_is_tagged(result,
+	                            purple_protocol_conversation_send_message_async))
+	{
+		return g_task_propagate_boolean(G_TASK(result), error);
+	}
+
 	iface = PURPLE_PROTOCOL_CONVERSATION_GET_IFACE(protocol);
 	if(iface != NULL && iface->send_message_finish != NULL) {
 		return iface->send_message_finish(protocol, result, error);
 	}
 
-	g_warning("%s does not implement send_message_finish",
-	          G_OBJECT_TYPE_NAME(protocol));
+	g_warning("purple_protocol_conversation_send_message_finish called "
+	          "without calling "
+	          "purple_protocol_conversation_send_message_async");
+
 
 	return FALSE;
 }
@@ -294,8 +287,11 @@
 		iface->set_topic_async(protocol, conversation, topic, cancellable,
 		                       callback, data);
 	} else {
-		g_warning("%s does not implement set_topic_async",
-		          G_OBJECT_TYPE_NAME(protocol));
+		g_task_report_new_error(G_OBJECT(protocol), callback, data,
+		                        purple_protocol_conversation_set_topic_async,
+		                        PURPLE_PROTOCOL_CONVERSATION_DOMAIN, 0,
+		                        "%s does not implement set_topic_async",
+		                        G_OBJECT_TYPE_NAME(protocol));
 	}
 }
 
@@ -309,14 +305,20 @@
 	g_return_val_if_fail(PURPLE_IS_PROTOCOL_CONVERSATION(protocol), FALSE);
 	g_return_val_if_fail(G_IS_ASYNC_RESULT(result), FALSE);
 
+	if(g_async_result_is_tagged(result,
+	                            purple_protocol_conversation_set_topic_async))
+	{
+		return g_task_propagate_boolean(G_TASK(result), error);
+	}
+
 	iface = PURPLE_PROTOCOL_CONVERSATION_GET_IFACE(protocol);
 	if(iface != NULL && iface->set_topic_finish != NULL) {
 		return iface->set_topic_finish(protocol, result, error);
-	} else {
-		g_warning("%s does not implement set_topic_finish",
-		          G_OBJECT_TYPE_NAME(protocol));
 	}
 
+	g_warning("purple_protocol_conversation_set_topic_finish called without "
+	          "calling purple_protocol_conversation_set_topic_async");
+
 	return FALSE;
 }
 
@@ -359,8 +361,11 @@
 		iface->join_channel_async(protocol, account, details, cancellable,
 		                          callback, data);
 	} else {
-		g_warning("%s does not implement join_channel_async",
-		          G_OBJECT_TYPE_NAME(protocol));
+		g_task_report_new_error(G_OBJECT(protocol), callback, data,
+		                        purple_protocol_conversation_join_channel_async,
+		                        PURPLE_PROTOCOL_CONVERSATION_DOMAIN, 0,
+		                        "%s does not implement join_channel_async",
+		                        G_OBJECT_TYPE_NAME(protocol));
 	}
 }
 
@@ -374,13 +379,20 @@
 	g_return_val_if_fail(PURPLE_IS_PROTOCOL_CONVERSATION(protocol), FALSE);
 	g_return_val_if_fail(G_IS_ASYNC_RESULT(result), FALSE);
 
+	if(g_async_result_is_tagged(result,
+	                            purple_protocol_conversation_join_channel_async))
+	{
+		return g_task_propagate_boolean(G_TASK(result), error);
+	}
+
 	iface = PURPLE_PROTOCOL_CONVERSATION_GET_IFACE(protocol);
 	if(iface != NULL && iface->join_channel_finish != NULL) {
 		return iface->join_channel_finish(protocol, result, error);
 	}
 
-	g_warning("%s does not implement join_channel_finish",
-	          G_OBJECT_TYPE_NAME(protocol));
+	g_warning("purple_protocol_conversation_join_channel_finish called "
+	          "without calling "
+	          "purple_protocol_conversation_join_channel_async");
 
 	return FALSE;
 }
@@ -403,8 +415,11 @@
 		iface->set_avatar_async(protocol, conversation, avatar, cancellable,
 		                        callback, data);
 	} else {
-		g_warning("%s does not implement set_avatar_async",
-		          G_OBJECT_TYPE_NAME(protocol));
+		g_task_report_new_error(G_OBJECT(protocol), callback, data,
+		                        purple_protocol_conversation_set_avatar_async,
+		                        PURPLE_PROTOCOL_CONVERSATION_DOMAIN, 0,
+		                        "%s does not implement set_avatar_async",
+		                        G_OBJECT_TYPE_NAME(protocol));
 	}
 }
 
@@ -418,13 +433,19 @@
 	g_return_val_if_fail(PURPLE_IS_PROTOCOL_CONVERSATION(protocol), FALSE);
 	g_return_val_if_fail(G_IS_ASYNC_RESULT(result), FALSE);
 
+	if(g_async_result_is_tagged(result,
+	                            purple_protocol_conversation_set_avatar_async))
+	{
+		return g_task_propagate_boolean(G_TASK(result), error);
+	}
+
 	iface = PURPLE_PROTOCOL_CONVERSATION_GET_IFACE(protocol);
 	if(iface != NULL && iface->set_avatar_finish != NULL) {
 		return iface->set_avatar_finish(protocol, result, error);
 	}
 
-	g_warning("%s does not implement set_avatar_finish",
-	          G_OBJECT_TYPE_NAME(protocol));
+	g_warning("purple_protocol_conversation_set_avatar_finish called without "
+	          "calling purple_protocol_conversation_set_avatar_async");
 
 	return FALSE;
 }
--- a/libpurple/tests/test_protocol_conversation.c	Tue Jul 23 01:03:57 2024 -0500
+++ b/libpurple/tests/test_protocol_conversation.c	Thu Jul 25 20:53:42 2024 -0500
@@ -159,36 +159,10 @@
 	g_main_context_iteration(NULL, FALSE);
 
 	g_assert_finalize_object(account);
+	g_assert_finalize_object(details);
 	g_assert_finalize_object(protocol);
 }
 
-static void
-test_purple_protocol_conversation_empty_create_conversation_finish(void) {
-	if(g_test_subprocess()) {
-		PurpleProtocolConversation *protocol = NULL;
-		PurpleConversation *conversation = NULL;
-		GError *error = NULL;
-		GTask *task = NULL;
-
-		protocol = g_object_new(test_purple_protocol_conversation_empty_get_type(),
-		                        NULL);
-
-		task = g_task_new(protocol, NULL, NULL, NULL);
-
-		conversation = purple_protocol_conversation_create_conversation_finish(protocol,
-		                                                                       G_ASYNC_RESULT(task),
-		                                                                       &error);
-		g_assert_no_error(error);
-		g_assert_null(conversation);
-
-		g_assert_finalize_object(task);
-		g_assert_finalize_object(protocol);
-	}
-
-	g_test_trap_subprocess(NULL, 0, 0);
-	g_test_trap_assert_stderr("*Purple-WARNING*TestPurpleProtocolConversationEmpty*create_conversation_finish*");
-}
-
 /******************************************************************************
  * Empty Leave Conversation Tests
  *****************************************************************************/
@@ -238,145 +212,96 @@
 }
 
 static void
-test_purple_protocol_conversation_empty_leave_conversation_finish(void) {
-	if(g_test_subprocess()) {
-		PurpleProtocolConversation *protocol = NULL;
-		GError *error = NULL;
-		GTask *task = NULL;
-		gboolean left = FALSE;
-
-		protocol = g_object_new(test_purple_protocol_conversation_empty_get_type(),
-		                        NULL);
-
-		task = g_task_new(protocol, NULL, NULL, NULL);
+test_purple_protocol_conversation_empty_send_message_cb(GObject *source,
+                                                        GAsyncResult *result,
+                                                        G_GNUC_UNUSED gpointer data)
+{
+	PurpleProtocolConversation *protocol = NULL;
+	GError *error = NULL;
+	gboolean sent = FALSE;
 
-		left = purple_protocol_conversation_leave_conversation_finish(protocol,
-		                                                              G_ASYNC_RESULT(task),
-		                                                              &error);
-		g_assert_no_error(error);
-		g_assert_false(left);
+	protocol = PURPLE_PROTOCOL_CONVERSATION(source);
+	sent = purple_protocol_conversation_send_message_finish(protocol, result,
+	                                                        &error);
 
-		g_assert_finalize_object(task);
-		g_assert_finalize_object(protocol);
-	}
-
-	g_test_trap_subprocess(NULL, 0, 0);
-	g_test_trap_assert_stderr("*Purple-WARNING*TestPurpleProtocolConversationEmpty*leave_conversation_finish*");
+	g_assert_error(error, PURPLE_PROTOCOL_CONVERSATION_DOMAIN, 0);
+	g_clear_error(&error);
+	g_assert_false(sent);
 }
 
 static void
 test_purple_protocol_conversation_empty_send_message_async(void) {
-	if(g_test_subprocess()) {
-		PurpleAccount *account = NULL;
-		PurpleConversation *conversation = NULL;
-		PurpleMessage *message = NULL;
-		PurpleProtocolConversation *protocol = NULL;
+	PurpleAccount *account = NULL;
+	PurpleConversation *conversation = NULL;
+	PurpleMessage *message = NULL;
+	PurpleProtocolConversation *protocol = NULL;
 
-		protocol = g_object_new(test_purple_protocol_conversation_empty_get_type(),
-		                        NULL);
-		account = purple_account_new("test", "test");
-		conversation = g_object_new(
-			PURPLE_TYPE_CONVERSATION,
-			"account", account,
-			"type", PURPLE_CONVERSATION_TYPE_DM,
-			NULL);
-		message = g_object_new(PURPLE_TYPE_MESSAGE, NULL);
+	protocol = g_object_new(test_purple_protocol_conversation_empty_get_type(),
+	                        NULL);
+	account = purple_account_new("test", "test");
+	conversation = g_object_new(
+		PURPLE_TYPE_CONVERSATION,
+		"account", account,
+		"type", PURPLE_CONVERSATION_TYPE_DM,
+		NULL);
+	message = g_object_new(PURPLE_TYPE_MESSAGE, NULL);
 
-		purple_protocol_conversation_send_message_async(protocol, conversation,
-		                                                message, NULL, NULL,
-		                                                NULL);
+	purple_protocol_conversation_send_message_async(protocol, conversation,
+	                                                message, NULL,
+	                                                test_purple_protocol_conversation_empty_send_message_cb,
+	                                                NULL);
 
-		g_clear_object(&account);
-		g_clear_object(&conversation);
-		g_clear_object(&message);
-		g_clear_object(&protocol);
-	}
+	g_main_context_iteration(NULL, FALSE);
 
-	g_test_trap_subprocess(NULL, 0, 0);
-	g_test_trap_assert_stderr("*Purple-WARNING*TestPurpleProtocolConversationEmpty*send_message_async*");
+	g_clear_object(&account);
+	g_assert_finalize_object(conversation);
+	g_assert_finalize_object(message);
+	g_assert_finalize_object(protocol);
 }
 
 static void
-test_purple_protocol_conversation_empty_send_message_finish(void) {
-	if(g_test_subprocess()) {
-		PurpleProtocolConversation *protocol = NULL;
-		GError *error = NULL;
-		GTask *task = NULL;
-		gboolean result = FALSE;
-
-		protocol = g_object_new(test_purple_protocol_conversation_empty_get_type(),
-		                        NULL);
-
-		task = g_task_new(protocol, NULL, NULL, NULL);
+test_purple_protocol_conversation_empty_set_topic_cb(GObject *source,
+                                                     GAsyncResult *result,
+                                                     G_GNUC_UNUSED gpointer data)
+{
+	PurpleProtocolConversation *protocol = NULL;
+	GError *error = NULL;
+	gboolean set = FALSE;
 
-		result = purple_protocol_conversation_send_message_finish(protocol,
-		                                                          G_ASYNC_RESULT(task),
-		                                                          &error);
-		g_assert_no_error(error);
-		g_assert_false(result);
+	protocol = PURPLE_PROTOCOL_CONVERSATION(source);
+	set = purple_protocol_conversation_set_topic_finish(protocol, result,
+	                                                    &error);
 
-		g_clear_object(&task);
-		g_clear_object(&protocol);
-	}
-
-	g_test_trap_subprocess(NULL, 0, 0);
-	g_test_trap_assert_stderr("*Purple-WARNING*TestPurpleProtocolConversationEmpty*send_message_finish*");
+	g_assert_error(error, PURPLE_PROTOCOL_CONVERSATION_DOMAIN, 0);
+	g_clear_error(&error);
+	g_assert_false(set);
 }
 
 static void
 test_purple_protocol_conversation_empty_set_topic_async(void) {
-	if(g_test_subprocess()) {
-		PurpleAccount *account = NULL;
-		PurpleConversation *conversation = NULL;
-		PurpleProtocolConversation *protocol = NULL;
-
-		protocol = g_object_new(test_purple_protocol_conversation_empty_get_type(),
-		                        NULL);
-		account = purple_account_new("test", "test");
-		conversation = g_object_new(
-			PURPLE_TYPE_CONVERSATION,
-			"account", account,
-			"type", PURPLE_CONVERSATION_TYPE_DM,
-			NULL);
-
-		purple_protocol_conversation_set_topic_async(protocol, conversation,
-		                                             "what a topic!", NULL,
-		                                             NULL, NULL);
-
-		g_clear_object(&account);
-		g_clear_object(&conversation);
-		g_clear_object(&protocol);
-	}
+	PurpleAccount *account = NULL;
+	PurpleConversation *conversation = NULL;
+	PurpleProtocolConversation *protocol = NULL;
 
-	g_test_trap_subprocess(NULL, 0, 0);
-	g_test_trap_assert_stderr("*Purple-WARNING*TestPurpleProtocolConversationEmpty*set_topic_async*");
-}
-
-static void
-test_purple_protocol_conversation_empty_set_topic_finish(void) {
-	if(g_test_subprocess()) {
-		PurpleProtocolConversation *protocol = NULL;
-		GError *error = NULL;
-		GTask *task = NULL;
-		gboolean result = FALSE;
-
-		protocol = g_object_new(test_purple_protocol_conversation_empty_get_type(),
-		                        NULL);
+	protocol = g_object_new(test_purple_protocol_conversation_empty_get_type(),
+	                        NULL);
+	account = purple_account_new("test", "test");
+	conversation = g_object_new(
+		PURPLE_TYPE_CONVERSATION,
+		"account", account,
+		"type", PURPLE_CONVERSATION_TYPE_DM,
+		NULL);
 
-		task = g_task_new(protocol, NULL, NULL, NULL);
+	purple_protocol_conversation_set_topic_async(protocol, conversation,
+	                                             "what a topic!", NULL,
+	                                             test_purple_protocol_conversation_empty_set_topic_cb,
+	                                             NULL);
 
-		result = purple_protocol_conversation_set_topic_finish(protocol,
-		                                                       G_ASYNC_RESULT(task),
-		                                                       &error);
-		g_assert_no_error(error);
-		g_assert_false(result);
+	g_main_context_iteration(NULL, FALSE);
 
-		g_clear_object(&task);
-		g_clear_object(&protocol);
-	}
-
-	g_test_trap_subprocess(NULL, 0, 0);
-	g_test_trap_assert_stderr("*Purple-WARNING*TestPurpleProtocolConversationEmpty*set_topic_finish*");
+	g_clear_object(&account);
+	g_assert_finalize_object(conversation);
+	g_assert_finalize_object(protocol);
 }
 
 static void
@@ -404,110 +329,88 @@
 }
 
 static void
-test_purple_protocol_conversation_empty_join_channel_async(void) {
-	if(g_test_subprocess()) {
-		PurpleAccount *account = NULL;
-		PurpleChannelJoinDetails *details = NULL;
-		PurpleProtocolConversation *protocol = NULL;
-
-		protocol = g_object_new(test_purple_protocol_conversation_empty_get_type(),
-		                        NULL);
-		account = purple_account_new("test", "test");
-		details = purple_channel_join_details_new(0, FALSE, 0, FALSE, 0);
+test_purple_protocol_conversation_empty_join_channel_cb(GObject *source,
+                                                        GAsyncResult *result,
+                                                        G_GNUC_UNUSED gpointer data)
+{
+	PurpleProtocolConversation *protocol = NULL;
+	GError *error = NULL;
+	gboolean joined = FALSE;
 
-		purple_protocol_conversation_join_channel_async(protocol, account,
-		                                                details, NULL, NULL,
-		                                                NULL);
+	protocol = PURPLE_PROTOCOL_CONVERSATION(source);
+	joined = purple_protocol_conversation_join_channel_finish(protocol, result,
+	                                                          &error);
 
-		g_clear_object(&account);
-		g_clear_object(&details);
-		g_clear_object(&protocol);
-	}
-
-	g_test_trap_subprocess(NULL, 0, 0);
-	g_test_trap_assert_stderr("*Purple-WARNING*TestPurpleProtocolConversationEmpty*join_channel_async*");
+	g_assert_error(error, PURPLE_PROTOCOL_CONVERSATION_DOMAIN, 0);
+	g_clear_error(&error);
+	g_assert_false(joined);
 }
 
 static void
-test_purple_protocol_conversation_empty_join_channel_finish(void) {
-	if(g_test_subprocess()) {
-		PurpleProtocolConversation *protocol = NULL;
-		GError *error = NULL;
-		GTask *task = NULL;
-		gboolean result = FALSE;
+test_purple_protocol_conversation_empty_join_channel_async(void) {
+	PurpleAccount *account = NULL;
+	PurpleChannelJoinDetails *details = NULL;
+	PurpleProtocolConversation *protocol = NULL;
 
-		protocol = g_object_new(test_purple_protocol_conversation_empty_get_type(),
-		                        NULL);
+	protocol = g_object_new(test_purple_protocol_conversation_empty_get_type(),
+	                        NULL);
+	account = purple_account_new("test", "test");
+	details = purple_channel_join_details_new(0, FALSE, 0, FALSE, 0);
 
-		task = g_task_new(protocol, NULL, NULL, NULL);
+	purple_protocol_conversation_join_channel_async(protocol, account,
+	                                                details, NULL,
+	                                                test_purple_protocol_conversation_empty_join_channel_cb,
+	                                                NULL);
+
+	g_main_context_iteration(NULL, FALSE);
 
-		result = purple_protocol_conversation_join_channel_finish(protocol,
-		                                                          G_ASYNC_RESULT(task),
-		                                                          &error);
-		g_assert_no_error(error);
-		g_assert_false(result);
+	g_clear_object(&account);
+	g_assert_finalize_object(details);
+	g_assert_finalize_object(protocol);
+}
 
-		g_clear_object(&task);
-		g_clear_object(&protocol);
-	}
+static void
+test_purple_protocol_conversation_empty_set_avatar_cb(GObject *source,
+                                                      GAsyncResult *result,
+                                                      G_GNUC_UNUSED gpointer data)
+{
+	PurpleProtocolConversation *protocol = NULL;
+	GError *error = NULL;
+	gboolean set = FALSE;
 
-	g_test_trap_subprocess(NULL, 0, 0);
-	g_test_trap_assert_stderr("*Purple-WARNING*TestPurpleProtocolConversationEmpty*join_channel_finish*");
+	protocol = PURPLE_PROTOCOL_CONVERSATION(source);
+	set = purple_protocol_conversation_set_avatar_finish(protocol, result,
+	                                                     &error);
+	g_assert_error(error, PURPLE_PROTOCOL_CONVERSATION_DOMAIN, 0);
+	g_clear_error(&error);
+	g_assert_false(set);
 }
 
 static void
 test_purple_protocol_conversation_empty_set_avatar_async(void) {
-	if(g_test_subprocess()) {
-		PurpleAccount *account = NULL;
-		PurpleConversation *conversation = NULL;
-		PurpleProtocolConversation *protocol = NULL;
-
-		protocol = g_object_new(test_purple_protocol_conversation_empty_get_type(),
-		                        NULL);
-		account = purple_account_new("test", "test");
-		conversation = g_object_new(
-			PURPLE_TYPE_CONVERSATION,
-			"account", account,
-			"type", PURPLE_CONVERSATION_TYPE_DM,
-			NULL);
-
-		purple_protocol_conversation_set_avatar_async(protocol, conversation,
-		                                              NULL, NULL, NULL, NULL);
-
-		g_clear_object(&account);
-		g_clear_object(&conversation);
-		g_clear_object(&protocol);
-	}
-
-	g_test_trap_subprocess(NULL, 0, 0);
-	g_test_trap_assert_stderr("*Purple-WARNING*TestPurpleProtocolConversationEmpty*set_avatar_async*");
-}
+	PurpleAccount *account = NULL;
+	PurpleConversation *conversation = NULL;
+	PurpleProtocolConversation *protocol = NULL;
 
-static void
-test_purple_protocol_conversation_empty_set_avatar_finish(void) {
-	if(g_test_subprocess()) {
-		PurpleProtocolConversation *protocol = NULL;
-		GError *error = NULL;
-		GTask *task = NULL;
-		gboolean result = FALSE;
-
-		protocol = g_object_new(test_purple_protocol_conversation_empty_get_type(),
-		                        NULL);
-
-		task = g_task_new(protocol, NULL, NULL, NULL);
+	protocol = g_object_new(test_purple_protocol_conversation_empty_get_type(),
+	                        NULL);
+	account = purple_account_new("test", "test");
+	conversation = g_object_new(
+		PURPLE_TYPE_CONVERSATION,
+		"account", account,
+		"type", PURPLE_CONVERSATION_TYPE_DM,
+		NULL);
 
-		result = purple_protocol_conversation_set_avatar_finish(protocol,
-		                                                        G_ASYNC_RESULT(task),
-		                                                        &error);
-		g_assert_no_error(error);
-		g_assert_false(result);
+	purple_protocol_conversation_set_avatar_async(protocol, conversation,
+	                                              NULL, NULL,
+	                                              test_purple_protocol_conversation_empty_set_avatar_cb,
+	                                              NULL);
 
-		g_clear_object(&task);
-		g_clear_object(&protocol);
-	}
+	g_main_context_iteration(NULL, FALSE);
 
-	g_test_trap_subprocess(NULL, 0, 0);
-	g_test_trap_assert_stderr("*Purple-WARNING*TestPurpleProtocolConversationEmpty*set_avatar_finish*");
+	g_clear_object(&account);
+	g_assert_finalize_object(conversation);
+	g_assert_finalize_object(protocol);
 }
 
 static void
@@ -1495,6 +1398,8 @@
 
 	g_test_init(&argc, &argv, NULL);
 
+	g_test_set_nonfatal_assertions();
+
 	test_ui_purple_init();
 
 	loop = g_main_loop_new(NULL, FALSE);
@@ -1506,36 +1411,24 @@
 	                test_purple_protocol_conversation_empty_get_create_conversation_details);
 	g_test_add_func("/protocol-conversation/empty/create-conversation-async",
 	                test_purple_protocol_conversation_empty_create_conversation_async);
-	g_test_add_func("/protocol-conversation/empty/create-conversation-finish",
-	                test_purple_protocol_conversation_empty_create_conversation_finish);
 
 	/* Empty leave conversation tests. */
 	g_test_add_func("/protocol-conversation/empty/leave-conversation-async",
 	                test_purple_protocol_conversation_empty_leave_conversation_async);
-	g_test_add_func("/protocol-conversation/empty/leave-conversation-finish",
-	                test_purple_protocol_conversation_empty_leave_conversation_finish);
 
 	/* Empty send message tests. */
 	g_test_add_func("/protocol-conversation/empty/send-message-async",
 	                test_purple_protocol_conversation_empty_send_message_async);
-	g_test_add_func("/protocol-conversation/empty/send-message-finish",
-	                test_purple_protocol_conversation_empty_send_message_finish);
 	g_test_add_func("/protocol-conversation/empty/set-topic-async",
 	                test_purple_protocol_conversation_empty_set_topic_async);
-	g_test_add_func("/protocol-conversation/empty/set-topic-finish",
-	                test_purple_protocol_conversation_empty_set_topic_finish);
 	g_test_add_func("/protocol-conversation/empty/set-avatar-async",
 	                test_purple_protocol_conversation_empty_set_avatar_async);
-	g_test_add_func("/protocol-conversation/empty/set-avatar-finish",
-	                test_purple_protocol_conversation_empty_set_avatar_finish);
 
 	/* Empty join channel tests. */
 	g_test_add_func("/protocol-conversation/empty/get-channel-join-details",
 	                test_purple_protocol_conversation_empty_get_channel_join_details);
 	g_test_add_func("/protocol-conversation/empty/join_channel_async",
 	                test_purple_protocol_conversation_empty_join_channel_async);
-	g_test_add_func("/protocol-conversation/empty/join_channel_finish",
-	                test_purple_protocol_conversation_empty_join_channel_finish);
 
 	/* Empty send typing tests. */
 	g_test_add_func("/protocol-conversation/empty/send-typing",

mercurial