Fri, 11 Mar 2022 03:29:48 -0600
Add an echo user to the demo protocol
Testing Done:
Opened a conversation and typed a few message.
Reviewed at https://reviews.imfreedom.org/r/1328/
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * Purple is the legal property of its developers, whose names are too |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * numerous to list here. Please refer to the COPYRIGHT file distributed |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * with this source distribution |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * This program is free software; you can redistribute it and/or modify |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * it under the terms of the GNU General Public License as published by |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * the Free Software Foundation; either version 2 of the License, or (at |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * your option) any later version. |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * This program is distributed in the hope that it will be useful, but |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * General Public License for more details. |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | * |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | * along with this program; if not, write to the Free Software |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | */ |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include <glib.h> |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | #include <string.h> |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | #include <purple.h> |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | |
|
38832
7ad7854d8e60
Create a very basic ui for testing
Gary Kramlich <grim@reaperworld.com>
parents:
38830
diff
changeset
|
28 | #include "test_ui.h" |
|
7ad7854d8e60
Create a very basic ui for testing
Gary Kramlich <grim@reaperworld.com>
parents:
38830
diff
changeset
|
29 | |
| 38830 | 30 | /****************************************************************************** |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | * PurpleProtcolXfer Implementations |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | *****************************************************************************/ |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | static GType test_purple_protocol_xfer_get_type(void); |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | typedef struct { |
|
38843
1e1822eeeb54
this is needs some cleanup but appears to work
Gary Kramlich <grim@reaperworld.com>
parents:
38842
diff
changeset
|
36 | PurpleProtocol parent; |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | gboolean can_send; |
|
38844
8b77fd20fcea
Another sanity check
Gary Kramlich <grim@reaperworld.com>
parents:
38843
diff
changeset
|
39 | gboolean new_xfer_called; |
|
38845
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
40 | gboolean send_called; |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | } TestPurpleProtocolXfer; |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | typedef struct { |
|
38843
1e1822eeeb54
this is needs some cleanup but appears to work
Gary Kramlich <grim@reaperworld.com>
parents:
38842
diff
changeset
|
44 | PurpleProtocolClass parent; |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | } TestPurpleProtocolXferClass; |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | static gboolean |
|
38842
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
49 | test_purple_protocol_xfer_can_receive(PurpleProtocolXfer *prplxfer, PurpleConnection *c, const gchar *who) { |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
50 | TestPurpleProtocolXfer *test_xfer = (TestPurpleProtocolXfer *)prplxfer; |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | |
|
38834
e4144efa975e
Clean up a bunch of the cruft I accidentally created
Gary Kramlich <grim@reaperworld.com>
parents:
38832
diff
changeset
|
52 | return test_xfer->can_send; |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | } |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | |
|
38845
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
55 | static void |
|
39005
6a56e1366809
xfer: Rename PurpleProtocolXferInterface.send() to send_file()
Mike Ruprecht <cmaiku@gmail.com>
parents:
38974
diff
changeset
|
56 | test_purple_protocol_xfer_send_file(PurpleProtocolXfer *prplxfer, PurpleConnection *c, const gchar *who, const gchar *filename) { |
|
38845
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
57 | TestPurpleProtocolXfer *test_xfer = (TestPurpleProtocolXfer *)prplxfer; |
|
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
58 | |
|
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
59 | test_xfer->send_called = TRUE; |
|
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
60 | } |
|
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
61 | |
|
38842
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
62 | static PurpleXfer * |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
63 | test_purple_protocol_xfer_new_xfer(PurpleProtocolXfer *prplxfer, PurpleConnection *c, const gchar *who) { |
|
38844
8b77fd20fcea
Another sanity check
Gary Kramlich <grim@reaperworld.com>
parents:
38843
diff
changeset
|
64 | TestPurpleProtocolXfer *test_xfer = (TestPurpleProtocolXfer *)prplxfer; |
|
38842
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
65 | PurpleAccount *a = purple_connection_get_account(c); |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
66 | |
|
38844
8b77fd20fcea
Another sanity check
Gary Kramlich <grim@reaperworld.com>
parents:
38843
diff
changeset
|
67 | test_xfer->new_xfer_called = TRUE; |
|
8b77fd20fcea
Another sanity check
Gary Kramlich <grim@reaperworld.com>
parents:
38843
diff
changeset
|
68 | |
|
38842
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
69 | return purple_xfer_new(a, PURPLE_XFER_TYPE_SEND, who); |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
70 | } |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
71 | |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | static void |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | test_purple_protocol_xfer_iface_init(PurpleProtocolXferInterface *iface) { |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | iface->can_receive = test_purple_protocol_xfer_can_receive; |
|
39005
6a56e1366809
xfer: Rename PurpleProtocolXferInterface.send() to send_file()
Mike Ruprecht <cmaiku@gmail.com>
parents:
38974
diff
changeset
|
75 | iface->send_file = test_purple_protocol_xfer_send_file; |
|
38842
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
76 | iface->new_xfer = test_purple_protocol_xfer_new_xfer; |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | } |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | G_DEFINE_TYPE_WITH_CODE( |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | TestPurpleProtocolXfer, |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | test_purple_protocol_xfer, |
|
38843
1e1822eeeb54
this is needs some cleanup but appears to work
Gary Kramlich <grim@reaperworld.com>
parents:
38842
diff
changeset
|
82 | PURPLE_TYPE_PROTOCOL, |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | G_IMPLEMENT_INTERFACE( |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | PURPLE_TYPE_PROTOCOL_XFER, |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | test_purple_protocol_xfer_iface_init |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | ) |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | ); |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | static void |
|
38843
1e1822eeeb54
this is needs some cleanup but appears to work
Gary Kramlich <grim@reaperworld.com>
parents:
38842
diff
changeset
|
90 | test_purple_protocol_xfer_init(TestPurpleProtocolXfer *prplxfer) { |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | } |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | static void |
|
38843
1e1822eeeb54
this is needs some cleanup but appears to work
Gary Kramlich <grim@reaperworld.com>
parents:
38842
diff
changeset
|
94 | test_purple_protocol_xfer_class_init(TestPurpleProtocolXferClass *klass) { |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | } |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
39005
diff
changeset
|
97 | static TestPurpleProtocolXfer * |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
39005
diff
changeset
|
98 | test_purple_protocol_xfer_new(void) { |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
39005
diff
changeset
|
99 | return (TestPurpleProtocolXfer *)g_object_new( |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
39005
diff
changeset
|
100 | test_purple_protocol_xfer_get_type(), |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
39005
diff
changeset
|
101 | "id", "prpl-xfer", |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
39005
diff
changeset
|
102 | NULL); |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
39005
diff
changeset
|
103 | } |
|
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
39005
diff
changeset
|
104 | |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | /****************************************************************************** |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | * Tests |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | *****************************************************************************/ |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | static void |
|
38842
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
109 | test_purple_protocol_xfer_can_receive_func(void) { |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
39005
diff
changeset
|
110 | TestPurpleProtocolXfer *xfer = test_purple_protocol_xfer_new(); |
|
38843
1e1822eeeb54
this is needs some cleanup but appears to work
Gary Kramlich <grim@reaperworld.com>
parents:
38842
diff
changeset
|
111 | PurpleAccount *a = purple_account_new("prpl-xfer-can-receive", "prpl-xfer"); |
| 38830 | 112 | PurpleConnection *c = g_object_new(PURPLE_TYPE_CONNECTION, "account", a, NULL); |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | gboolean actual = FALSE; |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | |
|
38834
e4144efa975e
Clean up a bunch of the cruft I accidentally created
Gary Kramlich <grim@reaperworld.com>
parents:
38832
diff
changeset
|
115 | g_assert_true(PURPLE_IS_PROTOCOL_XFER(xfer)); |
|
e4144efa975e
Clean up a bunch of the cruft I accidentally created
Gary Kramlich <grim@reaperworld.com>
parents:
38832
diff
changeset
|
116 | |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | xfer->can_send = FALSE; |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | actual = purple_protocol_xfer_can_receive( |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | PURPLE_PROTOCOL_XFER(xfer), |
|
40813
71305a7d7423
Modernize PurpleProtocol
Gary Kramlich <grim@reaperworld.com>
parents:
39005
diff
changeset
|
120 | c, |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | "foo" |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | ); |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | g_assert_false(actual); |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | xfer->can_send = TRUE; |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | actual = purple_protocol_xfer_can_receive( |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | PURPLE_PROTOCOL_XFER(xfer), |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | c, |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | "foo" |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | ); |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | g_assert_true(actual); |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
132 | } |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | |
|
38842
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
134 | static void |
|
39005
6a56e1366809
xfer: Rename PurpleProtocolXferInterface.send() to send_file()
Mike Ruprecht <cmaiku@gmail.com>
parents:
38974
diff
changeset
|
135 | test_purple_protocol_xfer_send_file_func(void) { |
|
38845
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
136 | TestPurpleProtocolXfer *prplxfer = g_object_new(test_purple_protocol_xfer_get_type(), NULL); |
|
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
137 | PurpleAccount *a = purple_account_new("prpl-xfer-send", "prpl-xfer"); |
|
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
138 | PurpleConnection *c = g_object_new(PURPLE_TYPE_CONNECTION, "account", a, NULL); |
|
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
139 | |
|
39005
6a56e1366809
xfer: Rename PurpleProtocolXferInterface.send() to send_file()
Mike Ruprecht <cmaiku@gmail.com>
parents:
38974
diff
changeset
|
140 | purple_protocol_xfer_send_file(PURPLE_PROTOCOL_XFER(prplxfer), c, "foo", "somefile"); |
|
38845
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
141 | g_assert_true(prplxfer->send_called); |
|
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
142 | } |
|
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
143 | |
|
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
144 | static void |
|
38842
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
145 | test_purple_protocol_xfer_new_func(void) { |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
146 | TestPurpleProtocolXfer *prplxfer = g_object_new(test_purple_protocol_xfer_get_type(), NULL); |
|
38843
1e1822eeeb54
this is needs some cleanup but appears to work
Gary Kramlich <grim@reaperworld.com>
parents:
38842
diff
changeset
|
147 | PurpleAccount *a = purple_account_new("prpl-xfer-new-xfer", "prpl-xfer"); |
|
38842
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
148 | PurpleConnection *c = g_object_new(PURPLE_TYPE_CONNECTION, "account", a, NULL); |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
149 | PurpleXfer *xfer = NULL; |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
150 | |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
151 | xfer = purple_protocol_xfer_new_xfer(PURPLE_PROTOCOL_XFER(prplxfer), c, "foo"); |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
152 | g_assert_true(PURPLE_IS_XFER(xfer)); |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
153 | g_assert_cmpstr("foo", ==, purple_xfer_get_remote_user(xfer)); |
|
38844
8b77fd20fcea
Another sanity check
Gary Kramlich <grim@reaperworld.com>
parents:
38843
diff
changeset
|
154 | g_assert_true(prplxfer->new_xfer_called); |
|
38842
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
155 | } |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
156 | |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
157 | /****************************************************************************** |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | * Main |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | *****************************************************************************/ |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
160 | gint |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
161 | main(gint argc, gchar **argv) { |
|
38842
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
162 | gint res = 0; |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
163 | |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
164 | g_test_init(&argc, &argv, NULL); |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
165 | |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
166 | g_test_set_nonfatal_assertions(); |
|
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
167 | |
|
38842
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
168 | test_ui_purple_init(); |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
169 | |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
170 | g_test_add_func( |
| 38830 | 171 | "/protocol-xfer/can-receive", |
|
38842
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
172 | test_purple_protocol_xfer_can_receive_func |
| 38830 | 173 | ); |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
174 | |
|
38842
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
175 | g_test_add_func( |
|
39005
6a56e1366809
xfer: Rename PurpleProtocolXferInterface.send() to send_file()
Mike Ruprecht <cmaiku@gmail.com>
parents:
38974
diff
changeset
|
176 | "/protocol-xfer/send-file", |
|
6a56e1366809
xfer: Rename PurpleProtocolXferInterface.send() to send_file()
Mike Ruprecht <cmaiku@gmail.com>
parents:
38974
diff
changeset
|
177 | test_purple_protocol_xfer_send_file_func |
|
38845
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
178 | ); |
|
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
179 | |
|
f451f9216e9d
add a test for the send function being called
Gary Kramlich <grim@reaperworld.com>
parents:
38844
diff
changeset
|
180 | g_test_add_func( |
|
38842
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
181 | "/protocol-xfer/new", |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
182 | test_purple_protocol_xfer_new_func |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
183 | ); |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
184 | |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
185 | res = g_test_run(); |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
186 | |
|
98227c37cd17
start implement the _new_xfer test, stopping here as there a lot more auxiliary work that needs to be done to make it work
Gary Kramlich <grim@reaperworld.com>
parents:
38834
diff
changeset
|
187 | return res; |
|
38829
2be373489ef1
Start of unit tests for the PurpleProtocolXferInterface
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | } |