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 * PurpleProtcolXfer Implementations
32 *****************************************************************************/
33 static GType
test_purple_protocol_xfer_get_type(void);
36 PurpleProtocol parent
;
39 gboolean new_xfer_called
;
41 } TestPurpleProtocolXfer
;
44 PurpleProtocolClass parent
;
45 } TestPurpleProtocolXferClass
;
49 test_purple_protocol_xfer_can_receive(PurpleProtocolXfer
*prplxfer
, PurpleConnection
*c
, const gchar
*who
) {
50 TestPurpleProtocolXfer
*test_xfer
= (TestPurpleProtocolXfer
*)prplxfer
;
52 return test_xfer
->can_send
;
56 test_purple_protocol_xfer_send_file(PurpleProtocolXfer
*prplxfer
, PurpleConnection
*c
, const gchar
*who
, const gchar
*filename
) {
57 TestPurpleProtocolXfer
*test_xfer
= (TestPurpleProtocolXfer
*)prplxfer
;
59 test_xfer
->send_called
= TRUE
;
63 test_purple_protocol_xfer_new_xfer(PurpleProtocolXfer
*prplxfer
, PurpleConnection
*c
, const gchar
*who
) {
64 TestPurpleProtocolXfer
*test_xfer
= (TestPurpleProtocolXfer
*)prplxfer
;
65 PurpleAccount
*a
= purple_connection_get_account(c
);
67 test_xfer
->new_xfer_called
= TRUE
;
69 return purple_xfer_new(a
, PURPLE_XFER_TYPE_SEND
, who
);
73 test_purple_protocol_xfer_iface_init(PurpleProtocolXferInterface
*iface
) {
74 iface
->can_receive
= test_purple_protocol_xfer_can_receive
;
75 iface
->send_file
= test_purple_protocol_xfer_send_file
;
76 iface
->new_xfer
= test_purple_protocol_xfer_new_xfer
;
79 G_DEFINE_TYPE_WITH_CODE(
80 TestPurpleProtocolXfer
,
81 test_purple_protocol_xfer
,
83 G_IMPLEMENT_INTERFACE(
84 PURPLE_TYPE_PROTOCOL_XFER
,
85 test_purple_protocol_xfer_iface_init
90 test_purple_protocol_xfer_init(TestPurpleProtocolXfer
*prplxfer
) {
91 PurpleProtocol
*prpl
= PURPLE_PROTOCOL(prplxfer
);
93 prpl
->id
= "prpl-xfer";
97 test_purple_protocol_xfer_class_init(TestPurpleProtocolXferClass
*klass
) {
100 /******************************************************************************
102 *****************************************************************************/
104 test_purple_protocol_xfer_can_receive_func(void) {
105 TestPurpleProtocolXfer
*xfer
= g_object_new(test_purple_protocol_xfer_get_type(), NULL
);
106 PurpleAccount
*a
= purple_account_new("prpl-xfer-can-receive", "prpl-xfer");
107 PurpleConnection
*c
= g_object_new(PURPLE_TYPE_CONNECTION
, "account", a
, NULL
);
108 gboolean actual
= FALSE
;
110 g_assert_true(PURPLE_IS_PROTOCOL_XFER(xfer
));
112 xfer
->can_send
= FALSE
;
113 actual
= purple_protocol_xfer_can_receive(
114 PURPLE_PROTOCOL_XFER(xfer
),
118 g_assert_false(actual
);
120 xfer
->can_send
= TRUE
;
121 actual
= purple_protocol_xfer_can_receive(
122 PURPLE_PROTOCOL_XFER(xfer
),
126 g_assert_true(actual
);
130 test_purple_protocol_xfer_send_file_func(void) {
131 TestPurpleProtocolXfer
*prplxfer
= g_object_new(test_purple_protocol_xfer_get_type(), NULL
);
132 PurpleAccount
*a
= purple_account_new("prpl-xfer-send", "prpl-xfer");
133 PurpleConnection
*c
= g_object_new(PURPLE_TYPE_CONNECTION
, "account", a
, NULL
);
135 purple_protocol_xfer_send_file(PURPLE_PROTOCOL_XFER(prplxfer
), c
, "foo", "somefile");
136 g_assert_true(prplxfer
->send_called
);
140 test_purple_protocol_xfer_new_func(void) {
141 TestPurpleProtocolXfer
*prplxfer
= g_object_new(test_purple_protocol_xfer_get_type(), NULL
);
142 PurpleAccount
*a
= purple_account_new("prpl-xfer-new-xfer", "prpl-xfer");
143 PurpleConnection
*c
= g_object_new(PURPLE_TYPE_CONNECTION
, "account", a
, NULL
);
144 PurpleXfer
*xfer
= NULL
;
146 xfer
= purple_protocol_xfer_new_xfer(PURPLE_PROTOCOL_XFER(prplxfer
), c
, "foo");
147 g_assert_true(PURPLE_IS_XFER(xfer
));
148 g_assert_cmpstr("foo", ==, purple_xfer_get_remote_user(xfer
));
149 g_assert_true(prplxfer
->new_xfer_called
);
152 /******************************************************************************
154 *****************************************************************************/
156 main(gint argc
, gchar
**argv
) {
159 g_test_init(&argc
, &argv
, NULL
);
161 g_test_set_nonfatal_assertions();
163 test_ui_purple_init();
166 "/protocol-xfer/can-receive",
167 test_purple_protocol_xfer_can_receive_func
171 "/protocol-xfer/send-file",
172 test_purple_protocol_xfer_send_file_func
176 "/protocol-xfer/new",
177 test_purple_protocol_xfer_new_func