Fri, 03 Jan 2025 00:38:29 -0600
Use g_timeout_add_once where possible
In cases where `G_SOURCE_REMOVE` is always returned and no destroy func is needed, then we can use these simplifying functions instead.
Also, for callbacks, use `G_SOURCE_CONTINUE`/`G_SOURCE_REMOVE` instead of `TRUE`/`FALSE`.
These were mostly added in GLib 2.74, except `g_timeout_add_seconds_once` is from 2.78.
Testing Done:
Ran `ninja turtles`.
Reviewed at https://reviews.imfreedom.org/r/3729/
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * This library is free software; you can redistribute it and/or |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * modify it under the terms of the GNU Lesser General Public |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * License as published by the Free Software Foundation; either |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * version 2 of the License, or (at your option) any later version. |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * This library is distributed in the hope that it will be useful, |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * Lesser General Public License for more details. |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU Lesser General Public |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * License along with this library; if not, see <https://www.gnu.org/licenses/>. |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | */ |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | #include <glib.h> |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | #include <purple.h> |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | /****************************************************************************** |
|
42779
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
24 | * Callbacks |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
25 | *****************************************************************************/ |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
26 | static void |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
27 | test_purple_conversation_member_notify_counter(GObject *self, |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
28 | G_GNUC_UNUSED GParamSpec *pspec, |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
29 | gpointer data) |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
30 | { |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
31 | guint *counter = data; |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
32 | |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
33 | g_assert_true(PURPLE_IS_CONVERSATION_MEMBER(self)); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
34 | |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
35 | *counter = *counter + 1; |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
36 | } |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
37 | |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
38 | /****************************************************************************** |
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | * Tests |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | *****************************************************************************/ |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | static void |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | test_purple_conversation_member_new(void) { |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | PurpleContactInfo *info = NULL; |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | PurpleConversationMember *member = NULL; |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | info = purple_contact_info_new(NULL); |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | g_assert_true(PURPLE_IS_CONTACT_INFO(info)); |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | member = purple_conversation_member_new(info); |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | g_assert_true(PURPLE_IS_CONVERSATION_MEMBER(member)); |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | g_clear_object(&info); |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | g_clear_object(&member); |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | } |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | static void |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | test_purple_conversation_member_properties(void) { |
|
42921
a595e51a5bfa
Add a badges property to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42869
diff
changeset
|
58 | PurpleBadges *badges = NULL; |
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | PurpleContactInfo *info = NULL; |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | PurpleContactInfo *info1 = NULL; |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | PurpleConversationMember *member = NULL; |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | PurpleTags *tags = NULL; |
|
42113
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
63 | PurpleTypingState typing_state = PURPLE_TYPING_STATE_NONE; |
|
42779
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
64 | char *name_for_display = NULL; |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
65 | char *nickname = NULL; |
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | info = purple_contact_info_new("abc123"); |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | /* Use g_object_new so we can test setting properties by name. All of them |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | * call the setter methods, so by doing it this way we exercise more of the |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | * code. |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | */ |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | member = g_object_new( |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | PURPLE_TYPE_CONVERSATION_MEMBER, |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | "contact-info", info, |
|
42779
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
76 | "nickname", "pidgy", |
|
42113
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
77 | "typing-state", PURPLE_TYPING_STATE_TYPING, |
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | NULL); |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | /* Now use g_object_get to read all of the properties. */ |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | g_object_get(member, |
|
42921
a595e51a5bfa
Add a badges property to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42869
diff
changeset
|
82 | "badges", &badges, |
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | "contact-info", &info1, |
|
42779
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
84 | "name-for-display", &name_for_display, |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
85 | "nickname", &nickname, |
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | "tags", &tags, |
|
42113
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
87 | "typing-state", &typing_state, |
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | NULL); |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | |
|
42921
a595e51a5bfa
Add a badges property to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42869
diff
changeset
|
90 | g_assert_true(PURPLE_IS_BADGES(badges)); |
|
a595e51a5bfa
Add a badges property to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42869
diff
changeset
|
91 | g_clear_object(&badges); |
|
a595e51a5bfa
Add a badges property to Purple.ConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42869
diff
changeset
|
92 | |
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | g_assert_true(info1 == info); |
|
42779
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
94 | g_clear_object(&info1); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
95 | |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
96 | g_assert_cmpstr(name_for_display, ==, "pidgy"); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
97 | g_clear_pointer(&name_for_display, g_free); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
98 | |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
99 | g_assert_cmpstr(nickname, ==, "pidgy"); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
100 | g_clear_pointer(&nickname, g_free); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
101 | |
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | g_assert_true(PURPLE_IS_TAGS(tags)); |
|
42779
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
103 | g_clear_object(&tags); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
104 | |
|
42113
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
105 | g_assert_cmpint(typing_state, ==, PURPLE_TYPING_STATE_TYPING); |
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | |
|
42779
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
107 | g_assert_finalize_object(member); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
108 | g_assert_finalize_object(info); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
109 | } |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
110 | |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
111 | static void |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
112 | test_purple_conversation_member_name_for_display(void) { |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
113 | PurpleContactInfo *info = NULL; |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
114 | PurpleConversationMember *member = NULL; |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
115 | const char *name_for_display = NULL; |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
116 | guint counter = 0; |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
117 | |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
118 | info = purple_contact_info_new("abc123"); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
119 | member = purple_conversation_member_new(info); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
120 | g_signal_connect(member, "notify::name-for-display", |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
121 | G_CALLBACK(test_purple_conversation_member_notify_counter), |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
122 | &counter); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
123 | |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
124 | /* Make sure our counter is still 0. */ |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
125 | g_assert_cmpuint(counter, ==, 0); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
126 | |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
127 | /* Make sure the default falls back to the contact info's id. */ |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
128 | name_for_display = purple_conversation_member_get_name_for_display(member); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
129 | g_assert_cmpstr(name_for_display, ==, "abc123"); |
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | |
|
42779
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
131 | /* Set the username on the contact info and make sure it propagates up. */ |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
132 | purple_contact_info_set_username(info, "tron"); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
133 | name_for_display = purple_conversation_member_get_name_for_display(member); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
134 | g_assert_cmpstr(name_for_display, ==, "tron"); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
135 | g_assert_cmpuint(counter, ==, 1); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
136 | |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
137 | /* Set the nickname on the conversation member and make sure that takes |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
138 | * precedence. |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
139 | */ |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
140 | purple_conversation_member_set_nickname(member, "rinzler"); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
141 | name_for_display = purple_conversation_member_get_name_for_display(member); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
142 | g_assert_cmpstr(name_for_display, ==, "rinzler"); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
143 | g_assert_cmpuint(counter, ==, 2); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
144 | |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
145 | /* Remove the nickname and verify it falls back to the value from the |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
146 | * contact info. |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
147 | */ |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
148 | purple_conversation_member_set_nickname(member, NULL); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
149 | name_for_display = purple_conversation_member_get_name_for_display(member); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
150 | g_assert_cmpstr(name_for_display, ==, "tron"); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
151 | g_assert_cmpuint(counter, ==, 3); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
152 | |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
153 | g_assert_finalize_object(member); |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
154 | g_assert_finalize_object(info); |
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
155 | } |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
156 | |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
157 | /****************************************************************************** |
|
42113
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
158 | * Typing State Timeout |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
159 | *****************************************************************************/ |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
160 | static void |
|
42869
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
161 | test_purple_conversation_manager_timeout_notify(GObject *obj, |
|
42113
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
162 | G_GNUC_UNUSED GParamSpec *pspec, |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
163 | gpointer data) |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
164 | { |
|
42869
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
165 | PurpleConversationMember *member = NULL; |
|
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
166 | PurpleTypingState state = PURPLE_TYPING_STATE_NONE; |
|
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
167 | gboolean *done = data; |
|
42113
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
168 | static guint count = 0; |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
169 | |
|
42869
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
170 | g_assert_true(PURPLE_IS_CONVERSATION_MEMBER(obj)); |
|
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
171 | member = PURPLE_CONVERSATION_MEMBER(obj); |
|
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
172 | |
|
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
173 | state = purple_conversation_member_get_typing_state(member); |
|
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
174 | if(count == 0) { |
|
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
175 | g_assert_cmpuint(state, ==, PURPLE_TYPING_STATE_TYPING); |
|
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
176 | } else if(count == 1) { |
|
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
177 | g_assert_cmpuint(state, ==, PURPLE_TYPING_STATE_NONE); |
|
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
178 | } else { |
|
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
179 | g_assert_not_reached(); |
|
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
180 | } |
|
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
181 | |
|
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
182 | /* Increment count each time we're called. */ |
|
42113
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
183 | count++; |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
184 | if(count >= 2) { |
|
42869
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
185 | *done = TRUE; |
|
42113
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
186 | } |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
187 | } |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
188 | |
|
43127
eae3279e871c
Use g_timeout_add_once where possible
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42921
diff
changeset
|
189 | static void |
|
42869
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
190 | test_purple_conversation_member_typing_state_fail_safe(gpointer data) { |
|
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
191 | gboolean *done = data; |
|
42113
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
192 | |
|
42869
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
193 | g_assert_not_reached(); |
|
42113
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
194 | |
|
42869
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
195 | *done = TRUE; |
|
42113
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
196 | } |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
197 | |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
198 | static void |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
199 | test_purple_conversation_member_typing_state_timeout(void) { |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
200 | PurpleContactInfo *info = NULL; |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
201 | PurpleConversationMember *member = NULL; |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
202 | PurpleTypingState typing_state = PURPLE_TYPING_STATE_TYPING; |
|
42869
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
203 | gboolean done = FALSE; |
|
42113
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
204 | |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
205 | /* Create the member and add a notify callback on the typing-state property |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
206 | * so we can check it and exit the main loop. |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
207 | */ |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
208 | info = purple_contact_info_new(NULL); |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
209 | member = purple_conversation_member_new(info); |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
210 | g_signal_connect(member, "notify::typing-state", |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
211 | G_CALLBACK(test_purple_conversation_manager_timeout_notify), |
|
42869
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
212 | &done); |
|
42113
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
213 | |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
214 | /* Set the state to typing with a timeout of 1 second. */ |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
215 | purple_conversation_member_set_typing_state(member, |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
216 | PURPLE_TYPING_STATE_TYPING, 1); |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
217 | |
|
42869
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
218 | /* We add a fail safe to set done after 2 seconds. */ |
|
43127
eae3279e871c
Use g_timeout_add_once where possible
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42921
diff
changeset
|
219 | g_timeout_add_seconds_once(2, |
|
eae3279e871c
Use g_timeout_add_once where possible
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42921
diff
changeset
|
220 | test_purple_conversation_member_typing_state_fail_safe, |
|
eae3279e871c
Use g_timeout_add_once where possible
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42921
diff
changeset
|
221 | &done); |
|
42113
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
222 | |
|
42869
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
223 | while(!done) { |
|
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
224 | g_main_context_iteration(NULL, FALSE); |
|
cd866a253d36
Modernize the Purple.ConversationMember tests
Gary Kramlich <grim@reaperworld.com>
parents:
42866
diff
changeset
|
225 | } |
|
42113
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
226 | |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
227 | /* Verify that our state got reset back to PURPLE_TYPING_STATE_NONE. */ |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
228 | typing_state = purple_conversation_member_get_typing_state(member); |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
229 | g_assert_cmpint(typing_state, ==, PURPLE_TYPING_STATE_NONE); |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
230 | |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
231 | /* Clean everything up. */ |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
232 | g_clear_object(&info); |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
233 | g_clear_object(&member); |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
234 | } |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
235 | |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
236 | /****************************************************************************** |
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
237 | * Main |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
238 | *****************************************************************************/ |
|
42866
4b201e18638f
Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
42779
diff
changeset
|
239 | int |
|
4b201e18638f
Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
42779
diff
changeset
|
240 | main(int argc, char *argv[]) { |
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
241 | g_test_init(&argc, &argv, NULL); |
|
42866
4b201e18638f
Modernize most of the unit tests
Gary Kramlich <grim@reaperworld.com>
parents:
42779
diff
changeset
|
242 | g_test_set_nonfatal_assertions(); |
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
243 | |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
244 | g_test_add_func("/conversation-member/new", |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
245 | test_purple_conversation_member_new); |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
246 | g_test_add_func("/conversation-member/properties", |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
247 | test_purple_conversation_member_properties); |
|
42779
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
248 | g_test_add_func("/conversation-member/name-for-display", |
|
365eaa9d46f8
Add ConversationMember:nickname and ConversationMember:name-for-display properties
Gary Kramlich <grim@reaperworld.com>
parents:
42113
diff
changeset
|
249 | test_purple_conversation_member_name_for_display); |
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
250 | |
|
42113
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
251 | g_test_add_func("/conversation-member/typing-state/timeout", |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
252 | test_purple_conversation_member_typing_state_timeout); |
|
393c2ea6b399
Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents:
42080
diff
changeset
|
253 | |
|
42080
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
254 | return g_test_run(); |
|
df47db24cee6
Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
255 | } |