libpurple/tests/test_protocol_action.c

Sat, 01 Oct 2022 01:50:52 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Sat, 01 Oct 2022 01:50:52 -0500
changeset 41771
c5877e2c93f2
parent 39486
3d00e6b24ca7
child 42089
083eae91c9a8
permissions
-rw-r--r--

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/

39484
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 *
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 * Purple is the legal property of its developers, whose names are too
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * numerous to list here. Please refer to the COPYRIGHT file distributed
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * with this source distribution
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 *
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or (at
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * your option) any later version.
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 *
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * General Public License for more details.
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 *
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib.h>
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include <purple.h>
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 /******************************************************************************
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 * Helpers
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 *****************************************************************************/
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 static void
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 _test_purple_protocol_action_callback(PurpleProtocolAction *action) {
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 }
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 /******************************************************************************
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 * Tests
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 *****************************************************************************/
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 static void
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 test_purple_protocol_action_new(void) {
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 PurpleProtocolAction *action = NULL;
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 action = purple_protocol_action_new(
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 "label",
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 _test_purple_protocol_action_callback
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 );
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 g_assert_nonnull(action);
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 g_assert_cmpstr(action->label, ==, "label");
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 g_assert(action->callback == _test_purple_protocol_action_callback);
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 purple_protocol_action_free(action);
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 }
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 static void
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 test_purple_protocol_action_copy(void) {
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 PurpleProtocolAction *orig = NULL, *copy = NULL;
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 orig = purple_protocol_action_new(
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 "label",
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 _test_purple_protocol_action_callback
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 );
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 g_assert_nonnull(orig);
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 copy = purple_protocol_action_copy(orig);
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 purple_protocol_action_free(orig);
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 g_assert_cmpstr(copy->label, ==, "label");
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 g_assert(copy->callback == _test_purple_protocol_action_callback);
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 purple_protocol_action_free(copy);
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 }
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 /******************************************************************************
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 * Main
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 *****************************************************************************/
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 gint
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 main(gint argc, gchar **argv) {
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 gint res = 0;
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 g_test_init(&argc, &argv, NULL);
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 g_test_set_nonfatal_assertions();
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 g_test_add_func(
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 "/protocol-action/new",
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 test_purple_protocol_action_new
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 );
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 g_test_add_func(
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 "/protocol-action/copy",
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 test_purple_protocol_action_copy
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 );
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 res = g_test_run();
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 return res;
0ece2412a0b0 Add some basic unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 }

mercurial