libpurple/tests/test_notification_manager.c

Mon, 23 Sep 2024 20:39:32 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 23 Sep 2024 20:39:32 -0500
changeset 42962
a2c1926ce7b2
parent 42927
51bee36eb6cb
child 42985
66ad6fc11879
permissions
-rw-r--r--

Update Purple.NotificationManager to remove notifications when they're deleted

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

Bugs closed: PIDGIN-17966

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

41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * Lesser General Public License for more details.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 #include <glib.h>
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 #include <purple.h>
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 /******************************************************************************
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 * Callbacks
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 *****************************************************************************/
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 test_purple_notification_manager_increment_cb(G_GNUC_UNUSED PurpleNotificationManager *manager,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 G_GNUC_UNUSED PurpleNotification *notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 gpointer data)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 {
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
31 guint *counter = data;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
33 *counter = *counter + 1;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 test_purple_notification_manager_unread_count_cb(G_GNUC_UNUSED GObject *obj,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 G_GNUC_UNUSED GParamSpec *pspec,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 gpointer data)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 {
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
41 guint *counter = data;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
43 *counter = *counter + 1;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45
42962
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
46 static void
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
47 test_purple_notification_manager_items_changed_cb(GListModel *model,
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
48 G_GNUC_UNUSED guint position,
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
49 G_GNUC_UNUSED guint removed,
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
50 G_GNUC_UNUSED guint added,
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
51 gpointer data)
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
52 {
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
53 guint *counter = data;
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
54
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
55 g_assert_true(PURPLE_IS_NOTIFICATION_MANAGER(model));
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
56
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
57 *counter = *counter + 1;
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
58 }
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
59
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 /******************************************************************************
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 * Tests
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 *****************************************************************************/
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 test_purple_notification_manager_add_remove(void) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 PurpleNotificationManager *manager = NULL;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 PurpleNotification *notification = NULL;
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
67 guint added_called = 0;
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
68 guint removed_called = 0;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 guint unread_count = 0;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 g_assert_true(PURPLE_IS_NOTIFICATION_MANAGER(manager));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 /* Wire up our signals. */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 g_signal_connect(manager, "added",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 G_CALLBACK(test_purple_notification_manager_increment_cb),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 &added_called);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 g_signal_connect(manager, "removed",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 G_CALLBACK(test_purple_notification_manager_increment_cb),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 &removed_called);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82
42638
81ef32d85e5a Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42565
diff changeset
83 /* Create the notification and store its id. */
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
84 notification = purple_notification_new_generic(NULL, NULL);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 /* Add the notification to the manager. */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 purple_notification_manager_add(manager, notification);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 /* Make sure the added signal was called. */
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
90 g_assert_cmpuint(added_called, ==, 1);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 /* Verify that the unread count is 1. */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 unread_count = purple_notification_manager_get_unread_count(manager);
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
94 g_assert_cmpuint(unread_count, ==, 1);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 /* Remove the notification. */
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
97 purple_notification_manager_remove(manager, notification);
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
98 g_assert_cmpuint(removed_called, ==, 1);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 /* Verify that the unread count is now 0. */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 unread_count = purple_notification_manager_get_unread_count(manager);
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
102 g_assert_cmpuint(unread_count, ==, 0);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103
42638
81ef32d85e5a Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42565
diff changeset
104 /* After removal from the manager, nothing else should know about this. */
81ef32d85e5a Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42565
diff changeset
105 g_assert_finalize_object(notification);
81ef32d85e5a Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42565
diff changeset
106
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 /* Clean up the manager. */
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
108 g_assert_finalize_object(manager);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 test_purple_notification_manager_double_add(void) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 if(g_test_subprocess()) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 PurpleNotificationManager *manager = NULL;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 PurpleNotification *notification = NULL;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
119 notification = purple_notification_new_generic(NULL, NULL);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 purple_notification_manager_add(manager, notification);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 purple_notification_manager_add(manager, notification);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123
42638
81ef32d85e5a Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42565
diff changeset
124 /* These will never get called as the double add outputs a g_warning()
81ef32d85e5a Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42565
diff changeset
125 * that causes the subprocess to exit. This is left to avoid a false
81ef32d85e5a Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42565
diff changeset
126 * positive in static analysis.
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 */
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
128 g_assert_finalize_object(notification);
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
129 g_assert_finalize_object(manager);
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
130
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
131 g_assert_not_reached();
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 g_test_trap_subprocess(NULL, 0, 0);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 g_test_trap_assert_stderr("*Purple-WARNING*double add detected for notification*");
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 test_purple_notification_manager_double_remove(void) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 PurpleNotificationManager *manager = NULL;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 PurpleNotification *notification = NULL;
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
142 guint removed_called = 0;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 g_signal_connect(manager, "removed",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 G_CALLBACK(test_purple_notification_manager_increment_cb),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 &removed_called);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
149 notification = purple_notification_new_generic(NULL, NULL);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 purple_notification_manager_add(manager, notification);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
153 purple_notification_manager_remove(manager, notification);
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
154 purple_notification_manager_remove(manager, notification);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
156 g_assert_cmpuint(removed_called, ==, 1);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157
42638
81ef32d85e5a Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42565
diff changeset
158 g_assert_finalize_object(notification);
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
159 g_assert_finalize_object(manager);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 static void
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
163 test_purple_notification_manager_remove_with_account_simple(void) {
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
164 PurpleNotificationManager *manager = NULL;
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
165 PurpleNotification *notification = NULL;
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
166 PurpleAccount *account = NULL;
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
167 GListModel *model = NULL;
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
168
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
169 manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL);
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
170 model = G_LIST_MODEL(manager);
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
171 account = purple_account_new("test", "test");
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
172
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
173 /* Make sure that nothing happens on an empty list. */
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
174 purple_notification_manager_remove_with_account(manager, account, TRUE);
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
175 g_assert_cmpuint(0, ==, g_list_model_get_n_items(model));
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
176
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
177 /* Add a single notification without the account */
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
178 notification = purple_notification_new_generic(NULL, NULL);
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
179 purple_notification_manager_add(manager, notification);
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
180 purple_notification_manager_remove_with_account(manager, account, TRUE);
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
181 g_assert_cmpuint(1, ==, g_list_model_get_n_items(model));
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
182 purple_notification_manager_clear(manager);
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
183 g_clear_object(&notification);
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
184
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
185 /* Add a single notification with the account */
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
186 notification = purple_notification_new_generic(NULL, NULL);
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
187 purple_notification_set_account(notification, account);
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
188 purple_notification_manager_add(manager, notification);
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
189 purple_notification_manager_remove_with_account(manager, account, TRUE);
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
190 g_assert_cmpuint(0, ==, g_list_model_get_n_items(model));
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
191 purple_notification_manager_clear(manager);
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
192 g_clear_object(&notification);
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
193
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
194 g_assert_finalize_object(manager);
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
195 g_assert_finalize_object(account);
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
196 }
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
197
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
198 static void
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
199 test_purple_notification_manager_remove_with_account_mixed(void) {
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
200 PurpleNotificationManager *manager = NULL;
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
201 PurpleNotification *notification = NULL;
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
202 PurpleAccount *accounts[3];
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
203 GListModel *model = NULL;
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
204 int pattern[] = {0, 0, 1, 0, 2, 1, 0, 0, 1, 2, 0, 1, 0, 0, -1};
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
205
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
206 manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL);
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
207 model = G_LIST_MODEL(manager);
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
208
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
209 accounts[0] = purple_account_new("account1", "account1");
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
210 accounts[1] = purple_account_new("account2", "account2");
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
211 accounts[2] = purple_account_new("account3", "account3");
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
212
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
213 /* Add our notifications. */
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
214 for(int i = 0; pattern[i] >= 0; i++) {
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
215 notification = purple_notification_new_generic(NULL, NULL);
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
216 purple_notification_set_account(notification, accounts[pattern[i]]);
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
217 purple_notification_manager_add(manager, notification);
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
218 g_clear_object(&notification);
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
219 }
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
220
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
221 g_assert_cmpuint(14, ==, g_list_model_get_n_items(model));
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
222
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
223 /* Remove notifications for accounts[0]. */
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
224 purple_notification_manager_remove_with_account(manager, accounts[0], TRUE);
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
225 g_assert_cmpuint(6, ==, g_list_model_get_n_items(model));
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
226
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
227 /* Remove notifications for accounts[1]. */
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
228 purple_notification_manager_remove_with_account(manager, accounts[1], TRUE);
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
229 g_assert_cmpuint(2, ==, g_list_model_get_n_items(model));
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
230
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
231 /* Remove notifications for accounts[2]. */
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
232 purple_notification_manager_remove_with_account(manager, accounts[2], TRUE);
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
233 g_assert_cmpuint(0, ==, g_list_model_get_n_items(model));
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
234
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
235 g_assert_finalize_object(manager);
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
236 g_assert_finalize_object(accounts[0]);
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
237 g_assert_finalize_object(accounts[1]);
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
238 g_assert_finalize_object(accounts[2]);
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
239 }
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
240
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
241 static void
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
242 test_purple_notification_manager_remove_with_account_all(void) {
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
243 PurpleConnectionErrorInfo *info = NULL;
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
244 PurpleNotificationManager *manager = NULL;
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
245 PurpleNotification *notification = NULL;
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
246 PurpleAccount *account = NULL;
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
247 GListModel *model = NULL;
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
248
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
249 /* This test will add 3 notifications to the notification manager for the
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
250 * same account. In order, they will be of types generic, connection error,
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
251 * and generic. We will also add a generic notification with no account, to
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
252 * make sure notifications don't accidentally get removed.
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
253 *
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
254 * Since the notification manager prepends items and leaves sorting up to
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
255 * the user interface, the order of the notifications will be the opposite
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
256 * of the order they were added.
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
257 *
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
258 * This ordering is specifically done because we batch remove items from
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
259 * the list. So by calling purple_notification_manager_remove_with_account
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
260 * with `all` set to FALSE, we should remove the second and fourth items,
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
261 * but leave the first and third items.
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
262 *
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
263 * We then call purple_notification_manager_remove_with_account with `all`
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
264 * set to TRUE, which will remove the connection error notification which
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
265 * is now the second item.
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
266 *
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
267 * Finally, we empty the manager and verify that its count is at 0.
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
268 */
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
269
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
270 manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL);
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
271 model = G_LIST_MODEL(manager);
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
272 account = purple_account_new("test", "test");
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
273
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
274 /* Make sure that nothing happens on an empty list. */
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
275 purple_notification_manager_remove_with_account(manager, account, TRUE);
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
276 g_assert_cmpuint(0, ==, g_list_model_get_n_items(model));
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
277
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
278 /* Add a generic notification with an account. */
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
279 notification = purple_notification_new_generic(NULL, NULL);
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
280 purple_notification_set_account(notification, account);
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
281 purple_notification_manager_add(manager, notification);
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
282 g_clear_object(&notification);
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
283
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
284 /* Add a connection error notification with the account. */
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
285 info = purple_connection_error_info_new(PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
286 "the network is borked.");
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
287 notification = purple_notification_new_from_connection_error(account, info);
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
288 purple_connection_error_info_free(info);
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
289 purple_notification_manager_add(manager, notification);
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
290 g_clear_object(&notification);
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
291
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
292 /* Add a generic notification with the account. */
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
293 notification = purple_notification_new_generic(NULL, NULL);
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
294 purple_notification_set_account(notification, account);
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
295 purple_notification_manager_add(manager, notification);
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
296 g_clear_object(&notification);
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
297
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
298 /* Add a generic notification without an account. */
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
299 notification = purple_notification_new_generic(NULL, NULL);
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
300 purple_notification_manager_add(manager, notification);
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
301 g_clear_object(&notification);
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
302
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
303 /* Verify that we have all of the notifications in the manager. */
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
304 g_assert_cmpuint(4, ==, g_list_model_get_n_items(model));
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
305
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
306 /* Remove the transient notifications for the account. */
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
307 purple_notification_manager_remove_with_account(manager, account, FALSE);
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
308 g_assert_cmpuint(2, ==, g_list_model_get_n_items(model));
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
309
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
310 /* Make sure that the second item is the connection error. */
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
311 notification = g_list_model_get_item(G_LIST_MODEL(model), 1);
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
312 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
313 g_assert_cmpint(purple_notification_get_notification_type(notification),
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
314 ==, PURPLE_NOTIFICATION_TYPE_CONNECTION_ERROR);
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
315 G_GNUC_END_IGNORE_DEPRECATIONS
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
316 g_clear_object(&notification);
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
317
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
318 /* Remove the non-transient notifications for the account. */
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
319 purple_notification_manager_remove_with_account(manager, account, TRUE);
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
320 g_assert_cmpuint(1, ==, g_list_model_get_n_items(model));
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
321
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
322 /* Remove the generic notification that's not tied to an account. */
41936
c4a96b5eecba Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents: 41817
diff changeset
323 purple_notification_manager_clear(manager);
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
324 g_assert_cmpuint(0, ==, g_list_model_get_n_items(model));
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
325
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
326 g_assert_finalize_object(manager);
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
327 g_assert_finalize_object(account);
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
328 }
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
329
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
330 static void
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
331 test_purple_notification_manager_read_propagation(void) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
332 PurpleNotificationManager *manager = NULL;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333 PurpleNotification *notification = NULL;
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
334 guint read_called = 0;
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
335 guint unread_called = 0;
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
336 guint unread_count_called = 0;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 /* Create the manager. */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 g_signal_connect(manager, "read",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342 G_CALLBACK(test_purple_notification_manager_increment_cb),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343 &read_called);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344 g_signal_connect(manager, "unread",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345 G_CALLBACK(test_purple_notification_manager_increment_cb),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346 &unread_called);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347 g_signal_connect(manager, "notify::unread-count",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348 G_CALLBACK(test_purple_notification_manager_unread_count_cb),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349 &unread_count_called);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350
42638
81ef32d85e5a Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42565
diff changeset
351 /* Create the notification. */
42927
51bee36eb6cb First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents: 42852
diff changeset
352 notification = purple_notification_new_generic(NULL, NULL);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 purple_notification_manager_add(manager, notification);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
356 /* Verify that the read and unread signals were not yet emitted. */
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
357 g_assert_cmpuint(read_called, ==, 0);
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
358 g_assert_cmpuint(unread_called, ==, 0);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
359
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
360 /* Verify that the unread_count property changed. */
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
361 g_assert_cmpuint(unread_count_called, ==, 1);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
363 /* Now mark the notification as read. */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364 purple_notification_set_read(notification, TRUE);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
365
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
366 g_assert_cmpuint(read_called, ==, 1);
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
367 g_assert_cmpuint(unread_called, ==, 0);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
368
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
369 g_assert_cmpuint(unread_count_called, ==, 2);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371 /* Now mark the notification as unread. */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 purple_notification_set_read(notification, FALSE);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
373
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
374 g_assert_cmpuint(read_called, ==, 1);
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
375 g_assert_cmpuint(unread_called, ==, 1);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
376
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
377 g_assert_cmpuint(unread_count_called, ==, 3);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
378
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
379 /* Cleanup. */
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
380 g_assert_finalize_object(manager);
42638
81ef32d85e5a Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42565
diff changeset
381 g_assert_finalize_object(notification);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
383
42962
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
384 static void
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
385 test_purple_notification_manager_remove_on_delete(void) {
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
386 PurpleNotificationManager *manager = NULL;
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
387 PurpleNotification *notification = NULL;
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
388 guint counter = 0;
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
389
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
390 manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL);
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
391 g_signal_connect(manager, "items-changed",
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
392 G_CALLBACK(test_purple_notification_manager_items_changed_cb),
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
393 &counter);
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
394
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
395 notification = purple_notification_new_generic(NULL, "title");
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
396 purple_notification_manager_add(manager, notification);
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
397 g_assert_cmpuint(counter, ==, 1);
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
398
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
399 counter = 0;
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
400 purple_notification_delete(notification);
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
401 g_assert_cmpuint(counter, ==, 1);
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
402
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
403 g_assert_finalize_object(notification);
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
404 g_assert_finalize_object(manager);
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
405 }
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
406
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
407 /******************************************************************************
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
408 * Main
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
409 *****************************************************************************/
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
410 int
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
411 main(int argc, char *argv[]) {
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
412 g_test_init(&argc, &argv, NULL);
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
413 g_test_set_nonfatal_assertions();
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
414
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
415 g_test_add_func("/notification-manager/add-remove",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
416 test_purple_notification_manager_add_remove);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
417 g_test_add_func("/notification-manager/double-add",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
418 test_purple_notification_manager_double_add);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
419 g_test_add_func("/notification-manager/double-remove",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
420 test_purple_notification_manager_double_remove);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
421
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
422 g_test_add_func("/notification-manager/remove-with-account/simple",
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
423 test_purple_notification_manager_remove_with_account_simple);
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
424 g_test_add_func("/notification-manager/remove-with-account/mixed",
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
425 test_purple_notification_manager_remove_with_account_mixed);
41817
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
426 g_test_add_func("/notification-manager/remove-with-account/all",
91f9ce89468b Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents: 41511
diff changeset
427 test_purple_notification_manager_remove_with_account_all);
41511
2036d450fd18 Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
428
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
429 g_test_add_func("/notification-manager/read-propagation",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
430 test_purple_notification_manager_read_propagation);
42962
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
431 g_test_add_func("/notification-manager/remove-on-delete",
a2c1926ce7b2 Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents: 42927
diff changeset
432 test_purple_notification_manager_remove_on_delete);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
433
42852
c86412606a01 Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents: 42638
diff changeset
434 return g_test_run();
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
435 }

mercurial