libpurple/tests/test_conversation.c

Thu, 07 Aug 2025 21:40:13 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 07 Aug 2025 21:40:13 -0500
changeset 43302
e7b0bbfec5d5
parent 43301
0e43dc8462e8
permissions
-rw-r--r--

Add an avatar-for-display property to Purple.ContactInfo

Testing Done:
Ran the tests under valgrind and called in the turtles.

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

42114
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 *
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * Lesser General Public License for more details.
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 *
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 */
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 #include <glib.h>
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 #include <purple.h>
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "test_ui.h"
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 /******************************************************************************
42773
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
26 * Callbacks
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
27 *****************************************************************************/
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
28 static void
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
29 test_purple_conversation_notify_counter_cb(GObject *obj,
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
30 G_GNUC_UNUSED GParamSpec *pspec,
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
31 gpointer data)
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
32 {
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
33 guint *counter = data;
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
34
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
35 g_assert_true(PURPLE_IS_CONVERSATION(obj));
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
36
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
37 *counter = *counter + 1;
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
38 }
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
39
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
40 /******************************************************************************
42114
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 * Tests
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 *****************************************************************************/
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 static void
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 test_purple_conversation_properties(void) {
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 PurpleAccount *account = NULL;
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 PurpleAccount *account1 = NULL;
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
47 PurpleContactInfo *creator = NULL;
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
48 PurpleContactInfo *creator1 = NULL;
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
49 PurpleContactInfo *topic_author = NULL;
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
50 PurpleContactInfo *topic_author1 = NULL;
42114
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 PurpleConversation *conversation = NULL;
42653
584895b844d2 PurpleConversationType's values were pascal case when they should be upper snake case
Gary Kramlich <grim@reaperworld.com>
parents: 42535
diff changeset
52 PurpleConversationType type = PURPLE_CONVERSATION_TYPE_UNSET;
43301
0e43dc8462e8 Replace Purple.Avatar with Purple.Image
Gary Kramlich <grim@reaperworld.com>
parents: 43234
diff changeset
53 PurpleImage *avatar = NULL;
0e43dc8462e8 Replace Purple.Avatar with Purple.Image
Gary Kramlich <grim@reaperworld.com>
parents: 43234
diff changeset
54 PurpleImage *avatar1 = NULL;
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
55 PurpleTags *tags = NULL;
42884
5a7d425c9d1b Add a typing-state property to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42857
diff changeset
56 PurpleTypingState typing_state;
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
57 GDateTime *created_on = NULL;
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
58 GDateTime *created_on1 = NULL;
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
59 GDateTime *topic_updated = NULL;
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
60 GDateTime *topic_updated1 = NULL;
42114
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 GListModel *members = NULL;
42773
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
62 char *alias = NULL;
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
63 char *description = NULL;
43064
ac5311a8f11e Add PurpleConversation:error property
Markus Fischer <ivanhoe@fiscari.de>
parents: 42968
diff changeset
64 GError *error = NULL;
ac5311a8f11e Add PurpleConversation:error property
Markus Fischer <ivanhoe@fiscari.de>
parents: 42968
diff changeset
65 GError *error1 = NULL;
42800
5c55680a1a6b Add Purple.Conversation:global-id
Gary Kramlich <grim@reaperworld.com>
parents: 42773
diff changeset
66 char *global_id = NULL;
42272
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
67 char *id = NULL;
42760
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
68 char *title = NULL;
42773
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
69 char *title_for_display = NULL;
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
70 char *topic = NULL;
43234
85be702275e6 Add Purple.Conversation:url
Gary Kramlich <grim@reaperworld.com>
parents: 43137
diff changeset
71 char *url = NULL;
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
72 char *user_nickname = NULL;
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
73 gboolean age_restricted = FALSE;
43137
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
74 gboolean avatar_editable = FALSE;
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
75 gboolean description_editable = FALSE;
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
76 gboolean drafting = FALSE;
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
77 gboolean favorite = FALSE;
43137
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
78 gboolean logging = FALSE;
42848
f9a04b0bed1f Add a needs-attention property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42823
diff changeset
79 gboolean needs_attention = FALSE;
43137
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
80 gboolean title_editable = FALSE;
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
81 gboolean topic_editable = FALSE;
42114
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82
42800
5c55680a1a6b Add Purple.Conversation:global-id
Gary Kramlich <grim@reaperworld.com>
parents: 42773
diff changeset
83 account = g_object_new(
5c55680a1a6b Add Purple.Conversation:global-id
Gary Kramlich <grim@reaperworld.com>
parents: 42773
diff changeset
84 PURPLE_TYPE_ACCOUNT,
5c55680a1a6b Add Purple.Conversation:global-id
Gary Kramlich <grim@reaperworld.com>
parents: 42773
diff changeset
85 "id", "test",
5c55680a1a6b Add Purple.Conversation:global-id
Gary Kramlich <grim@reaperworld.com>
parents: 42773
diff changeset
86 "protocol-id", "test",
5c55680a1a6b Add Purple.Conversation:global-id
Gary Kramlich <grim@reaperworld.com>
parents: 42773
diff changeset
87 NULL);
5c55680a1a6b Add Purple.Conversation:global-id
Gary Kramlich <grim@reaperworld.com>
parents: 42773
diff changeset
88
43301
0e43dc8462e8 Replace Purple.Avatar with Purple.Image
Gary Kramlich <grim@reaperworld.com>
parents: 43234
diff changeset
89 avatar = g_object_new(PURPLE_TYPE_IMAGE, NULL);
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
90 creator = purple_contact_info_new(NULL);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
91 created_on = g_date_time_new_now_utc();
43064
ac5311a8f11e Add PurpleConversation:error property
Markus Fischer <ivanhoe@fiscari.de>
parents: 42968
diff changeset
92 error = g_error_new(g_quark_from_static_string("test-conversation"), 0,
ac5311a8f11e Add PurpleConversation:error property
Markus Fischer <ivanhoe@fiscari.de>
parents: 42968
diff changeset
93 "recipient unavailable");
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
94 topic_author = purple_contact_info_new(NULL);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
95 topic_updated = g_date_time_new_now_utc();
42114
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 /* Use g_object_new so we can test setting properties by name. All of them
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 * call the setter methods, so by doing it this way we exercise more of the
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 * code.
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 */
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 conversation = g_object_new(
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 PURPLE_TYPE_CONVERSATION,
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 "account", account,
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
104 "age-restricted", TRUE,
42773
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
105 "alias", "talky talk",
42355
6f7c6b84aaa0 Add an avatar property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42316
diff changeset
106 "avatar", avatar,
43137
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
107 "avatar-editable", TRUE,
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
108 "created-on", created_on,
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
109 "creator", creator,
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
110 "description", "to describe or not to describe...",
43137
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
111 "description-editable", TRUE,
42916
28a4480fe746 Add Purple.Conversation:drafting
Gary Kramlich <grim@reaperworld.com>
parents: 42908
diff changeset
112 "drafting", TRUE,
43064
ac5311a8f11e Add PurpleConversation:error property
Markus Fischer <ivanhoe@fiscari.de>
parents: 42968
diff changeset
113 "error", error,
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
114 "favorite", TRUE,
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
115 "id", "id1",
42908
64bbb9d4bf94 Add a logging property to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42901
diff changeset
116 "logging", TRUE,
42848
f9a04b0bed1f Add a needs-attention property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42823
diff changeset
117 "needs-attention", TRUE,
42760
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
118 "title", "test conversation",
43137
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
119 "title-editable", TRUE,
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
120 "topic", "the topic...",
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
121 "topic-author", topic_author,
43137
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
122 "topic-editable", TRUE,
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
123 "topic-updated", topic_updated,
42653
584895b844d2 PurpleConversationType's values were pascal case when they should be upper snake case
Gary Kramlich <grim@reaperworld.com>
parents: 42535
diff changeset
124 "type", PURPLE_CONVERSATION_TYPE_THREAD,
42884
5a7d425c9d1b Add a typing-state property to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42857
diff changeset
125 "typing-state", PURPLE_TYPING_STATE_TYPING,
43234
85be702275e6 Add Purple.Conversation:url
Gary Kramlich <grim@reaperworld.com>
parents: 43137
diff changeset
126 "url", "https://pidgin.im/",
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
127 "user-nickname", "knick-knack",
42114
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 NULL);
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 /* Now use g_object_get to read all of the properties. */
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 g_object_get(conversation,
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
132 "account", &account1,
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
133 "age-restricted", &age_restricted,
42773
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
134 "alias", &alias,
42355
6f7c6b84aaa0 Add an avatar property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42316
diff changeset
135 "avatar", &avatar1,
43137
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
136 "avatar-editable", &avatar_editable,
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
137 "created-on", &created_on1,
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
138 "creator", &creator1,
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
139 "description", &description,
43137
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
140 "description-editable", &description_editable,
42916
28a4480fe746 Add Purple.Conversation:drafting
Gary Kramlich <grim@reaperworld.com>
parents: 42908
diff changeset
141 "drafting", &drafting,
43064
ac5311a8f11e Add PurpleConversation:error property
Markus Fischer <ivanhoe@fiscari.de>
parents: 42968
diff changeset
142 "error", &error1,
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
143 "favorite", &favorite,
42800
5c55680a1a6b Add Purple.Conversation:global-id
Gary Kramlich <grim@reaperworld.com>
parents: 42773
diff changeset
144 "global-id", &global_id,
42272
015257326ad4 Add an id property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42184
diff changeset
145 "id", &id,
42908
64bbb9d4bf94 Add a logging property to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42901
diff changeset
146 "logging", &logging,
42114
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 "members", &members,
42848
f9a04b0bed1f Add a needs-attention property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42823
diff changeset
148 "needs-attention", &needs_attention,
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
149 "tags", &tags,
42760
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
150 "title", &title,
43137
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
151 "title-editable", &title_editable,
42773
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
152 "title-for-display", &title_for_display,
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
153 "topic", &topic,
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
154 "topic-author", &topic_author1,
43137
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
155 "topic-editable", &topic_editable,
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
156 "topic-updated", &topic_updated1,
42316
3985c3404f20 Add PurpleConversationType
Gary Kramlich <grim@reaperworld.com>
parents: 42302
diff changeset
157 "type", &type,
42884
5a7d425c9d1b Add a typing-state property to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42857
diff changeset
158 "typing-state", &typing_state,
43234
85be702275e6 Add Purple.Conversation:url
Gary Kramlich <grim@reaperworld.com>
parents: 43137
diff changeset
159 "url", &url,
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
160 "user-nickname", &user_nickname,
42114
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 NULL);
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 /* Compare all the things. */
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 g_assert_true(account1 == account);
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
165 g_clear_object(&account1);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
166
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
167 g_assert_true(age_restricted);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
168
42773
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
169 g_assert_cmpstr(alias, ==, "talky talk");
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
170 g_clear_pointer(&alias, g_free);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
171
42355
6f7c6b84aaa0 Add an avatar property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42316
diff changeset
172 g_assert_true(avatar1 == avatar);
6f7c6b84aaa0 Add an avatar property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42316
diff changeset
173 g_clear_object(&avatar1);
6f7c6b84aaa0 Add an avatar property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42316
diff changeset
174
43137
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
175 g_assert_true(avatar_editable);
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
176
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
177 g_assert_nonnull(created_on1);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
178 g_assert_true(g_date_time_equal(created_on1, created_on));
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
179 g_clear_pointer(&created_on1, g_date_time_unref);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
180
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
181 g_assert_true(creator1 == creator);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
182 g_clear_object(&creator1);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
183
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
184 g_assert_cmpstr(description, ==, "to describe or not to describe...");
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
185 g_clear_pointer(&description, g_free);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
186
43137
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
187 g_assert_true(description_editable);
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
188
42916
28a4480fe746 Add Purple.Conversation:drafting
Gary Kramlich <grim@reaperworld.com>
parents: 42908
diff changeset
189 g_assert_true(drafting);
28a4480fe746 Add Purple.Conversation:drafting
Gary Kramlich <grim@reaperworld.com>
parents: 42908
diff changeset
190
43064
ac5311a8f11e Add PurpleConversation:error property
Markus Fischer <ivanhoe@fiscari.de>
parents: 42968
diff changeset
191 g_assert_error(error1, error->domain, error->code);
ac5311a8f11e Add PurpleConversation:error property
Markus Fischer <ivanhoe@fiscari.de>
parents: 42968
diff changeset
192 g_assert_cmpstr(error1->message, ==, "recipient unavailable");
ac5311a8f11e Add PurpleConversation:error property
Markus Fischer <ivanhoe@fiscari.de>
parents: 42968
diff changeset
193 g_clear_error(&error);
ac5311a8f11e Add PurpleConversation:error property
Markus Fischer <ivanhoe@fiscari.de>
parents: 42968
diff changeset
194 g_clear_error(&error1);
ac5311a8f11e Add PurpleConversation:error property
Markus Fischer <ivanhoe@fiscari.de>
parents: 42968
diff changeset
195
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
196 g_assert_true(favorite);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
197
42800
5c55680a1a6b Add Purple.Conversation:global-id
Gary Kramlich <grim@reaperworld.com>
parents: 42773
diff changeset
198 g_assert_cmpstr(global_id, ==, "test-id1");
5c55680a1a6b Add Purple.Conversation:global-id
Gary Kramlich <grim@reaperworld.com>
parents: 42773
diff changeset
199 g_clear_pointer(&global_id, g_free);
5c55680a1a6b Add Purple.Conversation:global-id
Gary Kramlich <grim@reaperworld.com>
parents: 42773
diff changeset
200
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
201 g_assert_cmpstr(id, ==, "id1");
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
202 g_clear_pointer(&id, g_free);
42114
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
204 g_assert_true(G_IS_LIST_MODEL(members));
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
205 g_clear_object(&members);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
206
42908
64bbb9d4bf94 Add a logging property to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42901
diff changeset
207 g_assert_true(logging);
64bbb9d4bf94 Add a logging property to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42901
diff changeset
208
42848
f9a04b0bed1f Add a needs-attention property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42823
diff changeset
209 g_assert_true(needs_attention);
f9a04b0bed1f Add a needs-attention property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42823
diff changeset
210
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
211 g_assert_true(PURPLE_IS_TAGS(tags));
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
212 g_clear_object(&tags);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
213
42760
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
214 g_assert_cmpstr(title, ==, "test conversation");
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
215 g_clear_pointer(&title, g_free);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
216
43137
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
217 g_assert_true(title_editable);
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
218
42773
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
219 g_assert_cmpstr(title_for_display, ==, "talky talk");
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
220 g_clear_pointer(&title_for_display, g_free);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
221
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
222 g_assert_cmpstr(topic, ==, "the topic...");
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
223 g_clear_pointer(&topic, g_free);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
224
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
225 g_assert_true(topic_author == topic_author1);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
226 g_clear_object(&topic_author1);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
227
43137
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
228 g_assert_true(topic_editable);
8d1d2ab65c87 Add properties to track whether conversation properties are editable
Gary Kramlich <grim@reaperworld.com>
parents: 43135
diff changeset
229
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
230 g_assert_nonnull(topic_updated1);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
231 g_assert_true(g_date_time_equal(topic_updated1, topic_updated));
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
232 g_clear_pointer(&topic_updated1, g_date_time_unref);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
233
42653
584895b844d2 PurpleConversationType's values were pascal case when they should be upper snake case
Gary Kramlich <grim@reaperworld.com>
parents: 42535
diff changeset
234 g_assert_cmpuint(type, ==, PURPLE_CONVERSATION_TYPE_THREAD);
42316
3985c3404f20 Add PurpleConversationType
Gary Kramlich <grim@reaperworld.com>
parents: 42302
diff changeset
235
42884
5a7d425c9d1b Add a typing-state property to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42857
diff changeset
236 g_assert_cmpuint(typing_state, ==, PURPLE_TYPING_STATE_TYPING);
5a7d425c9d1b Add a typing-state property to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42857
diff changeset
237
43234
85be702275e6 Add Purple.Conversation:url
Gary Kramlich <grim@reaperworld.com>
parents: 43137
diff changeset
238 g_assert_cmpstr(url, ==, "https://pidgin.im/");
85be702275e6 Add Purple.Conversation:url
Gary Kramlich <grim@reaperworld.com>
parents: 43137
diff changeset
239 g_clear_pointer(&url, g_free);
85be702275e6 Add Purple.Conversation:url
Gary Kramlich <grim@reaperworld.com>
parents: 43137
diff changeset
240
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
241 g_assert_cmpstr(user_nickname, ==, "knick-knack");
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
242 g_clear_pointer(&user_nickname, g_free);
42114
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243
42355
6f7c6b84aaa0 Add an avatar property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42316
diff changeset
244 g_clear_object(&avatar);
42292
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
245 g_clear_object(&topic_author);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
246 g_clear_pointer(&topic_updated, g_date_time_unref);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
247 g_clear_pointer(&created_on, g_date_time_unref);
5bc9561e5f2b Add a bunch of properties to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42272
diff changeset
248 g_clear_object(&creator);
42114
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 g_clear_object(&account);
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 g_clear_object(&conversation);
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 }
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252
42302
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
253 static void
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
254 test_purple_conversation_set_topic_full(void) {
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
255 PurpleAccount *account = NULL;
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
256 PurpleConversation *conversation = NULL;
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
257 PurpleContactInfo *author = NULL;
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
258 GDateTime *updated = NULL;
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
259 GDateTime *updated1 = NULL;
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
260 const char *topic = "this is the topic";
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
261
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
262 account = purple_account_new("test", "test");
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
263 conversation = g_object_new(
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
264 PURPLE_TYPE_CONVERSATION,
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
265 "account", account,
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
266 NULL);
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
267
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
268 g_assert_true(PURPLE_IS_CONVERSATION(conversation));
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
269
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
270 author = purple_contact_info_new(NULL);
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
271 updated = g_date_time_new_now_utc();
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
272
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
273 purple_conversation_set_topic_full(conversation, topic, author, updated);
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
274
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
275 g_assert_cmpstr(purple_conversation_get_topic(conversation), ==, topic);
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
276 g_assert_true(purple_conversation_get_topic_author(conversation) ==
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
277 author);
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
278
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
279 updated1 = purple_conversation_get_topic_updated(conversation);
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
280 g_assert_nonnull(updated1);
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
281 g_assert_true(g_date_time_equal(updated1, updated));
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
282
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
283 g_clear_pointer(&updated, g_date_time_unref);
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
284 g_clear_object(&author);
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
285 g_clear_object(&account);
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
286 g_clear_object(&conversation);
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
287 }
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
288
42773
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
289 static void
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
290 test_purple_conversation_title_for_display(void) {
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
291 PurpleAccount *account = NULL;
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
292 PurpleConversation *conversation = NULL;
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
293 const char *title_for_display = NULL;
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
294 guint counter = 0;
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
295
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
296 account = purple_account_new("test", "test");
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
297 conversation = g_object_new(
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
298 PURPLE_TYPE_CONVERSATION,
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
299 "account", account,
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
300 "id", "id1",
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
301 NULL);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
302 g_signal_connect(conversation, "notify::title-for-display",
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
303 G_CALLBACK(test_purple_conversation_notify_counter_cb),
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
304 &counter);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
305
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
306 /* Make sure the defaults are all as expected. */
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
307 g_assert_cmpuint(counter, ==, 0);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
308 title_for_display = purple_conversation_get_title_for_display(conversation);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
309 g_assert_cmpstr(title_for_display, ==, "id1");
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
310
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
311 /* Set the alias, verify that the notify was sent for name-for-display and
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
312 * that it returns the right value.
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
313 */
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
314 purple_conversation_set_alias(conversation, "alias1");
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
315 g_assert_cmpuint(counter, ==, 1);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
316 title_for_display = purple_conversation_get_title_for_display(conversation);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
317 g_assert_cmpstr(title_for_display, ==, "alias1");
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
318
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
319 /* Set the title, which won't change the name for display because alias is
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
320 * set, but it should still emit the signal because we don't track the
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
321 * name-for-display in every setter.
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
322 */
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
323 purple_conversation_set_title(conversation, "title1");
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
324 g_assert_cmpuint(counter, ==, 2);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
325 title_for_display = purple_conversation_get_title_for_display(conversation);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
326 g_assert_cmpstr(title_for_display, ==, "alias1");
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
327
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
328 /* Now set the alias to NULL which should emit the signal and
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
329 * title_for_display should now return title1.
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
330 */
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
331 purple_conversation_set_alias(conversation, NULL);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
332 g_assert_cmpuint(counter, ==, 3);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
333 title_for_display = purple_conversation_get_title_for_display(conversation);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
334 g_assert_cmpstr(title_for_display, ==, "title1");
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
335
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
336 /* Finally remove the title as well, which should emit the signal and
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
337 * get_title_for_display should return the id.
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
338 */
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
339 purple_conversation_set_title(conversation, NULL);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
340 g_assert_cmpuint(counter, ==, 4);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
341 title_for_display = purple_conversation_get_title_for_display(conversation);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
342 g_assert_cmpstr(title_for_display, ==, "id1");
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
343
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
344 /* We're done!! */
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
345 g_assert_finalize_object(conversation);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
346
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
347 /* We can't use g_assert_finalize_object because accounts automatically
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
348 * get added to the account manager.
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
349 */
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
350 g_clear_object(&account);
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
351 }
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
352
42114
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353 /******************************************************************************
42669
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
354 * "is" tests
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
355 *****************************************************************************/
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
356 static void
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
357 test_purple_conversation_is_dm(void) {
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
358 PurpleAccount *account = NULL;
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
359 PurpleConversation *conversation = NULL;
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
360
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
361 account = purple_account_new("test", "test");
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
362 conversation = g_object_new(
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
363 PURPLE_TYPE_CONVERSATION,
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
364 "account", account,
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
365 "type", PURPLE_CONVERSATION_TYPE_DM,
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
366 NULL);
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
367
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
368 g_assert_true(PURPLE_IS_CONVERSATION(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
369 g_assert_true(purple_conversation_is_dm(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
370 g_assert_false(purple_conversation_is_group_dm(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
371 g_assert_false(purple_conversation_is_channel(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
372 g_assert_false(purple_conversation_is_thread(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
373
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
374 g_assert_finalize_object(conversation);
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
375
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
376 g_clear_object(&account);
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
377 }
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
378
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
379 static void
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
380 test_purple_conversation_is_group_dm(void) {
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
381 PurpleAccount *account = NULL;
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
382 PurpleConversation *conversation = NULL;
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
383
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
384 account = purple_account_new("test", "test");
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
385 conversation = g_object_new(
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
386 PURPLE_TYPE_CONVERSATION,
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
387 "account", account,
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
388 "type", PURPLE_CONVERSATION_TYPE_GROUP_DM,
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
389 NULL);
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
390
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
391 g_assert_true(PURPLE_IS_CONVERSATION(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
392 g_assert_false(purple_conversation_is_dm(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
393 g_assert_true(purple_conversation_is_group_dm(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
394 g_assert_false(purple_conversation_is_channel(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
395 g_assert_false(purple_conversation_is_thread(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
396
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
397 g_assert_finalize_object(conversation);
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
398
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
399 g_clear_object(&account);
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
400 }
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
401
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
402 static void
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
403 test_purple_conversation_is_channel(void) {
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
404 PurpleAccount *account = NULL;
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
405 PurpleConversation *conversation = NULL;
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
406
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
407 account = purple_account_new("test", "test");
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
408 conversation = g_object_new(
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
409 PURPLE_TYPE_CONVERSATION,
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
410 "account", account,
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
411 "type", PURPLE_CONVERSATION_TYPE_CHANNEL,
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
412 NULL);
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
413
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
414 g_assert_true(PURPLE_IS_CONVERSATION(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
415 g_assert_false(purple_conversation_is_dm(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
416 g_assert_false(purple_conversation_is_group_dm(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
417 g_assert_true(purple_conversation_is_channel(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
418 g_assert_false(purple_conversation_is_thread(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
419
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
420 g_assert_finalize_object(conversation);
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
421
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
422 g_clear_object(&account);
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
423 }
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
424
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
425 static void
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
426 test_purple_conversation_is_thread(void) {
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
427 PurpleAccount *account = NULL;
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
428 PurpleConversation *conversation = NULL;
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
429
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
430 account = purple_account_new("test", "test");
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
431 conversation = g_object_new(
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
432 PURPLE_TYPE_CONVERSATION,
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
433 "account", account,
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
434 "type", PURPLE_CONVERSATION_TYPE_THREAD,
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
435 NULL);
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
436
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
437 g_assert_true(PURPLE_IS_CONVERSATION(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
438 g_assert_false(purple_conversation_is_dm(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
439 g_assert_false(purple_conversation_is_group_dm(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
440 g_assert_false(purple_conversation_is_channel(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
441 g_assert_true(purple_conversation_is_thread(conversation));
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
442
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
443 g_assert_finalize_object(conversation);
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
444
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
445 g_clear_object(&account);
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
446 }
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
447
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
448 /******************************************************************************
42299
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
449 * Message Tests
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
450 *****************************************************************************/
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
451 static void
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
452 test_purple_conversation_message_write_one(void) {
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
453 PurpleAccount *account = NULL;
42901
d3ff1696a39a Update Purple.Message to use the Purple.ContactInfo
Gary Kramlich <grim@reaperworld.com>
parents: 42891
diff changeset
454 PurpleContactInfo *info = NULL;
42299
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
455 PurpleConversation *conversation = NULL;
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43064
diff changeset
456 PurpleConversationMember *author = NULL;
42299
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
457 PurpleMessage *message = NULL;
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
458 GListModel *messages = NULL;
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
459
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
460 account = purple_account_new("test", "test");
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
461 conversation = g_object_new(
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
462 PURPLE_TYPE_CONVERSATION,
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
463 "account", account,
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
464 NULL);
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
465
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43064
diff changeset
466 info = purple_account_get_contact_info(account);
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43064
diff changeset
467 author = purple_conversation_find_or_add_member(conversation, info, FALSE,
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43064
diff changeset
468 NULL);
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43064
diff changeset
469
42299
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
470 messages = purple_conversation_get_messages(conversation);
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
471 g_assert_nonnull(messages);
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
472 g_assert_cmpuint(g_list_model_get_n_items(messages), ==, 0);
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
473
43100
e6df74d36862 Change Purple.Message:author to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 43064
diff changeset
474 message = purple_message_new(author, "hello world!");
42299
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
475 purple_conversation_write_message(conversation, message);
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
476 g_assert_cmpuint(g_list_model_get_n_items(messages), ==, 1);
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
477
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
478 g_clear_object(&message);
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
479 g_clear_object(&account);
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
480 g_clear_object(&conversation);
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
481 }
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
482
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
483 /******************************************************************************
42736
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
484 * Signal tests
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
485 *****************************************************************************/
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
486 static void
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
487 test_purple_conversation_present_cb(PurpleConversation *conversation,
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
488 gpointer data)
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
489 {
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
490 guint *counter = data;
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
491
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
492 g_assert_true(PURPLE_IS_CONVERSATION(conversation));
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
493
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
494 *counter = *counter + 1;
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
495 }
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
496
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
497 static void
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
498 test_purple_conversation_signals_present(void) {
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
499 PurpleAccount *account = NULL;
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
500 PurpleConversation *conversation = NULL;
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
501 guint counter = 0;
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
502
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
503 account = purple_account_new("test", "test");
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
504 conversation = g_object_new(
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
505 PURPLE_TYPE_CONVERSATION,
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
506 "account", account,
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
507 "type", PURPLE_CONVERSATION_TYPE_DM,
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
508 NULL);
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
509
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
510 g_signal_connect(conversation, "present",
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
511 G_CALLBACK(test_purple_conversation_present_cb),
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
512 &counter);
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
513
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
514 g_assert_cmpuint(counter, ==, 0);
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
515 purple_conversation_present(conversation);
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
516 g_assert_cmpuint(counter, ==, 1);
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
517
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
518 g_assert_finalize_object(conversation);
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
519 g_clear_object(&account);
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
520 }
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
521
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
522 /******************************************************************************
42760
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
523 * generate_title tests
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
524 *****************************************************************************/
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
525 static void
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
526 test_purple_conversation_generate_title_empty(void) {
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
527 PurpleAccount *account = NULL;
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
528 PurpleConversation *conversation = NULL;
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
529 const char *title = NULL;
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
530
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
531 account = purple_account_new("test", "test");
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
532 conversation = g_object_new(
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
533 PURPLE_TYPE_CONVERSATION,
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
534 "account", account,
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
535 "type", PURPLE_CONVERSATION_TYPE_DM,
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
536 NULL);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
537
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
538 title = purple_conversation_get_title(conversation);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
539 g_assert_null(title);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
540
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
541 purple_conversation_set_title(conversation, "test");
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
542 title = purple_conversation_get_title(conversation);
42823
77214989b64c Fix dead assignment bug reported by scan-build
Markus Fischer <ivanhoe@fiscari.de>
parents: 42805
diff changeset
543 g_assert_cmpstr(title, ==, "test");
42760
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
544
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
545 /* There are no members in this conversation, so calling generate_title
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
546 * doesn't change the title.
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
547 */
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
548 purple_conversation_generate_title(conversation);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
549 title = purple_conversation_get_title(conversation);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
550 g_assert_cmpstr(title, ==, "test");
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
551
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
552 g_assert_finalize_object(conversation);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
553 g_clear_object(&account);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
554 }
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
555
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
556 static void
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
557 test_purple_conversation_generate_title_dm(void) {
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
558 PurpleAccount *account = NULL;
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
559 PurpleContact *contact = NULL;
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
560 PurpleConversation *conversation = NULL;
42891
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42890
diff changeset
561 PurpleConversationMembers *members = NULL;
42760
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
562 const char *title = NULL;
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
563
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
564 account = purple_account_new("test", "test");
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
565 conversation = g_object_new(
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
566 PURPLE_TYPE_CONVERSATION,
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
567 "account", account,
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
568 "type", PURPLE_CONVERSATION_TYPE_DM,
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
569 NULL);
42891
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42890
diff changeset
570 members = purple_conversation_get_members(conversation);
42760
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
571
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
572 title = purple_conversation_get_title(conversation);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
573 g_assert_null(title);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
574
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
575 contact = purple_contact_new(account, NULL);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
576 purple_contact_info_set_username(PURPLE_CONTACT_INFO(contact), "Alice");
42891
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42890
diff changeset
577 purple_conversation_members_add_member(members,
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42890
diff changeset
578 PURPLE_CONTACT_INFO(contact), FALSE,
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42890
diff changeset
579 NULL);
42760
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
580
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
581 title = purple_conversation_get_title(conversation);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
582 g_assert_cmpstr(title, ==, "Alice");
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
583
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
584 /* Make sure the title updates when the display name changes. */
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
585 purple_contact_info_set_username(PURPLE_CONTACT_INFO(contact), "alice!");
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
586 title = purple_conversation_get_title(conversation);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
587 g_assert_cmpstr(title, ==, "alice!");
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
588
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
589 g_assert_finalize_object(conversation);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
590 g_assert_finalize_object(contact);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
591 g_clear_object(&account);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
592 }
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
593
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
594 static void
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
595 test_purple_conversation_generate_title_group_dm(void) {
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
596 PurpleAccount *account = NULL;
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
597 PurpleContact *contact1 = NULL;
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
598 PurpleContact *contact2 = NULL;
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
599 PurpleContact *contact3 = NULL;
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
600 PurpleConversation *conversation = NULL;
42891
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42890
diff changeset
601 PurpleConversationMembers *members = NULL;
42760
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
602 const char *title = NULL;
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
603
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
604 account = purple_account_new("test", "test");
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
605 conversation = g_object_new(
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
606 PURPLE_TYPE_CONVERSATION,
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
607 "account", account,
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
608 "type", PURPLE_CONVERSATION_TYPE_GROUP_DM,
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
609 NULL);
42891
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42890
diff changeset
610 members = purple_conversation_get_members(conversation);
42760
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
611
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
612 title = purple_conversation_get_title(conversation);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
613 g_assert_null(title);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
614
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
615 contact1 = purple_contact_new(account, NULL);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
616 purple_contact_info_set_username(PURPLE_CONTACT_INFO(contact1), "Alice");
42891
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42890
diff changeset
617 purple_conversation_members_add_member(members,
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42890
diff changeset
618 PURPLE_CONTACT_INFO(contact1),
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42890
diff changeset
619 FALSE, NULL);
42760
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
620
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
621 contact2 = purple_contact_new(account, NULL);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
622 purple_contact_info_set_username(PURPLE_CONTACT_INFO(contact2), "Bob");
42891
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42890
diff changeset
623 purple_conversation_members_add_member(members,
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42890
diff changeset
624 PURPLE_CONTACT_INFO(contact2),
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42890
diff changeset
625 FALSE, NULL);
42760
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
626
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
627 contact3 = purple_contact_new(account, NULL);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
628 purple_contact_info_set_username(PURPLE_CONTACT_INFO(contact3), "Eve");
42891
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42890
diff changeset
629 purple_conversation_members_add_member(members,
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42890
diff changeset
630 PURPLE_CONTACT_INFO(contact3),
7f8daf96e7d3 Move Purple.Conversation:members to Purple.ConversationMembers
Gary Kramlich <grim@reaperworld.com>
parents: 42890
diff changeset
631 FALSE, NULL);
42760
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
632
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
633 title = purple_conversation_get_title(conversation);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
634 g_assert_cmpstr(title, ==, "Alice, Bob, Eve");
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
635
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
636 /* Change some names around and verify the title was generated properly. */
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
637 purple_contact_info_set_username(PURPLE_CONTACT_INFO(contact2), "Robert");
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
638 purple_contact_info_set_username(PURPLE_CONTACT_INFO(contact3), "Evelyn");
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
639
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
640 title = purple_conversation_get_title(conversation);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
641 g_assert_cmpstr(title, ==, "Alice, Robert, Evelyn");
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
642
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
643 g_assert_finalize_object(conversation);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
644 g_assert_finalize_object(contact1);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
645 g_assert_finalize_object(contact2);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
646 g_assert_finalize_object(contact3);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
647 g_clear_object(&account);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
648 }
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
649
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
650 /******************************************************************************
42968
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
651 * Tags Tests
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
652 *****************************************************************************/
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
653 static void
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
654 test_purple_conversation_tags_unset(void) {
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
655 PurpleAccount *account = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
656 PurpleConversation *conversation = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
657 PurpleTags *actual = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
658 PurpleTags *expected = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
659 const char *account_id = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
660
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
661 expected = purple_tags_new();
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
662 purple_tags_add_with_value(expected, "protocol-id", "test");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
663 purple_tags_add(expected, "type");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
664
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
665 account = purple_account_new("test", "test");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
666 conversation = g_object_new(
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
667 PURPLE_TYPE_CONVERSATION,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
668 "account", account,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
669 NULL);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
670
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
671 actual = purple_conversation_get_tags(conversation);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
672 g_assert_true(purple_tags_contains(actual, expected));
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
673
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
674 /* Account id is randomly generated so we just make sure it's not null. */
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
675 account_id = purple_tags_get(actual, "account-id");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
676 g_assert_nonnull(account_id);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
677
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
678 g_assert_finalize_object(expected);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
679 g_assert_finalize_object(conversation);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
680 g_assert_finalize_object(account);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
681 }
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
682
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
683 static void
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
684 test_purple_conversation_tags_dm(void) {
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
685 PurpleAccount *account = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
686 PurpleConversation *conversation = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
687 PurpleTags *actual = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
688 PurpleTags *expected = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
689 const char *account_id = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
690
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
691 expected = purple_tags_new();
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
692 purple_tags_add_with_value(expected, "protocol-id", "test");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
693 purple_tags_add_with_value(expected, "type", "dm");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
694
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
695 account = purple_account_new("test", "test");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
696 conversation = g_object_new(
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
697 PURPLE_TYPE_CONVERSATION,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
698 "account", account,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
699 "type", PURPLE_CONVERSATION_TYPE_DM,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
700 NULL);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
701
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
702 actual = purple_conversation_get_tags(conversation);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
703 g_assert_true(purple_tags_contains(actual, expected));
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
704
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
705 /* Account id is randomly generated so we just make sure it's not null. */
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
706 account_id = purple_tags_get(actual, "account-id");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
707 g_assert_nonnull(account_id);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
708
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
709 g_assert_finalize_object(expected);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
710 g_assert_finalize_object(conversation);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
711 g_assert_finalize_object(account);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
712 }
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
713
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
714 static void
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
715 test_purple_conversation_tags_group_dm(void) {
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
716 PurpleAccount *account = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
717 PurpleConversation *conversation = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
718 PurpleTags *actual = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
719 PurpleTags *expected = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
720 const char *account_id = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
721
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
722 expected = purple_tags_new();
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
723 purple_tags_add_with_value(expected, "protocol-id", "test");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
724 purple_tags_add_with_value(expected, "type", "group-dm");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
725
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
726 account = purple_account_new("test", "test");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
727 conversation = g_object_new(
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
728 PURPLE_TYPE_CONVERSATION,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
729 "account", account,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
730 "type", PURPLE_CONVERSATION_TYPE_GROUP_DM,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
731 NULL);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
732
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
733 actual = purple_conversation_get_tags(conversation);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
734 g_assert_true(purple_tags_contains(actual, expected));
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
735
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
736 /* Account id is randomly generated so we just make sure it's not null. */
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
737 account_id = purple_tags_get(actual, "account-id");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
738 g_assert_nonnull(account_id);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
739
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
740 g_assert_finalize_object(expected);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
741 g_assert_finalize_object(conversation);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
742 g_assert_finalize_object(account);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
743 }
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
744
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
745 static void
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
746 test_purple_conversation_tags_channel(void) {
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
747 PurpleAccount *account = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
748 PurpleConversation *conversation = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
749 PurpleTags *actual = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
750 PurpleTags *expected = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
751 const char *account_id = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
752
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
753 expected = purple_tags_new();
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
754 purple_tags_add_with_value(expected, "protocol-id", "test");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
755 purple_tags_add_with_value(expected, "type", "channel");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
756
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
757 account = purple_account_new("test", "test");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
758 conversation = g_object_new(
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
759 PURPLE_TYPE_CONVERSATION,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
760 "account", account,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
761 "type", PURPLE_CONVERSATION_TYPE_CHANNEL,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
762 NULL);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
763
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
764 actual = purple_conversation_get_tags(conversation);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
765 g_assert_true(purple_tags_contains(actual, expected));
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
766
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
767 /* Account id is randomly generated so we just make sure it's not null. */
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
768 account_id = purple_tags_get(actual, "account-id");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
769 g_assert_nonnull(account_id);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
770
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
771 g_assert_finalize_object(expected);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
772 g_assert_finalize_object(conversation);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
773 g_assert_finalize_object(account);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
774 }
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
775
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
776 static void
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
777 test_purple_conversation_tags_federated_channel(void) {
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
778 PurpleAccount *account = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
779 PurpleConversation *conversation = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
780 PurpleTags *actual = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
781 PurpleTags *expected = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
782 const char *account_id = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
783
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
784 expected = purple_tags_new();
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
785 purple_tags_add(expected, "federated");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
786 purple_tags_add_with_value(expected, "protocol-id", "test");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
787 purple_tags_add_with_value(expected, "type", "channel");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
788
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
789 account = purple_account_new("test", "test");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
790 conversation = g_object_new(
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
791 PURPLE_TYPE_CONVERSATION,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
792 "account", account,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
793 "federated", TRUE,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
794 "type", PURPLE_CONVERSATION_TYPE_CHANNEL,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
795 NULL);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
796
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
797 actual = purple_conversation_get_tags(conversation);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
798 g_assert_true(purple_tags_contains(actual, expected));
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
799
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
800 /* Account id is randomly generated so we just make sure it's not null. */
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
801 account_id = purple_tags_get(actual, "account-id");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
802 g_assert_nonnull(account_id);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
803
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
804 g_assert_finalize_object(expected);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
805 g_assert_finalize_object(conversation);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
806 g_assert_finalize_object(account);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
807 }
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
808
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
809 static void
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
810 test_purple_conversation_tags_thread(void) {
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
811 PurpleAccount *account = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
812 PurpleConversation *conversation = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
813 PurpleTags *actual = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
814 PurpleTags *expected = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
815 const char *account_id = NULL;
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
816
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
817 expected = purple_tags_new();
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
818 purple_tags_add_with_value(expected, "protocol-id", "test");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
819 purple_tags_add_with_value(expected, "type", "thread");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
820
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
821 account = purple_account_new("test", "test");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
822 conversation = g_object_new(
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
823 PURPLE_TYPE_CONVERSATION,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
824 "account", account,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
825 "type", PURPLE_CONVERSATION_TYPE_THREAD,
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
826 NULL);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
827
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
828 actual = purple_conversation_get_tags(conversation);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
829 g_assert_true(purple_tags_contains(actual, expected));
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
830
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
831 /* Account id is randomly generated so we just make sure it's not null. */
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
832 account_id = purple_tags_get(actual, "account-id");
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
833 g_assert_nonnull(account_id);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
834
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
835 g_assert_finalize_object(expected);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
836 g_assert_finalize_object(conversation);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
837 g_assert_finalize_object(account);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
838 }
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
839
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
840 /******************************************************************************
42114
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
841 * Main
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
842 *****************************************************************************/
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
843 gint
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
844 main(gint argc, gchar *argv[]) {
42184
4e1bf25f5575 Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42114
diff changeset
845 gint ret = 0;
4e1bf25f5575 Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42114
diff changeset
846
42114
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
847 g_test_init(&argc, &argv, NULL);
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
848
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
849 test_ui_purple_init();
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
850
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
851 g_test_add_func("/conversation/properties",
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
852 test_purple_conversation_properties);
42302
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
853 g_test_add_func("/conversation/set-topic-full",
54e2bf5af34a Add purple_conversation_set_topic_full
Gary Kramlich <grim@reaperworld.com>
parents: 42299
diff changeset
854 test_purple_conversation_set_topic_full);
42773
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
855 g_test_add_func("/conversation/title-for-display",
2718698a94b9 Add Conversation:alias and Conversation:title-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents: 42760
diff changeset
856 test_purple_conversation_title_for_display);
42114
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
857
42669
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
858 g_test_add_func("/conversation/is-dm", test_purple_conversation_is_dm);
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
859 g_test_add_func("/conversation/is-group-dm",
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
860 test_purple_conversation_is_group_dm);
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
861 g_test_add_func("/conversation/is-channel",
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
862 test_purple_conversation_is_channel);
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
863 g_test_add_func("/conversation/is-thread",
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
864 test_purple_conversation_is_thread);
6d41b29637ef Add some "is" methods to PurpleConversation to make type checking easier
Gary Kramlich <grim@reaperworld.com>
parents: 42654
diff changeset
865
42299
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
866 g_test_add_func("/conversation/message/write-one",
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
867 test_purple_conversation_message_write_one);
2dce52f93848 Add a "messages" property to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents: 42292
diff changeset
868
42736
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
869 g_test_add_func("/conversation/signals/present",
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
870 test_purple_conversation_signals_present);
630084f39cc5 Add a present signal to PurpleConversation and propagate it from PurpleConversationManager
Gary Kramlich <grim@reaperworld.com>
parents: 42669
diff changeset
871
42760
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
872 g_test_add_func("/conversation/generate-title/empty",
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
873 test_purple_conversation_generate_title_empty);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
874 g_test_add_func("/conversation/generate-title/dm",
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
875 test_purple_conversation_generate_title_dm);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
876 g_test_add_func("/conversation/generate-title/group-dm",
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
877 test_purple_conversation_generate_title_group_dm);
0c293ecd56c2 Automatically generate titles for DMs and GroupDMs
Gary Kramlich <grim@reaperworld.com>
parents: 42736
diff changeset
878
42968
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
879 g_test_add_func("/conversation/tags/unset",
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
880 test_purple_conversation_tags_unset);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
881 g_test_add_func("/conversation/tags/dm",
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
882 test_purple_conversation_tags_dm);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
883 g_test_add_func("/conversation/tags/group-dm",
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
884 test_purple_conversation_tags_group_dm);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
885 g_test_add_func("/conversation/tags/channel",
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
886 test_purple_conversation_tags_channel);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
887 g_test_add_func("/conversation/tags/federated-channel",
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
888 test_purple_conversation_tags_federated_channel);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
889 g_test_add_func("/conversation/tags/thread",
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
890 test_purple_conversation_tags_thread);
9bb936b002a2 Add some automatic tags to Purple.Conversation
Gary Kramlich <grim@reaperworld.com>
parents: 42916
diff changeset
891
42184
4e1bf25f5575 Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42114
diff changeset
892 ret = g_test_run();
4e1bf25f5575 Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42114
diff changeset
893
4e1bf25f5575 Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42114
diff changeset
894 test_ui_purple_uninit();
4e1bf25f5575 Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42114
diff changeset
895
4e1bf25f5575 Fix several leaks in tests
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42114
diff changeset
896 return ret;
42114
d3fe2b899c89 Add membership management to PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
897 }

mercurial