summaryrefslogtreecommitdiff
path: root/libpurple/tests
diff options
context:
space:
mode:
authorGary Kramlich <grim@reaperworld.com>2023-03-03 04:49:01 -0600
committerGary Kramlich <grim@reaperworld.com>2023-03-03 04:49:01 -0600
commite6c5daa5ca37baa8854fbff9de1f281201f1122e (patch)
treef7732a35a7f5d1740856cb18186ebf2ece4b5ee2 /libpurple/tests
parent0884785f7bd2f15efd5a1631dfdd9ebd7ecbc4db (diff)
downloadpidgin-e6c5daa5ca37baa8854fbff9de1f281201f1122e.tar.gz
Propagate the notify signal for the Presence object on a ContactInfo
Testing Done: Ran the unit tests under valgrind and verified now no leaks. Also checked the docs and made sure the signal was documented properly. Reviewed at https://reviews.imfreedom.org/r/2306/
Diffstat (limited to 'libpurple/tests')
-rw-r--r--libpurple/tests/test_contact_info.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/libpurple/tests/test_contact_info.c b/libpurple/tests/test_contact_info.c
index b250a25255..9c64b59713 100644
--- a/libpurple/tests/test_contact_info.c
+++ b/libpurple/tests/test_contact_info.c
@@ -382,6 +382,57 @@ test_purple_contact_info_matches_none(void) {
}
/******************************************************************************
+ * presence-changed signal tests
+ *****************************************************************************/
+static void
+test_purple_contact_info_presence_changed_callback(PurpleContactInfo *info,
+ PurplePresence *presence,
+ GParamSpec *pspec,
+ gpointer data)
+{
+ guint *counter = data;
+
+ g_assert_true(PURPLE_IS_CONTACT_INFO(info));
+ g_assert_true(PURPLE_IS_PRESENCE(presence));
+ g_assert_true(G_IS_PARAM_SPEC(pspec));
+
+ *counter = *counter + 1;
+}
+
+static void
+test_purple_contact_info_presence_changed_signal(void) {
+ PurpleContactInfo *info = NULL;
+ PurplePresence *presence = NULL;
+ guint counter = 0;
+
+ /* Create the info and add our callbacks, one for everything and another
+ * for just idle to make sure detail works.
+ */
+ info = purple_contact_info_new(NULL);
+ g_signal_connect(info, "presence-changed",
+ G_CALLBACK(test_purple_contact_info_presence_changed_callback),
+ &counter);
+ g_signal_connect(info, "presence-changed::idle",
+ G_CALLBACK(test_purple_contact_info_presence_changed_callback),
+ &counter);
+
+ /* Grab the presence and start changing stuff. */
+ presence = purple_contact_info_get_presence(info);
+ g_assert_true(PURPLE_IS_PRESENCE(presence));
+
+ /* Set the presence as idle with no time, which should call our callback
+ * three times, twice for the non-detailed callback, and once for the
+ * detailed callback.
+ */
+ g_assert_cmpint(counter, ==, 0);
+ purple_presence_set_idle(presence, TRUE, NULL);
+ g_assert_cmpint(counter, ==, 3);
+
+ /* Cleanup. */
+ g_clear_object(&info);
+}
+
+/******************************************************************************
* Main
*****************************************************************************/
gint
@@ -432,5 +483,8 @@ main(gint argc, gchar *argv[]) {
g_test_add_func("/contact-info/matches/none",
test_purple_contact_info_matches_none);
+ g_test_add_func("/contact-info/presence-changed-signal",
+ test_purple_contact_info_presence_changed_signal);
+
return g_test_run();
}