Sun, 23 Oct 2022 02:16:19 -0500
Fix connection errors getting deleted when an account is disconnected
Testing Done:
* Ran the unit tests with the new test
* Caused a resource conflict on XMPP to verify that notification was displayed
* Attempted to connect an IRC account that had a bad hostname and verified that notification was displayed.
* Not integration testing was done for Finch.
Reviewed at https://reviews.imfreedom.org/r/1944/
|
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 | #include "test_ui.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 | { |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | gint *called = data; |
|
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 | *called = *called + 1; |
|
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 | static void |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | 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
|
40 | G_GNUC_UNUSED GParamSpec *pspec, |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | gpointer data) |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | { |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | gint *called = data; |
|
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 | *called = *called + 1; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | } |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | |
|
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 | * Tests |
|
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 | static void |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | test_purple_notification_manager_get_default(void) { |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | PurpleNotificationManager *manager1 = NULL, *manager2 = NULL; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | manager1 = purple_notification_manager_get_default(); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | g_assert_true(PURPLE_IS_NOTIFICATION_MANAGER(manager1)); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | manager2 = purple_notification_manager_get_default(); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | g_assert_true(PURPLE_IS_NOTIFICATION_MANAGER(manager2)); |
|
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 | g_assert_true(manager1 == manager2); |
|
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 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | static void |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | test_purple_notification_manager_add_remove(void) { |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | PurpleNotificationManager *manager = NULL; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | PurpleNotification *notification = NULL; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | gint added_called = 0, removed_called = 0; |
|
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 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | /* Create the notification and store it's id. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_GENERIC, |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | NULL, NULL, NULL); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | /* Add the notification to the manager. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | purple_notification_manager_add(manager, notification); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | /* Make sure the added signal was called. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | g_assert_cmpint(added_called, ==, 1); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | /* Verify that the unread count is 1. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | unread_count = purple_notification_manager_get_unread_count(manager); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | g_assert_cmpint(unread_count, ==, 1); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | /* Remove the notification. */ |
|
41438
86beaec0fa35
Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents:
41433
diff
changeset
|
98 | purple_notification_manager_remove(manager, notification); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | g_assert_cmpint(removed_called, ==, 1); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | /* Verify that the unread count is now 0. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | unread_count = purple_notification_manager_get_unread_count(manager); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | g_assert_cmpint(unread_count, ==, 0); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
104 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | /* Clean up the manager. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | g_clear_object(&manager); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | } |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | static void |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | test_purple_notification_manager_double_add(void) { |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | if(g_test_subprocess()) { |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | PurpleNotificationManager *manager = NULL; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | PurpleNotification *notification = NULL; |
|
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 | manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, 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 | notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_GENERIC, |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | NULL, NULL, NULL); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | purple_notification_manager_add(manager, notification); |
|
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 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | /* This will never get called as the double add outputs a g_warning() |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | * that causes the test to fail. This is left to avoid a false postive |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | * in static analysis. |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | g_clear_object(&manager); |
|
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 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | g_test_trap_subprocess(NULL, 0, 0); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | 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
|
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 | static void |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
135 | test_purple_notification_manager_double_remove(void) { |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | PurpleNotificationManager *manager = NULL; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | PurpleNotification *notification = NULL; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | gint removed_called = 0; |
|
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 | manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
141 | g_signal_connect(manager, "removed", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
142 | G_CALLBACK(test_purple_notification_manager_increment_cb), |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
143 | &removed_called); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_GENERIC, |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
146 | NULL, NULL, NULL); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
147 | /* Add an additional reference because the manager takes one and the id |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
148 | * belongs to the notification. So without this, the first remove frees |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
149 | * the id which would cause an invalid read. |
|
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 | g_object_ref(notification); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
152 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
153 | purple_notification_manager_add(manager, notification); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
154 | |
|
41438
86beaec0fa35
Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents:
41433
diff
changeset
|
155 | purple_notification_manager_remove(manager, notification); |
|
86beaec0fa35
Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents:
41433
diff
changeset
|
156 | purple_notification_manager_remove(manager, notification); |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
157 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | g_assert_cmpint(removed_called, ==, 1); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
160 | g_clear_object(¬ification); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
161 | g_clear_object(&manager); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
162 | } |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
164 | static void |
|
41511
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
165 | 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
|
166 | PurpleNotificationManager *manager = NULL; |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
167 | PurpleNotification *notification = NULL; |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
168 | PurpleAccount *account = NULL; |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
169 | GListModel *model = NULL; |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
170 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
171 | manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
172 | model = purple_notification_manager_get_model(manager); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
173 | account = purple_account_new("test", "test"); |
|
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 | /* 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
|
176 | 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
|
177 | 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
|
178 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
179 | /* Add a single notification without the account */ |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
180 | notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_GENERIC, |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
181 | NULL, NULL, NULL); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
182 | 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
|
183 | 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
|
184 | g_assert_cmpuint(1, ==, g_list_model_get_n_items(model)); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
185 | g_list_store_remove_all(G_LIST_STORE(model)); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
186 | g_clear_object(¬ification); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
187 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
188 | /* Add a single notification with the account */ |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
189 | notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_GENERIC, |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
190 | account, NULL, NULL); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
191 | 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
|
192 | 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
|
193 | 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
|
194 | g_list_store_remove_all(G_LIST_STORE(model)); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
195 | g_clear_object(¬ification); |
|
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 | g_clear_object(&manager); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
198 | g_clear_object(&account); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
199 | } |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
200 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
201 | static void |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
202 | 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
|
203 | PurpleNotificationManager *manager = NULL; |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
204 | PurpleNotification *notification = NULL; |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
205 | PurpleAccount *accounts[3]; |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
206 | GListModel *model = NULL; |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
207 | gint pattern[] = {0, 0, 1, 0, 2, 1, 0, 0, 1, 2, 0, 1, 0, 0, -1}; |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
208 | gint i = 0; |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
209 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
210 | manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
211 | model = purple_notification_manager_get_model(manager); |
|
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 | accounts[0] = purple_account_new("account1", "account1"); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
214 | accounts[1] = purple_account_new("account2", "account2"); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
215 | accounts[2] = purple_account_new("account3", "account3"); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
216 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
217 | /* Add our notifications. */ |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
218 | for(i = 0; pattern[i] >= 0; i++) { |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
219 | notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_GENERIC, |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
220 | accounts[pattern[i]], NULL, |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
221 | NULL); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
222 | purple_notification_manager_add(manager, notification); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
223 | g_clear_object(¬ification); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
224 | } |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
225 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
226 | 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
|
227 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
228 | /* 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
|
229 | 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
|
230 | 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
|
231 | |
|
41817
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
232 | /* 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
|
233 | 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
|
234 | 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
|
235 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
236 | /* 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
|
237 | 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
|
238 | 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
|
239 | |
|
41511
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
240 | g_clear_object(&manager); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
241 | g_clear_object(&accounts[0]); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
242 | g_clear_object(&accounts[1]); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
243 | g_clear_object(&accounts[2]); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
244 | } |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
245 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
246 | static void |
|
41817
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
247 | test_purple_notification_manager_remove_with_account_all(void) { |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
248 | PurpleNotificationManager *manager = NULL; |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
249 | PurpleNotification *notification = NULL; |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
250 | PurpleAccount *account = NULL; |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
251 | GListModel *model = NULL; |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
252 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
253 | /* 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
|
254 | * 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
|
255 | * 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
|
256 | * 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
|
257 | * |
|
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 |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
260 | * with `all` set to FALSE, we should remove the first and third items, |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
261 | * but leave the second and fourth items. |
|
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 |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
265 | * is now the first item. |
|
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); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
271 | model = purple_notification_manager_get_model(manager); |
|
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. */ |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
279 | notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_GENERIC, |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
280 | account, NULL, NULL); |
|
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(¬ification); |
|
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. */ |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
285 | notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_CONNECTION_ERROR, |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
286 | account, NULL, NULL); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
287 | 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
|
288 | g_clear_object(¬ification); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
289 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
290 | /* Add a generic notification with the account. */ |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
291 | notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_GENERIC, |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
292 | account, NULL, NULL); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
293 | 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
|
294 | g_clear_object(¬ification); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
295 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
296 | /* Add a generic notification without an account. */ |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
297 | notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_GENERIC, |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
298 | NULL, NULL, NULL); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
299 | 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
|
300 | g_clear_object(¬ification); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
301 | |
|
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 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
310 | /* Make sure that the first item is the connection error. */ |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
311 | notification = g_list_model_get_item(G_LIST_MODEL(model), 0); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
312 | 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
|
313 | ==, PURPLE_NOTIFICATION_TYPE_CONNECTION_ERROR); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
314 | g_clear_object(¬ification); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
315 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
316 | /* 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
|
317 | 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
|
318 | 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
|
319 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
320 | /* Remove the generic notification that's not tied to an account. */ |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
321 | g_list_store_remove_all(G_LIST_STORE(model)); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
322 | 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
|
323 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
324 | g_clear_object(&manager); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
325 | g_clear_object(&account); |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
326 | } |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
327 | |
|
91f9ce89468b
Fix connection errors getting deleted when an account is disconnected
Gary Kramlich <grim@reaperworld.com>
parents:
41511
diff
changeset
|
328 | static void |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
329 | test_purple_notification_manager_read_propagation(void) { |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
330 | PurpleNotificationManager *manager = NULL; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
331 | PurpleNotification *notification = NULL; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
332 | gint read_called = 0, unread_called = 0, unread_count_called = 0; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
333 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
334 | /* Create the manager. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
335 | manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL); |
|
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 | g_signal_connect(manager, "read", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
338 | G_CALLBACK(test_purple_notification_manager_increment_cb), |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
339 | &read_called); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
340 | g_signal_connect(manager, "unread", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
341 | G_CALLBACK(test_purple_notification_manager_increment_cb), |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
342 | &unread_called); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
343 | g_signal_connect(manager, "notify::unread-count", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
344 | G_CALLBACK(test_purple_notification_manager_unread_count_cb), |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
345 | &unread_count_called); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
346 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
347 | /* Create the notification and add a reference to it before we give our |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
348 | * original refernce to the manager. |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
349 | */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
350 | notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_GENERIC, |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
351 | NULL, |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
352 | NULL, |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
353 | NULL); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
354 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
355 | g_object_ref(notification); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
356 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
357 | purple_notification_manager_add(manager, notification); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
358 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
359 | /* Verify that the read and unread signals were not yet emitted. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
360 | g_assert_cmpint(read_called, ==, 0); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
361 | g_assert_cmpint(unread_called, ==, 0); |
|
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 | /* Verify that the unread_count property changed. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
364 | g_assert_cmpint(unread_count_called, ==, 1); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
365 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
366 | /* Now mark the notification as read. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
367 | purple_notification_set_read(notification, TRUE); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
368 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
369 | g_assert_cmpint(read_called, ==, 1); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
370 | g_assert_cmpint(unread_called, ==, 0); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
371 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
372 | g_assert_cmpint(unread_count_called, ==, 2); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
373 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
374 | /* Now mark the notification as unread. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
375 | purple_notification_set_read(notification, FALSE); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
376 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
377 | g_assert_cmpint(read_called, ==, 1); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
378 | g_assert_cmpint(unread_called, ==, 1); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
379 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
380 | g_assert_cmpint(unread_count_called, ==, 3); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
381 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
382 | /* Cleanup. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
383 | g_clear_object(¬ification); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
384 | g_clear_object(&manager); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
385 | } |
|
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 | /****************************************************************************** |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
388 | * Main |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
389 | *****************************************************************************/ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
390 | gint |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
391 | main(gint argc, gchar *argv[]) { |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
392 | GMainLoop *loop = NULL; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
393 | gint ret = 0; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
394 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
395 | g_test_init(&argc, &argv, NULL); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
396 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
397 | test_ui_purple_init(); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
398 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
399 | loop = g_main_loop_new(NULL, FALSE); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
400 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
401 | g_test_add_func("/notification-manager/get-default", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
402 | test_purple_notification_manager_get_default); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
403 | g_test_add_func("/notification-manager/add-remove", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
404 | test_purple_notification_manager_add_remove); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
405 | g_test_add_func("/notification-manager/double-add", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
406 | test_purple_notification_manager_double_add); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
407 | g_test_add_func("/notification-manager/double-remove", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
408 | test_purple_notification_manager_double_remove); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
409 | |
|
41511
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
410 | 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
|
411 | 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
|
412 | 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
|
413 | 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
|
414 | 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
|
415 | 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
|
416 | |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
417 | g_test_add_func("/notification-manager/read-propagation", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
418 | test_purple_notification_manager_read_propagation); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
419 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
420 | ret = g_test_run(); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
421 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
422 | g_main_loop_unref(loop); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
423 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
424 | return ret; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
425 | } |