Thu, 07 Aug 2025 21:40:13 -0500
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/
|
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 | |
|
43265
7960b5f85729
Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
43004
diff
changeset
|
21 | #include <birb.h> |
|
7960b5f85729
Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
43004
diff
changeset
|
22 | |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include <purple.h> |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
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 | * Callbacks |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | *****************************************************************************/ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | static void |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | 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
|
30 | G_GNUC_UNUSED PurpleNotification *notification, |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | gpointer data) |
|
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 | guint *counter = data; |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
35 | *counter = *counter + 1; |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | } |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | /****************************************************************************** |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | * Tests |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | *****************************************************************************/ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | static void |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | test_purple_notification_manager_add_remove(void) { |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | PurpleNotificationManager *manager = NULL; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | PurpleNotification *notification = NULL; |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
45 | guint added_called = 0; |
|
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
46 | guint removed_called = 0; |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | guint unread_count = 0; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | g_assert_true(PURPLE_IS_NOTIFICATION_MANAGER(manager)); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | /* Wire up our signals. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | g_signal_connect(manager, "added", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | G_CALLBACK(test_purple_notification_manager_increment_cb), |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | &added_called); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | g_signal_connect(manager, "removed", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | G_CALLBACK(test_purple_notification_manager_increment_cb), |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | &removed_called); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | |
|
42638
81ef32d85e5a
Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42565
diff
changeset
|
61 | /* Create the notification and store its id. */ |
|
42988
c2357ee36551
Replace Purple.Notification.new_generic with Purple.Notification.new
Gary Kramlich <grim@reaperworld.com>
parents:
42985
diff
changeset
|
62 | notification = purple_notification_new(NULL, NULL); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | /* Add the notification to the manager. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | purple_notification_manager_add(manager, notification); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | /* Make sure the added signal was called. */ |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
68 | g_assert_cmpuint(added_called, ==, 1); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | /* Verify that the unread count is 1. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | 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
|
72 | g_assert_cmpuint(unread_count, ==, 1); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | /* Remove the notification. */ |
|
41438
86beaec0fa35
Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents:
41433
diff
changeset
|
75 | purple_notification_manager_remove(manager, notification); |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
76 | g_assert_cmpuint(removed_called, ==, 1); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | /* Verify that the unread count is now 0. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | 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
|
80 | g_assert_cmpuint(unread_count, ==, 0); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | |
|
42638
81ef32d85e5a
Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42565
diff
changeset
|
82 | /* 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
|
83 | 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
|
84 | |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | /* Clean up the manager. */ |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
86 | g_assert_finalize_object(manager); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | } |
|
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 | static void |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | test_purple_notification_manager_double_add(void) { |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | if(g_test_subprocess()) { |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | PurpleNotificationManager *manager = NULL; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | PurpleNotification *notification = NULL; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | |
|
42988
c2357ee36551
Replace Purple.Notification.new_generic with Purple.Notification.new
Gary Kramlich <grim@reaperworld.com>
parents:
42985
diff
changeset
|
97 | notification = purple_notification_new(NULL, NULL); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | purple_notification_manager_add(manager, notification); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | purple_notification_manager_add(manager, notification); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | |
|
42638
81ef32d85e5a
Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42565
diff
changeset
|
102 | /* 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
|
103 | * 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
|
104 | * positive in static analysis. |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | */ |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
106 | g_assert_finalize_object(notification); |
|
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
107 | g_assert_finalize_object(manager); |
|
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
108 | |
|
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
109 | g_assert_not_reached(); |
|
41433
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 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | g_test_trap_subprocess(NULL, 0, 0); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | 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
|
114 | } |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | static void |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | test_purple_notification_manager_double_remove(void) { |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | PurpleNotificationManager *manager = NULL; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | PurpleNotification *notification = NULL; |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
120 | guint removed_called = 0; |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | g_signal_connect(manager, "removed", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | G_CALLBACK(test_purple_notification_manager_increment_cb), |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | &removed_called); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | |
|
42988
c2357ee36551
Replace Purple.Notification.new_generic with Purple.Notification.new
Gary Kramlich <grim@reaperworld.com>
parents:
42985
diff
changeset
|
127 | notification = purple_notification_new(NULL, NULL); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | purple_notification_manager_add(manager, notification); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | |
|
41438
86beaec0fa35
Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents:
41433
diff
changeset
|
131 | purple_notification_manager_remove(manager, notification); |
|
86beaec0fa35
Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents:
41433
diff
changeset
|
132 | purple_notification_manager_remove(manager, notification); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
134 | g_assert_cmpuint(removed_called, ==, 1); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
135 | |
|
42638
81ef32d85e5a
Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42565
diff
changeset
|
136 | g_assert_finalize_object(notification); |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
137 | g_assert_finalize_object(manager); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | } |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
139 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
140 | static void |
|
41511
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
141 | 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
|
142 | PurpleNotificationManager *manager = NULL; |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
143 | PurpleNotification *notification = NULL; |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
144 | PurpleAccount *account = NULL; |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
145 | GListModel *model = NULL; |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
146 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
147 | manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL); |
|
41936
c4a96b5eecba
Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents:
41817
diff
changeset
|
148 | model = G_LIST_MODEL(manager); |
|
41511
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
149 | account = purple_account_new("test", "test"); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
150 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
151 | /* 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
|
152 | 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
|
153 | 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
|
154 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
155 | /* Add a single notification without the account */ |
|
42988
c2357ee36551
Replace Purple.Notification.new_generic with Purple.Notification.new
Gary Kramlich <grim@reaperworld.com>
parents:
42985
diff
changeset
|
156 | notification = purple_notification_new(NULL, NULL); |
|
41511
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
157 | 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
|
158 | 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
|
159 | 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
|
160 | purple_notification_manager_clear(manager); |
|
41511
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
161 | g_clear_object(¬ification); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
162 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
163 | /* Add a single notification with the account */ |
|
42988
c2357ee36551
Replace Purple.Notification.new_generic with Purple.Notification.new
Gary Kramlich <grim@reaperworld.com>
parents:
42985
diff
changeset
|
164 | notification = purple_notification_new(NULL, NULL); |
|
42927
51bee36eb6cb
First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents:
42852
diff
changeset
|
165 | purple_notification_set_account(notification, account); |
|
41511
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
166 | 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
|
167 | 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
|
168 | 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
|
169 | purple_notification_manager_clear(manager); |
|
41511
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
170 | g_clear_object(¬ification); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
171 | |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
172 | g_assert_finalize_object(manager); |
|
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
173 | g_assert_finalize_object(account); |
|
41511
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
174 | } |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
175 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
176 | static void |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
177 | 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
|
178 | PurpleNotificationManager *manager = NULL; |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
179 | PurpleNotification *notification = NULL; |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
180 | PurpleAccount *accounts[3]; |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
181 | GListModel *model = NULL; |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
182 | 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
|
183 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
184 | manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL); |
|
41936
c4a96b5eecba
Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents:
41817
diff
changeset
|
185 | model = G_LIST_MODEL(manager); |
|
41511
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
186 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
187 | accounts[0] = purple_account_new("account1", "account1"); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
188 | accounts[1] = purple_account_new("account2", "account2"); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
189 | accounts[2] = purple_account_new("account3", "account3"); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
190 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
191 | /* Add our notifications. */ |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
192 | for(int i = 0; pattern[i] >= 0; i++) { |
|
42988
c2357ee36551
Replace Purple.Notification.new_generic with Purple.Notification.new
Gary Kramlich <grim@reaperworld.com>
parents:
42985
diff
changeset
|
193 | notification = purple_notification_new(NULL, NULL); |
|
42927
51bee36eb6cb
First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents:
42852
diff
changeset
|
194 | 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
|
195 | purple_notification_manager_add(manager, notification); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
196 | g_clear_object(¬ification); |
|
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 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
199 | 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
|
200 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
201 | /* 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
|
202 | 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
|
203 | 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
|
204 | |
|
41817
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
205 | /* 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
|
206 | 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
|
207 | 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
|
208 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
209 | /* 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
|
210 | 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
|
211 | 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
|
212 | |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
213 | g_assert_finalize_object(manager); |
|
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
214 | g_assert_finalize_object(accounts[0]); |
|
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
215 | g_assert_finalize_object(accounts[1]); |
|
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
216 | g_assert_finalize_object(accounts[2]); |
|
41511
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
217 | } |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
218 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
219 | static void |
|
41817
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
220 | test_purple_notification_manager_remove_with_account_all(void) { |
|
43004
06521648500e
Update Purple.Account:error to be a GLib.Error
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
221 | PurpleAccount *account = NULL; |
|
41817
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
222 | PurpleNotificationManager *manager = NULL; |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
223 | PurpleNotification *notification = NULL; |
|
43004
06521648500e
Update Purple.Account:error to be a GLib.Error
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
224 | GError *error = NULL; |
|
41817
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
225 | GListModel *model = NULL; |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
226 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
227 | /* 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
|
228 | * 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
|
229 | * 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
|
230 | * 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
|
231 | * |
|
41936
c4a96b5eecba
Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents:
41817
diff
changeset
|
232 | * 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
|
233 | * 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
|
234 | * of the order they were added. |
|
c4a96b5eecba
Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents:
41817
diff
changeset
|
235 | * |
|
41817
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
236 | * 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
|
237 | * 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
|
238 | * 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
|
239 | * 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
|
240 | * |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
241 | * 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
|
242 | * 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
|
243 | * 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
|
244 | * |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
245 | * 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
|
246 | */ |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
247 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
248 | manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL); |
|
41936
c4a96b5eecba
Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents:
41817
diff
changeset
|
249 | 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
|
250 | 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
|
251 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
252 | /* 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
|
253 | 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
|
254 | 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
|
255 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
256 | /* Add a generic notification with an account. */ |
|
42988
c2357ee36551
Replace Purple.Notification.new_generic with Purple.Notification.new
Gary Kramlich <grim@reaperworld.com>
parents:
42985
diff
changeset
|
257 | notification = purple_notification_new(NULL, NULL); |
|
42927
51bee36eb6cb
First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents:
42852
diff
changeset
|
258 | 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
|
259 | 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
|
260 | g_clear_object(¬ification); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
261 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
262 | /* Add a connection error notification with the account. */ |
|
43004
06521648500e
Update Purple.Account:error to be a GLib.Error
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
263 | error = g_error_new_literal(PURPLE_CONNECTION_ERROR, |
|
06521648500e
Update Purple.Account:error to be a GLib.Error
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
264 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
06521648500e
Update Purple.Account:error to be a GLib.Error
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
265 | "the network is borked."); |
|
06521648500e
Update Purple.Account:error to be a GLib.Error
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
266 | purple_account_set_error(account, error); |
|
06521648500e
Update Purple.Account:error to be a GLib.Error
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
267 | notification = purple_notification_connection_error_new(NULL, account); |
|
41817
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
268 | 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
|
269 | g_clear_object(¬ification); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
270 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
271 | /* Add a generic notification with the account. */ |
|
42988
c2357ee36551
Replace Purple.Notification.new_generic with Purple.Notification.new
Gary Kramlich <grim@reaperworld.com>
parents:
42985
diff
changeset
|
272 | notification = purple_notification_new(NULL, NULL); |
|
42927
51bee36eb6cb
First steps of cleaning up the notification API
Gary Kramlich <grim@reaperworld.com>
parents:
42852
diff
changeset
|
273 | 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
|
274 | 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
|
275 | g_clear_object(¬ification); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
276 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
277 | /* Add a generic notification without an account. */ |
|
42988
c2357ee36551
Replace Purple.Notification.new_generic with Purple.Notification.new
Gary Kramlich <grim@reaperworld.com>
parents:
42985
diff
changeset
|
278 | notification = purple_notification_new(NULL, NULL); |
|
41817
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
279 | 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
|
280 | g_clear_object(¬ification); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
281 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
282 | /* Verify that we have all of the notifications in the manager. */ |
|
42985
66ad6fc11879
Create Purple.NotificationConnectionError
Gary Kramlich <grim@reaperworld.com>
parents:
42962
diff
changeset
|
283 | g_assert_cmpuint(g_list_model_get_n_items(model), ==, 4); |
|
41817
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
284 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
285 | /* 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
|
286 | purple_notification_manager_remove_with_account(manager, account, FALSE); |
|
42985
66ad6fc11879
Create Purple.NotificationConnectionError
Gary Kramlich <grim@reaperworld.com>
parents:
42962
diff
changeset
|
287 | g_assert_cmpuint(g_list_model_get_n_items(model), ==, 2); |
|
41817
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
288 | |
|
41936
c4a96b5eecba
Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents:
41817
diff
changeset
|
289 | /* Make sure that the second item is the connection error. */ |
|
c4a96b5eecba
Make PurpleNotificationManager implement GListModel
Gary Kramlich <grim@reaperworld.com>
parents:
41817
diff
changeset
|
290 | notification = g_list_model_get_item(G_LIST_MODEL(model), 1); |
|
42985
66ad6fc11879
Create Purple.NotificationConnectionError
Gary Kramlich <grim@reaperworld.com>
parents:
42962
diff
changeset
|
291 | g_assert_true(PURPLE_IS_NOTIFICATION_CONNECTION_ERROR(notification)); |
|
41817
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
292 | g_clear_object(¬ification); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
293 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
294 | /* 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
|
295 | purple_notification_manager_remove_with_account(manager, account, TRUE); |
|
42985
66ad6fc11879
Create Purple.NotificationConnectionError
Gary Kramlich <grim@reaperworld.com>
parents:
42962
diff
changeset
|
296 | g_assert_cmpuint(g_list_model_get_n_items(model), ==, 1); |
|
41817
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 | /* 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
|
299 | purple_notification_manager_clear(manager); |
|
42985
66ad6fc11879
Create Purple.NotificationConnectionError
Gary Kramlich <grim@reaperworld.com>
parents:
42962
diff
changeset
|
300 | g_assert_cmpuint(g_list_model_get_n_items(model), ==, 0); |
|
41817
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
301 | |
|
43004
06521648500e
Update Purple.Account:error to be a GLib.Error
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
302 | /* We have a reference cycle between the account and its error |
|
06521648500e
Update Purple.Account:error to be a GLib.Error
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
303 | * notification. The dispose method does not get called in this case. So to |
|
06521648500e
Update Purple.Account:error to be a GLib.Error
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
304 | * break the stalemate, we just set the error to NULL. |
|
06521648500e
Update Purple.Account:error to be a GLib.Error
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
305 | */ |
|
06521648500e
Update Purple.Account:error to be a GLib.Error
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
306 | purple_account_set_error(account, NULL); |
|
06521648500e
Update Purple.Account:error to be a GLib.Error
Gary Kramlich <grim@reaperworld.com>
parents:
42988
diff
changeset
|
307 | |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
308 | g_assert_finalize_object(manager); |
|
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
309 | 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
|
310 | } |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
311 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
312 | static void |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
313 | test_purple_notification_manager_read_propagation(void) { |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
314 | PurpleNotificationManager *manager = NULL; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
315 | PurpleNotification *notification = NULL; |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
316 | guint read_called = 0; |
|
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
317 | guint unread_called = 0; |
|
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
318 | guint unread_count_called = 0; |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
319 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
320 | /* Create the manager. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
321 | manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
322 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
323 | g_signal_connect(manager, "read", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
324 | G_CALLBACK(test_purple_notification_manager_increment_cb), |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
325 | &read_called); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
326 | g_signal_connect(manager, "unread", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
327 | G_CALLBACK(test_purple_notification_manager_increment_cb), |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
328 | &unread_called); |
|
43265
7960b5f85729
Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
43004
diff
changeset
|
329 | birb_count_property_changed(G_OBJECT(manager), "unread-count", |
|
7960b5f85729
Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
43004
diff
changeset
|
330 | &unread_count_called); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
331 | |
|
42638
81ef32d85e5a
Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42565
diff
changeset
|
332 | /* Create the notification. */ |
|
42988
c2357ee36551
Replace Purple.Notification.new_generic with Purple.Notification.new
Gary Kramlich <grim@reaperworld.com>
parents:
42985
diff
changeset
|
333 | notification = purple_notification_new(NULL, NULL); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
334 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
335 | purple_notification_manager_add(manager, notification); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
336 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
337 | /* 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
|
338 | g_assert_cmpuint(read_called, ==, 0); |
|
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
339 | g_assert_cmpuint(unread_called, ==, 0); |
|
41433
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 | /* Verify that the unread_count property changed. */ |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
342 | g_assert_cmpuint(unread_count_called, ==, 1); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
343 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
344 | /* Now mark the notification as read. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
345 | purple_notification_set_read(notification, TRUE); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
346 | |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
347 | g_assert_cmpuint(read_called, ==, 1); |
|
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
348 | g_assert_cmpuint(unread_called, ==, 0); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
349 | |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
350 | g_assert_cmpuint(unread_count_called, ==, 2); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
351 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
352 | /* Now mark the notification as unread. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
353 | purple_notification_set_read(notification, FALSE); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
354 | |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
355 | g_assert_cmpuint(read_called, ==, 1); |
|
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
356 | g_assert_cmpuint(unread_called, ==, 1); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
357 | |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
358 | g_assert_cmpuint(unread_count_called, ==, 3); |
|
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 | /* Cleanup. */ |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
361 | 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
|
362 | g_assert_finalize_object(notification); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
363 | } |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
364 | |
|
42962
a2c1926ce7b2
Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents:
42927
diff
changeset
|
365 | static void |
|
a2c1926ce7b2
Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents:
42927
diff
changeset
|
366 | 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
|
367 | PurpleNotificationManager *manager = NULL; |
|
a2c1926ce7b2
Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents:
42927
diff
changeset
|
368 | PurpleNotification *notification = NULL; |
|
a2c1926ce7b2
Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents:
42927
diff
changeset
|
369 | guint counter = 0; |
|
a2c1926ce7b2
Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents:
42927
diff
changeset
|
370 | |
|
a2c1926ce7b2
Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents:
42927
diff
changeset
|
371 | manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL); |
|
43265
7960b5f85729
Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents:
43004
diff
changeset
|
372 | birb_count_list_model_items_changed(G_LIST_MODEL(manager), &counter); |
|
42962
a2c1926ce7b2
Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents:
42927
diff
changeset
|
373 | |
|
42988
c2357ee36551
Replace Purple.Notification.new_generic with Purple.Notification.new
Gary Kramlich <grim@reaperworld.com>
parents:
42985
diff
changeset
|
374 | notification = purple_notification_new(NULL, "title"); |
|
42962
a2c1926ce7b2
Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents:
42927
diff
changeset
|
375 | 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
|
376 | 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
|
377 | |
|
a2c1926ce7b2
Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents:
42927
diff
changeset
|
378 | counter = 0; |
|
a2c1926ce7b2
Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents:
42927
diff
changeset
|
379 | purple_notification_delete(notification); |
|
a2c1926ce7b2
Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents:
42927
diff
changeset
|
380 | 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
|
381 | |
|
a2c1926ce7b2
Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents:
42927
diff
changeset
|
382 | 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
|
383 | 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
|
384 | } |
|
a2c1926ce7b2
Update Purple.NotificationManager to remove notifications when they're deleted
Gary Kramlich <grim@reaperworld.com>
parents:
42927
diff
changeset
|
385 | |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
386 | /****************************************************************************** |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
387 | * Main |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
388 | *****************************************************************************/ |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
389 | int |
|
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
390 | main(int argc, char *argv[]) { |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
391 | g_test_init(&argc, &argv, NULL); |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
392 | g_test_set_nonfatal_assertions(); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
393 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
394 | g_test_add_func("/notification-manager/add-remove", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
395 | test_purple_notification_manager_add_remove); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
396 | g_test_add_func("/notification-manager/double-add", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
397 | test_purple_notification_manager_double_add); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
398 | g_test_add_func("/notification-manager/double-remove", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
399 | test_purple_notification_manager_double_remove); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
400 | |
|
41511
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
401 | 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
|
402 | 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
|
403 | 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
|
404 | 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
|
405 | 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
|
406 | 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
|
407 | |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
408 | g_test_add_func("/notification-manager/read-propagation", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
409 | 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
|
410 | 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
|
411 | test_purple_notification_manager_remove_on_delete); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
412 | |
|
42852
c86412606a01
Modernize the notification manager tests
Gary Kramlich <grim@reaperworld.com>
parents:
42638
diff
changeset
|
413 | return g_test_run(); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
414 | } |