4 * Purple is the legal property of its developers, whose names are too
5 * numerous to list here. Please refer to the COPYRIGHT file distributed
6 * with this source distribution
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or (at
11 * your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
30 /******************************************************************************
31 * PurpleProtcolAttention Implementations
32 *****************************************************************************/
33 static GType
test_purple_protocol_attention_get_type(void);
36 PurpleProtocol parent
;
39 } TestPurpleProtocolAttention
;
42 PurpleProtocolClass parent
;
43 } TestPurpleProtocolAttentionClass
;
47 test_purple_protocol_attention_send(PurpleProtocolAttention
*attn
, PurpleConnection
*c
, const gchar
*username
, guint type
) {
48 TestPurpleProtocolAttention
*test_attn
= (TestPurpleProtocolAttention
*)attn
;
50 test_attn
->send_called
= TRUE
;
56 test_purple_protocol_attention_get_types(PurpleProtocolAttention
*attn
, PurpleAccount
*acct
) {
59 types
= g_list_append(types
, purple_attention_type_new("id", "name", "incoming", "outgoing"));
65 test_purple_protocol_attention_iface_init(PurpleProtocolAttentionInterface
*iface
) {
66 iface
->send
= test_purple_protocol_attention_send
;
67 iface
->get_types
= test_purple_protocol_attention_get_types
;
70 G_DEFINE_TYPE_WITH_CODE(
71 TestPurpleProtocolAttention
,
72 test_purple_protocol_attention
,
74 G_IMPLEMENT_INTERFACE(
75 PURPLE_TYPE_PROTOCOL_ATTENTION
,
76 test_purple_protocol_attention_iface_init
81 test_purple_protocol_attention_init(TestPurpleProtocolAttention
*prplattn
) {
82 PurpleProtocol
*prpl
= PURPLE_PROTOCOL(prplattn
);
84 prpl
->id
= "prpl-attention";
88 test_purple_protocol_attention_class_init(TestPurpleProtocolAttentionClass
*klass
) {
91 /******************************************************************************
93 *****************************************************************************/
95 test_purple_protocol_attention_can_send(void) {
96 TestPurpleProtocolAttention
*attn
= g_object_new(test_purple_protocol_attention_get_type(), NULL
);
97 PurpleAccount
*a
= purple_account_new("prpl-attn-can-send", "prpl-attn");
98 PurpleConnection
*c
= g_object_new(PURPLE_TYPE_CONNECTION
, "account", a
, NULL
);
99 gboolean actual
= FALSE
;
101 attn
->send_called
= FALSE
;
102 actual
= purple_protocol_attention_send(PURPLE_PROTOCOL_ATTENTION(attn
), c
, "someguy", 0);
103 g_assert_true(actual
);
105 g_assert_true(attn
->send_called
);
109 test_purple_protocol_attention_can_get_types(void) {
110 TestPurpleProtocolAttention
*attn
= g_object_new(test_purple_protocol_attention_get_type(), NULL
);
111 PurpleAccount
*a
= purple_account_new("prpl-attn-can-get-types", "prpl-attn");
113 PurpleAttentionType
*type
= NULL
;
115 types
= purple_protocol_attention_get_types(PURPLE_PROTOCOL_ATTENTION(attn
), a
);
116 g_assert_true(g_list_length(types
) == 1);
118 /* take the first item and cast it into type */
119 type
= (PurpleAttentionType
*)(types
->data
);
122 g_assert_cmpstr(purple_attention_type_get_unlocalized_name(type
), ==, "id");
123 g_assert_cmpstr(purple_attention_type_get_name(type
), ==, "name");
124 g_assert_cmpstr(purple_attention_type_get_incoming_desc(type
), ==, "incoming");
125 g_assert_cmpstr(purple_attention_type_get_outgoing_desc(type
), ==, "outgoing");
128 /******************************************************************************
130 *****************************************************************************/
132 main(gint argc
, gchar
**argv
) {
135 g_test_init(&argc
, &argv
, NULL
);
137 g_test_set_nonfatal_assertions();
139 test_ui_purple_init();
142 "/protocol-attention/send",
143 test_purple_protocol_attention_can_send
147 "/protocol-attention/get-types",
148 test_purple_protocol_attention_can_get_types