Sat, 01 Oct 2022 01:50:52 -0500
Create and add PurpleContacts to the manager when purple_buddy_new is called
This required some additional changes to PurpleContact. Namely that the contact always has a presence and it is no longer writeable.
Testing Done:
Ran the unit tests and verified nothing funky happens when running.
We can't test that all of the properties are properly bound because we would have to start up a lot more of libpurple than I'm willing to do for something that's temporary.
Bugs closed: PIDGIN-17685
Reviewed at https://reviews.imfreedom.org/r/1873/
|
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. */ |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
176 | purple_notification_manager_remove_with_account(manager, account); |
|
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); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
183 | purple_notification_manager_remove_with_account(manager, account); |
|
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); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
192 | purple_notification_manager_remove_with_account(manager, account); |
|
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)); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
227 | purple_notification_manager_remove_with_account(manager, accounts[0]); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
228 | 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
|
229 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
230 | g_clear_object(&manager); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
231 | g_clear_object(&accounts[0]); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
232 | g_clear_object(&accounts[1]); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
233 | g_clear_object(&accounts[2]); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
234 | } |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
235 | |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
236 | static void |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
237 | test_purple_notification_manager_read_propagation(void) { |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
238 | PurpleNotificationManager *manager = NULL; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
239 | PurpleNotification *notification = NULL; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
240 | 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
|
241 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
242 | /* Create the manager. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
243 | manager = g_object_new(PURPLE_TYPE_NOTIFICATION_MANAGER, NULL); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
244 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
245 | g_signal_connect(manager, "read", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
246 | G_CALLBACK(test_purple_notification_manager_increment_cb), |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
247 | &read_called); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
248 | g_signal_connect(manager, "unread", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
249 | G_CALLBACK(test_purple_notification_manager_increment_cb), |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
250 | &unread_called); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
251 | g_signal_connect(manager, "notify::unread-count", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
252 | G_CALLBACK(test_purple_notification_manager_unread_count_cb), |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
253 | &unread_count_called); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
254 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
255 | /* 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
|
256 | * original refernce to the manager. |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
257 | */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
258 | notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_GENERIC, |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
259 | NULL, |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
260 | NULL, |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
261 | NULL); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
262 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
263 | g_object_ref(notification); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
264 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
265 | purple_notification_manager_add(manager, notification); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
266 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
267 | /* 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
|
268 | g_assert_cmpint(read_called, ==, 0); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
269 | g_assert_cmpint(unread_called, ==, 0); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
270 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
271 | /* Verify that the unread_count property changed. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
272 | g_assert_cmpint(unread_count_called, ==, 1); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
273 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
274 | /* Now mark the notification as read. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
275 | purple_notification_set_read(notification, TRUE); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
276 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
277 | g_assert_cmpint(read_called, ==, 1); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
278 | g_assert_cmpint(unread_called, ==, 0); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
279 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
280 | g_assert_cmpint(unread_count_called, ==, 2); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
281 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
282 | /* Now mark the notification as unread. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
283 | purple_notification_set_read(notification, FALSE); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
284 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
285 | g_assert_cmpint(read_called, ==, 1); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
286 | g_assert_cmpint(unread_called, ==, 1); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
287 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
288 | g_assert_cmpint(unread_count_called, ==, 3); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
289 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
290 | /* Cleanup. */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
291 | g_clear_object(¬ification); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
292 | g_clear_object(&manager); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
293 | } |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
294 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
295 | /****************************************************************************** |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
296 | * Main |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
297 | *****************************************************************************/ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
298 | gint |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
299 | main(gint argc, gchar *argv[]) { |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
300 | GMainLoop *loop = NULL; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
301 | gint ret = 0; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
302 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
303 | g_test_init(&argc, &argv, NULL); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
304 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
305 | test_ui_purple_init(); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
306 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
307 | loop = g_main_loop_new(NULL, FALSE); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
308 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
309 | g_test_add_func("/notification-manager/get-default", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
310 | test_purple_notification_manager_get_default); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
311 | g_test_add_func("/notification-manager/add-remove", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
312 | test_purple_notification_manager_add_remove); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
313 | g_test_add_func("/notification-manager/double-add", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
314 | test_purple_notification_manager_double_add); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
315 | g_test_add_func("/notification-manager/double-remove", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
316 | test_purple_notification_manager_double_remove); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
317 | |
|
41511
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
318 | 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
|
319 | 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
|
320 | 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
|
321 | test_purple_notification_manager_remove_with_account_mixed); |
|
2036d450fd18
Add purple_notification_manager_remove_with_account.
Gary Kramlich <grim@reaperworld.com>
parents:
41438
diff
changeset
|
322 | |
|
41433
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
323 | g_test_add_func("/notification-manager/read-propagation", |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
324 | test_purple_notification_manager_read_propagation); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
325 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
326 | ret = g_test_run(); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
327 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
328 | g_main_loop_unref(loop); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
329 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
330 | return ret; |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
331 | } |