libpurple/tests/test_presence.c

Thu, 07 Aug 2025 21:40:13 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 07 Aug 2025 21:40:13 -0500
changeset 43302
e7b0bbfec5d5
parent 43240
0dd5d0ab4908
permissions
-rw-r--r--

Add an avatar-for-display property to Purple.ContactInfo

Testing Done:
Ran the tests under valgrind and called in the turtles.

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

42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 *
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * Lesser General Public License for more details.
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 *
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 */
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 #include <glib.h>
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 #include <purple.h>
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 /******************************************************************************
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 * Main
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 *****************************************************************************/
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 static void
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
27 test_purple_presence_new(void) {
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 PurplePresence *presence = NULL;
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 presence = purple_presence_new();
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
31 g_assert_true(PURPLE_IS_PRESENCE(presence));
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 /* Cleanup. */
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 g_clear_object(&presence);
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 }
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 static void
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
38 test_purple_presence_properties(void) {
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 PurplePresence *presence = NULL;
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
40 PurplePresencePrimitive primitive = PURPLE_PRESENCE_PRIMITIVE_OFFLINE;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
41 GDateTime *now = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
42 GDateTime *login = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
43 GDateTime *login1 = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
44 GDateTime *idle = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
45 GDateTime *idle1 = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
46 char *message = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
47 char *emoji = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
48 gboolean mobile = FALSE;
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
49 gboolean notifications_disabled = FALSE;
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
51 /* Create the login and idle times. */
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
52 now = g_date_time_new_now_utc();
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
53 login = g_date_time_add_hours(now, -1);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
54 idle = g_date_time_add_minutes(now, -10);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
55 g_clear_pointer(&now, g_date_time_unref);
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
57 /* Create the presence using g_object_new to make sure set_property is
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
58 * wired up correctly.
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
59 */
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
60 presence = g_object_new(
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
61 PURPLE_TYPE_PRESENCE,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
62 "primitive", PURPLE_PRESENCE_PRIMITIVE_AVAILABLE,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
63 "message", "I'll be back!",
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
64 "emoji", "🤖",
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
65 "login-time", login,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
66 "idle-time", idle,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
67 "mobile", TRUE,
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
68 "notifications-disabled", TRUE,
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
69 NULL);
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
71 /* Grab the values via g_object_get to make sure get_property is wired up
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
72 * correctly.
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 */
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
74 g_object_get(
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
75 presence,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
76 "primitive", &primitive,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
77 "message", &message,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
78 "emoji", &emoji,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
79 "login-time", &login1,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
80 "idle-time", &idle1,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
81 "mobile", &mobile,
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
82 "notifications-disabled", &notifications_disabled,
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
83 NULL);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
84
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
85 /* Test the things! */
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
86 g_assert_cmpint(primitive, ==, PURPLE_PRESENCE_PRIMITIVE_AVAILABLE);
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
87
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
88 g_assert_cmpstr(message, ==, "I'll be back!");
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
89 g_clear_pointer(&message, g_free);
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
90
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
91 g_assert_cmpstr(emoji, ==, "🤖");
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
92 g_clear_pointer(&emoji, g_free);
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
93
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
94 g_assert_nonnull(login1);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
95 g_assert_true(g_date_time_equal(login, login1));
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
96 g_clear_pointer(&login1, g_date_time_unref);
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
97
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
98 g_assert_nonnull(idle1);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
99 g_assert_true(g_date_time_equal(idle, idle1));
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
100 g_clear_pointer(&idle1, g_date_time_unref);
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
101
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
102 g_assert_true(mobile);
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
104 g_assert_true(notifications_disabled);
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
105
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 /* Cleanup. */
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
107 g_clear_pointer(&login, g_date_time_unref);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
108 g_clear_pointer(&idle, g_date_time_unref);
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 g_clear_object(&presence);
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 }
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 /******************************************************************************
43240
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
113 * Signal Tests
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
114 *****************************************************************************/
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
115 static void
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
116 test_purple_presence_primitive_changed_signal_cb(PurplePresence *presence,
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
117 PurplePresencePrimitive new_primitive,
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
118 PurplePresencePrimitive old_primitive,
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
119 gpointer data)
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
120 {
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
121 guint *counter = data;
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
122
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
123 g_assert_true(PURPLE_IS_PRESENCE(presence));
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
124 g_assert_cmpuint(new_primitive, ==, PURPLE_PRESENCE_PRIMITIVE_STREAMING);
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
125 g_assert_cmpuint(old_primitive, ==, PURPLE_PRESENCE_PRIMITIVE_OFFLINE);
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
126
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
127 *counter = *counter + 1;
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
128 }
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
129
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
130 static void
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
131 test_purple_presence_primitive_changed_signal(void) {
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
132 PurplePresence *presence = NULL;
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
133 guint counter = 0;
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
134
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
135 presence = purple_presence_new();
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
136 g_signal_connect(presence, "primitive-changed",
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
137 G_CALLBACK(test_purple_presence_primitive_changed_signal_cb),
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
138 &counter);
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
139
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
140 purple_presence_set_primitive(presence,
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
141 PURPLE_PRESENCE_PRIMITIVE_STREAMING);
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
142
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
143 g_assert_cmpuint(counter, ==, 1);
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
144
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
145 g_assert_finalize_object(presence);
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
146 }
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
147
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
148 /******************************************************************************
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 * Main
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 *****************************************************************************/
42859
939cdcccf5ae Modernize PurplePresence and its unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42310
diff changeset
151 int
939cdcccf5ae Modernize PurplePresence and its unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42310
diff changeset
152 main(int argc, char *argv[]) {
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 g_test_init(&argc, &argv, NULL);
42859
939cdcccf5ae Modernize PurplePresence and its unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42310
diff changeset
154 g_test_set_nonfatal_assertions();
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
156 g_test_add_func("/presence/new", test_purple_presence_new);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
157 g_test_add_func("/presence/properties", test_purple_presence_properties);
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158
43240
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
159 g_test_add_func("/presence/primitive-primitive-changed-signal",
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
160 test_purple_presence_primitive_changed_signal);
0dd5d0ab4908 Add Purple.Presence.primitive-changed signal
Gary Kramlich <grim@reaperworld.com>
parents: 42859
diff changeset
161
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 return g_test_run();
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 }

mercurial