libpurple/tests/test_person.c

Thu, 07 Aug 2025 21:34:33 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 07 Aug 2025 21:34:33 -0500
changeset 43301
0e43dc8462e8
parent 43265
7960b5f85729
permissions
-rw-r--r--

Replace Purple.Avatar with Purple.Image

Purple.Avatar was unnecessary and this just moves everything to Purple.Image
which should work just fine.

Testing Done:
Loaded a demo account and verified that the avatars were shown in the contact list properly. Also called in the turtles.

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

41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 *
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * Lesser General Public License for more details.
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 *
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 */
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 #include <glib.h>
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
21 #include <birb.h>
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
23 #include <purple.h>
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 /******************************************************************************
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 * Tests
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 *****************************************************************************/
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 static void
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 test_purple_person_new(void) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 PurplePerson *person = NULL;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 person = purple_person_new();
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 g_assert_true(PURPLE_IS_PERSON(person));
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
36 g_assert_finalize_object(person);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 static void
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 test_purple_person_properties(void) {
43301
0e43dc8462e8 Replace Purple.Avatar with Purple.Image
Gary Kramlich <grim@reaperworld.com>
parents: 43265
diff changeset
41 PurpleImage *avatar = NULL;
0e43dc8462e8 Replace Purple.Avatar with Purple.Image
Gary Kramlich <grim@reaperworld.com>
parents: 43265
diff changeset
42 PurpleImage *avatar1 = NULL;
0e43dc8462e8 Replace Purple.Avatar with Purple.Image
Gary Kramlich <grim@reaperworld.com>
parents: 43265
diff changeset
43 PurpleImage *avatar_for_display = NULL;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 PurpleContact *person = NULL;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 PurpleTags *tags = NULL;
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
46 char *id = NULL;
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
47 char *alias = NULL;
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
48 char *color = NULL;
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
49 char *color_for_display = NULL;
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
50 char *name_for_display = NULL;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 /* Create our avatar for testing. */
43301
0e43dc8462e8 Replace Purple.Avatar with Purple.Image
Gary Kramlich <grim@reaperworld.com>
parents: 43265
diff changeset
53 avatar = g_object_new(PURPLE_TYPE_IMAGE, NULL);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 /* Use g_object_new so we can test setting properties by name. All of them
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 * call the setter methods, so by doing it this way we exercise more of the
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 * code.
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 */
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 person = g_object_new(
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 PURPLE_TYPE_PERSON,
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 "alias", "alias",
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 "avatar", avatar,
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
63 "color", "#794a85",
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 NULL);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 /* Now use g_object_get to read all of the properties. */
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 g_object_get(person,
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 "id", &id,
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 "alias", &alias,
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 "avatar", &avatar1,
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
71 "avatar-for-display", &avatar_for_display,
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
72 "color", &color,
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
73 "color-for-display", &color_for_display,
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
74 "name-for-display", &name_for_display,
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 "tags", &tags,
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 NULL);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
78 /* Test all the things. */
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 g_assert_nonnull(id);
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
80 g_clear_pointer(&id, g_free);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
81
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 g_assert_cmpstr(alias, ==, "alias");
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
83 g_clear_pointer(&alias, g_free);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
84
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 g_assert_true(avatar1 == avatar);
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
86 g_clear_object(&avatar1);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
87
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
88 g_assert_true(avatar_for_display == avatar);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
89 g_clear_object(&avatar_for_display);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
90
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
91 g_assert_cmpstr(color, ==, "#794a85");
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
92 g_clear_pointer(&color, g_free);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
93
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
94 g_assert_cmpstr(color_for_display, ==, "#794a85");
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
95 g_clear_pointer(&color_for_display, g_free);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
96
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
97 g_assert_cmpstr(name_for_display, ==, "alias");
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
98 g_clear_pointer(&name_for_display, g_free);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
99
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 g_assert_nonnull(tags);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 g_clear_object(&tags);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
103 /* Additional cleanup. */
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
104 g_assert_finalize_object(person);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
105 g_assert_finalize_object(avatar);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 static void
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
109 test_purple_person_avatar_for_display_person(void) {
43301
0e43dc8462e8 Replace Purple.Avatar with Purple.Image
Gary Kramlich <grim@reaperworld.com>
parents: 43265
diff changeset
110 PurpleImage *avatar = NULL;
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
111 PurpleContactInfo *info = NULL;
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
112 PurplePerson *person = NULL;
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
113 guint avatar_counter = 0;
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
114 guint avatar_for_display_counter = 0;
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
115
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
116 person = purple_person_new();
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
117 birb_count_property_changed(G_OBJECT(person), "avatar", &avatar_counter);
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
118 birb_count_property_changed(G_OBJECT(person), "avatar-for-display",
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
119 &avatar_for_display_counter);
43301
0e43dc8462e8 Replace Purple.Avatar with Purple.Image
Gary Kramlich <grim@reaperworld.com>
parents: 43265
diff changeset
120 avatar = g_object_new(PURPLE_TYPE_IMAGE, NULL);
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
121 purple_person_set_avatar(person, avatar);
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
122 g_assert_cmpuint(avatar_counter, ==, 1);
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
123 g_assert_cmpuint(avatar_for_display_counter, ==, 1);
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
124
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
125 info = purple_contact_info_new("id");
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
126 purple_person_add_contact_info(person, info);
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
127
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
128 /* Make sure the person's avatar is overriding the contact info. */
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
129 g_assert_true(purple_person_get_avatar_for_display(person) == avatar);
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
130
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
131 /* Contact info's have a reference on the person, so the easiest way to
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
132 * remove that is to remove them from the person.
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
133 */
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
134 purple_person_remove_contact_info(person, info);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
135
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
136 g_assert_finalize_object(person);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
137 g_assert_finalize_object(info);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
138 g_assert_finalize_object(avatar);
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
139 }
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
140
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
141 static void
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
142 test_purple_person_avatar_for_display_contact(void) {
43301
0e43dc8462e8 Replace Purple.Avatar with Purple.Image
Gary Kramlich <grim@reaperworld.com>
parents: 43265
diff changeset
143 PurpleImage *avatar = NULL;
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
144 PurpleContactInfo *info = NULL;
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
145 PurplePerson *person = NULL;
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
146 guint counter = 0;
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
147
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
148 person = purple_person_new();
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
149 birb_count_property_changed(G_OBJECT(person), "avatar-for-display",
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
150 &counter);
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
151
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
152 info = purple_contact_info_new("id");
43301
0e43dc8462e8 Replace Purple.Avatar with Purple.Image
Gary Kramlich <grim@reaperworld.com>
parents: 43265
diff changeset
153 avatar = g_object_new(PURPLE_TYPE_IMAGE, NULL);
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
154 purple_contact_info_set_avatar(info, avatar);
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
155 purple_person_add_contact_info(person, info);
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
156
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
157 g_assert_cmpuint(counter, ==, 1);
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
158
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
159 /* Make sure the person's avatar is overriding the contact info. */
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
160 g_assert_true(purple_person_get_avatar_for_display(person) == avatar);
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
161 g_clear_object(&avatar);
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
162
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
163 /* Now change the avatar on the contact info an verify that we not notified
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
164 * of the property changing.
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
165 */
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
166 counter = 0;
43301
0e43dc8462e8 Replace Purple.Avatar with Purple.Image
Gary Kramlich <grim@reaperworld.com>
parents: 43265
diff changeset
167 avatar = g_object_new(PURPLE_TYPE_IMAGE, NULL);
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
168 purple_contact_info_set_avatar(info, avatar);
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
169 g_assert_cmpuint(counter, ==, 1);
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
170
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
171 /* Contact info's have a reference on the person, so the easiest way to
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
172 * remove that is to remove them from the person.
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
173 */
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
174 purple_person_remove_contact_info(person, info);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
175
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
176 g_assert_finalize_object(person);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
177 g_assert_finalize_object(info);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
178 g_assert_finalize_object(avatar);
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
179 }
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
180
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
181 static void
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
182 test_purple_person_color_for_display_person(void) {
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
183 PurpleContactInfo *info = NULL;
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
184 PurplePerson *person = NULL;
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
185 const char *color = NULL;
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
186 guint color_counter = 0;
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
187 guint color_for_display_counter = 0;
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
188
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
189 person = purple_person_new();
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
190 birb_count_property_changed(G_OBJECT(person), "color", &color_counter);
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
191 birb_count_property_changed(G_OBJECT(person), "color-for-display",
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
192 &color_for_display_counter);
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
193 purple_person_set_color(person, "#abcdef");
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
194
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
195 g_assert_cmpuint(color_counter, ==, 1);
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
196 g_assert_cmpuint(color_for_display_counter, ==, 1);
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
197
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
198 /* Make sure the person's color is overriding the contact info. */
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
199 color_counter = 0;
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
200 color_for_display_counter = 0;
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
201 info = purple_contact_info_new("id");
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
202 purple_person_add_contact_info(person, info);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
203
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
204 color = purple_person_get_color_for_display(person);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
205 g_assert_cmpstr(color, ==, "#abcdef");
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
206
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
207 g_assert_cmpuint(color_counter, ==, 0);
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
208 g_assert_cmpuint(color_for_display_counter, ==, 0);
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
209
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
210 /* Contact info's have a reference on the person, so the easiest way to
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
211 * remove that is to remove them from the person.
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
212 */
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
213 purple_person_remove_contact_info(person, info);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
214
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
215 /* Cleanup. */
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
216 g_assert_finalize_object(person);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
217 g_assert_finalize_object(info);
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
218 }
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
219
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
220 static void
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
221 test_purple_person_color_for_display_contact(void) {
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
222 PurpleContactInfo *info = NULL;
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
223 PurplePerson *person = NULL;
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
224 const char *color = NULL;
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
225 guint counter = 0;
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
226
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
227 person = purple_person_new();
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
228 birb_count_property_changed(G_OBJECT(person), "color-for-display",
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
229 &counter);
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
230
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
231 info = purple_contact_info_new("id");
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
232 purple_contact_info_set_color(info, "#012345");
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
233 purple_person_add_contact_info(person, info);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
234
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
235 g_assert_cmpuint(counter, ==, 1);
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
236
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
237 /* Make sure the person's color is overriding the contact info. */
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
238 color = purple_person_get_color_for_display(person);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
239 g_assert_cmpstr(color, ==, "#012345");
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
240
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
241 /* Now change the color on the contact info and verify that we are notified
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
242 * of the property changing.
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
243 */
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
244 counter = 0;
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
245 purple_contact_info_set_color(info, "#6789ab");
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
246 g_assert_cmpuint(counter, ==, 1);
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
247
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
248 /* Contact info's have a reference on the person, so the easiest way to
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
249 * remove that is to remove them from the person.
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
250 */
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
251 purple_person_remove_contact_info(person, info);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
252
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
253 g_assert_finalize_object(person);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
254 g_assert_finalize_object(info);
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
255 }
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
256
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
257 static void
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
258 test_purple_person_name_for_display_person(void) {
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
259 PurpleContactInfo *info = NULL;
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
260 PurplePerson *person = NULL;
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
261
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
262 person = purple_person_new();
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
263 purple_person_set_alias(person, "person-alias");
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
264
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
265 info = purple_contact_info_new("id");
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
266 purple_person_add_contact_info(person, info);
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
267
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
268 /* Make sure the person's alias is overriding the contact info. */
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
269 g_assert_cmpstr(purple_person_get_name_for_display(person), ==,
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
270 "person-alias");
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
271
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
272 /* Contact info's have a reference on the person, so the easiest way to
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
273 * remove that is to remove them from the person.
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
274 */
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
275 purple_person_remove_contact_info(person, info);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
276
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
277 g_assert_finalize_object(person);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
278 g_assert_finalize_object(info);
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
279 }
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
280
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
281 static void
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
282 test_purple_person_name_for_display_contact(void) {
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
283 PurpleContactInfo *info = NULL;
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
284 PurplePerson *person = NULL;
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
285 guint counter = 0;
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
286
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
287 person = purple_person_new();
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
288 birb_count_property_changed(G_OBJECT(person), "name-for-display",
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
289 &counter);
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
290
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
291 info = purple_contact_info_new("id");
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
292 purple_person_add_contact_info(person, info);
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
293 g_assert_cmpuint(counter, ==, 1);
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
294
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
295 /* Make sure the name for display matches the id of the contact. */
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
296 g_assert_cmpstr(purple_person_get_name_for_display(person), ==, "id");
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
297
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
298 /* Now set a username on the contact and verify that the name for display
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
299 * matches and that the notify signal was emitted for the property.
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
300 */
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
301 counter = 0;
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
302 purple_contact_info_set_username(info, "clu");
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
303 g_assert_cmpstr(purple_person_get_name_for_display(person), ==, "clu");
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
304 g_assert_cmpuint(counter, ==, 1);
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
305
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
306 /* Contact info's have a reference on the person, so the easiest way to
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
307 * remove that is to remove them from the person.
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
308 */
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
309 purple_person_remove_contact_info(person, info);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
310
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
311 g_assert_finalize_object(person);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
312 g_assert_finalize_object(info);
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
313 }
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
314
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
315 static void
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
316 test_purple_person_contacts_single(void) {
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
317 PurpleContactInfo *info = NULL;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318 PurplePerson *person = NULL;
41761
9dc5d28fca99 When a Contact is added to a Person set the Contact's Person to that Person.
Gary Kramlich <grim@reaperworld.com>
parents: 41749
diff changeset
319 PurplePerson *person1 = NULL;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320 gboolean removed = FALSE;
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
321 guint counter = 0;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
323 info = purple_contact_info_new("id");
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324 person = purple_person_new();
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
325 birb_count_list_model_items_changed(G_LIST_MODEL(person), &counter);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
326
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
327 birb_assert_list_model_n_items(person, 0);
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
328 purple_person_add_contact_info(person, info);
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
329 birb_assert_list_model_n_items(person, 1);
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
330 g_assert_cmpuint(counter, ==, 1);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
331
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
332 person1 = purple_contact_info_get_person(info);
41761
9dc5d28fca99 When a Contact is added to a Person set the Contact's Person to that Person.
Gary Kramlich <grim@reaperworld.com>
parents: 41749
diff changeset
333 g_assert_true(person1 == person);
9dc5d28fca99 When a Contact is added to a Person set the Contact's Person to that Person.
Gary Kramlich <grim@reaperworld.com>
parents: 41749
diff changeset
334
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
335 counter = 0;
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
336 removed = purple_person_remove_contact_info(person, info);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337 g_assert_true(removed);
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
338 g_assert_cmpuint(counter, ==, 1);
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
339 birb_assert_list_model_n_items(person, 0);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
341 person1 = purple_contact_info_get_person(info);
41761
9dc5d28fca99 When a Contact is added to a Person set the Contact's Person to that Person.
Gary Kramlich <grim@reaperworld.com>
parents: 41749
diff changeset
342 g_assert_null(person1);
9dc5d28fca99 When a Contact is added to a Person set the Contact's Person to that Person.
Gary Kramlich <grim@reaperworld.com>
parents: 41749
diff changeset
343
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
344 g_assert_finalize_object(person);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
345 g_assert_finalize_object(info);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348 static void
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349 test_purple_person_contacts_multiple(void) {
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350 PurplePerson *person = NULL;
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
351 GPtrArray *infos = NULL;
42866
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42312
diff changeset
352 const int n_infos = 5;
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
353 guint counter = 0;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355 person = purple_person_new();
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
356 birb_count_list_model_items_changed(G_LIST_MODEL(person), &counter);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
358 infos = g_ptr_array_new_full(n_infos, g_object_unref);
42866
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42312
diff changeset
359 for(int i = 0; i < n_infos; i++) {
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
360 PurpleContactInfo *info = NULL;
42866
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42312
diff changeset
361 char *username = NULL;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
363 counter = 0;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
365 birb_assert_list_model_n_items(person, i);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 username = g_strdup_printf("username%d", i);
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
368 info = purple_contact_info_new(NULL);
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
369 purple_contact_info_set_username(info, username);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370 g_free(username);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
372 /* Add the contact info to the ptr array so we can remove it below. */
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
373 g_ptr_array_add(infos, info);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
374
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
375 /* Add the contact info to the person and make sure that all the magic
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
376 * happened.
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
377 */
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
378 purple_person_add_contact_info(person, info);
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
379 birb_assert_list_model_n_items(person, i + 1);
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
380 g_assert_cmpuint(counter, ==, 1);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
381 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382
42866
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42312
diff changeset
383 for(int i = 0; i < n_infos; i++) {
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
384 PurpleContactInfo *info = g_ptr_array_index(infos, i);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
385 gboolean removed = FALSE;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
386
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
387 counter = 0;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
388
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
389 birb_assert_list_model_n_items(person, n_infos - i);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
390
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
391 removed = purple_person_remove_contact_info(person, info);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
392 g_assert_true(removed);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
393
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
394 birb_assert_list_model_n_items(person, n_infos - (i + 1));
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
395 g_assert_cmpuint(counter, ==, 1);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
396 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
397
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
398 /* Final sanity check that the person has no more contacts. */
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
399 birb_assert_list_model_n_items(person, 0);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
400
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
401 g_ptr_array_free(infos, TRUE);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
402
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
403 g_assert_finalize_object(person);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
404 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
405
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
406 static void
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
407 test_purple_person_priority_single(void) {
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
408 PurpleContactInfo *info = NULL;
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
409 PurpleContactInfo *priority = NULL;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
410 PurplePerson *person = NULL;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
411 PurplePresence *presence = NULL;
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
412 guint counter = 0;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
413
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
414 person = purple_person_new();
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
415 birb_count_property_changed(G_OBJECT(person), "priority-contact-info",
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
416 &counter);
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
417 priority = purple_person_get_priority_contact_info(person);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
418 g_assert_null(priority);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
419
41771
c5877e2c93f2 Create and add PurpleContacts to the manager when purple_buddy_new is called
Gary Kramlich <grim@reaperworld.com>
parents: 41761
diff changeset
420 /* Now create a real contact. */
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
421 info = purple_contact_info_new(NULL);
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
422 purple_person_add_contact_info(person, info);
41771
c5877e2c93f2 Create and add PurpleContacts to the manager when purple_buddy_new is called
Gary Kramlich <grim@reaperworld.com>
parents: 41761
diff changeset
423
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
424 /* Set the presence of the contact. */
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
425 presence = purple_contact_info_get_presence(info);
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
426 purple_presence_set_primitive(presence,
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
427 PURPLE_PRESENCE_PRIMITIVE_AVAILABLE);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
428
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
429 g_assert_cmpuint(counter, ==, 1);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
430
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
431 priority = purple_person_get_priority_contact_info(person);
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
432 g_assert_true(priority == info);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
433
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
434 /* Contact info's have a reference on the person, so the easiest way to
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
435 * remove that is to remove them from the person.
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
436 */
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
437 purple_person_remove_contact_info(person, info);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
438
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
439 g_assert_finalize_object(person);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
440 g_assert_finalize_object(info);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
441 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
442
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
443 static void
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
444 test_purple_person_priority_multiple_with_change(void) {
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
445 PurpleContactInfo *priority = NULL;
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
446 PurpleContactInfo *first = NULL;
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
447 PurpleContactInfo *sorted_contact = NULL;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
448 PurplePerson *person = NULL;
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
449 PurplePresence *sorted_presence = NULL;
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
450 guint counter = 0;
42866
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42312
diff changeset
451 int n_infos = 5;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
452
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
453 /* This unit test is a bit complicated, but it adds 5 contact infos to a
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
454 * person all whose presences are set to offline. After adding all the
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
455 * contact infos, we verify that the first contact info we added is the
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
456 * priority contact info. Then we flip the active status of the n_infos - 2
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
457 * infos to available. This should make it the priority contact info which
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
458 * we then assert.
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
459 */
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
460
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
461 /* Create the person and connected to the notify signal for the
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
462 * priority-contact property.
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
463 */
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
464 person = purple_person_new();
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
465 birb_count_property_changed(G_OBJECT(person), "priority-contact-info",
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
466 &counter);
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
467 priority = purple_person_get_priority_contact_info(person);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
468 g_assert_null(priority);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
469
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
470 /* Create and add all contact infos. */
42866
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42312
diff changeset
471 for(int i = 0; i < n_infos; i++) {
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
472 PurpleContactInfo *info = NULL;
42866
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42312
diff changeset
473 char *username = NULL;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
474
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
475 /* Set counter to 0 as it shouldn't be called as the priority contact
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
476 * info shouldn't change except for the first index.
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
477 */
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
478 counter = 0;
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
479
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
480 /* Now create a real contact. */
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
481 username = g_strdup_printf("username%d", i + 1);
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
482 info = purple_contact_info_new(NULL);
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
483 purple_contact_info_set_username(info, username);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
484 g_free(username);
41771
c5877e2c93f2 Create and add PurpleContacts to the manager when purple_buddy_new is called
Gary Kramlich <grim@reaperworld.com>
parents: 41761
diff changeset
485
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
486 purple_person_add_contact_info(person, info);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
487
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
488 if(i == 0) {
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
489 first = g_object_ref(info);
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
490 g_assert_cmpuint(counter, ==, 1);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
491 } else {
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
492 g_assert_cmpuint(counter, ==, 0);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
493
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
494 if(i == n_infos - 2) {
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
495 PurplePresence *presence = NULL;
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
496
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
497 /* Add a reference to the presence of this specific contact
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
498 * info, as we want to tweak it later.
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
499 */
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
500 presence = purple_contact_info_get_presence(info);
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
501 sorted_presence = g_object_ref(presence);
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
502
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
503 sorted_contact = g_object_ref(info);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
504 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
505 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
506
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
507 g_clear_object(&info);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
508 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
509
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
510 birb_assert_list_model_n_items(person, n_infos);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
511
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
512 priority = purple_person_get_priority_contact_info(person);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
513 g_assert_true(priority == first);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
514 g_clear_object(&first);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
515
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
516 /* Now set the second from the last contact info's status to available, and
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
517 * verify that that contact info is now the priority contact info.
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
518 */
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
519 counter = 0;
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
520 purple_presence_set_primitive(sorted_presence,
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
521 PURPLE_PRESENCE_PRIMITIVE_AVAILABLE);
41948
6d844d2faff1 Split PurpleContactInfo out of PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 41771
diff changeset
522 priority = purple_person_get_priority_contact_info(person);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
523 g_assert_true(priority == sorted_contact);
43265
7960b5f85729 Update to birb 0.4 and use the testing helpers in libpurple
Gary Kramlich <grim@reaperworld.com>
parents: 43171
diff changeset
524 g_assert_cmpuint(counter, ==, 1);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
525
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
526 /* Cleanup. */
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
527 purple_person_remove_all_contact_infos(person);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
528
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
529 g_clear_object(&sorted_contact);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
530 g_clear_object(&sorted_presence);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
531
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
532 g_assert_finalize_object(person);
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
533 }
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
534
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
535 /******************************************************************************
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
536 * Matches tests
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
537 *****************************************************************************/
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
538 static void
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
539 test_purple_person_matches_accepts_null(void) {
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
540 PurplePerson *person = purple_person_new();
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
541
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
542 g_assert_true(purple_person_matches(person, NULL));
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
543
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
544 g_assert_finalize_object(person);
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
545 }
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
546
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
547 static void
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
548 test_purple_person_matches_empty_string(void) {
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
549 PurplePerson *person = purple_person_new();
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
550
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
551 g_assert_true(purple_person_matches(person, ""));
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
552
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
553 g_assert_finalize_object(person);
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
554 }
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
555
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
556 static void
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
557 test_purple_person_matches_alias(void) {
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
558 PurplePerson *person = purple_person_new();
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
559
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
560 purple_person_set_alias(person, "this is the alias");
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
561
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
562 g_assert_true(purple_person_matches(person, "the"));
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
563 g_assert_false(purple_person_matches(person, "what"));
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
564
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
565 g_assert_finalize_object(person);
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
566 }
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
567
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
568 static void
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
569 test_purple_person_matches_contact_info(void) {
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
570 PurplePerson *person = purple_person_new();
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
571 PurpleContactInfo *info = purple_contact_info_new(NULL);
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
572
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
573 purple_contact_info_set_username(info, "user1");
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
574 purple_person_add_contact_info(person, info);
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
575
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
576 g_assert_true(purple_person_matches(person, "user1"));
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
577
43171
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
578 /* Contact info's have a reference on the person, so the easiest way to
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
579 * remove that is to remove them from the person.
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
580 */
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
581 purple_person_remove_contact_info(person, info);
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
582
914049a55a72 Update the tests for Purple.Person
Gary Kramlich <grim@reaperworld.com>
parents: 42866
diff changeset
583 g_assert_finalize_object(person);
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
584 }
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
585
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
586 /******************************************************************************
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
587 * Main
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
588 *****************************************************************************/
42866
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42312
diff changeset
589 int
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42312
diff changeset
590 main(int argc, char *argv[]) {
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
591 g_test_init(&argc, &argv, NULL);
42866
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42312
diff changeset
592 g_test_set_nonfatal_assertions();
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
593
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
594 g_test_add_func("/person/new",
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
595 test_purple_person_new);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
596 g_test_add_func("/person/properties",
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
597 test_purple_person_properties);
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
598
42054
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
599 g_test_add_func("/person/avatar-for-display/person",
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
600 test_purple_person_avatar_for_display_person);
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
601 g_test_add_func("/person/avatar-for-display/contact",
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
602 test_purple_person_avatar_for_display_contact);
7aa77854392d Add a property and accessor for getting the avatar to display for a PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42053
diff changeset
603
42309
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
604 g_test_add_func("/person/color-for-display/person",
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
605 test_purple_person_color_for_display_person);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
606 g_test_add_func("/person/color-for-display/contact",
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
607 test_purple_person_color_for_display_contact);
52571584c0ae Add color and color-for-display properties to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
608
42053
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
609 g_test_add_func("/person/name-for-display/person",
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
610 test_purple_person_name_for_display_person);
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
611 g_test_add_func("/person/name-for-display/contact",
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
612 test_purple_person_name_for_display_contact);
742efe62e610 Add a name-for-display property to PurplePerson
Gary Kramlich <grim@reaperworld.com>
parents: 41948
diff changeset
613
41749
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
614 g_test_add_func("/person/contacts/single",
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
615 test_purple_person_contacts_single);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
616 g_test_add_func("/person/contacts/multiple",
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
617 test_purple_person_contacts_multiple);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
618
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
619 g_test_add_func("/person/priority/single",
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
620 test_purple_person_priority_single);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
621 g_test_add_func("/person/priority/multiple-with-change",
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
622 test_purple_person_priority_multiple_with_change);
c22448f50d5d Create PurplePerson.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
623
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
624 g_test_add_func("/person/matches/accepts_null",
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
625 test_purple_person_matches_accepts_null);
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
626 g_test_add_func("/person/matches/empty_string",
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
627 test_purple_person_matches_empty_string);
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
628 g_test_add_func("/person/matches/alias",
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
629 test_purple_person_matches_alias);
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
630 g_test_add_func("/person/matches/contact_info",
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
631 test_purple_person_matches_contact_info);
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
632
42866
4b201e18638f Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents: 42312
diff changeset
633 return g_test_run();
42059
e6dcbf0db616 Add search support to the contact list
Gary Kramlich <grim@reaperworld.com>
parents: 42054
diff changeset
634 }

mercurial