libpurple/tests/test_protocol_action.c

Tue, 05 Sep 2023 00:05:12 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 05 Sep 2023 00:05:12 -0500
changeset 42312
7d6f0b8b6e77
parent 42089
083eae91c9a8
permissions
-rw-r--r--

Use PurpleAvatar for PurplePerson and PurpleContactInfo

I'm not sure why we didn't do this earlier, but it's done now.

Testing Done:
Connected a demo account and verified all of its icons showed up in the contact list.

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

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
42089
083eae91c9a8 Update the libpurple tests for the warning level 2 update
Gary Kramlich <grim@reaperworld.com>
parents: 39486
diff changeset
31 _test_purple_protocol_action_callback(G_GNUC_UNUSED PurpleProtocolAction *action) {
39484
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